Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.MethodDeclaration.resolveBinding()


 
  @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;
View Full Code Here


  @Test
  public void testFieldInitializer() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("FieldInit", FIELD_INIT);
    MethodDeclaration c = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(c.resolveBinding());
    VariableDeclarationFragment f = EclipseTACSimpleTestDriver.getFirstField(cu);
    Expression init = f.getInitializer();
    Assert.assertNotNull(init);

    TACInstruction decl = tac.instruction(f);
View Full Code Here

 
  @Test
  public void testFieldInitNew() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("FieldInitNew", FIELD_INIT_NEW);
    MethodDeclaration c = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(c.resolveBinding());
    VariableDeclarationFragment f = EclipseTACSimpleTestDriver.getFirstField(cu);
    Expression init = f.getInitializer();
    Assert.assertNotNull(init);

    TACInstruction decl = tac.instruction(f);
View Full Code Here

 
  @Test
  public void testFieldNoInitializer() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("FieldNoInit", FIELD_NO_INIT);
    MethodDeclaration c = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(c.resolveBinding());
    VariableDeclarationFragment f = EclipseTACSimpleTestDriver.getFirstField(cu);
    Expression init = f.getInitializer();
    Assert.assertNull(init);

    TACInstruction decl = tac.instruction(f);
View Full Code Here

    return compilationUnitCache.getSignatures(type, methodName);
  }

  public void changeInvocationsTo(String fromClass, String fromMethodName, String[] fromSignature, String code) {
    MethodDeclaration fromMethodDeclaration = compilationUnitCache.getMethodDeclaration(fromClass, fromMethodName, fromSignature);
    final IMethod fromMethod = (IMethod) fromMethodDeclaration.resolveBinding().getJavaElement();

    BlockModifier blockModifier = new ConvertMethodInvocationToCode(fromMethod, code);
    modifyBlocks(fromMethod, blockModifier);
  }
View Full Code Here

  public String getMethodReturnType(String targetClass, String methodName, String[] signature) {
    try {
      MethodDeclaration methodDeclaration = compilationUnitCache.getMethodDeclaration(targetClass, methodName, signature);

      return methodDeclaration.resolveBinding().getReturnType().getQualifiedName();
    } catch (Exception e) {
      warnings.add(String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.10"), targetClass, methodName)); //$NON-NLS-1$
    }

    return null;
View Full Code Here

    }
  }

  public void changeInvocationsToConstructor(String fromClass, final String fromMethodName, String[] fromSignature, final String toClass) {
    MethodDeclaration fromMethodDeclaration = compilationUnitCache.getMethodDeclaration(fromClass, fromMethodName, fromSignature);
    final IMethod fromMethod = (IMethod) fromMethodDeclaration.resolveBinding().getJavaElement();

    BlockModifier blockModifier = new ConvertMethodInvocationToConstructor(fromMethod, toClass);
    modifyBlocks(fromMethod, blockModifier);
  }
View Full Code Here

      // Get the corresponding method declaration.
      final MethodDeclaration methDecl = Util.getMethodDeclaration(rs);

      // Get the corresponding method.
      final IMethod meth = (IMethod) methDecl.resolveBinding()
          .getJavaElement();

      // Get the top most method
      final IMethod top = Util.getTopMostSourceMethod(meth, this.monitor);
View Full Code Here

          // look at the methods...
         
          List<?> methods = resource.getTypedNodeList(typeDec, ASTNode.METHOD_DECLARATION, false);
          for (Object methObj : methods) {
            MethodDeclaration meth = (MethodDeclaration) methObj;
            IMethodBinding methBinding = meth.resolveBinding();
           
            // The name must begin with get or set
            if (!methBinding.getName().startsWith("set") &&
                !methBinding.getName().startsWith("get") &&
                !methBinding.getName().startsWith("is") &&
View Full Code Here

      AbstractTypeDeclaration dec = (AbstractTypeDeclaration) o;
      List bodyDeclarations = dec.bodyDeclarations();
      assertNotNull(dec.resolveBinding());
      for(Object body:bodyDeclarations){
        MethodDeclaration methodDec = (MethodDeclaration) body;
        IMethodBinding binding = methodDec.resolveBinding();
        assertNotNull(binding);
        ASTNode node = cu.findDeclaringNode(binding);
        assertNotNull("can't find declaring node",node);
        System.out.println(node);
      }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.