void reconciled(CompilationUnit ast, IJavaElement javaElement, IProgressMonitor progressMonitor) { if (DEBUG) System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "reconciled: " + toString(javaElement) + ", AST: " + toString(ast)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ synchronized (fReconcileLock) { fIsReconciling= progressMonitor != null && progressMonitor.isCanceled(); if (javaElement == null || !javaElement.equals(fReconcilingJavaElement)) { if (DEBUG) System.out.println(getThreadName() + " - " + DEBUG_PREFIX + " ignoring AST of out-dated editor"); //$NON-NLS-1$ //$NON-NLS-2$ // Signal - threads might wait for wrong element synchronized (fWaitLock) { fWaitLock.notifyAll(); } return; } cache(ast, javaElement); } }
/** * Update internal structures after reconcile. * * @param ast the compilation unit AST or <code>null</code> if the working copy was consistent * or reconciliation has been cancelled * @param javaElement the Java element for which the AST was built * @param progressMonitor the progress monitor * @see org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener#reconciled(CompilationUnit, * boolean, IProgressMonitor) */ void reconciled(CompilationUnit ast, ITypeRoot javaElement, IProgressMonitor progressMonitor) { if (JavaPlugin.DEBUG_AST_PROVIDER) System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "reconciled: " + toString(javaElement) + ", AST: " + toString(ast)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ synchronized (fReconcileLock) { fIsReconciling= false; if (javaElement == null || !javaElement.equals(fReconcilingJavaElement)) { if (JavaPlugin.DEBUG_AST_PROVIDER) System.out.println(getThreadName() + " - " + DEBUG_PREFIX + " ignoring AST of out-dated editor"); //$NON-NLS-1$ //$NON-NLS-2$ // Signal - threads might wait for wrong element synchronized (fWaitLock) { fWaitLock.notifyAll(); } return; } cache(ast, javaElement); } }
/** * Informs that reconciling for the given element is about to be started. * * @param javaElement the Java element * @see org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener#aboutToBeReconciled() */ void aboutToBeReconciled(ITypeRoot javaElement) { if (javaElement == null) return; if (JavaPlugin.DEBUG_AST_PROVIDER) System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "about to reconcile: " + toString(javaElement)); //$NON-NLS-1$ //$NON-NLS-2$ synchronized (fReconcileLock) { fReconcilingJavaElement= javaElement; fIsReconciling= true; } cache(null, javaElement); }
/** * 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(); } }
/** * 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(); } }
/** * 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); }
/** * Informs that reconciling for the given element is about to be started. * * @param javaElement the Java element * @see org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener#aboutToBeReconciled() */ void aboutToBeReconciled(IJavaElement javaElement) { if (javaElement == null) return; if (DEBUG) System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "about to reconcile: " + toString(javaElement)); //$NON-NLS-1$ //$NON-NLS-2$ synchronized (fReconcileLock) { fIsReconciling= true; fReconcilingJavaElement= javaElement; } cache(null, javaElement); }
/** * 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); }
private void activeJavaEditorChanged(IWorkbenchPart editor) { IJavaElement javaElement= null; if (editor instanceof JavaEditor) javaElement= ((JavaEditor)editor).getInputJavaElement(); synchronized (this) { fActiveEditor= editor; fActiveJavaElement= javaElement; cache(null, javaElement); } if (DEBUG) System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "active editor is: " + toString(javaElement)); //$NON-NLS-1$ //$NON-NLS-2$ synchronized (fReconcileLock) { if (fIsReconciling && (fReconcilingJavaElement == null || !fReconcilingJavaElement.equals(javaElement))) { fIsReconciling= false; fReconcilingJavaElement= null; } else if (javaElement == null) { fIsReconciling= false; fReconcilingJavaElement= null; } } }
void activeJavaEditorChanged(IWorkbenchPart editor) { ITypeRoot javaElement= null; if (editor instanceof JavaEditor) javaElement= ((JavaEditor)editor).getInputJavaElement(); synchronized (this) { fActiveEditor= editor; fActiveJavaElement= javaElement; cache(null, javaElement); } if (JavaPlugin.DEBUG_AST_PROVIDER) System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "active editor is: " + toString(javaElement)); //$NON-NLS-1$ //$NON-NLS-2$ synchronized (fReconcileLock) { if (fIsReconciling && (fReconcilingJavaElement == null || !fReconcilingJavaElement.equals(javaElement))) { fIsReconciling= false; fReconcilingJavaElement= null; } else if (javaElement == null) { fIsReconciling= false; fReconcilingJavaElement= null; } } }
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$ 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$ ast= null; if (JavaPlugin.DEBUG_AST_PROVIDER) System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "Ignore created AST for: " + input.getElementName() + " - operation has been cancelled"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "Ignore created AST for " + input.getElementName() + " - AST from reconciler is newer"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ reconciled(fAST, input, null); return fAST;
if (fAST != null) { if (DEBUG) System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "returning cached AST:" + toString(fAST) + " for: " + je.getElementName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "returning null (WAIT_NO) for: " + je.getElementName()); //$NON-NLS-1$ //$NON-NLS-2$ System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "waiting for AST for: " + je.getElementName()); //$NON-NLS-1$ //$NON-NLS-2$ if (activeElement == fActiveJavaElement && fAST != null) { if (DEBUG) System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "...got AST for: " + je.getElementName()); //$NON-NLS-1$ //$NON-NLS-2$ ast= null; if (DEBUG) System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "Ignore created AST for: " + je.getElementName() + " - operation has been cancelled"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (fAST != null) { if (DEBUG) System.out.println(getThreadName() + " - " + DEBUG_PREFIX + "Ignore created AST for " + je.getElementName() + " - AST from reconciler is newer"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ reconciled(fAST, je, null); } else