Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Ryall2007-09-17 17:27:45 -0400
committerKen Ryall2007-09-17 17:27:45 -0400
commit56e73c78890ea29e393bcbe6ebd99aabc37d2e2a (patch)
tree898d72ada1810e2ee721c92c3aaefc56fcf2f9f6 /debug/org.eclipse.cdt.debug.ui
parent69adae3fc6808f8680dcbda52f95d04e7d0c981f (diff)
downloadorg.eclipse.cdt-56e73c78890ea29e393bcbe6ebd99aabc37d2e2a.tar.gz
org.eclipse.cdt-56e73c78890ea29e393bcbe6ebd99aabc37d2e2a.tar.xz
org.eclipse.cdt-56e73c78890ea29e393bcbe6ebd99aabc37d2e2a.zip
Cleaned up the CSourceNotFound editor. It now works for non IDebugElements too.
Diffstat (limited to 'debug/org.eclipse.cdt.debug.ui')
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.xml2
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java3
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java143
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditorInput.java9
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebugUIConstants.java6
5 files changed, 115 insertions, 48 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml
index 7604cd5715..e1d5bb22ba 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml
@@ -1372,7 +1372,7 @@
name="C/C++ Source Not Found Editor"
icon="$nl$/icons/obj16/c_app.gif"
class="org.eclipse.cdt.debug.internal.ui.sourcelookup.CSourceNotFoundEditor"
- id="org.eclipse.cdt.debug.internal.ui.sourcelookup.CSourceNotFoundEditor">
+ id="org.eclipse.cdt.debug.ui.SourceNotFoundEditor">
</editor>
</extension>
<!-- Breakpoint Action UI -->
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 c9e08c72bb..a091d9b346 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
@@ -51,6 +51,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.debug.ui.ICDebugUIConstants;
import org.eclipse.cdt.internal.core.model.ExternalTranslationUnit;
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
import org.eclipse.cdt.ui.CUIPlugin;
@@ -186,7 +187,7 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
*/
public String getEditorId( IEditorInput input, Object element ) {
if (element instanceof CSourceNotFoundElement)
- return "org.eclipse.cdt.debug.internal.ui.sourcelookup.CSourceNotFoundEditor";
+ return ICDebugUIConstants.CSOURCENOTFOUND_EDITOR_ID;
String id = null;
if ( input != null ) {
IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java
index 7e116f54d4..dac52b2fb4 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java
@@ -17,11 +17,16 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer;
+import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLookupDirector;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceNotFoundElement;
import org.eclipse.cdt.debug.internal.core.sourcelookup.MapEntrySourceContainer;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
+import org.eclipse.cdt.internal.core.model.ExternalTranslationUnit;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -35,8 +40,8 @@ import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.ISourceLocator;
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
+import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
import org.eclipse.debug.ui.sourcelookup.CommonSourceNotFoundEditor;
-import org.eclipse.debug.ui.sourcelookup.CommonSourceNotFoundEditorInput;
import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -67,12 +72,15 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
private String missingFile;
private ILaunch launch;
private IDebugElement context;
+ private ITranslationUnit tunit;
private Button disassemblyButton;
private Button locateFileButton;
private Button editLookupButton;
+ private boolean isDebugElement;
+ private boolean isTranslationUnit;
public CSourceNotFoundEditor() {
super();
@@ -84,17 +92,23 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
}
public void setInput(IEditorInput input) {
- if (input instanceof CommonSourceNotFoundEditorInput)
- {
- Object artifact = ((CommonSourceNotFoundEditorInput)input).getArtifact();
- if (artifact instanceof CSourceNotFoundElement)
- {
+ if (input instanceof CSourceNotFoundEditorInput) {
+ isDebugElement = false;
+ isTranslationUnit = false;
+ Object artifact = ((CSourceNotFoundEditorInput) input).getArtifact();
+ if (artifact instanceof CSourceNotFoundElement) {
CSourceNotFoundElement element = (CSourceNotFoundElement) artifact;
missingFile = element.getFile();
launch = element.getLaunch();
context = element.getElement();
- }
- else
+ isDebugElement = true;
+ } else if (artifact instanceof ITranslationUnit) {
+ isTranslationUnit = true;
+ tunit = (ITranslationUnit) artifact;
+ IPath tuPath = tunit.getLocation();
+ if (tuPath != null)
+ missingFile = tuPath.toOSString();
+ } else
missingFile = ""; //$NON-NLS-1$
}
super.setInput(input);
@@ -102,7 +116,6 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
}
private void syncButtons() {
-
if (locateFileButton != null)
locateFileButton.setVisible(missingFile.length() > 0);
if (editLookupButton != null)
@@ -122,7 +135,7 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
protected void createButtons(Composite parent) {
-
+ if (isDebugElement)
{
GridData data;
disassemblyButton = new Button(parent, SWT.PUSH);
@@ -137,7 +150,6 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
}
});
disassemblyButton.setData(UID_KEY, UID_DISASSEMBLY_BUTTON);
-
}
{
@@ -156,6 +168,7 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
locateFileButton.setData(UID_KEY, UID_LOCATE_FILE_BUTTON);
}
+ if (isDebugElement)
{
GridData data;
editLookupButton = new Button(parent, SWT.PUSH);
@@ -183,10 +196,43 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
page.showView(ICDebugUIConstants.ID_DISASSEMBLY_VIEW);
} catch (PartInitException e) {}
}
+ }
+
+ private void addSourceMappingToDirector(IPath missingPath, IPath newSourcePath, AbstractSourceLookupDirector director) throws CoreException {
+
+ ArrayList containerList = new ArrayList(Arrays.asList(director.getSourceContainers()));
+
+ boolean hasFoundMappings = false;
+
+ MappingSourceContainer foundMappings = null;
+
+ for (Iterator iter = containerList.iterator(); iter.hasNext() && !hasFoundMappings;) {
+ ISourceContainer container = (ISourceContainer) iter.next();
+ if (container instanceof MappingSourceContainer)
+ {
+ hasFoundMappings = container.getName().equals(foundMappingsContainerName);
+ if (hasFoundMappings)
+ foundMappings = (MappingSourceContainer) container;
+ }
+ }
+ if (!hasFoundMappings) {
+ foundMappings = new MappingSourceContainer(foundMappingsContainerName);
+ foundMappings.init(director);
+ containerList.add(foundMappings);
+ }
+
+ foundMappings.addMapEntry(new MapEntrySourceContainer(missingPath, newSourcePath));
+ director.setSourceContainers((ISourceContainer[]) containerList.toArray(new ISourceContainer[containerList.size()]));
}
- private void addSourceMapping(IPath missingPath, IPath newSourcePath) throws CoreException {
+ private void addSourceMappingToCommon(IPath missingPath, IPath newSourcePath) throws CoreException {
+ CSourceLookupDirector director = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector();
+ addSourceMappingToDirector(missingPath, newSourcePath, director);
+ CDebugCorePlugin.getDefault().savePluginPreferences();
+ }
+
+ private void addSourceMappingToLaunch(IPath missingPath, IPath newSourcePath) throws CoreException {
String memento = null;
String type = null;
@@ -206,30 +252,8 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
director.initializeFromMemento(memento, configuration);
}
- ArrayList containerList = new ArrayList(Arrays.asList(director.getSourceContainers()));
-
- boolean hasFoundMappings = false;
-
- MappingSourceContainer foundMappings = null;
-
- for (Iterator iter = containerList.iterator(); iter.hasNext() && !hasFoundMappings;) {
- ISourceContainer container = (ISourceContainer) iter.next();
- if (container instanceof MappingSourceContainer)
- {
- hasFoundMappings = container.getName().equals(foundMappingsContainerName);
- if (hasFoundMappings)
- foundMappings = (MappingSourceContainer) container;
- }
- }
-
- if (!hasFoundMappings) {
- foundMappings = new MappingSourceContainer(foundMappingsContainerName);
- foundMappings.init(director);
- containerList.add(foundMappings);
- director.setSourceContainers((ISourceContainer[]) containerList.toArray(new ISourceContainer[containerList.size()]));
- }
+ addSourceMappingToDirector(missingPath, newSourcePath, director);
- foundMappings.addMapEntry(new MapEntrySourceContainer(missingPath, newSourcePath));
configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, director.getMemento());
configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, director.getId());
configuration.doSave();
@@ -260,18 +284,59 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
IPath compPath = missingPath.removeLastSegments(missingPath.segmentCount() - missingPathSegCount - 1);
IPath newSourcePath = newPath.removeLastSegments(newPath.segmentCount() - newPathSegCount - 1);
try {
- addSourceMapping(compPath, newSourcePath);
+ if (isDebugElement)
+ addSourceMappingToLaunch(compPath, newSourcePath);
+ else
+ addSourceMappingToCommon(compPath, newSourcePath);
} catch (CoreException e) {}
}
IWorkbenchPage page = getEditorSite().getPage();
- ISourceDisplay adapter = (ISourceDisplay)context.getAdapter(ISourceDisplay.class);
- if (adapter != null) {
- adapter.displaySource(context, page, true);
+
+ if (isDebugElement)
+ {
+ ISourceDisplay adapter = (ISourceDisplay)context.getAdapter(ISourceDisplay.class);
+ if (adapter != null) {
+ adapter.displaySource(context, page, true);
+ }
+ }
+ else
+ if (isTranslationUnit)
+ {
+ reopenTranslationUnit(tunit);
}
closeEditor();
}
}
}
+
+ private boolean reopenTranslationUnit(ITranslationUnit tu)
+ {
+ if (tu != null)
+ {
+ IPath tuPath = tu.getLocation();
+ if (tuPath != null)
+ {
+ String filePath = tuPath.toOSString();
+ try {
+ Object[] foundElements = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector().findSourceElements(filePath);
+ if (foundElements.length == 1 && foundElements[0] instanceof LocalFileStorage)
+ {
+ LocalFileStorage newLocation = (LocalFileStorage) foundElements[0];
+ if (newLocation.getFullPath().toFile().exists())
+ {
+ ITranslationUnit remappedTU = tu;
+ if (tu instanceof ExternalTranslationUnit)
+ remappedTU = new ExternalTranslationUnit(tu.getParent(), newLocation.getFullPath(), tu.getContentTypeId());
+ EditorUtility.openInEditor(remappedTU);
+ return true;
+ }
+ }
+ } catch (CoreException e) {}
+ }
+ }
+ return false;
+ }
+
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditorInput.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditorInput.java
index 9eb1083855..4042f6e4b1 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditorInput.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditorInput.java
@@ -11,17 +11,12 @@
package org.eclipse.cdt.debug.internal.ui.sourcelookup;
-import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceNotFoundElement;
import org.eclipse.debug.ui.sourcelookup.CommonSourceNotFoundEditorInput;
public class CSourceNotFoundEditorInput extends CommonSourceNotFoundEditorInput {
- public CSourceNotFoundElement getElement() {
- return (CSourceNotFoundElement) getArtifact();
- }
-
- public CSourceNotFoundEditorInput(CSourceNotFoundElement artifact) {
+ public CSourceNotFoundEditorInput(Object artifact) {
super(artifact);
}
-
+
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebugUIConstants.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebugUIConstants.java
index ed5079427a..727beb01cb 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebugUIConstants.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebugUIConstants.java
@@ -74,4 +74,10 @@ public interface ICDebugUIConstants {
* Identifier for a shared libraries group in a menu (value <code>"modulesGroup"</code>).
*/
public static final String MODULES_GROUP = "modulesGroup"; //$NON-NLS-1$
+
+ /**
+ * Editor ID for the CSourceNotFoundEditor.
+ */
+ public static final String CSOURCENOTFOUND_EDITOR_ID = PREFIX + "SourceNotFoundEditor"; //$NON-NLS-1$
+
}

Back to the top