Package org.eclipse.jdt.core.dom

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


        final ICompilationUnit cunit = type.getCompilationUnit();
        if (cunit == null)
            return null; // not a source type

        ASTParser parser = ASTParser.newParser(AST.JLS4);
        parser.setKind(ASTParser.K_COMPILATION_UNIT);
        parser.setSource(cunit);
        parser.setResolveBindings(true);
        return (CompilationUnit) parser.createAST(null);
    }
View Full Code Here


* </ul>
*/
public 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(this.workingCopy.getJavaProject().getOptions(true));
    if (JavaProject.hasJavaNature(this.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(this.workingCopy);
    parser.setIgnoreMethodBodies((this.operation.reconcileFlags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0);
    return (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(this.operation.progressMonitor);
  }
  return this.operation.makeConsistent(this.workingCopy);
}
View Full Code Here

* @since 3.7.1
*/
public org.eclipse.jdt.core.dom.CompilationUnit getAST4() throws JavaModelException {
  if (this.operation.astLevel != AST.JLS4 || !this.operation.resolveBindings) {
    // create AST (optionally resolving bindings)
    ASTParser parser = ASTParser.newParser(AST.JLS4);
    parser.setCompilerOptions(this.workingCopy.getJavaProject().getOptions(true));
    if (JavaProject.hasJavaNature(this.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(this.workingCopy);
    parser.setIgnoreMethodBodies((this.operation.reconcileFlags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0);
    return (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(this.operation.progressMonitor);
  }
  return this.operation.makeConsistent(this.workingCopy);
}
View Full Code Here

* </ul>
*/
public 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.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(this.operation.progressMonitor);   
  }
  return this.operation.makeConsistent(this.workingCopy);
}
View Full Code Here

        // iterate over this file
        String name = file.substring(0, file.lastIndexOf(".java")); // remove extension
       
        System.out.println("Parsing '" + inFile + "'...");
       
        ASTParser parser = ASTParser.newParser(AST.JLS3);
        parser.setKind(ASTParser.K_COMPILATION_UNIT);
        char[] input = readFile(inFile);
        parser.setSource(input);
        parser.setResolveBindings(true);
        CompilationUnit cu = (CompilationUnit) parser.createAST(null);
       
        // create a new JavaClass
        JavaClass cls = factory.createJavaClass();
        cls.setPlugin(plugin);
        cls.setPackage(pkg);
View Full Code Here

  }

  // may have problem?!!
  public CompilationUnit getASTNode() {
    try {
      ASTParser parser = ASTParser.newParser(AST.JLS3);
      parser.setSource((ICompilationUnit) getJavaElement());
      return (CompilationUnit) parser.createAST(null);
    } catch (RuntimeException e) {
      e.printStackTrace();
      return null;
    }
  }
View Full Code Here

   * @param unit
   * @return
   */

  private static CompilationUnit parse(ICompilationUnit unit) {
    ASTParser parser = ASTParser.newParser(AST.JLS3);
    parser.setKind(ASTParser.K_COMPILATION_UNIT);
    parser.setSource(unit);
    parser.setResolveBindings(true);
    return (CompilationUnit) parser.createAST(null); // parse
  }
View Full Code Here

   * @param unit
   * @return
   */

  private static CompilationUnit parse(ICompilationUnit unit) {
    ASTParser parser = ASTParser.newParser(AST.JLS3);
    parser.setKind(ASTParser.K_COMPILATION_UNIT);
    parser.setSource(unit);
    parser.setResolveBindings(true);
    return (CompilationUnit) parser.createAST(null); // parse
  }
View Full Code Here

   * @param unit
   * @return
   */

  private static CompilationUnit parse(ICompilationUnit unit) {
    ASTParser parser = ASTParser.newParser(AST.JLS3);
    parser.setKind(ASTParser.K_COMPILATION_UNIT);
    parser.setSource(unit);
    parser.setResolveBindings(true);
    return (CompilationUnit) parser.createAST(null); // parse
  }
View Full Code Here

  public static List<JavaElement> getWicketComponentTypes(final IFile javaFile) {
    Assert.isNotNull(javaFile);
    final Set<JavaElement> set = new HashSet<JavaElement>();

    final ASTParser parser = ASTParser.newParser(AST.JLS4);
    parser.setResolveBindings(true);
    parser.setSource(JavaCore.createCompilationUnitFrom(javaFile));
    final CompilationUnit cu = (CompilationUnit) parser.createAST(null);
    cu.accept(new ASTVisitor() {

      @Override
      public boolean visit(final ClassInstanceCreation node) {
        final ITypeBinding ntb = node.resolveTypeBinding();
View Full Code Here

TOP

Related Classes of 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.