Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.StringLiteral


       
        /*
         * the parameter
         */
        String thePropertyKey = method.getName().toString().substring(3);
        StringLiteral literal = ast.newStringLiteral();
        literal.setLiteralValue(thePropertyKey);
       
        methodInvocation.arguments().add(literal);
       
        /*
         * the return statement
         */
        ReturnStatement returnStatement = ast.newReturnStatement();
        returnStatement.setExpression(methodInvocation);

        block.statements().add(returnStatement); //add the return statement to the block
        newMethod.setBody(block); // add the block to the method
        newType.bodyDeclarations().add(newMethod); //add the method to the type
       
      }
      if (method.getName().getIdentifier().startsWith("set")) {
        List<SingleVariableDeclaration> parameters = method.parameters();
        if (parameters.size() != 1)
          continue;
        setMethods.add(method);
        MethodDeclaration newMethod = copyMethodDeclaration(newType.getAST(), method);
        SingleVariableDeclaration oldParameter = parameters.get(0);
        SimpleName paramName = oldParameter.getName();
        /*
         * the statement
         */
        org.eclipse.jdt.core.dom.Block block = ast.newBlock();
        MethodInvocation methodInvocation = ast.newMethodInvocation();
        methodInvocation.setName(ast.newSimpleName("set"));
       
        /*
         * the parameters
         */
        String thePropertyKey = method.getName().toString().substring(3);
        StringLiteral literal = ast.newStringLiteral();
        literal.setLiteralValue(thePropertyKey);
        methodInvocation.arguments().add(literal);
        methodInvocation.arguments().add(paramName.copySubtree(newMethod.getAST(), paramName));
       
        ExpressionStatement expressionStatement = ast.newExpressionStatement(methodInvocation);
        block.statements().add(expressionStatement);
View Full Code Here


            String paramName = mvp.getName()
                .getFullyQualifiedName();
            if (paramName.startsWith("serialized")) {
              Expression val = mvp.getValue();
              if (val instanceof StringLiteral) {
                StringLiteral sl = (StringLiteral) val;
                if (sl.getLiteralValue().equals("true")) {
                  return true;
                }
              }
            }
          }
View Full Code Here

            // System.err.println("TODO -> Name: " + name);
            VariableDeclaration varDecl = LapseView.name2decl(name, unit, resource);
            if (varDecl instanceof SingleVariableDeclaration) {
                SingleVariableDeclaration decl = (SingleVariableDeclaration) varDecl;
                if (decl.getInitializer() != null && decl.getInitializer() instanceof StringLiteral) {
                    StringLiteral l = (StringLiteral) decl.getInitializer();
                    return true;
                }
            } else {
                VariableDeclarationFragment decl = (VariableDeclarationFragment) varDecl;
                if (decl.getInitializer() != null) {
View Full Code Here

            // System.err.println("TODO -> Name: " + name);
            VariableDeclaration varDecl = LapseView.name2decl(name, unit, resource);
            if (varDecl instanceof SingleVariableDeclaration) {
                SingleVariableDeclaration decl = (SingleVariableDeclaration) varDecl;
                if (decl.getInitializer() != null && decl.getInitializer() instanceof StringLiteral) {
                    StringLiteral l = (StringLiteral) decl.getInitializer();
                    return true;
                }
            } else {
                VariableDeclarationFragment decl = (VariableDeclarationFragment) varDecl;
                if (decl.getInitializer() != null) {
View Full Code Here

   *         required name.
   */
  static boolean isObjectHandler(MethodDeclaration methodDeclaration, String name) {
    SingleMemberAnnotation handlerAnnotation = getHandlerAnnotation(methodDeclaration);
    if (handlerAnnotation != null && handlerAnnotation.getValue() instanceof StringLiteral) {
      StringLiteral handlerLiteral = (StringLiteral) handlerAnnotation.getValue();
      String handlerName = handlerLiteral.getLiteralValue();
      return name.equals(handlerName);
    }
    return false;
  }
View Full Code Here

          }
          String propertyName = null;
          if (m_editor == null) {
            Expression expression = arguments.get(0);
            if (expression instanceof StringLiteral) {
              StringLiteral literal = (StringLiteral) expression;
              propertyName = literal.getLiteralValue();
            }
          } else {
            propertyName = CoreUtils.evaluate(String.class, m_editor, arguments.get(0));
          }
          if (!StringUtils.isEmpty(propertyName)) {
View Full Code Here

      } else if (type.getName().equalsIgnoreCase("Boolean")) {
        BooleanLiteral booleanLiteral = ast
            .newBooleanLiteral(valueSpecification.booleanValue());
        ec.arguments().add(booleanLiteral);
      } else if (type.getName().equalsIgnoreCase("String")) {
        StringLiteral stringLiteral = ast.newStringLiteral();
        stringLiteral.setLiteralValue(valueSpecification.stringValue());
        ec.arguments().add(stringLiteral);
      }
    }
  }
View Full Code Here

   * @return
   */
  public static Expression createExpression(AST ast, Object value) {
    if (value instanceof String) {
      String stringValue = (String)value;
      StringLiteral newStringLiteral = ast.newStringLiteral();
      newStringLiteral.setLiteralValue(stringValue);
      return newStringLiteral;
    }
    if (value instanceof Boolean) {
      Boolean booleanValue = (Boolean)value;
      return ast.newBooleanLiteral(booleanValue);
View Full Code Here

//        SimpleType simpleType = (SimpleType) node;
//        return "Simple type (" + simpleType.getName().toString() + ")";
//      case ASTNode.SINGLE_VARIABLE_DECLARATION:
//        return "Single variable declaration";
      case ASTNode.STRING_LITERAL:
        StringLiteral stringLiteral = (StringLiteral) node;
        return stringLiteral.getLiteralValue();
//      case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
//        return "Super constructor invocation";
//      case ASTNode.SUPER_FIELD_ACCESS:
//        return "Super field access";
//      case ASTNode.SUPER_METHOD_INVOCATION:
View Full Code Here

  /**
   * Convenience method on AST. Creates a StringLiteral and calls setLiteralValue(STRING)
   */
  public static StringLiteral newStringLiteral(AST ast, String literalValue) {
    StringLiteral stringLiteral = ast.newStringLiteral();
    stringLiteral.setLiteralValue(literalValue);
    return stringLiteral;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.StringLiteral

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.