Package org.eclipse.jdt.core.dom

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


        this.javaFile = javaFile;
    }

    // use ASTParse to parse string
    public void parse() throws IOException {
        final ASTParser parser = ASTParser.newParser(AST.JLS3);
        parser.setSource(readFileToString().toCharArray());
        parser.setKind(ASTParser.K_COMPILATION_UNIT);

        // For now we only care about the package, parse more data as need
        // arises
        final CompilationUnit cu = (CompilationUnit) parser.createAST(null);
        javaPackage = cu.getPackage();
    }
View Full Code Here


    public char[] getContents() {
      StringBuilder bs = new StringBuilder();
     
      bs
          .append("package snippet;import java.io.PrintWriter;");
      ASTParser newParser = ASTParser.newParser(AST.JLS3);
      newParser.setSource(str.toCharArray());
      StringBuilder bls=new StringBuilder(str);
      CompilationUnit createAST = (CompilationUnit) newParser.createAST(null);
      //ArrayList<String> results = new ArrayList<String>();
      for (Object n : createAST.imports()) {
        ImportDeclaration decl = (ImportDeclaration) n;
        String name = decl.getName().getFullyQualifiedName();
        if (decl.isOnDemand()) {
View Full Code Here

   
  }

  protected String[] getImports() {
    String snippet = getSourceViewer().getDocument().get();
    ASTParser newParser = ASTParser.newParser(AST.JLS3);
    newParser.setSource(snippet.toCharArray());
    CompilationUnit createAST = (CompilationUnit) newParser.createAST(null);
    ArrayList<String> results = new ArrayList<String>();
    for (Object n : createAST.imports()) {
      ImportDeclaration decl = (ImportDeclaration) n;
      String name = decl.getName().getFullyQualifiedName();
      if (decl.isOnDemand()) {
View Full Code Here

   
    return null;
  }
 
  private void goThroughClass(ICompilationUnit ClassContent, final String contextTypeId) {
    ASTParser parser = ASTParser.newParser(AST.JLS3);
    parser.setSource(ClassContent);
    parser.setKind(ASTParser.K_COMPILATION_UNIT);
    final CompilationUnit cu = (CompilationUnit) parser.createAST(null);
    cu.accept(new ASTVisitor() {
      private boolean parameter = false;
      private String paramName = "";
      public void endVisit(FieldDeclaration node) {
        paramName = "";
View Full Code Here

     
      // create AST
      try
      {
        // use the parser directly, the use of static shared classes don't work with multipage editor
        ASTParser parser = ASTParser.newParser(AST.JLS3);
        parser.setResolveBindings(true);
        parser.setStatementsRecovery(true);
        parser.setBindingsRecovery(true);
        parser.setSource(input);
       
        CompilationUnit astRoot = (CompilationUnit)parser.createAST(monitor);
       
        if (astRoot != null && !monitor.isCanceled()) {
          Object[] listeners;
          synchronized (PartListenerGroup.this) {
            listeners= fAstListeners.getListeners();
View Full Code Here

    }
    return completionList;
  }

  private void goThroughClass(String ClassContent) {
    ASTParser parser = ASTParser.newParser(AST.JLS3);
    parser.setSource(ClassContent.toCharArray());
    parser.setKind(ASTParser.K_COMPILATION_UNIT);
    final CompilationUnit cu = (CompilationUnit) parser.createAST(null);
    cu.accept(new ASTVisitor() {

      private String elNodeName;
      private boolean intoEL;
View Full Code Here

    }
    return completionList;
  }

  private void goThroughClass(String ClassContent) {
    ASTParser parser = ASTParser.newParser(AST.JLS3);
    parser.setSource(ClassContent.toCharArray());
    parser.setKind(ASTParser.K_COMPILATION_UNIT);
    final CompilationUnit cu = (CompilationUnit) parser.createAST(null);
    cu.accept(new ASTVisitor() {

      private String elNodeName;
      private boolean intoEL;
      private boolean definedId;
View Full Code Here

      for (IPackageFragment packageFragment : project
          .getPackageFragments()) {
        if (packageFragment.getKind() == IPackageFragmentRoot.K_SOURCE) {
          for (ICompilationUnit compilationUnit : packageFragment
              .getCompilationUnits()) {
            ASTParser parser = ASTParser.newParser(AST.JLS4);
            parser.setKind(ASTParser.K_COMPILATION_UNIT);
            parser.setSource(compilationUnit);
            // a switch for turning on/off resolve bindings
            parser.setResolveBindings(ifBindings);
            parser.createAST(null).accept(this);
          }
        }
      }
    }
    return all;
View Full Code Here

      for (IPackageFragment packageFragment : project
          .getPackageFragments()) {
        if (packageFragment.getKind() == IPackageFragmentRoot.K_SOURCE) {
          for (ICompilationUnit compilationUnit : packageFragment
              .getCompilationUnits()) {
            ASTParser parser = ASTParser.newParser(AST.JLS4);
            parser.setKind(ASTParser.K_COMPILATION_UNIT);
            parser.setSource(compilationUnit);
            // a switch for turning on/off resolve bindings
            parser.setResolveBindings(ifBindings);
            parser.createAST(null).accept(this);
          }
        }
      }
    }
  }
View Full Code Here

   *
   * @param unit
   * @return
   */
  public static CompilationUnit parse(ICompilationUnit iUnit) {
    ASTParser parser = ASTParser.newParser(AST.JLS4);
    parser.setKind(ASTParser.K_COMPILATION_UNIT);
    parser.setSource(iUnit);
    parser.setResolveBindings(true);
    Visitor visitor = new Visitor();
    CompilationUnit unit = (CompilationUnit) parser.createAST(null);
    unit.accept(visitor);
    return unit; // parse
  }
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.