Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Cortell2009-12-12 15:11:34 +0000
committerJohn Cortell2009-12-12 15:11:34 +0000
commit487a57e98d6fee5335327ad1f8e81eb5aa460e3f (patch)
tree418b63bd59f98cb42d20e02dff3aaac667392ed4 /launch/org.eclipse.cdt.launch
parentb83991daa5fef1969e38ca1d4273bc0b80387423 (diff)
downloadorg.eclipse.cdt-487a57e98d6fee5335327ad1f8e81eb5aa460e3f.tar.gz
org.eclipse.cdt-487a57e98d6fee5335327ad1f8e81eb5aa460e3f.tar.xz
org.eclipse.cdt-487a57e98d6fee5335327ad1f8e81eb5aa460e3f.zip
[273502] Follow up fix. Launch configuration refactoring doesn't work for non-locals configs that live in the project folder (a .launch file)
Diffstat (limited to 'launch/org.eclipse.cdt.launch')
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/refactoring/ProjectRenameChange.java42
1 files changed, 36 insertions, 6 deletions
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/refactoring/ProjectRenameChange.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/refactoring/ProjectRenameChange.java
index baec869e0b..d9f317892f 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/refactoring/ProjectRenameChange.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/refactoring/ProjectRenameChange.java
@@ -19,11 +19,14 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.osgi.util.NLS;
@@ -42,6 +45,12 @@ class ProjectRenameChange extends AbstractLaunchConfigChange {
private String newName;
/**
+ * The project relative path of the .launch file if the launch config is a
+ * non-local one and is stored within the project.
+ */
+ private IPath projectRelativePath;
+
+ /**
* Initializes me.
*
* @param launchConfig
@@ -57,6 +66,16 @@ class ProjectRenameChange extends AbstractLaunchConfigChange {
this.oldName = oldName;
this.newName = newName;
+
+ // keep the project relative path if launch config is contained in the old project
+ if (!launchConfig.isLocal()) {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject oldProject = root.getProject(oldName);
+ IPath oldConfig = launchConfig.getFile().getLocation();
+ if (oldConfig != null && oldProject.getLocation().isPrefixOf(oldConfig)) {
+ projectRelativePath = oldConfig.makeRelativeTo(oldProject.getLocation());
+ }
+ }
}
@Override
@@ -72,15 +91,22 @@ class ProjectRenameChange extends AbstractLaunchConfigChange {
@Override
public Change perform(IProgressMonitor pm) throws CoreException {
- ILaunchConfiguration launchConfig = getLaunchConfiguration();
- ILaunchConfigurationWorkingCopy copy = launchConfig.getWorkingCopy();
-
- IResource[] mapped = launchConfig.getMappedResources();
-
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject oldProject = root.getProject(oldName);
IProject newProject = root.getProject(newName);
+ ILaunchConfiguration launchConfig = getLaunchConfiguration();
+ if (projectRelativePath != null) {
+ // If the launch config is non-local and lives in the project, we
+ // need to update its representation in the new project folder, not
+ // the old one
+ ILaunchManager mgr = DebugPlugin.getDefault().getLaunchManager();
+ launchConfig = mgr.getLaunchConfiguration(newProject.getFile(projectRelativePath));
+ }
+
+ ILaunchConfigurationWorkingCopy copy = launchConfig.getWorkingCopy();
+ IResource[] mapped = launchConfig.getMappedResources();
+
if ((oldProject != null) && (newProject != null)) {
if ((mapped != null) && (mapped.length > 0)) {
for (int i = 0; i < mapped.length; i++) {
@@ -97,6 +123,10 @@ class ProjectRenameChange extends AbstractLaunchConfigChange {
newName);
try {
+ // Note: for non-local LCs, this will end up updating the .launch
+ // file on disk but Eclipse's in memory representation will not
+ // get updated. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=288368#c1
+ // This comment can/should be removed when 288368 is fixed.
copy.doSave();
} catch (CoreException e) {
LaunchUIPlugin.log(new MultiStatus(LaunchUIPlugin.PLUGIN_ID, 0,
@@ -106,7 +136,7 @@ class ProjectRenameChange extends AbstractLaunchConfigChange {
return null; // not undoable, as we didn't effect our change
}
- return new ProjectRenameChange(getLaunchConfiguration(), newName,
+ return new ProjectRenameChange(launchConfig, newName,
oldName);
}

Back to the top