mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 23:15:24 +02:00
Bug 515296: Cosmetics
Reformatted file, added missing braces and removed "non-Javadoc" comments. This file had suffered particularly badly from mixed spaces and tabs in a single file, with some lines having both on the same line. Change-Id: I0bff49effa0225cb6409547d8daa9dbf9c22e1b9
This commit is contained in:
parent
65c9e08d68
commit
8da9b7a0b8
1 changed files with 661 additions and 605 deletions
|
@ -89,21 +89,22 @@ 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.
|
||||
* <p>
|
||||
* The implementation relies on three types of jobs to perform the operations.<br>
|
||||
* The implementation relies on three types of jobs to perform the
|
||||
* operations.<br>
|
||||
* - The first kind, "lookup job" performs the source lookup operation. <br>
|
||||
* - The second "display job" positions and annotates the editor. <br>
|
||||
* - The third clears the old IP annotations when a thread or process has resumed
|
||||
* or exited.
|
||||
* - The third clears the old IP annotations when a thread or process has
|
||||
* resumed or exited.
|
||||
* </p>
|
||||
* <p>
|
||||
* 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.
|
||||
* 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.
|
||||
* </p>
|
||||
* <p>
|
||||
* Debuggers can override the default source editor used by the source display
|
||||
|
@ -115,8 +116,7 @@ import org.eclipse.ui.texteditor.ITextEditor;
|
|||
* @since 1.0
|
||||
*/
|
||||
@ThreadSafe
|
||||
public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControlParticipant
|
||||
{
|
||||
public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControlParticipant {
|
||||
private static final class FrameData {
|
||||
IFrameDMContext fDmc;
|
||||
int fLine;
|
||||
|
@ -125,28 +125,36 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
|
||||
@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
|
||||
* @return <code>true</code> if the frame data refers to the same location
|
||||
* @return <code>true</code> if the frame data refers to the same
|
||||
* location
|
||||
*/
|
||||
public boolean isIdentical(FrameData frameData) {
|
||||
return equals(frameData) && fLine == frameData.fLine;
|
||||
|
@ -174,7 +182,9 @@ 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) {
|
||||
|
@ -183,7 +193,8 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
}
|
||||
|
||||
final SourceLookupResult result = performLookup();
|
||||
executeFromJob(new DsfRunnable() { @Override
|
||||
executeFromJob(new DsfRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!monitor.isCanceled()) {
|
||||
fPrevResult = result;
|
||||
|
@ -191,22 +202,24 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
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);
|
||||
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));
|
||||
editorInput = new CSourceNotFoundEditorInput(
|
||||
new CSourceNotFoundElement(dmc, fSourceLookup.getLaunchConfiguration(), fFrameData.fFile));
|
||||
editorId = ICDebugUIConstants.CSOURCENOTFOUND_EDITOR_ID;
|
||||
} else {
|
||||
ISourcePresentation presentation= null;
|
||||
ISourcePresentation presentation = null;
|
||||
if (fSourceLookup instanceof ISourcePresentation) {
|
||||
presentation = (ISourcePresentation) fSourceLookup;
|
||||
} else {
|
||||
|
@ -220,20 +233,21 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
editorId = presentation.getEditorId(editorInput, sourceElement);
|
||||
}
|
||||
} else if (sourceElement instanceof IFile) {
|
||||
editorId = getEditorIdForFilename(((IFile)sourceElement).getName());
|
||||
editorInput = new FileEditorInput((IFile)sourceElement);
|
||||
editorId = getEditorIdForFilename(((IFile) sourceElement).getName());
|
||||
editorInput = new FileEditorInput((IFile) sourceElement);
|
||||
} else if (sourceElement instanceof ITranslationUnit) {
|
||||
try {
|
||||
URI uriLocation = ((ITranslationUnit)sourceElement).getLocationURI();
|
||||
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));
|
||||
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();
|
||||
File file = ((LocalFileStorage) sourceElement).getFile();
|
||||
IFileStore fileStore = EFS.getLocalFileSystem().fromLocalFile(file);
|
||||
editorInput = new FileStoreEditorInput(fileStore);
|
||||
editorId = getEditorIdForFilename(file.getName());
|
||||
|
@ -248,7 +262,7 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
|
||||
private String getEditorIdForFilename(String filename) {
|
||||
try {
|
||||
IEditorDescriptor descriptor= IDE.getEditorDescriptor(filename);
|
||||
IEditorDescriptor descriptor = IDE.getEditorDescriptor(filename);
|
||||
return descriptor.getId();
|
||||
} catch (PartInitException exc) {
|
||||
DsfUIPlugin.log(exc);
|
||||
|
@ -268,8 +282,11 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
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 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)) {
|
||||
|
@ -285,7 +302,9 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
private ITextViewer fTextViewer;
|
||||
private final boolean fEventTriggered;
|
||||
|
||||
IDMContext getDmc() { return fResult.getDmc(); }
|
||||
IDMContext getDmc() {
|
||||
return fResult.getDmc();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new source display job
|
||||
|
@ -325,7 +344,7 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
|
||||
ITextEditor textEditor = null;
|
||||
if (editor instanceof ITextEditor) {
|
||||
textEditor = (ITextEditor)editor;
|
||||
textEditor = (ITextEditor) editor;
|
||||
} else {
|
||||
textEditor = editor.getAdapter(ITextEditor.class);
|
||||
}
|
||||
|
@ -370,13 +389,13 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
}
|
||||
|
||||
/**
|
||||
* Opens the editor used to display the source for an element selected in
|
||||
* this view and returns the editor that was opened or <code>null</code> if
|
||||
* no editor could be opened.
|
||||
* Opens the editor used to display the source for an element selected
|
||||
* in this view and returns the editor that was opened or
|
||||
* <code>null</code> if no editor could be opened.
|
||||
*/
|
||||
private IEditorPart openEditor(SourceLookupResult result, IWorkbenchPage page) {
|
||||
IEditorInput input= result.getEditorInput();
|
||||
String id= result.getEditorId();
|
||||
IEditorInput input = result.getEditorInput();
|
||||
String id = result.getEditorId();
|
||||
if (input == null || id == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -385,30 +404,34 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
}
|
||||
|
||||
/**
|
||||
* Opens an editor in the workbench and returns the editor that was opened
|
||||
* or <code>null</code> if an error occurred while attempting to open the
|
||||
* editor.
|
||||
* Opens an editor in the workbench and returns the editor that was
|
||||
* opened or <code>null</code> 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};
|
||||
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.
|
||||
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()))
|
||||
IReusableEditor re = (IReusableEditor) editor[0];
|
||||
if (!input.equals(re.getEditorInput())) {
|
||||
re.setInput(input);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else {
|
||||
editor[0] = page.openEditor(input, id, false);
|
||||
} catch (PartInitException e) {}
|
||||
}
|
||||
} catch (PartInitException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -421,17 +444,17 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
*/
|
||||
private boolean positionEditor(ITextEditor editor, final FrameData frameData) {
|
||||
// Position and annotate the editor.
|
||||
fRegion= getLineInformation(editor, frameData.fLine);
|
||||
fRegion = getLineInformation(editor, frameData.fLine);
|
||||
if (fRegion != null) {
|
||||
// add annotation
|
||||
fIPManager.addAnnotation(
|
||||
editor, frameData.fDmc, new Position(fRegion.getOffset(), fRegion.getLength()),
|
||||
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
|
||||
// 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;
|
||||
fTextViewer = (ITextViewer) tot;
|
||||
int widgetLine = frameData.fLine;
|
||||
if (tot instanceof ITextViewerExtension5) {
|
||||
ITextViewerExtension5 ext5 = (ITextViewerExtension5) tot;
|
||||
|
@ -462,6 +485,7 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
|
||||
/**
|
||||
* 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)
|
||||
*/
|
||||
|
@ -481,7 +505,8 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
} 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 {
|
||||
|
@ -494,15 +519,16 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
}
|
||||
|
||||
/**
|
||||
* @return the number of visible lines in the view port assuming a constant
|
||||
* line height.
|
||||
* @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())
|
||||
Rectangle clArea = textWidget.getClientArea();
|
||||
if (!clArea.isEmpty()) {
|
||||
return clArea.height / textWidget.getLineHeight();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -510,17 +536,18 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
* 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();
|
||||
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)
|
||||
IDocument document = provider.getDocument(input);
|
||||
if (document != null) {
|
||||
return document.getLineInformation(lineNumber);
|
||||
}
|
||||
} catch (BadLocationException e) {
|
||||
} finally {
|
||||
provider.disconnect(input);
|
||||
|
@ -544,17 +571,16 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
fDmcsToClear = dmcs;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
@Override
|
||||
public IStatus runInUIThread(IProgressMonitor monitor) {
|
||||
DsfRunnable clearingJobFinishedRunnable = new DsfRunnable() { @Override
|
||||
DsfRunnable clearingJobFinishedRunnable = new DsfRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
assert fRunningClearingJob == ClearingJob.this;
|
||||
fRunningClearingJob = null;
|
||||
serviceDisplayAndClearingJobs();
|
||||
}};
|
||||
}
|
||||
};
|
||||
|
||||
enableLineBackgroundPainter();
|
||||
|
||||
|
@ -590,7 +616,10 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
private Set<IRunControl.IExecutionDMContext> fPendingExecDmcsToClear = new HashSet<IRunControl.IExecutionDMContext>();
|
||||
private SteppingController fController;
|
||||
|
||||
/** Delay (in milliseconds) before the selection is changed to the IP location */
|
||||
/**
|
||||
* Delay (in milliseconds) before the selection is changed to the IP
|
||||
* location
|
||||
*/
|
||||
private int fSelectionChangeDelay = 150;
|
||||
|
||||
private long fStepStartTime = 0;
|
||||
|
@ -606,21 +635,25 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
/**
|
||||
* @since 1.1
|
||||
*/
|
||||
public DsfSourceDisplayAdapter(DsfSession session, ISourceLookupDirector sourceLocator, SteppingController controller) {
|
||||
public DsfSourceDisplayAdapter(DsfSession session, ISourceLookupDirector sourceLocator,
|
||||
SteppingController controller) {
|
||||
fSession = session;
|
||||
fExecutor = session.getExecutor();
|
||||
fServicesTracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), session.getId());
|
||||
fSourceLookup = sourceLocator;
|
||||
fSourceLookupParticipant = new DsfSourceLookupParticipant(session);
|
||||
fSourceLookup.addParticipants(new ISourceLookupParticipant[] {fSourceLookupParticipant} );
|
||||
fSourceLookup.addParticipants(new ISourceLookupParticipant[] { fSourceLookupParticipant });
|
||||
|
||||
final IInstructionPointerPresentation ipPresentation = (IInstructionPointerPresentation) session.getModelAdapter(IInstructionPointerPresentation.class);
|
||||
final IInstructionPointerPresentation ipPresentation = (IInstructionPointerPresentation) session
|
||||
.getModelAdapter(IInstructionPointerPresentation.class);
|
||||
fIPManager = new InstructionPointerManager(ipPresentation);
|
||||
|
||||
fExecutor.execute(new DsfRunnable() { @Override
|
||||
fExecutor.execute(new DsfRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fSession.addServiceEventListener(DsfSourceDisplayAdapter.this, null);
|
||||
}});
|
||||
}
|
||||
});
|
||||
|
||||
fController = controller;
|
||||
if (fController != null) {
|
||||
|
@ -632,7 +665,8 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
* Configure the delay (in milliseconds) before the selection in the editor
|
||||
* is changed to the IP location.
|
||||
*
|
||||
* @param delay the delay in milliseconds, a non-negative integer
|
||||
* @param delay
|
||||
* the delay in milliseconds, a non-negative integer
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
|
@ -647,16 +681,18 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
}
|
||||
|
||||
try {
|
||||
fExecutor.execute(new DsfRunnable() { @Override
|
||||
fExecutor.execute(new DsfRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fSession.removeServiceEventListener(DsfSourceDisplayAdapter.this);
|
||||
}});
|
||||
}
|
||||
});
|
||||
} catch (RejectedExecutionException e) {
|
||||
// Session is shut down.
|
||||
}
|
||||
|
||||
fServicesTracker.dispose();
|
||||
fSourceLookup.removeParticipants(new ISourceLookupParticipant[] {fSourceLookupParticipant});
|
||||
fSourceLookup.removeParticipants(new ISourceLookupParticipant[] { fSourceLookupParticipant });
|
||||
|
||||
// fSourceLookupParticipant is disposed by the source lookup director
|
||||
|
||||
|
@ -668,54 +704,59 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
public void run() {
|
||||
enableLineBackgroundPainter();
|
||||
fIPManager.removeAllAnnotations();
|
||||
}});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.contexts.ISourceDisplayAdapter#displaySource(java.lang.Object, org.eclipse.ui.IWorkbenchPage, boolean)
|
||||
*/
|
||||
@Override
|
||||
public void displaySource(Object context, final IWorkbenchPage page,
|
||||
final boolean force) {
|
||||
public void displaySource(Object context, final IWorkbenchPage page, final boolean force) {
|
||||
fStepCount = 0;
|
||||
|
||||
IFrameDMContext displayFrame = null;
|
||||
if (context instanceof IDMVMContext) {
|
||||
IDMContext dmc = ((IDMVMContext) context).getDMContext();
|
||||
if (dmc instanceof IFrameDMContext)
|
||||
if (dmc instanceof IFrameDMContext) {
|
||||
displayFrame = (IFrameDMContext) dmc;
|
||||
} else if (context instanceof IFrameDMContext)
|
||||
}
|
||||
} else if (context instanceof IFrameDMContext) {
|
||||
displayFrame = (IFrameDMContext) context;
|
||||
}
|
||||
|
||||
// Quick test. DMC is checked again in source lookup participant, but
|
||||
// it's much quicker to test here.
|
||||
if (displayFrame != null)
|
||||
if (displayFrame != null) {
|
||||
doDisplaySource(displayFrame, page, force, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void doDisplaySource(final IFrameDMContext context, final IWorkbenchPage page, final boolean force, final boolean eventTriggered) {
|
||||
if (DEBUG) System.out.println("[DsfSourceDisplayAdapter] doDisplaySource ctx="+context+" eventTriggered="+eventTriggered); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private void doDisplaySource(final IFrameDMContext context, final IWorkbenchPage page, final boolean force,
|
||||
final boolean eventTriggered) {
|
||||
if (DEBUG) {
|
||||
System.out.println(
|
||||
"[DsfSourceDisplayAdapter] doDisplaySource ctx=" + context + " eventTriggered=" + eventTriggered); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
if (context.getLevel() < 0) {
|
||||
return;
|
||||
}
|
||||
// Re-dispatch to executor thread before accessing job lists.
|
||||
fExecutor.execute(new DsfRunnable() { @Override
|
||||
fExecutor.execute(new DsfRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// We need to retrieve the frame level and line number from the service.
|
||||
// We need to retrieve the frame level and line number from the
|
||||
// service.
|
||||
IStack stackService = fServicesTracker.getService(IStack.class);
|
||||
if (stackService == null) {
|
||||
return;
|
||||
}
|
||||
stackService.getFrameData(
|
||||
context,
|
||||
new DataRequestMonitor<IFrameDMData>(fExecutor, null) {
|
||||
stackService.getFrameData(context, new DataRequestMonitor<IFrameDMData>(fExecutor, null) {
|
||||
@Override
|
||||
public void handleSuccess() {
|
||||
FrameData frameData = new FrameData();
|
||||
frameData.fDmc = context;
|
||||
frameData.fLevel = context.getLevel();
|
||||
// Document line numbers are 0-based. While debugger line numbers are 1-based.
|
||||
// Document line numbers are 0-based. While debugger
|
||||
// line numbers are 1-based.
|
||||
IFrameDMData data = getData();
|
||||
frameData.fLine = data.getLine() - 1;
|
||||
frameData.fFile = data.getFile();
|
||||
|
@ -726,6 +767,7 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
startLookupJob(frameData, page, eventTriggered);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleFailure() {
|
||||
doneStepping(context);
|
||||
|
@ -736,7 +778,8 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
doneStepping(context);
|
||||
}
|
||||
});
|
||||
}});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void executeFromJob(Runnable runnable) {
|
||||
|
@ -756,9 +799,11 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
}
|
||||
// cancel running lookup job
|
||||
fRunningLookupJob.cancel();
|
||||
// make sure doneStepping() is called even if the job never ran - bug 325394
|
||||
// make sure doneStepping() is called even if the job never ran -
|
||||
// bug 325394
|
||||
if (fRunningLookupJob.fEventTriggered) {
|
||||
// ... but not if this request is event-triggered for the same context (duplicate suspended event)
|
||||
// ... but not if this request is event-triggered for the same
|
||||
// context (duplicate suspended event)
|
||||
if (!eventTriggered || !fRunningLookupJob.getDmc().equals(frameData.fDmc)) {
|
||||
doneStepping(fRunningLookupJob.getDmc());
|
||||
}
|
||||
|
@ -770,11 +815,13 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
}
|
||||
|
||||
// To be called only on dispatch thread.
|
||||
private void startDisplayJob(SourceLookupResult lookupResult, FrameData frameData, IWorkbenchPage page, boolean eventTriggered) {
|
||||
private void startDisplayJob(SourceLookupResult lookupResult, FrameData frameData, IWorkbenchPage page,
|
||||
boolean eventTriggered) {
|
||||
DisplayJob nextDisplayJob = new DisplayJob(lookupResult, frameData, page, eventTriggered);
|
||||
if (fRunningDisplayJob != null) {
|
||||
fPendingDisplayJob = null;
|
||||
IExecutionDMContext[] execCtxs = DMContexts.getAllAncestorsOfType(frameData.fDmc, IExecutionDMContext.class);
|
||||
IExecutionDMContext[] execCtxs = DMContexts.getAllAncestorsOfType(frameData.fDmc,
|
||||
IExecutionDMContext.class);
|
||||
fPendingExecDmcsToClear.removeAll(Arrays.asList(execCtxs));
|
||||
|
||||
if (!eventTriggered && frameData.isIdentical(fRunningDisplayJob.fFrameData)) {
|
||||
|
@ -783,9 +830,11 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
}
|
||||
// cancel running display job
|
||||
fRunningDisplayJob.cancel();
|
||||
// make sure doneStepping() is called even if the job never ran - bug 325394
|
||||
// make sure doneStepping() is called even if the job never ran -
|
||||
// bug 325394
|
||||
if (fRunningDisplayJob.fEventTriggered && !fRunningDisplayJob.fDoneStepping.getAndSet(true)) {
|
||||
// ... but not if this request is event-triggered for the same context (duplicate suspended event)
|
||||
// ... but not if this request is event-triggered for the same
|
||||
// context (duplicate suspended event)
|
||||
if (!eventTriggered || !fRunningDisplayJob.getDmc().equals(lookupResult.getDmc())) {
|
||||
doneStepping(fRunningDisplayJob.getDmc());
|
||||
}
|
||||
|
@ -854,7 +903,8 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
}
|
||||
}
|
||||
|
||||
// If no display or clearing jobs are running, schedule the clearing job.
|
||||
// If no display or clearing jobs are running, schedule the clearing
|
||||
// job.
|
||||
if (fRunningClearingJob == null && fRunningDisplayJob == null) {
|
||||
fRunningClearingJob = new ClearingJob(fPendingExecDmcsToClear);
|
||||
fRunningClearingJob.schedule();
|
||||
|
@ -886,14 +936,16 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
public void eventDispatched(final IRunControl.ISuspendedDMEvent e) {
|
||||
updateStepTiming();
|
||||
if (e.getReason() == StateChangeReason.STEP || e.getReason() == StateChangeReason.BREAKPOINT) {
|
||||
if (DEBUG) System.out.println("[DsfSourceDisplayAdapter] eventDispatched e="+e); //$NON-NLS-1$
|
||||
if (DEBUG) {
|
||||
System.out.println("[DsfSourceDisplayAdapter] eventDispatched e=" + e); //$NON-NLS-1$
|
||||
}
|
||||
// trigger source display immediately (should be optional?)
|
||||
Display.getDefault().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Object context = DebugUITools.getDebugContext();
|
||||
if (context instanceof IDMVMContext) {
|
||||
final IDMContext dmc = ((IDMVMContext)context).getDMContext();
|
||||
final IDMContext dmc = ((IDMVMContext) context).getDMContext();
|
||||
if (dmc instanceof IFrameDMContext && DMContexts.isAncestorOf(dmc, e.getDMContext())) {
|
||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||
doDisplaySource((IFrameDMContext) dmc, page, false, true);
|
||||
|
@ -901,7 +953,8 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
}
|
||||
}
|
||||
doneStepping(e.getDMContext());
|
||||
}});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
doneStepping(e.getDMContext());
|
||||
}
|
||||
|
@ -918,8 +971,8 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
++fStepCount;
|
||||
if (DEBUG) {
|
||||
long delta = now - fStepStartTime;
|
||||
float meanTime = delta/(float)fStepCount/1000;
|
||||
System.out.println("[DsfSourceDisplayAdapter] step speed = " + 1/meanTime); //$NON-NLS-1$
|
||||
float meanTime = delta / (float) fStepCount / 1000;
|
||||
System.out.println("[DsfSourceDisplayAdapter] step speed = " + 1 / meanTime); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -931,9 +984,11 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
*/
|
||||
private void disableLineBackgroundPainter() {
|
||||
if (!fEnableLineBackgroundPainter) {
|
||||
fEnableLineBackgroundPainter = EditorsUI.getPreferenceStore().getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE);
|
||||
fEnableLineBackgroundPainter = EditorsUI.getPreferenceStore()
|
||||
.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE);
|
||||
if (fEnableLineBackgroundPainter) {
|
||||
EditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, false);
|
||||
EditorsUI.getPreferenceStore()
|
||||
.setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -947,7 +1002,8 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
|||
private void enableLineBackgroundPainter() {
|
||||
if (fEnableLineBackgroundPainter) {
|
||||
fEnableLineBackgroundPainter = false;
|
||||
EditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, true);
|
||||
EditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE,
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue