Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJared Burns2002-06-10 15:13:04 -0400
committerJared Burns2002-06-10 15:13:04 -0400
commitb5c9f4154a3bf03f32a426c1e2cd238e9297ede7 (patch)
tree2d1590e58ff98be108a810b89c272e4659025bbd /org.eclipse.debug.core
parent552d9b960bc5978f606515e372e4da7dca0b569b (diff)
downloadeclipse.platform.debug-b5c9f4154a3bf03f32a426c1e2cd238e9297ede7.tar.gz
eclipse.platform.debug-b5c9f4154a3bf03f32a426c1e2cd238e9297ede7.tar.xz
eclipse.platform.debug-b5c9f4154a3bf03f32a426c1e2cd238e9297ede7.zip
Bug 19375 - Duplicate launch config naming problem
Diffstat (limited to 'org.eclipse.debug.core')
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java37
1 files changed, 28 insertions, 9 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
index c085748b0..74ffab9a7 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
@@ -686,22 +686,25 @@ public class LaunchManager implements ILaunchManager, IResourceChangeListener {
/**
* @see org.eclipse.debug.core.ILaunchManager#generateUniqueLaunchConfigurationNameFrom(String)
*/
- public String generateUniqueLaunchConfigurationNameFrom(String namePrefix) {
+ public String generateUniqueLaunchConfigurationNameFrom(String baseName) {
int index = 1;
- String baseName = namePrefix;
+ int length= baseName.length();
int copyIndex = baseName.lastIndexOf(" ("); //$NON-NLS-1$
- if (copyIndex > -1) {
- String trailer = baseName.substring(copyIndex + 1);
- try {
- index = Integer.parseInt(trailer);
- baseName = namePrefix.substring(0, copyIndex);
- } catch (NumberFormatException nfe) {
+ if (copyIndex > -1 && length > copyIndex + 2 && baseName.charAt(length - 1) == ')') {
+ String trailer = baseName.substring(copyIndex + 2, length -1);
+ if (isNumber(trailer)) {
+ try {
+ index = Integer.parseInt(trailer);
+ baseName = baseName.substring(0, copyIndex);
+ } catch (NumberFormatException nfe) {
+ }
}
}
String newName = baseName;
try {
+ StringBuffer buffer= null;
while (isExistingLaunchConfigurationName(newName)) {
- StringBuffer buffer = new StringBuffer(baseName);
+ buffer = new StringBuffer(baseName);
buffer.append(" ("); //$NON-NLS-1$
buffer.append(String.valueOf(index));
index++;
@@ -715,6 +718,22 @@ public class LaunchManager implements ILaunchManager, IResourceChangeListener {
}
/**
+ * Returns whether the given String is composed solely of digits
+ */
+ private boolean isNumber(String string) {
+ int numChars= string.length();
+ if (numChars == 0) {
+ return false;
+ }
+ for (int i= 0; i < numChars; i++) {
+ if (!Character.isDigit(string.charAt(i))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
* Return a sorted array of the names of all <code>ILaunchConfiguration</code>s in
* the workspace. These are cached, and cache is cleared when a new config is added,
* deleted or changed.

Back to the top