Examples of rewriteAST()


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

                Messages.format("fail(\"{0}\");", message),
                ASTNode.RETURN_STATEMENT));

          memberRewriter.insertLast(stub, null);
        }
        edit.addChild(astRewrite.rewriteAST());

        JavaModelUtil.applyEdit(src, edit, true, null);
      }catch(Exception e){
        throw new RuntimeException(e);
      }
View Full Code Here

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

    if (node == null)
      Assert.isTrue(false, "Failed to locate " + elementToRemove.getElementName() + " in " + cu.getElementName()); //$NON-NLS-1$//$NON-NLS-2$
    AST ast = astCU.getAST();
    ASTRewrite rewriter = ASTRewrite.create(ast);
    rewriter.remove(node, null);
     TextEdit edits = rewriter.rewriteAST();
     applyTextEdit(cu, edits);
  }

  private void initASTParser() {
    this.parser = ASTParser.newParser(AST.JLS4);
View Full Code Here

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

            this.parser.setSource(cu);
            CompilationUnit astCU = (CompilationUnit) this.parser.createAST(this.progressMonitor);
            AST ast = astCU.getAST();
            ASTRewrite rewrite = ASTRewrite.create(ast);
            updatePackageStatement(astCU, newFragName, rewrite, cu);
            TextEdit edits = rewrite.rewriteAST();
            applyTextEdit(cu, edits);
            cu.save(null, false);
          }
        }
      }
View Full Code Here

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

      CompilationUnit astCU = (CompilationUnit) this.parser.createAST(this.progressMonitor);
      AST ast = astCU.getAST();
      ASTRewrite rewrite = ASTRewrite.create(ast);
      updateTypeName(cu, astCU, cu.getElementName(), newName, rewrite);
      updatePackageStatement(astCU, destPackageName, rewrite, cu);
      return rewrite.rewriteAST();
    }
  }
  private void updatePackageStatement(CompilationUnit astCU, String[] pkgName, ASTRewrite rewriter, ICompilationUnit cu) throws JavaModelException {
    boolean defaultPackage = pkgName.length == 0;
    AST ast = astCU.getAST();
View Full Code Here

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

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

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

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

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

    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

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

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

            }
           
            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

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

            }

            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
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.