Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorKen Ryall2007-02-17 14:39:49 +0000
committerKen Ryall2007-02-17 14:39:49 +0000
commit2a54313bd69179a50387fe04f1bc9e1d4d1c05c2 (patch)
tree86bf2a13c14225f6c5fb84352c72c85c5d0c11a0 /debug
parentac5bca2e7bb3054832f759ae316c0f5cf9fd14a0 (diff)
downloadorg.eclipse.cdt-2a54313bd69179a50387fe04f1bc9e1d4d1c05c2.tar.gz
org.eclipse.cdt-2a54313bd69179a50387fe04f1bc9e1d4d1c05c2.tar.xz
org.eclipse.cdt-2a54313bd69179a50387fe04f1bc9e1d4d1c05c2.zip
When the source locator finds source files by absolute path attempt to create an external translation unit to display them with. Bug 159831.
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/AbsolutePathSourceContainer.java34
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java5
2 files changed, 31 insertions, 8 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/AbsolutePathSourceContainer.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/AbsolutePathSourceContainer.java
index 9e74fce12f9..e9a937890f5 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/AbsolutePathSourceContainer.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/AbsolutePathSourceContainer.java
@@ -14,10 +14,15 @@ package org.eclipse.cdt.debug.core.sourcelookup;
import java.io.File;
import java.io.IOException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+import org.eclipse.cdt.internal.core.model.ExternalTranslationUnit;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainer;
@@ -30,20 +35,33 @@ public class AbsolutePathSourceContainer extends AbstractSourceContainer {
*/
public static final String TYPE_ID = CDebugCorePlugin.getUniqueIdentifier() + ".containerType.absolutePath"; //$NON-NLS-1$
- private Object[] findSourceElementByFile( File file ) {
- IFile[] wfiles = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation( new Path( file.getAbsolutePath() ) );
- if ( wfiles.length > 0 )
+ private Object[] findSourceElementByFile(File file) {
+ IFile[] wfiles = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(file.getAbsolutePath()));
+ if (wfiles.length > 0)
return wfiles;
try {
- // Check the canonical path as well to support case insensitive file systems like Windows.
- wfiles = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation( new Path( file.getCanonicalPath() ) );
- if ( wfiles.length > 0 )
+ // Check the canonical path as well to support case insensitive file
+ // systems like Windows.
+ wfiles = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(file.getCanonicalPath()));
+ if (wfiles.length > 0)
return wfiles;
- } catch (IOException e) { // ignore if getCanonicalPath throws
+
+ // The file is not already in the workspace so try to create an external translation unit for it.
+ String projectName = getDirector().getLaunchConfiguration().getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
+ ICProject project = CoreModel.getDefault().getCModel().getCProject(projectName);
+ if (project != null)
+ {
+ IPath path = Path.fromOSString(file.getCanonicalPath());
+ String id = CoreModel.getRegistedContentTypeId(project.getProject(), path.lastSegment());
+ return new ExternalTranslationUnit[] { new ExternalTranslationUnit(project, new Path(file.getCanonicalPath()), id) };
}
+ } catch (IOException e) { // ignore if getCanonicalPath throws
+ } catch (CoreException e) {
+ }
- return new LocalFileStorage[] { new LocalFileStorage( file ) };
+ // If we can't create an ETU then fall back on LocalFileStorage.
+ return new LocalFileStorage[] { new LocalFileStorage(file) };
}
public boolean isValidAbsoluteFilePath( String name )
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 17cff89bae9..ce7d3ee8e34 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
@@ -48,6 +48,7 @@ import org.eclipse.cdt.debug.core.model.IEnableDisableTarget;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceNotFoundElement;
import org.eclipse.cdt.debug.internal.ui.sourcelookup.CSourceNotFoundEditorInput;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.cdt.internal.core.model.ExternalTranslationUnit;
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IFile;
@@ -167,6 +168,10 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
if ( element instanceof FileStorage || element instanceof LocalFileStorage ) {
return new ExternalEditorInput( (IStorage)element );
}
+ if ( element instanceof ExternalTranslationUnit ) {
+ ExternalTranslationUnit etu = (ExternalTranslationUnit) element;
+ return new ExternalEditorInput( etu , new LocalFileStorage( etu.getPath().toFile() ) );
+ }
if (element instanceof CSourceNotFoundElement)
{
return new CSourceNotFoundEditorInput((CSourceNotFoundElement) element);

Back to the top