X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java index 34ceb6f..a7cc596 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java @@ -7,15 +7,19 @@ import java.util.List; import net.sourceforge.phpdt.core.ICompilationUnit; import net.sourceforge.phpdt.core.IJavaElement; +import net.sourceforge.phpdt.core.IMember; import net.sourceforge.phpdt.core.ISourceRange; import net.sourceforge.phpdt.core.ISourceReference; import net.sourceforge.phpdt.core.JavaCore; import net.sourceforge.phpdt.core.JavaModelException; +import net.sourceforge.phpdt.core.dom.CompilationUnit; import net.sourceforge.phpdt.internal.compiler.parser.Scanner; import net.sourceforge.phpdt.internal.ui.actions.CompositeActionGroup; import net.sourceforge.phpdt.internal.ui.text.ContentAssistPreference; import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions; import net.sourceforge.phpdt.internal.ui.text.PHPPairMatcher; +import net.sourceforge.phpdt.internal.ui.text.SmartBackspaceManager; +import net.sourceforge.phpdt.internal.ui.text.java.IJavaReconcilingListener; import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionManager; import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionUI; import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionUI.ExitFlags; @@ -25,6 +29,7 @@ import net.sourceforge.phpdt.ui.actions.GenerateActionGroup; import net.sourceforge.phpdt.ui.text.JavaTextTools; import net.sourceforge.phpeclipse.PHPeclipsePlugin; +import org.eclipse.core.internal.runtime.ListenerList; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; @@ -47,7 +52,6 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ILineTracker; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextOperationTarget; -import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.text.ITextViewerExtension; import org.eclipse.jface.text.ITypedRegion; import org.eclipse.jface.text.IWidgetTokenKeeper; @@ -58,7 +62,6 @@ import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.IVerticalRuler; import org.eclipse.jface.text.source.SourceViewerConfiguration; import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.VerifyKeyListener; @@ -70,13 +73,17 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.dialogs.SaveAsDialog; import org.eclipse.ui.editors.text.IStorageDocumentProvider; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.part.FileEditorInput; +import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; import org.eclipse.ui.texteditor.ContentAssistAction; import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditorActionConstants; @@ -504,7 +511,358 @@ public class PHPUnitEditor extends PHPEditor { //implements // IDocument.DEFAULT_CONTENT_TYPE); } }; + /** + * Remembers data related to the current selection to be able to + * restore it later. + * + * @since 3.0 + */ + private class RememberedSelection { + /** The remembered selection start. */ + private RememberedOffset fStartOffset= new RememberedOffset(); + /** The remembered selection end. */ + private RememberedOffset fEndOffset= new RememberedOffset(); + + /** + * Remember current selection. + */ + public void remember() { + /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=52257 + * This method may be called inside an async call posted + * to the UI thread, so protect against intermediate disposal + * of the editor. + */ + ISourceViewer viewer= getSourceViewer(); + if (viewer != null) { + IRegion selection= getSignedSelection(viewer); + int startOffset= selection.getOffset(); + int endOffset= startOffset + selection.getLength(); + + fStartOffset.setOffset(startOffset); + fEndOffset.setOffset(endOffset); + } + } + + /** + * Restore remembered selection. + */ + public void restore() { + /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=52257 + * This method may be called inside an async call posted + * to the UI thread, so protect against intermediate disposal + * of the editor. + */ + if (getSourceViewer() == null) + return; + + try { + + int startOffset, endOffset; + int revealStartOffset, revealEndOffset; + if (showsHighlightRangeOnly()) { + IJavaElement newStartElement= fStartOffset.getElement(); + startOffset= fStartOffset.getRememberedOffset(newStartElement); + revealStartOffset= fStartOffset.getRevealOffset(newStartElement, startOffset); + if (revealStartOffset == -1) + startOffset= -1; + + IJavaElement newEndElement= fEndOffset.getElement(); + endOffset= fEndOffset.getRememberedOffset(newEndElement); + revealEndOffset= fEndOffset.getRevealOffset(newEndElement, endOffset); + if (revealEndOffset == -1) + endOffset= -1; + } else { + startOffset= fStartOffset.getOffset(); + revealStartOffset= startOffset; + endOffset= fEndOffset.getOffset(); + revealEndOffset= endOffset; + } + + if (startOffset == -1) { + startOffset= endOffset; // fallback to caret offset + revealStartOffset= revealEndOffset; + } + + if (endOffset == -1) { + endOffset= startOffset; // fallback to other offset + revealEndOffset= revealStartOffset; + } + + IJavaElement element; + if (endOffset == -1) { + // fallback to element selection + element= fEndOffset.getElement(); + if (element == null) + element= fStartOffset.getElement(); + if (element != null) + setSelection(element); + return; + } + + if (isValidSelection(revealStartOffset, revealEndOffset - revealStartOffset) && isValidSelection(startOffset, endOffset - startOffset)) + selectAndReveal(startOffset, endOffset - startOffset, revealStartOffset, revealEndOffset - revealStartOffset); + } finally { + fStartOffset.clear(); + fEndOffset.clear(); + } + } + + private boolean isValidSelection(int offset, int length) { + IDocumentProvider provider= getDocumentProvider(); + if (provider != null) { + IDocument document= provider.getDocument(getEditorInput()); + if (document != null) { + int end= offset + length; + int documentLength= document.getLength(); + return 0 <= offset && offset <= documentLength && 0 <= end && end <= documentLength; + } + } + return false; + } + + } + /** + * Remembers additional data for a given + * offset to be able restore it later. + * + * @since 3.0 + */ + private class RememberedOffset { + /** Remembered line for the given offset */ + private int fLine; + /** Remembered column for the given offset*/ + private int fColumn; + /** Remembered Java element for the given offset*/ + private IJavaElement fElement; + /** Remembered Java element line for the given offset*/ + private int fElementLine; + + /** + * Store visual properties of the given offset. + * + * @param offset Offset in the document + */ + public void setOffset(int offset) { + try { + IDocument document= getSourceViewer().getDocument(); + fLine= document.getLineOfOffset(offset); + fColumn= offset - document.getLineOffset(fLine); + fElement= getElementAt(offset, true); + + fElementLine= -1; + if (fElement instanceof IMember) { + ISourceRange range= ((IMember) fElement).getNameRange(); + if (range != null) + fElementLine= document.getLineOfOffset(range.getOffset()); + } + if (fElementLine == -1) + fElementLine= document.getLineOfOffset(getOffset(fElement)); + } catch (BadLocationException e) { + // should not happen + PHPeclipsePlugin.log(e); + clear(); + } catch (JavaModelException e) { + // should not happen + PHPeclipsePlugin.log(e.getStatus()); + clear(); + } + } + + /** + * Return offset recomputed from stored visual properties. + * + * @return Offset in the document + */ + public int getOffset() { + IJavaElement newElement= getElement(); + + int offset= getRememberedOffset(newElement); + + if (offset != -1 && !containsOffset(newElement, offset) && (offset == 0 || !containsOffset(newElement, offset - 1))) + return -1; + + return offset; + } + + /** + * Return offset recomputed from stored visual properties. + * + * @param newElement Enclosing element + * @return Offset in the document + */ + public int getRememberedOffset(IJavaElement newElement) { + try { + if (newElement == null) + return -1; + + IDocument document= getSourceViewer().getDocument(); + int newElementLine= -1; + if (newElement instanceof IMember) { + ISourceRange range= ((IMember) newElement).getNameRange(); + if (range != null) + newElementLine= document.getLineOfOffset(range.getOffset()); + } + if (newElementLine == -1) + newElementLine= document.getLineOfOffset(getOffset(newElement)); + if (newElementLine == -1) + return -1; + + int newLine= fLine + newElementLine - fElementLine; + if (newLine < 0 || newLine >= document.getNumberOfLines()) + return -1; + int maxColumn= document.getLineLength(newLine); + String lineDelimiter= document.getLineDelimiter(newLine); + if (lineDelimiter != null) + maxColumn= maxColumn - lineDelimiter.length(); + int offset; + if (fColumn > maxColumn) + offset= document.getLineOffset(newLine) + maxColumn; + else + offset= document.getLineOffset(newLine) + fColumn; + + return offset; + } catch (BadLocationException e) { + // should not happen + PHPeclipsePlugin.log(e); + return -1; + } catch (JavaModelException e) { + // should not happen + PHPeclipsePlugin.log(e.getStatus()); + return -1; + } + } + + /** + * Returns the offset used to reveal the given element based on the given selection offset. + * @param element the element + * @param offset the selection offset + * @return the offset to reveal the given element based on the given selection offset + */ + public int getRevealOffset(IJavaElement element, int offset) { + if (element == null || offset == -1) + return -1; + + if (containsOffset(element, offset)) { + if (offset > 0) { + IJavaElement alternateElement= getElementAt(offset, false); + if (element.getHandleIdentifier().equals(alternateElement.getParent().getHandleIdentifier())) + return offset - 1; // Solves test case 2 from https://bugs.eclipse.org/bugs/show_bug.cgi?id=47727#c3 + } + return offset; + } else if (offset > 0 && containsOffset(element, offset - 1)) + return offset - 1; // Solves test case 1 from https://bugs.eclipse.org/bugs/show_bug.cgi?id=47727#c3 + + return -1; + } + + /** + * Return Java element recomputed from stored visual properties. + * + * @return Java element + */ + public IJavaElement getElement() { + if (fElement == null) + return null; + + return findElement(fElement); + } + + /** + * Clears the stored position + */ + public void clear() { + fLine= -1; + fColumn= -1; + fElement= null; + fElementLine= -1; + } + + /** + * Does the given Java element contain the given offset? + * @param element Java element + * @param offset Offset + * @return true iff the Java element contains the offset + */ + private boolean containsOffset(IJavaElement element, int offset) { + int elementOffset= getOffset(element); + int elementLength= getLength(element); + return (elementOffset > -1 && elementLength > -1) ? (offset >= elementOffset && offset < elementOffset + elementLength) : false; + } + /** + * Returns the offset of the given Java element. + * + * @param element Java element + * @return Offset of the given Java element + */ + private int getOffset(IJavaElement element) { + if (element instanceof ISourceReference) { + ISourceReference sr= (ISourceReference) element; + try { + ISourceRange srcRange= sr.getSourceRange(); + if (srcRange != null) + return srcRange.getOffset(); + } catch (JavaModelException e) { + } + } + return -1; + } + + /** + * Returns the length of the given Java element. + * + * @param element Java element + * @return Length of the given Java element + */ + private int getLength(IJavaElement element) { + if (element instanceof ISourceReference) { + ISourceReference sr= (ISourceReference) element; + try { + ISourceRange srcRange= sr.getSourceRange(); + if (srcRange != null) + return srcRange.getLength(); + } catch (JavaModelException e) { + } + } + return -1; + } + + /** + * Returns the updated java element for the old java element. + * + * @param element Old Java element + * @return Updated Java element + */ + private IJavaElement findElement(IJavaElement element) { + + if (element == null) + return null; + + IWorkingCopyManager manager= PHPeclipsePlugin.getDefault().getWorkingCopyManager(); + ICompilationUnit unit= manager.getWorkingCopy(getEditorInput()); + + if (unit != null) { + try { + + synchronized (unit) { +// unit.reconcile(ICompilationUnit.NO_AST, false, null, null); + unit.reconcile(); + } + IJavaElement[] findings= unit.findElements(element); + if (findings != null && findings.length > 0) + return findings[0]; + + } catch (JavaModelException x) { + PHPeclipsePlugin.log(x.getStatus()); + // nothing found, be tolerant and go on + } + } + + return null; + } + + } + static class TabConverter implements ITextConverter { private int fTabRatio; @@ -862,8 +1220,12 @@ public class PHPUnitEditor extends PHPEditor { //implements /** The remembered java element */ private IJavaElement fRememberedElement; - /** The remembered selection */ - private ITextSelection fRememberedSelection; + /** + * The remembered selection. + * @since 3.0 + */ + private RememberedSelection fRememberedSelection= new RememberedSelection(); + /** The remembered php element offset */ private int fRememberedElementOffset; @@ -1060,6 +1422,22 @@ public class PHPUnitEditor extends PHPEditor { //implements /** * Creates a new php unit editor. */ + + /** + * Reconciling listeners. + * @since 3.0 + */ + private ListenerList fReconcilingListeners= new ListenerList(); + + /** + * Mutex for the reconciler. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=63898 + * for a description of the problem. + *

+ * TODO remove once the underlying problem is solved. + *

+ */ + private final Object fReconcilerLock= new Object(); + public PHPUnitEditor() { super(); setDocumentProvider(PHPeclipsePlugin.getDefault() @@ -1746,28 +2124,6 @@ public class PHPUnitEditor extends PHPEditor { //implements } /* - * @see AbstractTextEditor#canHandleMove(IEditorInput, IEditorInput) - */ - protected boolean canHandleMove(IEditorInput originalElement, - IEditorInput movedElement) { - String oldExtension = ""; //$NON-NLS-1$ - if (originalElement instanceof IFileEditorInput) { - IFile file = ((IFileEditorInput) originalElement).getFile(); - if (file != null) { - String ext = file.getFileExtension(); - if (ext != null) - oldExtension = ext; - } - } - String newExtension = ""; //$NON-NLS-1$ - if (movedElement instanceof IFileEditorInput) { - IFile file = ((IFileEditorInput) movedElement).getFile(); - if (file != null) - newExtension = file.getFileExtension(); - } - return oldExtension.equals(newExtension); - } - /* * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#getInputElement() */ protected IJavaElement getInputJavaElement() { @@ -1795,6 +2151,7 @@ public class PHPUnitEditor extends PHPEditor { //implements page.setInput(manager.getWorkingCopy(input)); } } + /* * @see AbstractTextEditor#performSaveOperation(WorkspaceModifyOperation, @@ -2115,26 +2472,47 @@ public class PHPUnitEditor extends PHPEditor { //implements return true; } + /* + * @see org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener#aboutToBeReconciled() + * @since 3.0 + */ + public void aboutToBeReconciled() { + + // Notify AST provider +// PHPeclipsePlugin.getDefault().getASTProvider().aboutToBeReconciled(getInputJavaElement()); + + // Notify listeners + Object[] listeners = fReconcilingListeners.getListeners(); + for (int i = 0, length= listeners.length; i < length; ++i) + ((IJavaReconcilingListener)listeners[i]).aboutToBeReconciled(); + } + /* - * @see IReconcilingParticipant#reconciled() - */ - public void reconciled() { - if (synchronizeOutlineOnCursorMove()) { - Shell shell = getSite().getShell(); - if (shell != null && !shell.isDisposed()) { - shell.getDisplay().asyncExec(new Runnable() { - public void run() { - synchronizeOutlinePageSelection(); - } - }); - } - } - } - - protected void updateStateDependentActions() { - super.updateStateDependentActions(); - fGenerateActionGroup.editorStateChanged(); - } + * @see org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener#reconciled(CompilationUnit, boolean, IProgressMonitor) + * @since 3.0 + */ + public void reconciled(CompilationUnit ast, boolean forced, IProgressMonitor progressMonitor) { + + // Always notify AST provider +// PHPeclipsePlugin.getDefault().getASTProvider().reconciled(ast, getInputJavaElement()); + + // Notify listeners +// Object[] listeners = fReconcilingListeners.getListeners(); +// for (int i = 0, length= listeners.length; i < length; ++i) +// ((IJavaReconcilingListener)listeners[i]).reconciled(ast, forced, progressMonitor); + + // Update Java Outline page selection + if (!forced && !progressMonitor.isCanceled()) { + Shell shell= getSite().getShell(); + if (shell != null && !shell.isDisposed()) { + shell.getDisplay().asyncExec(new Runnable() { + public void run() { + selectionChanged(); + } + }); + } + } + } private boolean synchronizeOutlineOnCursorMove() { return PreferenceConstants.getPreferenceStore().getBoolean( @@ -2182,86 +2560,147 @@ public class PHPUnitEditor extends PHPEditor { //implements return -1; } - /* - * @see AbstractTextEditor#rememberSelection() - */ - protected void rememberSelection() { - ISelectionProvider sp = getSelectionProvider(); - fRememberedSelection = (sp == null ? null : (ITextSelection) sp - .getSelection()); - if (fRememberedSelection != null) { - fRememberedElement = getElementAt(fRememberedSelection.getOffset(), true); - fRememberedElementOffset = getOffset(fRememberedElement); - } - } + /* * @see AbstractTextEditor#restoreSelection() */ - protected void restoreSelection() { - try { - if (getSourceViewer() == null || fRememberedSelection == null) - return; - IJavaElement newElement = findElement(fRememberedElement); - int newOffset = getOffset(newElement); - int delta = (newOffset > -1 && fRememberedElementOffset > -1) ? newOffset - - fRememberedElementOffset : 0; - if (isValidSelection(delta + fRememberedSelection.getOffset(), - fRememberedSelection.getLength())) - selectAndReveal(delta + fRememberedSelection.getOffset(), - fRememberedSelection.getLength()); - } finally { - fRememberedSelection = null; - fRememberedElement = null; - fRememberedElementOffset = -1; - } - } +// protected void restoreSelection() { +// try { +// if (getSourceViewer() == null || fRememberedSelection == null) +// return; +// IJavaElement newElement = findElement(fRememberedElement); +// int newOffset = getOffset(newElement); +// int delta = (newOffset > -1 && fRememberedElementOffset > -1) ? newOffset +// - fRememberedElementOffset : 0; +// if (isValidSelection(delta + fRememberedSelection.getOffset(), +// fRememberedSelection.getLength())) +// selectAndReveal(delta + fRememberedSelection.getOffset(), +// fRememberedSelection.getLength()); +// } finally { +// fRememberedSelection = null; +// fRememberedElement = null; +// fRememberedElementOffset = -1; +// } +// } - // /* - // * @see - // org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener#aboutToBeReconciled() - // * @since 3.0 - // */ - // public void aboutToBeReconciled() { - // - // // Notify AST provider - // PHPeclipsePlugin.getDefault().getASTProvider().aboutToBeReconciled(getInputJavaElement()); - // - // // Notify listeners - // Object[] listeners = fReconcilingListeners.getListeners(); - // for (int i = 0, length= listeners.length; i < length; ++i) - // ((IJavaReconcilingListener)listeners[i]).aboutToBeReconciled(); - // } - // - // /* - // * @see - // org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener#reconciled(CompilationUnit, - // boolean, IProgressMonitor) - // * @since 3.0 - // */ - // public void reconciled(net.sourceforge.phpdt.core.dom.CompilationUnit - // ast, boolean forced, IProgressMonitor progressMonitor) { - // - // // Always notify AST provider - // PHPeclipsePlugin.getDefault().getASTProvider().reconciled(ast, - // getInputJavaElement()); - // - // // Notify listeners - // Object[] listeners = fReconcilingListeners.getListeners(); - // for (int i = 0, length= listeners.length; i < length; ++i) - // ((IJavaReconcilingListener)listeners[i]).reconciled(ast, forced, - // progressMonitor); - // - // // Update Java Outline page selection - // if (!forced && !progressMonitor.isCanceled()) { - // Shell shell= getSite().getShell(); - // if (shell != null && !shell.isDisposed()) { - // shell.getDisplay().asyncExec(new Runnable() { - // public void run() { - // selectionChanged(); - // } - // }); - // } - // } - // } + /** + * Tells whether this is the active editor in the active page. + * + * @return true if this is the active editor in the active page + * @see IWorkbenchPage#getActiveEditor(); + */ + protected final boolean isActiveEditor() { + IWorkbenchWindow window= getSite().getWorkbenchWindow(); + IWorkbenchPage page= window.getActivePage(); + if (page == null) + return false; + IEditorPart activeEditor= page.getActiveEditor(); + return activeEditor != null && activeEditor.equals(this); + } + + /** + * Adds the given listener. + * Has no effect if an identical listener was not already registered. + * + * @param listener The reconcile listener to be added + * @since 3.0 + */ + final void addReconcileListener(IJavaReconcilingListener listener) { + synchronized (fReconcilingListeners) { + fReconcilingListeners.add(listener); + } + } + + /** + * Removes the given listener. + * Has no effect if an identical listener was not already registered. + * + * @param listener the reconcile listener to be removed + * @since 3.0 + */ + final void removeReconcileListener(IJavaReconcilingListener listener) { + synchronized (fReconcilingListeners) { + fReconcilingListeners.remove(listener); + } + } + + protected void updateStateDependentActions() { + super.updateStateDependentActions(); + fGenerateActionGroup.editorStateChanged(); + } + + /* + * @see AbstractTextEditor#rememberSelection() + */ + protected void rememberSelection() { + fRememberedSelection.remember(); + } + + /* + * @see AbstractTextEditor#restoreSelection() + */ + protected void restoreSelection() { + fRememberedSelection.restore(); + } + + /* + * @see AbstractTextEditor#canHandleMove(IEditorInput, IEditorInput) + */ + protected boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement) { + + String oldExtension= ""; //$NON-NLS-1$ + if (originalElement instanceof IFileEditorInput) { + IFile file= ((IFileEditorInput) originalElement).getFile(); + if (file != null) { + String ext= file.getFileExtension(); + if (ext != null) + oldExtension= ext; + } + } + + String newExtension= ""; //$NON-NLS-1$ + if (movedElement instanceof IFileEditorInput) { + IFile file= ((IFileEditorInput) movedElement).getFile(); + if (file != null) + newExtension= file.getFileExtension(); + } + + return oldExtension.equals(newExtension); + } + + /* + * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#isPrefQuickDiffAlwaysOn() + */ + protected boolean isPrefQuickDiffAlwaysOn() { + // reestablishes the behaviour from AbstractDecoratedTextEditor which was hacked by JavaEditor + // to disable the change bar for the class file (attached source) java editor. + IPreferenceStore store= getPreferenceStore(); + return store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON); + } + + /* + * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#getAdapter(java.lang.Class) + */ + public Object getAdapter(Class required) { + if (SmartBackspaceManager.class.equals(required)) { + if (getSourceViewer() instanceof JavaSourceViewer) { + return ((JavaSourceViewer) getSourceViewer()).getBackspaceManager(); + } + } + + return super.getAdapter(required); + } + /** + * Returns the mutex for the reconciler. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=63898 + * for a description of the problem. + *

+ * TODO remove once the underlying problem is solved. + *

+ * @return the lock reconcilers may use to synchronize on + */ + public Object getReconcilerLock() { + return fReconcilerLock; + } + } \ No newline at end of file