/** * Returns the AST provider. * * @return the AST provider * @since 3.0 */ public synchronized ASTProvider getASTProvider() { if (fASTProvider == null) fASTProvider= new ASTProvider(); return fASTProvider; }
if (fAST != null) { if (JavaPlugin.DEBUG_AST_PROVIDER) System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "returning cached AST:" + toString(fAST) + " for: " + input.getElementName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "returning null (WAIT_NO) for: " + input.getElementName()); //$NON-NLS-1$ //$NON-NLS-2$ synchronized (fReconcileLock) { activeElement= fReconcilingJavaElement; isReconciling= isReconciling(input); if (!isReconciling && !canReturnNull) aboutToBeReconciled(input); if (isReconciling(input)) { if (JavaPlugin.DEBUG_AST_PROVIDER) System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "waiting for AST for: " + input.getElementName()); //$NON-NLS-1$ //$NON-NLS-2$ fWaitLock.wait(30000); // XXX: The 30 seconds timeout is an attempt to at least avoid a deadlock. See https://bugs.eclipse.org/366048#c21 if (activeElement == fActiveJavaElement && fAST != null) { if (JavaPlugin.DEBUG_AST_PROVIDER) System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "...got AST: " + toString(fAST) + " for: " + input.getElementName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ return getAST(input, waitFlag, progressMonitor); } catch (InterruptedException e) { return null; // thread has been interrupted don't compute AST ast= createAST(input, progressMonitor); if (progressMonitor != null && progressMonitor.isCanceled()) { ast= null; if (JavaPlugin.DEBUG_AST_PROVIDER)
/** * Creates a new AST provider. */ public ASTProvider() { install(); }
/** * Disposes the cached AST. */ private synchronized void disposeAST() { if (fAST == null) return; if (DEBUG) System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "disposing AST: " + toString(fAST) + " for: " + toString(fActiveJavaElement)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ fAST= null; cache(null, null); }
private static CompilationUnit getAST(ISourceReference sr) { return ASTProvider.getASTProvider().getAST((IJavaElement) sr, ASTProvider.WAIT_YES, null); }
/** * Caches the given compilation unit AST for the given Java element. * * @param ast the ast * @param javaElement the java element */ private synchronized void cache(CompilationUnit ast, ITypeRoot javaElement) { if (fActiveJavaElement != null && !fActiveJavaElement.equals(javaElement)) { if (JavaPlugin.DEBUG_AST_PROVIDER && javaElement != null) // don't report call from disposeAST() System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "don't cache AST for inactive: " + toString(javaElement)); //$NON-NLS-1$ //$NON-NLS-2$ return; } if (JavaPlugin.DEBUG_AST_PROVIDER && (javaElement != null || ast != null)) // don't report call from disposeAST() System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "caching AST: " + toString(ast) + " for: " + toString(javaElement)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (fAST != null) disposeAST(); fAST= ast; // Signal AST change synchronized (fWaitLock) { fWaitLock.notifyAll(); } }
/** * Returns a shared compilation unit AST for the given * Java element. * <p> * Clients are not allowed to modify the AST and must * synchronize all access to its nodes. * </p> * * @param je the Java element * @param wait <code>true</code> if the client wants to wait for the result, * <code>null</code> will be returned if the AST is not ready and * the client does not want to wait * @param progressMonitor the progress monitor or <code>null</code> * @return the AST or <code>null</code> if the AST is not available * @deprecated As of 3.1, use {@link #getAST(IJavaElement, WAIT_FLAG, IProgressMonitor)} */ public CompilationUnit getAST(IJavaElement je, boolean wait, IProgressMonitor progressMonitor) { if (wait) return getAST(je, WAIT_YES, progressMonitor); else return getAST(je, WAIT_NO, progressMonitor); }
@Override public void partClosed(IWorkbenchPartReference ref) { if (isActiveEditor(ref)) { if (JavaPlugin.DEBUG_AST_PROVIDER) System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "closed active editor: " + ref.getTitle()); //$NON-NLS-1$ //$NON-NLS-2$ activeJavaEditorChanged(null); } }
boolean isASTNeeded= initialReconcile || JavaPlugin.getDefault().getASTProvider().isActive(unit);
fASTProvider.dispose(); fASTProvider= null;
/** * Disposes this AST provider. */ public void dispose() { // Dispose activation listener PlatformUI.getWorkbench().removeWindowListener(fActivationListener); fActivationListener= null; disposeAST(); synchronized (fWaitLock) { fWaitLock.notifyAll(); } }
@Override public void aboutToBeReconciled() { // Notify AST provider JavaPlugin.getDefault().getASTProvider().aboutToBeReconciled(getInputJavaElement()); // Notify listeners for (IJavaReconcilingListener listener : fReconcilingListeners) { listener.aboutToBeReconciled(); } }
private CompilationUnit getASTRoot(ICompilationUnit compilationUnit) { return JavaPlugin.getDefault().getASTProvider().getAST(compilationUnit, ASTProvider.WAIT_NO, new NullProgressMonitor()); }
/** * Disposes the cached AST. */ private synchronized void disposeAST() { if (fAST == null) return; if (JavaPlugin.DEBUG_AST_PROVIDER) System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "disposing AST: " + toString(fAST) + " for: " + toString(fActiveJavaElement)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ fAST= null; cache(null, 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; }
/** * Caches the given compilation unit AST for the given Java element. * * @param ast * @param javaElement */ private synchronized void cache(CompilationUnit ast, IJavaElement javaElement) { if (fActiveJavaElement != null && !fActiveJavaElement.equals(javaElement)) { if (DEBUG && javaElement != null) // don't report call from disposeAST() System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "don't cache AST for inactive: " + toString(javaElement)); //$NON-NLS-1$ //$NON-NLS-2$ return; } if (DEBUG && (javaElement != null || ast != null)) // don't report call from disposeAST() System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "caching AST: " + toString(ast) + " for: " + toString(javaElement)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (fAST != null) disposeAST(); fAST= ast; // Signal AST change synchronized (fWaitLock) { fWaitLock.notifyAll(); } }
@Override public void partClosed(IWorkbenchPartReference ref) { if (isActiveEditor(ref)) { if (JavaPlugin.DEBUG_AST_PROVIDER) System.out.println(CoreASTProvider.getThreadName() + " - " + CoreASTProvider.DEBUG_PREFIX + "closed active editor: " + ref.getTitle()); //$NON-NLS-1$ //$NON-NLS-2$ activeJavaEditorChanged(null); } }
boolean isASTNeeded= initialReconcile || JavaPlugin.getDefault().getASTProvider().isActive(unit);
fASTProvider.dispose(); fASTProvider= null;
/** * Disposes this AST provider. */ public void dispose() { // Dispose activation listener PlatformUI.getWorkbench().removeWindowListener(fActivationListener); fActivationListener= null; disposeAST(); synchronized (fWaitLock) { fWaitLock.notifyAll(); } }