Package org.eclipse.jdt.core.dom

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


      /**
       * Rough approximation for association checking, may fail sometimes.
       */
      private boolean isPossibleAssociation(ASTNode node) {
        if (node instanceof MethodInvocation) {
          MethodInvocation invocation = (MethodInvocation) node;
          List<Expression> arguments = DomGenerics.arguments(invocation);
          return !arguments.isEmpty() && isRepresentedBy(arguments.get(0));
        }
        return false;
      }
View Full Code Here


        getEditor().replaceExpression(object.m_valueExpression, widthSource);
        return;
      }
    }
    //
    MethodInvocation invocation = addMethodInvocation(signature, index + ", " + widthSource);
    JavaInfoEvaluationHelper.setValue(DomGenerics.arguments(invocation).get(0), index);
    setColumnWidth_sort();
  }
View Full Code Here

      }
    });
    // move invocations
    StatementTarget target = getMethodInvocationTarget(signature);
    for (ValueObject_setColumnWidth object : objects) {
      MethodInvocation invocation = object.m_invocation;
      Statement statement = AstNodeUtils.getEnclosingStatement(invocation);
      getEditor().moveStatement(statement, target);
      target = new StatementTarget(statement, false);
    }
  }
View Full Code Here

          }
        }
      };
      {
        String text = description.getName();
        MethodInvocation invocation = getInvocation(component, description);
        if (invocation != null) {
          int line = 1 + component.getEditor().getLineNumber(invocation.getStartPosition());
          text += "\tline " + line;
        }
        action.setText(text);
      }
      action.setImageDescriptor(EventsPropertyUtils.LISTENER_METHOD_IMAGE_DESCRIPTOR);
View Full Code Here

    }
    return null;
  }

  private void removeListener(final ComponentInfo component, EventDescription description) {
    final MethodInvocation invocation = getInvocation(component, description);
    if (invocation != null) {
      ExecutionUtils.run(component, new RunnableEx() {
        public void run() throws Exception {
          component.getEditor().removeEnclosingStatement(invocation);
        }
View Full Code Here

  }

  private void openListener(final ComponentInfo component, final EventDescription description) {
    // try to find existing addListener()
    {
      MethodInvocation invocation = getInvocation(component, description);
      if (invocation != null) {
        JavaInfoUtils.scheduleOpenNode(component, invocation);
        return;
      }
    }
    // generate new addListener()
    ExecutionUtils.run(component, new RunnableEx() {
      public void run() throws Exception {
        MethodInvocation invocation =
            component.addMethodInvocation(
                ADD_LISTENER_SIGNATURE,
                "com.extjs.gxt.ui.client.event.Events."
                    + description.getName()
                    + ", "
View Full Code Here

  public Object parseValue(Object oldValue, List args) {
    if (oldValue != null && !(oldValue instanceof ResourceImage)) {
      Image icon = (Image)oldValue;
      Expression arg = (Expression) args.get(0);
      if (arg instanceof MethodInvocation) {
        MethodInvocation mi = (MethodInvocation) arg;
        args = mi.arguments();
        arg = (Expression) args.get(0);
        if (arg instanceof MethodInvocation) {
          mi = (MethodInvocation) arg;
          args = mi.arguments();
          arg = (Expression) args.get(0);
          if (arg instanceof StringLiteral) {
            StringLiteral sl = (StringLiteral) arg;
            String path = sl.getLiteralValue();
            return new ResourceImage(icon, path);
View Full Code Here

      if (arg instanceof ClassInstanceCreation) {
        ClassInstanceCreation instanceCreation = (ClassInstanceCreation) arg;
        args = instanceCreation.arguments();
        arg = (Expression) args.get(0);
        if (arg instanceof MethodInvocation) {
          MethodInvocation mi = (MethodInvocation) arg;
          args = mi.arguments();
          arg = (Expression) args.get(0);
          if (arg instanceof StringLiteral) {
            StringLiteral sl = (StringLiteral) arg;
            String path = sl.getLiteralValue();
            return new ResourceIcon(icon, path);
View Full Code Here

    }

    protected MethodInvocation createDoPrivilegedInvocation(ASTRewrite rewrite, ClassInstanceCreation classLoaderCreation) {
        AST ast = rewrite.getAST();

        MethodInvocation doPrivilegedInvocation = ast.newMethodInvocation();
        ClassInstanceCreation privilegedActionCreation = createPrivilegedActionCreation(rewrite, classLoaderCreation);
        List<Expression> arguments = checkedList(doPrivilegedInvocation.arguments());

        if (!isStaticImport()) {
            Name accessControllerName;
            if (isUpdateImports()) {
                accessControllerName = ast.newSimpleName(AccessController.class.getSimpleName());
            } else {
                accessControllerName = ast.newName(AccessController.class.getName());
            }
            doPrivilegedInvocation.setExpression(accessControllerName);
        }
        doPrivilegedInvocation.setName(ast.newSimpleName(DO_PRIVILEGED_METHOD_NAME));
        arguments.add(privilegedActionCreation);

        return doPrivilegedInvocation;
    }
View Full Code Here

        getMethods.add(method);
        /*
         * the statement
         */
        org.eclipse.jdt.core.dom.Block block = ast.newBlock();
        MethodInvocation methodInvocation = ast.newMethodInvocation();
        methodInvocation.setName(ast.newSimpleName("get"));
       
        /*
         * 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);
         
        newMethod.setBody(block); // add the block to the method
View Full Code Here

TOP

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

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.