Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.Block.statements()


    AST ast = manager.getFirstReference().getAST();
    VariableDeclarationStatement statement = createNewVariableDeclarationStatement(
        manager, ast);
    int firstReferenceIndex = getFirstReferenceListIndex(manager);
    Block block = Helper.getParentBlock(manager.getFirstReference());
    block.statements().add(firstReferenceIndex, statement);
  }

  /*
   * (non-Javadoc)
   *
 
View Full Code Here


   *            the variable binding manager
   * @return the index position within the statement list
   */
  protected int getFirstReferenceListIndex(VariableBindingManager manager) {
    Block block = Helper.getParentBlock(manager.getFirstReference());
    return block.statements().indexOf(manager.getFirstReference());
  }

  /**
   * Creates a new {@link VariableDeclarationStatement}. As initializer
   * figures a copy of the initializer retrieved from the variable binding
View Full Code Here

              // Method is a getter or setter. Check if there is only
              // one statement in the method so that there can be no
              // computations.
              Block body = meth.getBody();
              if (body != null) {
                if (body.statements().size() != 1) {
                  generateResultsForASTNode(history, meth, resource, "The getter "+
                      methBinding.getName() + " in the Model class "+
                      binding.getName() + " must include exactly one statement.");
                }
              }
View Full Code Here

    MethodInvocation mi = ast.newMethodInvocation();
    mi.setName(ast.newSimpleName("x"));

    ExpressionStatement e = ast.newExpressionStatement(mi);
    block.statements().add(e);

    System.out.println(cu);
  }

}
View Full Code Here

    for (int index = 0; index < varNames.length; index++) {
      constructorInvocation.arguments().add(
          ast.newSimpleName(varNames[index]));
    }

    block.statements().add(constructorInvocation);
    constructor.setBody(block);
    td.bodyDeclarations().add(constructor);
  }

  @SuppressWarnings("unchecked")
View Full Code Here

      // Content of getter method
      Block block = ast.newBlock();
      ReturnStatement returnStatement = ast.newReturnStatement();
      SimpleName simpleName = ast.newSimpleName(property.getName());
      returnStatement.setExpression(simpleName);
      block.statements().add(returnStatement);
      methodDeclaration.setBody(block);
    }
  }

  /**
 
View Full Code Here

      // Expression
      ExpressionStatement expressionStatement = ast
          .newExpressionStatement(assignment);

      block.statements().add(expressionStatement);
    }

    // Set Body to MethodDeclaration
    md.setBody(block);
  }
View Full Code Here

    MethodInvocation mi = ast.newMethodInvocation();
    mi.setName(ast.newSimpleName("x"));

    ExpressionStatement e = ast.newExpressionStatement(mi);
    block.statements().add(e);

    System.out.println(cu);
  }

}
View Full Code Here

                           final Node parentNode ) throws Exception {
        final Block block = initializer.getBody();

        if (block != null) {
            @SuppressWarnings( "unchecked" )
            final List<Statement> statements = block.statements();

            if ((statements != null) && !statements.isEmpty()) {
                final Node initializerNode = parentNode.addNode(nodeName, ClassFileSequencerLexicon.STATEMENTS);
                record(block, initializerNode);
            }
View Full Code Here

        }

        { // body
            final Block body = method.getBody();

            if ((body != null) && (body.statements() != null) && !body.statements().isEmpty()) {
                final Node bodyNode = methodNode.addNode(ClassFileSequencerLexicon.BODY, ClassFileSequencerLexicon.STATEMENTS);
                record(body, bodyNode);
            }
        }
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.