Package org.eclipse.jdt.core.dom

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


      ASTNode node= (ASTNode) event.getOriginalValue();
      // check for ranges and add a placeholder for them
      while (nextInfo != null && node == nextInfo.getStartNode()) { // is this child the beginning of a range?
        nextInfo.updatePlaceholderSourceRanges(sourceRangeComputer);

        Block internalPlaceholder= nextInfo.getInternalPlaceholder();
        RewriteEvent newEvent;
        if (nextInfo.isMove()) {
          newEvent= new NodeRewriteEvent(internalPlaceholder, nextInfo.replacingNode); // remove or replace
        } else {
          newEvent= new NodeRewriteEvent(internalPlaceholder, internalPlaceholder); // unchanged
        }
        newChildEvents.add(newEvent);
        if (nextInfo.editGroup != null) {
          setEventEditGroup(newEvent, nextInfo.editGroup);
        }

        newChildrenStack.push(newChildEvents);
        topInfoStack.push(topInfo);

        newChildEvents= new ArrayList(childEvents.length);
        topInfo= nextInfo;

        nextInfo= rangeInfoIterator.hasNext() ? (NodeRangeInfo) rangeInfoIterator.next() : null;
      }

      newChildEvents.add(event);

      while (topInfo != null && node == topInfo.getEndNode()) {
        RewriteEvent[] placeholderChildEvents= (RewriteEvent[]) newChildEvents.toArray(new RewriteEvent[newChildEvents.size()]);
        Block internalPlaceholder= topInfo.getInternalPlaceholder();
        addEvent(internalPlaceholder, Block.STATEMENTS_PROPERTY, new ListRewriteEvent(placeholderChildEvents));

        newChildEvents= (List) newChildrenStack.pop();
        topInfo= (NodeRangeInfo) topInfoStack.pop();
      }
View Full Code Here


   */
  public final ASTNode createGroupNode(ASTNode[] targetNodes) {
    if (targetNodes == null || targetNodes.length == 0) {
      throw new IllegalArgumentException();
    }
    Block res= getNodeStore().createCollapsePlaceholder();
    ListRewrite listRewrite= getListRewrite(res, Block.STATEMENTS_PROPERTY);
    for (int i= 0; i < targetNodes.length; i++) {
      listRewrite.insertLast(targetNodes[i], null);
    }
    return res;
View Full Code Here

      TargetSourceRangeComputer.SourceRange startRange= sourceRangeComputer.computeSourceRange(getStartNode());
      TargetSourceRangeComputer.SourceRange endRange= sourceRangeComputer.computeSourceRange(getEndNode());
      int startPos= startRange.getStartPosition();
      int endPos= endRange.getStartPosition() + endRange.getLength();

      Block internalPlaceholder= getInternalPlaceholder();
      internalPlaceholder.setSourceRange(startPos, endPos - startPos);
    }
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

  // collapsed nodes: in source: use one node that represents many; to be used as
  // copy/move source or to replace at once.
  // in the target: one block node that is not flattened.

  public Block createCollapsePlaceholder() {
    Block placeHolder= this.ast.newBlock();
    if (this.collapsedNodes == null) {
      this.collapsedNodes= new HashSet();
    }
    this.collapsedNodes.add(placeHolder);
    return placeHolder;
View Full Code Here

    ASTNode placeholder= nodeStore.newPlaceholderNode(first.getNodeType()); // revisit: could use list type
    if (placeholder == null) {
      throw new IllegalArgumentException("Creating a target node is not supported for nodes of type" + first.getClass().getName()); //$NON-NLS-1$
    }

    Block internalPlaceHolder= nodeStore.createCollapsePlaceholder();
    CopySourceInfo info= getRewriteStore().createRangeCopy(this.parent, this.childListProperty, first, last, isMove, internalPlaceHolder, replacingNode, editGroup);
    nodeStore.markAsCopyTarget(placeholder, info);

    return placeholder;
  }
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) JavaParser.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

          .newSimpleName(varTypes[index])));
      variableDeclaration.setName(ast.newSimpleName(varNames[index]));
      constructor.parameters().add(variableDeclaration);
    }

    Block block = ast.newBlock();
    SuperConstructorInvocation constructorInvocation = ast
        .newSuperConstructorInvocation();

    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);
  }
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.