Java Code Examples for org.eclipse.jdt.core.ITypeRoot#equals()

The following examples show how to use org.eclipse.jdt.core.ITypeRoot#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ASTProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 (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= false;
		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);
	}
}
 
Example 2
Source File: JavaElementHyperlinkDetector.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
	ITextEditor textEditor= (ITextEditor)getAdapter(ITextEditor.class);
	if (region == null || !(textEditor instanceof JavaEditor))
		return null;

	IAction openAction= textEditor.getAction("OpenEditor"); //$NON-NLS-1$
	if (!(openAction instanceof SelectionDispatchAction))
		return null;

	int offset= region.getOffset();

	ITypeRoot input= EditorUtility.getEditorInputJavaElement(textEditor, false);
	if (input == null)
		return null;

	try {
		IDocumentProvider documentProvider= textEditor.getDocumentProvider();
		IEditorInput editorInput= textEditor.getEditorInput();
		IDocument document= documentProvider.getDocument(editorInput);
		IRegion wordRegion= JavaWordFinder.findWord(document, offset);
		if (wordRegion == null || wordRegion.getLength() == 0)
			return null;

		if (isInheritDoc(document, wordRegion) && getClass() != JavaElementHyperlinkDetector.class)
			return null;

		if (JavaElementHyperlinkDetector.class == getClass() && findBreakOrContinueTarget(input, region) != null)
			return new IHyperlink[] { new JavaElementHyperlink(wordRegion, (SelectionDispatchAction)openAction, null, false) };
		
		IJavaElement[] elements;
		long modStamp= documentProvider.getModificationStamp(editorInput);
		if (input.equals(fLastInput) && modStamp == fLastModStamp && wordRegion.equals(fLastWordRegion)) {
			elements= fLastElements;
		} else {
			elements= ((ICodeAssist) input).codeSelect(wordRegion.getOffset(), wordRegion.getLength());
			elements= selectOpenableElements(elements);
			fLastInput= input;
			fLastModStamp= modStamp;
			fLastWordRegion= wordRegion;
			fLastElements= elements;
		}
		if (elements.length == 0)
			return null;
		
		ArrayList<IHyperlink> links= new ArrayList<IHyperlink>(elements.length);
		for (int i= 0; i < elements.length; i++) {
			addHyperlinks(links, wordRegion, (SelectionDispatchAction)openAction, elements[i], elements.length > 1, (JavaEditor)textEditor);
		}
		if (links.size() == 0)
			return null;
		
		return CollectionsUtil.toArray(links, IHyperlink.class);

	} catch (JavaModelException e) {
		return null;
	}
}
 
Example 3
Source File: ASTProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Tells whether the given Java element is the one
 * reported as currently being reconciled.
 *
 * @param javaElement the Java element
 * @return <code>true</code> if reported as currently being reconciled
 */
private boolean isReconciling(ITypeRoot javaElement) {
	return javaElement != null && javaElement.equals(fReconcilingJavaElement) && fIsReconciling;
}