diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java index e37f434d2e9..8069eb40b06 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java @@ -89,25 +89,26 @@ import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditor; /** - * Source display adapter that performs the source lookup, opens the editor, - * and paints the IP for the given object. + * Source display adapter that performs the source lookup, opens the editor, and + * paints the IP for the given object. *
- * The implementation relies on three types of jobs to perform the operations.
- * - The first kind, "lookup job" performs the source lookup operation.
- * - The second "display job" positions and annotates the editor.
- * - The third clears the old IP annotations when a thread or process has resumed
- * or exited.
+ * The implementation relies on three types of jobs to perform the
+ * operations.
+ * - The first kind, "lookup job" performs the source lookup operation.
+ * - The second "display job" positions and annotates the editor.
+ * - The third clears the old IP annotations when a thread or process has
+ * resumed or exited.
*
- * The the lookup jobs can run in parallel with the display or the clearing job, - * but the clearing job and the display job must not run at the same time. - * Hence there is some involved logic which ensures that the jobs are run in - * proper order. To avoid race conditions, this logic uses the session's - * dispatch thread to synchronize access to the state data of the running jobs. + * The the lookup jobs can run in parallel with the display or the clearing job, + * but the clearing job and the display job must not run at the same time. Hence + * there is some involved logic which ensures that the jobs are run in proper + * order. To avoid race conditions, this logic uses the session's dispatch + * thread to synchronize access to the state data of the running jobs. *
** Debuggers can override the default source editor used by the source display - * adapter by registering their own ISourcePresentation adapter. + * adapter by registering their own ISourcePresentation adapter. *
* * @see ISourcePresentation @@ -115,49 +116,56 @@ import org.eclipse.ui.texteditor.ITextEditor; * @since 1.0 */ @ThreadSafe -public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControlParticipant -{ - private static final class FrameData { +public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControlParticipant { + private static final class FrameData { IFrameDMContext fDmc; - int fLine; - int fLevel; + int fLine; + int fLevel; String fFile; - + @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } FrameData other = (FrameData) obj; - if (!fDmc.equals(other.fDmc)) + if (!fDmc.equals(other.fDmc)) { return false; + } if (fFile == null) { - if (other.fFile != null) + if (other.fFile != null) { return false; - } else if (!fFile.equals(other.fFile)) + } + } else if (!fFile.equals(other.fFile)) { return false; + } return true; } /** - * Test whether the given frame data instance refers to the very same location. + * Test whether the given frame data instance refers to the very same + * location. * * @param frameData - * @returntrue
if the frame data refers to the same location
+ * @return true
if the frame data refers to the same
+ * location
*/
public boolean isIdentical(FrameData frameData) {
return equals(frameData) && fLine == frameData.fLine;
}
- }
-
- /**
+ }
+
+ /**
* A job to perform source lookup on the given DMC.
*/
class LookupJob extends Job {
-
+
private final IWorkbenchPage fPage;
private final FrameData fFrameData;
private final boolean fEventTriggered;
@@ -166,7 +174,7 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
* Constructs a new source lookup job.
*/
public LookupJob(FrameData frameData, IWorkbenchPage page, boolean eventTriggered) {
- super("DSF Source Lookup"); //$NON-NLS-1$
+ super("DSF Source Lookup"); //$NON-NLS-1$
setPriority(Job.INTERACTIVE);
setSystem(true);
fFrameData = frameData;
@@ -174,124 +182,135 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
fEventTriggered = eventTriggered;
}
- IDMContext getDmc() { return fFrameData.fDmc; }
-
+ IDMContext getDmc() {
+ return fFrameData.fDmc;
+ }
+
@Override
- protected IStatus run(final IProgressMonitor monitor) {
+ protected IStatus run(final IProgressMonitor monitor) {
if (monitor.isCanceled()) {
- return Status.CANCEL_STATUS;
- }
-
+ return Status.CANCEL_STATUS;
+ }
+
final SourceLookupResult result = performLookup();
- executeFromJob(new DsfRunnable() { @Override
- public void run() {
- if (!monitor.isCanceled()) {
- fPrevResult = result;
- fPrevFrameData = fFrameData;
- fRunningLookupJob = null;
- startDisplayJob(fPrevResult, fFrameData, fPage, fEventTriggered);
- }
- }});
+ executeFromJob(new DsfRunnable() {
+ @Override
+ public void run() {
+ if (!monitor.isCanceled()) {
+ fPrevResult = result;
+ fPrevFrameData = fFrameData;
+ fRunningLookupJob = null;
+ startDisplayJob(fPrevResult, fFrameData, fPage, fEventTriggered);
+ }
+ }
+ });
return Status.OK_STATUS;
}
-
- private SourceLookupResult performLookup() {
- IDMContext dmc = fFrameData.fDmc;
- SourceLookupResult result = new SourceLookupResult(dmc , null, null, null);
- String editorId = null;
- IEditorInput editorInput = null;
- Object sourceElement = fSourceLookup.getSourceElement(dmc);
- if (sourceElement == null) {
- editorInput = new CSourceNotFoundEditorInput(new CSourceNotFoundElement(dmc, fSourceLookup.getLaunchConfiguration(), fFrameData.fFile));
+ private SourceLookupResult performLookup() {
+ IDMContext dmc = fFrameData.fDmc;
+ SourceLookupResult result = new SourceLookupResult(dmc, null, null, null);
+ String editorId = null;
+ IEditorInput editorInput = null;
+ Object sourceElement = fSourceLookup.getSourceElement(dmc);
+
+ if (sourceElement == null) {
+ editorInput = new CSourceNotFoundEditorInput(
+ new CSourceNotFoundElement(dmc, fSourceLookup.getLaunchConfiguration(), fFrameData.fFile));
editorId = ICDebugUIConstants.CSOURCENOTFOUND_EDITOR_ID;
- } else {
- ISourcePresentation presentation= null;
+ } else {
+ ISourcePresentation presentation = null;
if (fSourceLookup instanceof ISourcePresentation) {
presentation = (ISourcePresentation) fSourceLookup;
} else {
- if (dmc != null) {
- presentation = dmc.getAdapter(ISourcePresentation.class);
- }
+ if (dmc != null) {
+ presentation = dmc.getAdapter(ISourcePresentation.class);
+ }
}
- if (presentation != null) {
- editorInput = presentation.getEditorInput(sourceElement);
- if (editorInput != null) {
- editorId = presentation.getEditorId(editorInput, sourceElement);
- }
- } else if (sourceElement instanceof IFile) {
- editorId = getEditorIdForFilename(((IFile)sourceElement).getName());
- editorInput = new FileEditorInput((IFile)sourceElement);
- } else if (sourceElement instanceof ITranslationUnit) {
- try {
- URI uriLocation = ((ITranslationUnit)sourceElement).getLocationURI();
- IFileStore fileStore = EFS.getStore(uriLocation);
- editorInput = new FileStoreEditorInput(fileStore);
- editorId = getEditorIdForFilename(fileStore.getName());
- } catch (CoreException e) {
- editorInput = new CSourceNotFoundEditorInput(new CSourceNotFoundElement(dmc, fSourceLookup.getLaunchConfiguration(), fFrameData.fFile));
+ if (presentation != null) {
+ editorInput = presentation.getEditorInput(sourceElement);
+ if (editorInput != null) {
+ editorId = presentation.getEditorId(editorInput, sourceElement);
+ }
+ } else if (sourceElement instanceof IFile) {
+ editorId = getEditorIdForFilename(((IFile) sourceElement).getName());
+ editorInput = new FileEditorInput((IFile) sourceElement);
+ } else if (sourceElement instanceof ITranslationUnit) {
+ try {
+ URI uriLocation = ((ITranslationUnit) sourceElement).getLocationURI();
+ IFileStore fileStore = EFS.getStore(uriLocation);
+ editorInput = new FileStoreEditorInput(fileStore);
+ editorId = getEditorIdForFilename(fileStore.getName());
+ } catch (CoreException e) {
+ editorInput = new CSourceNotFoundEditorInput(new CSourceNotFoundElement(dmc,
+ fSourceLookup.getLaunchConfiguration(), fFrameData.fFile));
editorId = ICDebugUIConstants.CSOURCENOTFOUND_EDITOR_ID;
- }
- } else if (sourceElement instanceof LocalFileStorage) {
- File file = ((LocalFileStorage)sourceElement).getFile();
- IFileStore fileStore = EFS.getLocalFileSystem().fromLocalFile(file);
- editorInput = new FileStoreEditorInput(fileStore);
- editorId = getEditorIdForFilename(file.getName());
- }
- }
- result.setEditorInput(editorInput);
- result.setEditorId(editorId);
- result.setSourceElement(sourceElement);
+ }
+ } else if (sourceElement instanceof LocalFileStorage) {
+ File file = ((LocalFileStorage) sourceElement).getFile();
+ IFileStore fileStore = EFS.getLocalFileSystem().fromLocalFile(file);
+ editorInput = new FileStoreEditorInput(fileStore);
+ editorId = getEditorIdForFilename(file.getName());
+ }
+ }
+ result.setEditorInput(editorInput);
+ result.setEditorId(editorId);
+ result.setSourceElement(sourceElement);
- return result;
- }
-
- private String getEditorIdForFilename(String filename) {
+ return result;
+ }
+
+ private String getEditorIdForFilename(String filename) {
try {
- IEditorDescriptor descriptor= IDE.getEditorDescriptor(filename);
- return descriptor.getId();
+ IEditorDescriptor descriptor = IDE.getEditorDescriptor(filename);
+ return descriptor.getId();
} catch (PartInitException exc) {
DsfUIPlugin.log(exc);
}
return "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$
- }
+ }
}
- /**
- * Job that positions the editor and paints the IP Annotation for given DMC.
- */
+ /**
+ * Job that positions the editor and paints the IP Annotation for given DMC.
+ */
class DisplayJob extends UIJob {
private final SourceLookupResult fResult;
private final IWorkbenchPage fPage;
private final FrameData fFrameData;
- private final DsfRunnable fDisplayJobFinishedRunnable = new DsfRunnable() {
- @Override
+ private final DsfRunnable fDisplayJobFinishedRunnable = new DsfRunnable() {
+ @Override
public void run() {
- // If the current display job does not match up with "this", it means that this job got canceled
- // after it already completed and after this runnable was queued into the dispatch thread.
- if (fRunningDisplayJob == DisplayJob.this) {
- fRunningDisplayJob = null;
- if (fEventTriggered && !fDoneStepping.getAndSet(true)) {
- doneStepping(fResult.getDmc());
- }
- serviceDisplayAndClearingJobs();
- }
- }
- };
+ /*
+ * If the current display job does not match up with "this", it
+ * means that this job got canceled after it already completed
+ * and after this runnable was queued into the dispatch thread.
+ */
+ if (fRunningDisplayJob == DisplayJob.this) {
+ fRunningDisplayJob = null;
+ if (fEventTriggered && !fDoneStepping.getAndSet(true)) {
+ doneStepping(fResult.getDmc());
+ }
+ serviceDisplayAndClearingJobs();
+ }
+ }
+ };
- private final AtomicBoolean fDoneStepping = new AtomicBoolean(false);
- private IRegion fRegion;
- private ITextViewer fTextViewer;
+ private final AtomicBoolean fDoneStepping = new AtomicBoolean(false);
+ private IRegion fRegion;
+ private ITextViewer fTextViewer;
private final boolean fEventTriggered;
-
- IDMContext getDmc() { return fResult.getDmc(); }
-
+
+ IDMContext getDmc() {
+ return fResult.getDmc();
+ }
+
/**
* Constructs a new source display job
*/
public DisplayJob(SourceLookupResult result, FrameData frameData, IWorkbenchPage page, boolean eventTriggered) {
- super("Debug Source Display"); //$NON-NLS-1$
+ super("Debug Source Display"); //$NON-NLS-1$
setSystem(true);
setPriority(Job.INTERACTIVE);
fResult = result;
@@ -301,172 +320,177 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
}
@Override
- public IStatus runInUIThread(final IProgressMonitor monitor) {
-
- if (monitor.isCanceled()) {
- executeFromJob(fDisplayJobFinishedRunnable);
- return Status.CANCEL_STATUS;
- }
-
- if (fRegion != null && fTextViewer != null) {
- if (fRunningDisplayJob == this) {
- if (!shouldCancelSelectionChange()) {
- enableLineBackgroundPainter();
- fTextViewer.setSelectedRange(fRegion.getOffset(), 0);
- }
- executeFromJob(fDisplayJobFinishedRunnable);
- }
- } else {
- IEditorPart editor = openEditor(fResult, fPage);
- if (editor == null) {
- executeFromJob(fDisplayJobFinishedRunnable);
- return Status.OK_STATUS;
- }
-
- ITextEditor textEditor = null;
- if (editor instanceof ITextEditor) {
- textEditor = (ITextEditor)editor;
- } else {
- textEditor = editor.getAdapter(ITextEditor.class);
- }
- if (textEditor != null) {
- if (positionEditor(textEditor, fFrameData)) {
- return Status.OK_STATUS;
- }
- }
- executeFromJob(fDisplayJobFinishedRunnable);
- }
+ public IStatus runInUIThread(final IProgressMonitor monitor) {
+
+ if (monitor.isCanceled()) {
+ executeFromJob(fDisplayJobFinishedRunnable);
+ return Status.CANCEL_STATUS;
+ }
+
+ if (fRegion != null && fTextViewer != null) {
+ if (fRunningDisplayJob == this) {
+ if (!shouldCancelSelectionChange()) {
+ enableLineBackgroundPainter();
+ fTextViewer.setSelectedRange(fRegion.getOffset(), 0);
+ }
+ executeFromJob(fDisplayJobFinishedRunnable);
+ }
+ } else {
+ IEditorPart editor = openEditor(fResult, fPage);
+ if (editor == null) {
+ executeFromJob(fDisplayJobFinishedRunnable);
+ return Status.OK_STATUS;
+ }
+
+ ITextEditor textEditor = null;
+ if (editor instanceof ITextEditor) {
+ textEditor = (ITextEditor) editor;
+ } else {
+ textEditor = editor.getAdapter(ITextEditor.class);
+ }
+ if (textEditor != null) {
+ if (positionEditor(textEditor, fFrameData)) {
+ return Status.OK_STATUS;
+ }
+ }
+ executeFromJob(fDisplayJobFinishedRunnable);
+ }
return Status.OK_STATUS;
}
-
+
private boolean shouldCancelSelectionChange() {
- Querynull
if
- * no editor could be opened.
- */
- private IEditorPart openEditor(SourceLookupResult result, IWorkbenchPage page) {
- IEditorInput input= result.getEditorInput();
- String id= result.getEditorId();
- if (input == null || id == null) {
- return null;
- }
-
- return openEditor(page, input, id);
- }
+ try {
+ fExecutor.execute(delaySelectionChangeQuery);
+ } catch (RejectedExecutionException e) {
+ return false;
+ }
- /**
- * Opens an editor in the workbench and returns the editor that was opened
- * or null
if an error occurred while attempting to open the
- * editor.
- */
- private IEditorPart openEditor(final IWorkbenchPage page, final IEditorInput input, final String id) {
- final IEditorPart[] editor = new IEditorPart[] {null};
- Runnable r = new Runnable() {
+ try {
+ return delaySelectionChangeQuery.get();
+ } catch (InterruptedException e) {
+ return false;
+ } catch (ExecutionException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Opens the editor used to display the source for an element selected
+ * in this view and returns the editor that was opened or
+ * null
if no editor could be opened.
+ */
+ private IEditorPart openEditor(SourceLookupResult result, IWorkbenchPage page) {
+ IEditorInput input = result.getEditorInput();
+ String id = result.getEditorId();
+ if (input == null || id == null) {
+ return null;
+ }
+
+ return openEditor(page, input, id);
+ }
+
+ /**
+ * Opens an editor in the workbench and returns the editor that was
+ * opened or null
if an error occurred while attempting to
+ * open the editor.
+ */
+ private IEditorPart openEditor(final IWorkbenchPage page, final IEditorInput input, final String id) {
+ final IEditorPart[] editor = new IEditorPart[] { null };
+ Runnable r = new Runnable() {
@Override
public void run() {
- if (!page.getWorkbenchWindow().getWorkbench().isClosing()) {
- try {
- if (input instanceof CSourceNotFoundEditorInput)
- { // Don't open additional source not found editors if
- // there is one to reuse.
- editor[0] = page.openEditor(input, id, false, IWorkbenchPage.MATCH_ID);
- if (editor[0] instanceof IReusableEditor) {
- IReusableEditor re = (IReusableEditor)editor[0];
- if (! input.equals(re.getEditorInput()))
- re.setInput(input);
- }
- }
- else
- editor[0] = page.openEditor(input, id, false);
- } catch (PartInitException e) {}
- }
- }
- };
- BusyIndicator.showWhile(Display.getDefault(), r);
- return editor[0];
- }
+ if (!page.getWorkbenchWindow().getWorkbench().isClosing()) {
+ try {
+ if (input instanceof CSourceNotFoundEditorInput) {
+ /*
+ * Don't open additional source not found
+ * editors if there is one to reuse.
+ */
+ editor[0] = page.openEditor(input, id, false, IWorkbenchPage.MATCH_ID);
+ if (editor[0] instanceof IReusableEditor) {
+ IReusableEditor re = (IReusableEditor) editor[0];
+ if (!input.equals(re.getEditorInput())) {
+ re.setInput(input);
+ }
+ }
+ } else {
+ editor[0] = page.openEditor(input, id, false);
+ }
+ } catch (PartInitException e) {
+ }
+ }
+ }
+ };
+ BusyIndicator.showWhile(Display.getDefault(), r);
+ return editor[0];
+ }
- /**
- * Positions the text editor for the given stack frame
- */
- private boolean positionEditor(ITextEditor editor, final FrameData frameData) {
- // Position and annotate the editor.
- fRegion= getLineInformation(editor, frameData.fLine);
- if (fRegion != null) {
- // add annotation
- fIPManager.addAnnotation(
- editor, frameData.fDmc, new Position(fRegion.getOffset(), fRegion.getLength()),
- frameData.fLevel == 0);
+ /**
+ * Positions the text editor for the given stack frame
+ */
+ private boolean positionEditor(ITextEditor editor, final FrameData frameData) {
+ // Position and annotate the editor.
+ fRegion = getLineInformation(editor, frameData.fLine);
+ if (fRegion != null) {
+ // add annotation
+ fIPManager.addAnnotation(editor, frameData.fDmc, new Position(fRegion.getOffset(), fRegion.getLength()),
+ frameData.fLevel == 0);
- // this is a dirty trick to get access to the ITextViewer of the editor
- Object tot = editor.getAdapter(ITextOperationTarget.class);
- if (tot instanceof ITextViewer) {
- fTextViewer = (ITextViewer)tot;
- int widgetLine = frameData.fLine;
- if (tot instanceof ITextViewerExtension5) {
- ITextViewerExtension5 ext5 = (ITextViewerExtension5) tot;
- // expand region if collapsed
- ext5.exposeModelRange(fRegion);
- widgetLine = ext5.modelLine2WidgetLine(widgetLine);
- }
- revealLine(fTextViewer, widgetLine);
-
- if (fStepCount > 0 && fSelectionChangeDelay > 0) {
- disableLineBackgroundPainter();
- // reschedule for selection change
- schedule(fSelectionChangeDelay);
- if (!fDoneStepping.getAndSet(true)) {
- doneStepping(getDmc());
- }
- return true;
- } else {
- enableLineBackgroundPainter();
- fTextViewer.setSelectedRange(fRegion.getOffset(), 0);
- }
- } else {
- editor.selectAndReveal(fRegion.getOffset(), 0);
- }
- }
- return false;
- }
+ // this is a dirty trick to get access to the ITextViewer of the
+ // editor
+ Object tot = editor.getAdapter(ITextOperationTarget.class);
+ if (tot instanceof ITextViewer) {
+ fTextViewer = (ITextViewer) tot;
+ int widgetLine = frameData.fLine;
+ if (tot instanceof ITextViewerExtension5) {
+ ITextViewerExtension5 ext5 = (ITextViewerExtension5) tot;
+ // expand region if collapsed
+ ext5.exposeModelRange(fRegion);
+ widgetLine = ext5.modelLine2WidgetLine(widgetLine);
+ }
+ revealLine(fTextViewer, widgetLine);
- /**
- * Scroll the given line into the visible area if it is not yet visible.
- * @param focusLine
- * @see org.eclipse.jface.text.TextViewer#revealRange(int, int)
- */
- private void revealLine(ITextViewer viewer, int focusLine) {
- StyledText textWidget = viewer.getTextWidget();
+ if (fStepCount > 0 && fSelectionChangeDelay > 0) {
+ disableLineBackgroundPainter();
+ // reschedule for selection change
+ schedule(fSelectionChangeDelay);
+ if (!fDoneStepping.getAndSet(true)) {
+ doneStepping(getDmc());
+ }
+ return true;
+ } else {
+ enableLineBackgroundPainter();
+ fTextViewer.setSelectedRange(fRegion.getOffset(), 0);
+ }
+ } else {
+ editor.selectAndReveal(fRegion.getOffset(), 0);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Scroll the given line into the visible area if it is not yet visible.
+ *
+ * @param focusLine
+ * @see org.eclipse.jface.text.TextViewer#revealRange(int, int)
+ */
+ private void revealLine(ITextViewer viewer, int focusLine) {
+ StyledText textWidget = viewer.getTextWidget();
int top = textWidget.getTopIndex();
if (top > -1) {
@@ -475,13 +499,14 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
int bottom = top + lines;
int bottomBuffer = Math.max(1, lines / 3);
-
+
if (focusLine >= top && focusLine <= bottom - bottomBuffer) {
// do not scroll at all as it is already visible
} else {
if (focusLine > bottom - bottomBuffer && focusLine <= bottom) {
// focusLine is already in bottom bufferZone
- // scroll to top of bottom bufferzone - for smooth down-scrolling
+ // scroll to top of bottom bufferzone - for smooth
+ // down-scrolling
int scrollDelta = focusLine - (bottom - bottomBuffer);
textWidget.setTopIndex(top + scrollDelta);
} else {
@@ -491,231 +516,247 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
}
}
}
- }
+ }
- /**
- * @return the number of visible lines in the view port assuming a constant
- * line height.
- */
- private int getEstimatedVisibleLinesInViewport(StyledText textWidget) {
- if (textWidget != null) {
- Rectangle clArea= textWidget.getClientArea();
- if (!clArea.isEmpty())
- return clArea.height / textWidget.getLineHeight();
- }
- return -1;
- }
+ /**
+ * @return the number of visible lines in the view port assuming a
+ * constant line height.
+ */
+ private int getEstimatedVisibleLinesInViewport(StyledText textWidget) {
+ if (textWidget != null) {
+ Rectangle clArea = textWidget.getClientArea();
+ if (!clArea.isEmpty()) {
+ return clArea.height / textWidget.getLineHeight();
+ }
+ }
+ return -1;
+ }
- /**
- * Returns the line information for the given line in the given editor
- */
- private IRegion getLineInformation(ITextEditor editor, int lineNumber) {
- IDocumentProvider provider= editor.getDocumentProvider();
- IEditorInput input= editor.getEditorInput();
- try {
- provider.connect(input);
- } catch (CoreException e) {
- return null;
- }
- try {
- IDocument document= provider.getDocument(input);
- if (document != null)
- return document.getLineInformation(lineNumber);
- } catch (BadLocationException e) {
- } finally {
- provider.disconnect(input);
- }
- return null;
- }
+ /**
+ * Returns the line information for the given line in the given editor
+ */
+ private IRegion getLineInformation(ITextEditor editor, int lineNumber) {
+ IDocumentProvider provider = editor.getDocumentProvider();
+ IEditorInput input = editor.getEditorInput();
+ try {
+ provider.connect(input);
+ } catch (CoreException e) {
+ return null;
+ }
+ try {
+ IDocument document = provider.getDocument(input);
+ if (document != null) {
+ return document.getLineInformation(lineNumber);
+ }
+ } catch (BadLocationException e) {
+ } finally {
+ provider.disconnect(input);
+ }
+ return null;
+ }
- }
-
- /**
- * Job that removes the old IP Annotations associated with given execution
- * context.
- */
- class ClearingJob extends UIJob {
- Set