Package org.aspectj.org.eclipse.jdt.core.dom

Examples of org.aspectj.org.eclipse.jdt.core.dom.ASTParser


  }
}
protected ASTNode generateElementAST(ASTRewrite rewriter, IDocument document, ICompilationUnit cu) throws JavaModelException {
  if (this.createdNode == null) {
    this.source = removeIndentAndNewLines(this.source, document, cu);
    ASTParser parser = ASTParser.newParser(AST.JLS3);
    parser.setSource(this.source.toCharArray());
    parser.setProject(getCompilationUnit().getJavaProject());
    parser.setKind(ASTParser.K_CLASS_BODY_DECLARATIONS);
    ASTNode node = parser.createAST(this.progressMonitor);
    String createdNodeSource;
    if (node.getNodeType() != ASTNode.TYPE_DECLARATION) {
      createdNodeSource = generateSyntaxIncorrectAST();
      if (this.createdNode == null)
        throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_CONTENTS));
View Full Code Here


  IType type = getType();
  String lineSeparator = org.aspectj.org.eclipse.jdt.internal.core.util.Util.getLineSeparator(this.source, type == null ? null : type.getJavaProject());
  buff.append(lineSeparator + " public class A {" + lineSeparator); //$NON-NLS-1$
  buff.append(this.source);
  buff.append(lineSeparator).append('}');
  ASTParser parser = ASTParser.newParser(AST.JLS3);
  parser.setSource(buff.toString().toCharArray());
  CompilationUnit compilationUnit = (CompilationUnit) parser.createAST(null);
  TypeDeclaration typeDeclaration = (TypeDeclaration) compilationUnit.types().iterator().next();
  List bodyDeclarations = typeDeclaration.bodyDeclarations();
  if (bodyDeclarations.size() != 0)
    this.createdNode = (ASTNode) bodyDeclarations.iterator().next();
  return buff.toString();
View Full Code Here

* </ul>
*/
public org.aspectj.org.eclipse.jdt.core.dom.CompilationUnit getAST3() throws JavaModelException {
  if (this.operation.astLevel != AST.JLS3 || !this.operation.resolveBindings) {
    // create AST (optionally resolving bindings)
    ASTParser parser = ASTParser.newParser(AST.JLS3);
    parser.setCompilerOptions(workingCopy.getJavaProject().getOptions(true));
    if (JavaProject.hasJavaNature(workingCopy.getJavaProject().getProject()))
      parser.setResolveBindings(true);
    parser.setStatementsRecovery((this.operation.reconcileFlags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0);
    parser.setBindingsRecovery((this.operation.reconcileFlags & ICompilationUnit.ENABLE_BINDINGS_RECOVERY) != 0);
    parser.setSource(workingCopy);
    return (org.aspectj.org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(this.operation.progressMonitor);   
  }
  return this.operation.makeConsistent(this.workingCopy);
}
View Full Code Here

   * @param source
   */
  private String processElement(ICompilationUnit unit, char[] source) {
    Document document = new Document(new String(source));
    CompilerOptions options = new CompilerOptions(unit.getJavaProject().getOptions(true));
    ASTParser parser = ASTParser.newParser(this.apiLevel);
    parser.setCompilerOptions(options.getMap());
    parser.setSource(source);
    parser.setKind(ASTParser.K_COMPILATION_UNIT);
    parser.setResolveBindings(false);
    org.aspectj.org.eclipse.jdt.core.dom.CompilationUnit ast = (org.aspectj.org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(null);
       
    ASTRewrite rewriter= sortCompilationUnit(ast, null);
    if (rewriter == null)
      return document.get();
   
View Full Code Here

   }
  protected CompilationUnit parse(ICompilationUnit cu) throws JavaModelException {
    // ensure cu is consistent (noop if already consistent)
    cu.makeConsistent(this.progressMonitor);
    // create an AST for the compilation unit
    ASTParser parser = ASTParser.newParser(AST.JLS3);
    parser.setSource(cu);
    return (CompilationUnit) parser.createAST(this.progressMonitor);
  }
View Full Code Here

TOP

Related Classes of org.aspectj.org.eclipse.jdt.core.dom.ASTParser

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.