Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/dsf
diff options
context:
space:
mode:
authorJonah Graham2017-05-11 12:28:28 +0000
committerJonah Graham2017-05-11 12:32:18 +0000
commitd3ecfbd4f1760c86d25f4985e4ab49b8381be50a (patch)
tree520213d0b7d47fb74eb7ae223a977d450bf9b1dc /dsf
parentcea32dfe7b27a098f05e1e9daf9eea3634527ba0 (diff)
downloadorg.eclipse.cdt-d3ecfbd4f1760c86d25f4985e4ab49b8381be50a.tar.gz
org.eclipse.cdt-d3ecfbd4f1760c86d25f4985e4ab49b8381be50a.tar.xz
org.eclipse.cdt-d3ecfbd4f1760c86d25f4985e4ab49b8381be50a.zip
Bug 516461: use file contents to determine content type when debugging
Diffstat (limited to 'dsf')
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java23
1 files changed, 17 insertions, 6 deletions
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 d50382f8428..3d2b668fb92 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
@@ -25,6 +25,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CCorePreferenceConstants;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceNotFoundElement;
+import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils;
import org.eclipse.cdt.debug.internal.ui.sourcelookup.CSourceNotFoundEditorInput;
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
@@ -237,14 +238,15 @@ 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);
+ IFile file = (IFile) sourceElement;
+ editorId = getEditorIdForFile(file);
+ editorInput = new FileEditorInput(file);
} else if (sourceElement instanceof ITranslationUnit) {
try {
URI uriLocation = ((ITranslationUnit) sourceElement).getLocationURI();
IFileStore fileStore = EFS.getStore(uriLocation);
editorInput = new FileStoreEditorInput(fileStore);
- editorId = getEditorIdForFilename(fileStore.getName());
+ editorId = getEditorIdForFileStore(fileStore);
} catch (CoreException e) {
editorInput = new CSourceNotFoundEditorInput(new CSourceNotFoundElement(dmc,
fSourceLookup.getLaunchConfiguration(), fFrameData.fFile));
@@ -254,7 +256,7 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
File file = ((LocalFileStorage) sourceElement).getFile();
IFileStore fileStore = EFS.getLocalFileSystem().fromLocalFile(file);
editorInput = new FileStoreEditorInput(fileStore);
- editorId = getEditorIdForFilename(file.getName());
+ editorId = getEditorIdForFileStore(fileStore); // NOT RIGHT?
}
}
result.setEditorInput(editorInput);
@@ -264,15 +266,24 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
return result;
}
- private String getEditorIdForFilename(String filename) {
+ private String getEditorIdForFile(IFile file) {
try {
- IEditorDescriptor descriptor = IDE.getEditorDescriptor(filename);
+ IEditorDescriptor descriptor = IDE.getEditorDescriptor(file);
return descriptor.getId();
} catch (PartInitException exc) {
DsfUIPlugin.log(exc);
}
return "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$
}
+
+ private String getEditorIdForFileStore(IFileStore fileStore) {
+ try {
+ return CDebugUIUtils.getEditorId(fileStore);
+ } catch (PartInitException exc) {
+ DsfUIPlugin.log(exc);
+ }
+ return "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$
+ }
}
/**

Back to the top