Package org.eclipse.jdt.core.dom

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


      for (int i = 0; i < parameters.size(); i++) {
        SingleVariableDeclaration parameter = (SingleVariableDeclaration) parameters.get(i);
        code = code.replaceAll("\\$\\{" + Integer.toString(i) + "\\}", parameter.resolveBinding().getName()); //$NON-NLS-1$ //$NON-NLS-2$
      }

      Block block = JDTUtils.parseBlock(code);
      block = (Block) ASTNode.copySubtree(methodDeclaration.getAST(), block);

      methodDeclaration.setBody((Block) block);
    } catch (Exception e) {
      warnings.add(String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.7"), targetClass, methodName)); //$NON-NLS-1$
View Full Code Here


          if (!(match instanceof MethodReferenceMatch)) {
            continue;
          }

          IMethod javaElement = (IMethod) ((PlatformObject) (match.getElement())).getAdapter(IJavaElement.class);
          Block block = compilationUnitCache.getMethodDeclaration(javaElement).getBody();
          blockModifier.modify(block);
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
View Full Code Here

    method.parameters().add(svd);
    return this;
  }

  public BlockWriter body() {
    Block block = ast.newBlock();
    method.setBody(block);
    return new BlockWriter(block);
  }
View Full Code Here

   public Method<O> setBody(final String body)
   {
      String stub = "public class Stub { public void method() {" + body + "} }";
      JavaClass temp = (JavaClass) JavaParser.parse(stub);
      List<Method<JavaClass>> methods = temp.getMethods();
      Block block = ((MethodDeclaration) methods.get(0).getInternal()).getBody();

      block = (Block) ASTNode.copySubtree(method.getAST(), block);
      method.setBody(block);

      return this;
View Full Code Here

   public MethodSource<O> setBody(final String body)
   {
      String stub = "public class Stub { public void method() {" + body + "} }";
      JavaClassSource temp = (JavaClassSource) Roaster.parse(stub);
      List<MethodSource<JavaClassSource>> methods = temp.getMethods();
      Block block = ((MethodDeclaration) methods.get(0).getInternal()).getBody();

      block = (Block) ASTNode.copySubtree(method.getAST(), block);
      method.setBody(block);

      return this;
View Full Code Here

   public Method<O> setBody(final String body)
   {
      String stub = "public class Stub { public void method() {" + body + "} }";
      JavaClass temp = (JavaClass) JavaParser.parse(stub);
      List<Method<JavaClass>> methods = temp.getMethods();
      Block block = ((MethodDeclaration) methods.get(0).getInternal()).getBody();

      block = (Block) ASTNode.copySubtree(method.getAST(), block);
      method.setBody(block);

      return this;
View Full Code Here

   public MethodSource<O> setBody(final String body)
   {
      String stub = "public class Stub { public void method() {" + body + "} }";
      JavaClassSource temp = (JavaClassSource) Roaster.parse(stub);
      List<MethodSource<JavaClassSource>> methods = temp.getMethods();
      Block block = ((MethodDeclaration) methods.get(0).getInternal()).getBody();

      block = (Block) ASTNode.copySubtree(method.getAST(), block);
      method.setBody(block);

      return this;
View Full Code Here

   *            the reference to be tested
   * @return {@code true}, if reference is within the same or underlying
   *         block. {@code false} otherwise.
   */
  private boolean isReferenceWhithinScope(SimpleName reference) {
    Block firstReferenceBlock = Helper.getParentBlock(firstReference);
    // get the block that contains the first reference statement

    ASTNode node = reference;

    // step down in the ast parent-child-node hierarchy. If
View Full Code Here

  protected void addNewVariableDeclaration(VariableBindingManager manager) {
    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);
  }
View Full Code Here

  protected void deleteOldVariableDeclaration(VariableBindingManager manager) {
    AST ast = manager.getFirstReference().getAST();
    VariableDeclarationStatement statement = createNewVariableDeclarationStatement(
        manager, ast);
    int firstReferenceIndex = getFirstReferenceListIndex(manager);
    Block block = Helper.getParentBlock(manager.getFirstReference());
    // get the list rewriter for the statments list
    ListRewrite statementsListRewrite = rewrite.getListRewrite(block,
        Block.STATEMENTS_PROPERTY);
    // add insert-at command to the protocol
    statementsListRewrite.insertAt(statement, firstReferenceIndex, null);
View Full Code Here

TOP

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

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.