Skip to main content
summaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorJames Blackburn2009-06-28 11:02:21 -0400
committerJames Blackburn2009-06-28 11:02:21 -0400
commitc8d7d6591c3270e4971e2fba2c7a9cf4e3826365 (patch)
tree8080045cfc3fbb868ef12d77d6fc18b956b91442 /debug
parent132dc23a39d8d42d82b9d61b5976dfd4c163710e (diff)
downloadorg.eclipse.cdt-c8d7d6591c3270e4971e2fba2c7a9cf4e3826365.tar.gz
org.eclipse.cdt-c8d7d6591c3270e4971e2fba2c7a9cf4e3826365.tar.xz
org.eclipse.cdt-c8d7d6591c3270e4971e2fba2c7a9cf4e3826365.zip
Bug 248422 Double clicking in breakpoint view opens wrong source file
- If the breakpoint marker is set in an IFile, then we show that. Otherwise we delegate to ResourceLookup for the location and finally java.io.File if file is not in the workspace. - Logic simplified
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java43
1 files changed, 16 insertions, 27 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java
index 67eb6e6ffd..1ff564509e 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java
@@ -55,6 +55,7 @@ import org.eclipse.cdt.debug.internal.ui.sourcelookup.CSourceNotFoundEditorInput
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
import org.eclipse.cdt.internal.core.model.ExternalTranslationUnit;
+import org.eclipse.cdt.internal.core.resources.ResourceLookup;
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.filesystem.URIUtil;
@@ -63,7 +64,6 @@ import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -150,33 +150,24 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
}
if ( element instanceof ICBreakpoint ) {
ICBreakpoint b = (ICBreakpoint)element;
- IFile file = null;
- try {
- String handle = b.getSourceHandle();
- if ( handle != null ) {
- IPath path = new Path( handle );
- if ( path.isValidPath( handle ) ) {
- IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation( path );
- if ( files.length > 0 ) {
- // default to the first file found in the workspace
- file = files[0];
-
- // now try to match any finding to the project in the breakpoint
- IProject project = b.getMarker().getResource().getProject();
- for (IFile f : files) {
- if (f.getProject().equals(project)) {
- file = f;
- break;
- }
- }
- }
- else {
+ // If the BP's marker is on an IFile, job done
+ IFile file = (IFile)b.getMarker().getResource().getAdapter(IFile.class);
+ if (file == null) {
+ try {
+ // Not backed by an IFile, try its source handle (may be workspace / project based)
+ String handle = b.getSourceHandle();
+ if (handle != null && Path.ROOT.isValidPath(handle)) {
+ Path path = new Path(handle);
+ IProject project = b.getMarker().getResource().getProject();
+ // Select the most 'relevant' IFile for an external location
+ file = ResourceLookup.selectFileForLocation(path, project);
+ if (file == null) {
+ // Try resolving the path to a real io.File
File fsfile = new File( handle );
if ( fsfile.isFile() && fsfile.exists() ) {
// create an ExternalEditorInput with an external tu so when you
// open the file from the breakpoints view it opens in the
// proper editor.
- IProject project = b.getMarker().getResource().getProject();
if (project != null) {
ICProject cproject = CoreModel.getDefault().create(project);
String id = CoreModel.getRegistedContentTypeId(project, path.lastSegment());
@@ -189,12 +180,10 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
}
}
}
+ } catch(CoreException e) {
+ CDebugCorePlugin.log(e);
}
}
- catch( CoreException e ) {
- }
- if ( file == null )
- file = (IFile)b.getMarker().getResource().getAdapter( IFile.class );
if ( file != null )
return new FileEditorInput( file );
}

Back to the top