Package org.eclipse.jdt.core.dom.rewrite

Examples of org.eclipse.jdt.core.dom.rewrite.ASTRewrite.rewriteAST()


    if (child != null) {
      ASTNode parent = ((JavaElement) getParentElement()).findNode(this.cuAST);
      if (parent == null)
        parent = this.cuAST;
      insertASTNode(rewriter, parent, child);
      TextEdit edits = rewriter.rewriteAST();
      applyTextEdit(cu, edits);
    }
    worked(1);
  }
  /**
 
View Full Code Here


      if (rewrite == null) {
        return null;
      }

      Document document= new Document(content);
      return rewrite.rewriteAST(document, cu.getJavaProject().getOptions(true));
    } finally {
      done();
    }
  }
View Full Code Here

    ASTRewrite rewriter= sortCompilationUnit(ast, null);
    if (rewriter == null)
      return document.get();

    TextEdit edits = rewriter.rewriteAST(document, unit.getJavaProject().getOptions(true));

    RangeMarker[] markers = null;
    if (this.positions != null) {
      markers = new RangeMarker[this.positions.length];
      for (int i = 0, max = this.positions.length; i < max; i++) {
View Full Code Here

    if (child != null) {
      ASTNode parent = ((JavaElement) getParentElement()).findNode(this.cuAST);
      if (parent == null)
        parent = this.cuAST;
      insertASTNode(rewriter, parent, child);
      TextEdit edits = rewriter.rewriteAST();
      applyTextEdit(cu, edits);
    }
    worked(1);
  }
  /**
 
View Full Code Here

            }
           
            listRewrite.insertAt(node, i++, null);
        }

        textEdit = rewrite.rewriteAST(document, JavaCore.getOptions());
        try {
            textEdit.apply(document);
        } catch (BadLocationException e) {
            throw new ShellException(
                    "BadLocationException adding new fields and methods");
View Full Code Here

            }

            listRewrite.insertAt(node, i++, null);
        }

        textEdit = rewrite.rewriteAST(document, JavaCore.getOptions());
        try {
            textEdit.apply(document);
        } catch (BadLocationException e) {
            throw new ShellException(
                    "BadLocationException adding new fields and methods");
View Full Code Here

  protected void addEdits(IDocument document, TextEdit editRoot) throws CoreException {
//    super.addEdits(document, editRoot);
    ASTRewrite rewrite = m_rewriter;
    if (rewrite != null) {
      try {
        TextEdit edit= rewrite.rewriteAST();
        editRoot.addChild(edit);
      } catch (IllegalArgumentException e) {
        throw new CoreException(JavaUIStatus.createError(IStatus.ERROR, e));
      }
    }
View Full Code Here

//    AST ast = context.getASTRoot().getAST();
    AST ast = astRoot.getAST();
    ASTRewrite rewriter = new AnnotationRewriter().createRewriter(astRoot, ast);
    try {
      TextEdit edit = rewriter.rewriteAST();
      result = new TextFileChange(resource.getName(), (IFile) resource);
      result.setEdit(edit);
    } catch (JavaModelException e) {
      e.printStackTrace();
    } catch (IllegalArgumentException e) {
View Full Code Here

        listRewrite.insertFirst(pair, null);
      }

      astRewrite.getListRewrite(decl, MethodDeclaration.MODIFIERS2_PROPERTY).insertFirst(annotation, null);

      edit.addChild(astRewrite.rewriteAST());

      int oldLength = document.getLength();
      // int oldCurserPos = document.getCursorPosition();
      edit.apply(document);
View Full Code Here

    annotation.setTypeName(astRewrite.getAST().newSimpleName("RequestMapping"));
    astRewrite.getListRewrite(decl, TypeDeclaration.MODIFIERS2_PROPERTY).insertFirst(annotation, null);

    ITrackedNodePosition tracker = astRewrite.track(annotation.getTypeName());
    edit.addChild(astRewrite.rewriteAST());

    edit.apply(document);

    setReplacementOffset(tracker.getStartPosition() + annotation.getTypeName().getFullyQualifiedName().length() + 1);
  }
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.