Examples of createAST()


Examples of org.eclipse.jdt.core.dom.ASTParser.createAST()

    private CompilationUnit createASTForImports(ICompilationUnit cu) {
        ASTParser parser = ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
        parser.setSource(cu);
        parser.setResolveBindings(false);
        parser.setFocalPosition(0);
        return (CompilationUnit) parser.createAST(null);
    }

    private Set<String> getExistingImports(CompilationUnit root) {
        @SuppressWarnings("unchecked")
        List<ImportDeclaration> imports = root.imports();
View Full Code Here

Examples of org.eclipse.jdt.core.dom.ASTParser.createAST()

    private void removeUnusedImports(ICompilationUnit cu, Set<String> existingImports, boolean needsSave) throws CoreException {
        ASTParser parser = ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
        parser.setSource(cu);
        parser.setResolveBindings(true);

        CompilationUnit root = (CompilationUnit) parser.createAST(null);
        if (root.getProblems().length == 0) {
            return;
        }

        @SuppressWarnings("unchecked")
View Full Code Here

Examples of org.eclipse.jdt.core.dom.ASTParser.createAST()

        String content = CodeGeneration.getCompilationUnitContent(cu, fileComment, typeComment, typeContent, lineDelimiter);
        if (content != null) {
            ASTParser parser = ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
            parser.setProject(cu.getJavaProject());
            parser.setSource(content.toCharArray());
            CompilationUnit unit = (CompilationUnit) parser.createAST(null);
            if ((pack.isDefaultPackage() || unit.getPackage() != null) && !unit.types().isEmpty()) {
                return content;
            }
        }
        StringBuffer buf = new StringBuffer();
View Full Code Here

Examples of org.eclipse.jdt.core.dom.ASTParser.createAST()

        CodeGenerationSettings settings = JavaPreferencesSettings.getCodeGenerationSettings(type.getJavaProject());
        settings.createComments = isAddComments();
        ASTParser parser = ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
        parser.setResolveBindings(true);
        parser.setSource(cu);
        CompilationUnit unit = (CompilationUnit) parser.createAST(new SubProgressMonitor(monitor, 1));
        final ITypeBinding binding = ASTNodes.getTypeBinding(unit, type);
        if (binding != null) {
            if (doUnimplementedMethods) {
                AddUnimplementedMethodsOperation operation = new AddUnimplementedMethodsOperation(unit, binding, null, -1, false, true, false);
                operation.setCreateComments(isAddComments());
View Full Code Here

Examples of org.eclipse.jdt.core.dom.ASTParser.createAST()

    parser.setCompilerOptions(options);

    parser.setEnvironment(classPathEntries.toArray(new String[classPathEntries.size()]),
        sourcePathEntries.toArray(new String[sourcePathEntries.size()]), null, true);

    CompilationUnit cu = (CompilationUnit) parser.createAST(null);

    return cu;
  }

  private char[] getFileContents(ISourceLocation loc, IEvaluatorContext ctx) throws IOException {
View Full Code Here

Examples of org.eclipse.jdt.core.dom.ASTParser.createAST()

        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();
    }

    private String readFileToString() throws IOException {
        final FileInputStream in = new FileInputStream(javaFile);
View Full Code Here

Examples of org.eclipse.jdt.core.dom.ASTParser.createAST()

      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

Examples of org.eclipse.jdt.core.dom.ASTParser.createAST()

  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

Examples of org.eclipse.jdt.core.dom.ASTParser.createAST()

 
  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

Examples of org.eclipse.jdt.core.dom.ASTParser.createAST()

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