private static CompilationUnit getAST(ISourceReference sr) { return ASTProvider.getASTProvider().getAST((IJavaElement) sr, ASTProvider.WAIT_YES, null); }
public CompilationUnit getASTRoot() { if (fASTRoot == null) { fASTRoot= ASTProvider.getASTProvider().getAST(fCompilationUnit, ASTProvider.WAIT_YES, null); if (fASTRoot == null) { // see bug 63554 fASTRoot= ASTResolving.createQuickFixAST(fCompilationUnit, null); } } return fASTRoot; }
private static CompilationUnit getASTRoot(ICompilationUnit compilationUnit, IProgressMonitor monitor) { CompilationUnit result= ASTProvider.getASTProvider().getAST(compilationUnit, ASTProvider.WAIT_YES, monitor); if (result == null) { // see bug 63554 result= ASTResolving.createQuickFixAST(compilationUnit, monitor); } return result; } }
/** * Tries to get the shared AST from the ASTProvider. * If the shared AST is not available, parses the type root with a * RefactoringASTParser that uses settings similar to the ASTProvider. * * @param typeRoot the type root * @param resolveBindings TODO * @param pm an {@link IProgressMonitor}, or <code>null</code> * @return the parsed CompilationUnit */ public static CompilationUnit parseWithASTProvider(ITypeRoot typeRoot, boolean resolveBindings, IProgressMonitor pm) { CompilationUnit cuNode= ASTProvider.getASTProvider().getAST(typeRoot, ASTProvider.WAIT_ACTIVE_ONLY, pm); if (cuNode != null) { return cuNode; } else { return new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(typeRoot, null, resolveBindings, ASTProvider.SHARED_AST_STATEMENT_RECOVERY, ASTProvider.SHARED_BINDING_RECOVERY, pm); } }
protected void doPropertyChanged(String property) { if (property.equals(PreferenceConstants.EDITOR_QUICKASSIST_LIGHTBULB)) { if (isSetInPreferences()) { ICompilationUnit cu= getCompilationUnit(); if (cu != null) { installSelectionListener(); Point point= fViewer.getSelectedRange(); CompilationUnit astRoot= ASTProvider.getASTProvider().getAST(cu, ASTProvider.WAIT_ACTIVE_ONLY, null); if (astRoot != null) { doSelectionChanged(point.x, point.y, astRoot); } } } else { uninstallSelectionListener(); } } }
astRoot= ASTProvider.getASTProvider().getAST(fCompilationUnit, ASTProvider.WAIT_YES, new SubProgressMonitor(monitor, 2)); if (monitor.isCanceled()) throw new OperationCanceledException();
astRoot= ASTProvider.getASTProvider().getAST(fCompilationUnit, ASTProvider.WAIT_YES, new SubProgressMonitor(monitor, 2)); } else { monitor.worked(2);
private CompilationUnit createAst(ICompilationUnit unit, Map cleanUpOptions, IProgressMonitor monitor) { IJavaProject project= unit.getJavaProject(); if (compatibleOptions(project, cleanUpOptions)) { CompilationUnit ast= ASTProvider.getASTProvider().getAST(unit, ASTProvider.WAIT_NO, monitor); if (ast != null) return ast; } ASTParser parser= ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL); parser.setResolveBindings(true); parser.setProject(project); parser.setSource(unit); Map compilerOptions= RefactoringASTParser.getCompilerOptions(unit.getJavaProject()); compilerOptions.putAll(cleanUpOptions); parser.setCompilerOptions(compilerOptions); return (CompilationUnit)parser.createAST(monitor); }
public static boolean isApplicable(IInvocationContext context) throws JavaModelException { ICompilationUnit unit= context.getCompilationUnit(); CompilationUnit ast= ASTProvider.getASTProvider().getAST(unit, ASTProvider.WAIT_NO, null); if (ast == null) return true; Selection selection= Selection.createFromStartLength(context.getSelectionOffset(), context.getSelectionLength()); SurroundWithAnalyzer analyzer= new SurroundWithAnalyzer(unit, selection); context.getASTRoot().accept(analyzer); return analyzer.getStatus().isOK() && analyzer.hasSelectedNodes(); }
/** * Opens and reveals the defining method. */ public void open() { CompilationUnit ast= ASTProvider.getASTProvider().getAST(fJavaElement, ASTProvider.WAIT_ACTIVE_ONLY, null); if (ast != null) { ASTNode node= ast.findDeclaringNode(fAstNodeKey); if (node instanceof MethodDeclaration) { try { IMethodBinding methodBinding= ((MethodDeclaration)node).resolveBinding(); IMethodBinding definingMethodBinding= Bindings.findOverriddenMethod(methodBinding, true); if (definingMethodBinding != null) { IJavaElement definingMethod= definingMethodBinding.getJavaElement(); if (definingMethod != null) { JavaUI.openInEditor(definingMethod, true, true); return; } } } catch (CoreException e) { ExceptionHandler.handle(e, JavaEditorMessages.OverrideIndicatorManager_open_error_title, JavaEditorMessages.OverrideIndicatorManager_open_error_messageHasLogEntry); return; } } } String title= JavaEditorMessages.OverrideIndicatorManager_open_error_title; String message= JavaEditorMessages.OverrideIndicatorManager_open_error_message; MessageDialog.openError(JavaPlugin.getActiveWorkbenchShell(), title, message); } }
CompilationUnit ast= ASTProvider.getASTProvider().getAST(element, ASTProvider.WAIT_YES, null); if (ast == null) return null;