Package org.eclipse.jdt.core.dom

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


  }

  private List getBeanPropertyInitStatements(WidgetAdapter adapter, TypeDeclaration type) {
    List statements;
    if (adapter.isRoot()) {
      MethodDeclaration initMethod = getMethodDeclaration(type, INIT_METHOD_NAME);
      if (initMethod != null) {
        Block body = initMethod.getBody();
        statements = body.statements();
      } else {
        initMethod = getMethodDeclaration(type, type.getName().getFullyQualifiedName());
        if (initMethod != null) {
          Block body = initMethod.getBody();
          statements = body.statements();
        } else {
          statements = new ArrayList();
        }
      }
    } else {
      String getMethodName = NamespaceUtil.getGetMethodName(adapter, adapter.getID());
      MethodDeclaration getMethod = getMethodDeclaration(type, getMethodName);
      if (getMethod != null) {
        Block body = getMethod.getBody();
        statements = body.statements();
        if (!statements.isEmpty()) {
          Object first = statements.get(0);
          if (first instanceof IfStatement) {
            IfStatement ifs = (IfStatement) statements.get(0);
            Statement thenstmt = ifs.getThenStatement();
            if (thenstmt instanceof Block) {
              Block block = (Block) thenstmt;
              statements = block.statements();
            }
          }
        }
      } else {
        MethodDeclaration initMethod = getMethodDeclaration(type, INIT_METHOD_NAME);
        Block body = initMethod.getBody();
        statements = body.statements();
      }
    }
    return statements;
  }
View Full Code Here


public class MethodEvaluatorFactory extends ASTEvaluatorFactory{
  @Override
  public Object getAdapter(Object adaptableObject, Class adapterType) {
    if(adaptableObject instanceof MethodDeclaration){
      MethodDeclaration method = (MethodDeclaration) adaptableObject;
      if(adapterType==IEvaluator.class){
        return new MethodEvaluator(method);
      }
    }
    return null;
View Full Code Here

  }

  @Override
  protected IEvaluator createEvaluator(Object adaptable) {
    if(adaptable instanceof MethodDeclaration){
      MethodDeclaration method = (MethodDeclaration) adaptable;
      return new MethodEvaluator(method);
    }
    return null;
  }
View Full Code Here

    Method[] lMethods = esd.getListenerMethods();
    for (Object element : bodys) {
      if (!(element instanceof MethodDeclaration)) {
        return false;
      }
      MethodDeclaration method = (MethodDeclaration) element;
      if (method.isConstructor())
        return false;
      List modifiers = method.modifiers();
      boolean isPublic = false;
      for (Object mod : modifiers) {
        IExtendedModifier exm = (IExtendedModifier) mod;
        if (exm instanceof Modifier) {
          Modifier m = (Modifier) exm;
          if (m.getKeyword().equals(ModifierKeyword.PUBLIC_KEYWORD)) {
            isPublic = true;
          }
        }
      }
      if (!isPublic)
        return false;
      boolean isLM = false;
      List params = method.parameters();
      for (Method m : lMethods) {
        if (m.getName().equals(method.getName().getFullyQualifiedName())) {
          if (params != null && params.size() == 1) {
            SingleVariableDeclaration svd = (SingleVariableDeclaration) params.get(0);
            if (!svd.isVarargs()) {
              Type type = svd.getType();
              if (!type.isArrayType() && !type.isParameterizedType() && !type.isPrimitiveType() && !type.isWildcardType()) {
View Full Code Here

  protected IStatus run(IProgressMonitor monitor) {
    if (componentType != null) {
      EvaluationContext context = createContext();
      TypeDeclaration typeDec = getCompTypeDeclaration();
      if (typeDec != null) {
        MethodDeclaration constructor = getConstructor(typeDec);
        if (constructor != null) {
          IEvaluator evaluator = (IEvaluator) Platform
              .getAdapterManager().getAdapter(constructor,
                  IEvaluator.class);
          if (evaluator != null) {
View Full Code Here

    frame.push(arguments);
    return context;
  }

  private MethodDeclaration getConstructor(TypeDeclaration typeDec) {
    MethodDeclaration constructor = null;
    for(MethodDeclaration method:typeDec.getMethods()){
      if(method.isConstructor()){
        List parameters = method.parameters();
        if(parameters==null||parameters.isEmpty()){
          constructor = method;
View Full Code Here

          if(retName.equals(fieldName)){
            ASTNode current = node;
            while(current!=null&&!(current instanceof MethodDeclaration))
              current = current.getParent();
            if(current!=null){
              MethodDeclaration bingo=(MethodDeclaration) current;
              ret[0]=bingo.getName().getFullyQualifiedName();
              return false;
            }
          }
        }
        return true;
View Full Code Here

   * @return the depth of the node in loops. 0 is no loops, 1 is nested in one loop,
   * etc.
   */
  public int getLoopDepth(ASTNode node) {   
    if(!loopDepth.containsKey(node)) {
      final MethodDeclaration d = Utilities.getMethodDeclaration(node);
      if (d == null) {
        return 0; // not in method --> cannot be in loop
      }
      else {
        if (decl == null || !decl.equals(d))
View Full Code Here

public class EclipseTACNewObjectTest {

  @Test
  public void testOuter() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("MainClass", MAIN);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    ClassInstanceCreation instance = (ClassInstanceCreation) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(instance);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof NewObjectInstruction);
    NewObjectInstruction newobj = (NewObjectInstruction) instr;
View Full Code Here

    "}";
 
  @Test
  public void testTopLevel() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("TopLevel", TOP_LEVEL);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    ClassInstanceCreation instance = (ClassInstanceCreation) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(instance);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof NewObjectInstruction);
    NewObjectInstruction newobj = (NewObjectInstruction) instr;
View Full Code Here

TOP

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

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.