Package org.eclipse.jdt.core.dom

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


      if (arg instanceof ClassInstanceCreation) {
        ClassInstanceCreation instanceCreation = (ClassInstanceCreation) arg;
        List 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


  private boolean processWidgetCreationStatement(TypeDeclaration type, WidgetAdapter adapter, EventSetDescriptor esd, MethodDescriptor mListener, Statement statement) {
    ExpressionStatement expressionStatement = (ExpressionStatement) statement;
    Expression expression = expressionStatement.getExpression();
    if (expression instanceof MethodInvocation) {
      MethodInvocation mi = (MethodInvocation) expression;
      if (adapter.isRoot()) {
        return createAddMethod(type, adapter, esd, mListener, mi);
      } else {
        Expression optionalExpression = mi.getExpression();
        if (optionalExpression instanceof SimpleName) {
          SimpleName simplename = (SimpleName) optionalExpression;
          String idName = simplename.getFullyQualifiedName();
          if (idName.equals(adapter.getID()))
            return createAddMethod(type, adapter, esd, mListener, mi);
View Full Code Here

      Statement statement = (Statement) stmt;
      if (statement instanceof ExpressionStatement) {
        ExpressionStatement es = (ExpressionStatement) statement;
        Expression expression = es.getExpression();
        if (expression instanceof MethodInvocation) {
          MethodInvocation mi = (MethodInvocation) expression;
          Expression optional = mi.getExpression();
          if (isShouldCheck(optional)) {
            String mName = mi.getName().getFullyQualifiedName();
            if (mName.startsWith("set")) {
              parseSetStatement(lnfClassname, mi);
            } else if (mName.startsWith("add")) {
              parseAddStatement(lnfClassname, mi);
            }
View Full Code Here

      Object stmt = statements.get(0);
      if (stmt instanceof ExpressionStatement) {
        ExpressionStatement es = (ExpressionStatement) stmt;
        Expression expression = es.getExpression();
        if (expression instanceof MethodInvocation) {
          MethodInvocation mi = (MethodInvocation) expression;
          Expression optional = mi.getExpression();
          if (optional == null||optional instanceof ThisExpression) {
            List list = mi.arguments();
            if (list.size() != 1) {
              return new CodeSnippet(adapter, eventSet, methodDesc, es.toString());
            }
            Expression exp = (Expression) list.get(0);
            if (exp instanceof SimpleName) {
              SimpleName sn = (SimpleName) exp;
              SimpleName varn = var.getName();
              if (sn.getFullyQualifiedName().equals(varn.getFullyQualifiedName()))
                return new EventDelegation(methodDesc, mi.getName().getFullyQualifiedName());
            }
            return new CodeSnippet(adapter, eventSet, methodDesc, es.toString());
          } else {
            return new CodeSnippet(adapter, eventSet, methodDesc, es.toString());
          }
View Full Code Here

public class MethodInvocationEvaluatorFactory extends ASTEvaluatorFactory {

  @Override
  protected IEvaluator createEvaluator(Object adaptable) {
    if(adaptable instanceof MethodInvocation){
      MethodInvocation mi = (MethodInvocation) adaptable;
      return new MethodInvocationEvaluator(mi);
    }
    return null;
  }
View Full Code Here

  @Test
  public void testNestedFieldWrite() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("NestedFieldWrite", NESTED_FIELD_WRITE);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    MethodInvocation inv = (MethodInvocation) ((ExpressionStatement) EclipseTACSimpleTestDriver.getLastStatement(m)).getExpression();
    TACInstruction instr = tac.instruction(inv);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof MethodCallInstruction);
    MethodCallInstruction call = (MethodCallInstruction) instr;
   
    List<Variable> args = call.getArgOperands();
    EclipseTACSimpleTestDriver.assertOperands(inv.arguments(), args, tac);
    Assert.assertEquals(1, args.size());
   
    Assignment write = (Assignment) inv.arguments().get(0);
    instr = tac.instruction(write);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof StoreFieldInstruction);
    StoreFieldInstruction store = (StoreFieldInstruction) instr;
   
View Full Code Here

  @Test
  public void testSimpleCall() throws Exception {
    CompilationUnit simple = EclipseTACSimpleTestDriver.parseCode("SimpleCall", SIMPLE_CALL);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(simple);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    MethodInvocation invoke = (MethodInvocation) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(invoke);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof MethodCallInstruction);
    MethodCallInstruction call = (MethodCallInstruction) instr;
    Assert.assertNull(((ThisVariable) tac.implicitThisVariable(m.resolveBinding())).getQualifier());
    Assert.assertEquals(tac.implicitThisVariable(m.resolveBinding()), call.getReceiverOperand());
    EclipseTACSimpleTestDriver.assertOperands(invoke.arguments(), call.getArgOperands(), tac);
    Assert.assertTrue(call.getArgOperands().get(0) instanceof SourceVariable);
    Assert.assertEquals(
        tac.sourceVariable(((SingleVariableDeclaration) m.parameters().get(0)).resolveBinding()),
        call.getArgOperands().get(0));
  }
View Full Code Here

  @Test
  public void testStaticCall() throws Exception {
    CompilationUnit simple = EclipseTACSimpleTestDriver.parseCode("StaticCall", STATIC_CALL);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(simple);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    MethodInvocation invoke = (MethodInvocation) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(invoke);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof MethodCallInstruction);
    MethodCallInstruction call = (MethodCallInstruction) instr;
    Assert.assertEquals(tac.typeVariable(m.resolveBinding().getDeclaringClass()), call.getReceiverOperand());
    EclipseTACSimpleTestDriver.assertOperands(invoke.arguments(), call.getArgOperands(), tac);
    Assert.assertTrue(call.getArgOperands().get(0) instanceof SourceVariable);
    Assert.assertEquals(
        tac.sourceVariable(((SingleVariableDeclaration) m.parameters().get(0)).resolveBinding()),
        call.getArgOperands().get(0));
  }
View Full Code Here

  @Test
  public void testNestedArrayWrite() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("NestedArrayWrite", NESTED_ARRAY_WRITE);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    MethodInvocation inv = (MethodInvocation) ((ExpressionStatement) EclipseTACSimpleTestDriver.getLastStatement(m)).getExpression();
    TACInstruction instr = tac.instruction(inv);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof MethodCallInstruction);
    MethodCallInstruction call = (MethodCallInstruction) instr;
   
    List<Variable> args = call.getArgOperands();
    EclipseTACSimpleTestDriver.assertOperands(inv.arguments(), args, tac);
    Assert.assertEquals(1, args.size());
   
    Assignment write = (Assignment) inv.arguments().get(0);
    instr = tac.instruction(write);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof StoreArrayInstruction);
    StoreArrayInstruction store = (StoreArrayInstruction) instr;
View Full Code Here

       * Rough approximation for association checking, may fail sometimes. But I think that GWT-Ext
       * deserve hardly better implementation.
       */
      private boolean isPossibleAssociation(ASTNode node) {
        if (node instanceof MethodInvocation) {
          MethodInvocation invocation = (MethodInvocation) node;
          for (Expression argument : DomGenerics.arguments(invocation)) {
            if (m_javaInfo.isRepresentedBy(argument)) {
              return true;
            }
          }
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.