Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java')
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java1097
1 files changed, 553 insertions, 544 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 6352f866d..0d77b6204 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
@@ -4,14 +4,14 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Sebastian Davids - bug 50567 Eclipse native environment support on Win98
* Pawel Piech - Bug 82001: When shutting down the IDE, the debugger should first
* attempt to disconnect debug targets before terminating them
* Alena Laskavaia - Bug 259281
- * Marc Khouzam - Bug 313143: Preferred Launch Delegate not recovered from preferences
+ * Marc Khouzam - Bug 313143: Preferred Launch Delegate not recovered from preferences
*******************************************************************************/
package org.eclipse.debug.internal.core;
@@ -30,17 +30,16 @@ import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.Comparator;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
-import java.util.Map.Entry;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -74,12 +73,12 @@ import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
@@ -119,75 +118,76 @@ import com.ibm.icu.text.MessageFormat;
* @see ILaunchManager
*/
public class LaunchManager extends PlatformObject implements ILaunchManager, IResourceChangeListener {
-
+
/**
- * Preferred launch delegate preference name.
+ * Preferred launch delegate preference name.
* <p>
- * Prior to 3.5 this preferred launch delegates for all launch
+ * Prior to 3.5 this preferred launch delegates for all launch
* configuration types were serialized into a single XML string
- * and stored in this preference.
+ * and stored in this preference.
* </p>
* <p>
- * Since 3.5, the preferred launch delegates are stored in a separate
- * preference for each launch configuration type. The name of this
- * preference is composed of the prefix, followed by a slash, followed by
- * the launch configuration type id. The values contain a set of launch
- * delegates, delimited by a semicolon, and each delegate entry contains
- * the delegate ID, followed by a comma, followed by comma-delimited
+ * Since 3.5, the preferred launch delegates are stored in a separate
+ * preference for each launch configuration type. The name of this
+ * preference is composed of the prefix, followed by a slash, followed by
+ * the launch configuration type id. The values contain a set of launch
+ * delegates, delimited by a semicolon, and each delegate entry contains
+ * the delegate ID, followed by a comma, followed by comma-delimited
* launch modes.
- *
+ *
* @since 3.3
*/
protected static final String PREF_PREFERRED_DELEGATES = DebugPlugin.getUniqueIdentifier() + ".PREFERRED_DELEGATES"; //$NON-NLS-1$
-
+
/**
* Constant to define debug.ui for the status codes
- *
+ *
* @since 3.2
*/
private static final String DEBUG_UI = "org.eclipse.debug.ui"; //$NON-NLS-1$
-
+
/**
* Listing of unsupported launch configuration names for the Win 32 platform
* @since 3.5
*/
- static final String[] UNSUPPORTED_WIN32_CONFIG_NAMES = new String[] {"aux", "clock$", "com1", "com2", "com3", "com4", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ static final String[] UNSUPPORTED_WIN32_CONFIG_NAMES = new String[] {"aux", "clock$", "com1", "com2", "com3", "com4", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"com5", "com6", "com7", "com8", "com9", "con", "lpt1", "lpt2", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
"lpt3", "lpt4", "lpt5", "lpt6", "lpt7", "lpt8", "lpt9", "nul", "prn"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
-
+
/**
* Disallowed characters for launch configuration names
* '@' and '&' are disallowed because they corrupt menu items.
- *
+ *
* @since 3.5
*/
static final char[] DISALLOWED_CONFIG_NAME_CHARS = new char[] { '@', '&','\\', '/', ':', '*', '?', '"', '<', '>', '|', '\0' };
-
+
/**
* Status code for which a UI prompter is registered.
- *
+ *
* @since 3.2
*/
protected static final IStatus promptStatus = new Status(IStatus.INFO, DEBUG_UI, 200, IInternalDebugCoreConstants.EMPTY_STRING, null);
-
+
/**
* Step filter manager
*/
private StepFilterManager fStepFilterManager = null;
-
+
/**
* Notifies a launch config listener in a safe runnable to handle
* exceptions.
*/
class ConfigurationNotifier implements ISafeRunnable {
-
+
private ILaunchConfigurationListener fListener;
private int fType;
private ILaunchConfiguration fConfiguration;
-
+
/**
* @see org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.Throwable)
*/
+ @Override
public void handleException(Throwable exception) {
IStatus status = new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, "An exception occurred during launch configuration change notification.", exception); //$NON-NLS-1$
DebugPlugin.log(status);
@@ -195,7 +195,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
/**
* Notifies the given listener of the add/change/remove
- *
+ *
* @param configuration the configuration that has changed
* @param update the type of change
*/
@@ -210,12 +210,13 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
}
fConfiguration = null;
- fListener = null;
+ fListener = null;
}
/**
* @see org.eclipse.core.runtime.ISafeRunnable#run()
*/
+ @Override
public void run() throws Exception {
switch (fType) {
case ADDED:
@@ -227,24 +228,27 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
case CHANGED:
fListener.launchConfigurationChanged(fConfiguration);
break;
- }
+ default:
+ break;
+ }
}
}
-
+
/**
* Notifies a launch listener (multiple launches) in a safe runnable to
* handle exceptions.
*/
class LaunchesNotifier implements ISafeRunnable {
-
+
private ILaunchesListener fListener;
private int fType;
private ILaunch[] fNotifierLaunches;
private ILaunch[] fRegistered;
-
+
/**
* @see org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.Throwable)
*/
+ @Override
public void handleException(Throwable exception) {
IStatus status = new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, "An exception occurred during launch change notification.", exception); //$NON-NLS-1$
DebugPlugin.log(status);
@@ -252,7 +256,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
/**
* Notifies the given listener of the adds/changes/removes
- *
+ *
* @param launches the launches that changed
* @param update the type of change
*/
@@ -264,15 +268,16 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
for (int i= 0; i < copiedListeners.length; i++) {
fListener = (ILaunchesListener)copiedListeners[i];
SafeRunner.run(this);
- }
+ }
fNotifierLaunches = null;
fRegistered = null;
- fListener = null;
+ fListener = null;
}
/**
* @see org.eclipse.core.runtime.ISafeRunnable#run()
*/
+ @Override
public void run() throws Exception {
switch (fType) {
case ADDED:
@@ -284,15 +289,15 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
case CHANGED:
case TERMINATE:
if (fRegistered == null) {
- List registered = null;
+ List<ILaunch> registered = null;
for (int j = 0; j < fNotifierLaunches.length; j++) {
if (isRegistered(fNotifierLaunches[j])) {
if (registered != null) {
registered.add(fNotifierLaunches[j]);
- }
+ }
} else {
if (registered == null) {
- registered = new ArrayList(fNotifierLaunches.length);
+ registered = new ArrayList<ILaunch>(fNotifierLaunches.length);
for (int k = 0; k < j; k++) {
registered.add(fNotifierLaunches[k]);
}
@@ -302,7 +307,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
if (registered == null) {
fRegistered = fNotifierLaunches;
} else {
- fRegistered = (ILaunch[])registered.toArray(new ILaunch[registered.size()]);
+ fRegistered = registered.toArray(new ILaunch[registered.size()]);
}
}
if (fRegistered.length > 0) {
@@ -314,33 +319,34 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
}
break;
+ default:
+ break;
}
}
}
-
+
/**
* Visitor for handling a resource begin deleted, and the need to check mapped configurations
* for auto-deletion
* @since 3.4
*/
class MappedResourceVisitor implements IResourceDeltaVisitor {
-
+
/* (non-Javadoc)
* @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
*/
+ @Override
public boolean visit(IResourceDelta delta) throws CoreException {
if (0 != (delta.getFlags() & IResourceDelta.OPEN)) {
return false;
}
if(delta.getKind() == IResourceDelta.REMOVED && delta.getFlags() != IResourceDelta.MOVED_TO) {
- ArrayList configs = collectAssociatedLaunches(delta.getResource());
- if(configs.size() > 0) {
- for(Iterator iter = configs.iterator(); iter.hasNext();) {
- try {
- ((ILaunchConfiguration)iter.next()).delete();
- } catch (CoreException e) {
- DebugPlugin.log(e.getStatus());
- }
+ ArrayList<ILaunchConfiguration> configs = collectAssociatedLaunches(delta.getResource());
+ for (ILaunchConfiguration config : configs) {
+ try {
+ config.delete();
+ } catch (CoreException e) {
+ DebugPlugin.log(e.getStatus());
}
}
return false;
@@ -348,15 +354,16 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
return true;
}
}
-
+
/**
* Visitor for handling resource deltas.
*/
class LaunchManagerVisitor implements IResourceDeltaVisitor {
-
+
/**
* @see IResourceDeltaVisitor#visit(IResourceDelta)
*/
+ @Override
public boolean visit(IResourceDelta delta) {
if (delta == null) {
return false;
@@ -366,7 +373,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
IProject project = (IProject)delta.getResource();
if (project.isOpen()) {
LaunchManager.this.projectOpened(project);
- } else {
+ } else {
LaunchManager.this.projectClosed(project);
}
}
@@ -377,7 +384,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
IFile file = (IFile)resource;
if (ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION.equals(file.getFileExtension())) {
ILaunchConfiguration handle = new LaunchConfiguration(file);
- switch (delta.getKind()) {
+ switch (delta.getKind()) {
case IResourceDelta.ADDED :
LaunchManager.this.launchConfigurationAdded(handle);
break;
@@ -387,6 +394,8 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
case IResourceDelta.CHANGED :
LaunchManager.this.launchConfigurationChanged(handle);
break;
+ default:
+ break;
}
}
return false;
@@ -394,20 +403,21 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
return true;
}
}
-
+
/**
* Notifies a launch listener (single launch) in a safe runnable to handle
* exceptions.
*/
class LaunchNotifier implements ISafeRunnable {
-
+
private ILaunchListener fListener;
private int fType;
private ILaunch fLaunch;
-
+
/**
* @see org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.Throwable)
*/
+ @Override
public void handleException(Throwable exception) {
IStatus status = new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, "An exception occurred during launch change notification.", exception); //$NON-NLS-1$
DebugPlugin.log(status);
@@ -415,7 +425,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
/**
* Notifies listeners of the add/change/remove
- *
+ *
* @param launch the launch that has changed
* @param update the type of change
*/
@@ -426,14 +436,15 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
for (int i= 0; i < copiedListeners.length; i++) {
fListener = (ILaunchListener)copiedListeners[i];
SafeRunner.run(this);
- }
+ }
fLaunch = null;
- fListener = null;
+ fListener = null;
}
/**
* @see org.eclipse.core.runtime.ISafeRunnable#run()
*/
+ @Override
public void run() throws Exception {
switch (fType) {
case ADDED:
@@ -447,24 +458,27 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
fListener.launchChanged(fLaunch);
}
break;
- }
+ default:
+ break;
+ }
}
}
-
+
/**
* Collects files whose extension matches the launch configuration file
* extension.
*/
class ResourceProxyVisitor implements IResourceProxyVisitor {
-
- private List fList;
-
- protected ResourceProxyVisitor(List list) {
+
+ private List<IResource> fList;
+
+ protected ResourceProxyVisitor(List<IResource> list) {
fList= list;
}
/**
* @see org.eclipse.core.resources.IResourceProxyVisitor#visit(org.eclipse.core.resources.IResourceProxy)
*/
+ @Override
public boolean visit(IResourceProxy proxy) {
if (proxy.getType() == IResource.FILE) {
if (ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION.equalsIgnoreCase(proxy.requestFullPath().getFileExtension())) {
@@ -475,36 +489,36 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
return true;
}
}
-
+
/**
* Internal class used to hold information about a preferred delegate
- *
+ *
* @since 3.3
*/
class PreferredDelegate {
private ILaunchDelegate fDelegate = null;
private String fTypeid = null;
- private Set fModes = null;
-
- public PreferredDelegate(ILaunchDelegate delegate, String typeid, Set modes) {
+ private Set<String> fModes = null;
+
+ public PreferredDelegate(ILaunchDelegate delegate, String typeid, Set<String> modes) {
fDelegate = delegate;
fTypeid = typeid;
fModes = modes;
}
-
+
public String getTypeId() {
return fTypeid;
}
-
- public Set getModes() {
+
+ public Set<String> getModes() {
return fModes;
}
-
+
public ILaunchDelegate getDelegate() {
return fDelegate;
}
}
-
+
/**
* Types of notifications
*/
@@ -512,14 +526,14 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
public static final int REMOVED= 1;
public static final int CHANGED= 2;
public static final int TERMINATE= 3;
-
+
/**
* The collection of native environment variables on the user's system. Cached
* after being computed once as the environment cannot change.
*/
- private static HashMap fgNativeEnv= null;
- private static HashMap fgNativeEnvCasePreserved= null;
-
+ private static HashMap<String, String> fgNativeEnv = null;
+ private static HashMap<String, String> fgNativeEnvCasePreserved = null;
+
/**
* Path to the local directory where local launch configurations
* are stored with the workspace.
@@ -542,7 +556,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
/**
* Serializes a XML document into a string - encoded in UTF8 format,
* with platform line separators.
- *
+ *
* @param doc document to serialize
* @return the document as a string
* @throws TransformerException if an unrecoverable error occurs during the serialization
@@ -557,179 +571,189 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
DOMSource source = new DOMSource(doc);
StreamResult outputTarget = new StreamResult(s);
transformer.transform(source, outputTarget);
- return s.toString("UTF8"); //$NON-NLS-1$
+ return s.toString("UTF8"); //$NON-NLS-1$
}
-
+
/**
* Collection of defined launch configuration type
* extensions.
*/
- private List fLaunchConfigurationTypes = null;
+ private List<ILaunchConfigurationType> fLaunchConfigurationTypes = null;
/**
* Launch configuration cache. Keys are <code>LaunchConfiguration</code>,
* values are <code>LaunchConfigurationInfo</code>.
*/
- private Map fLaunchConfigurations = new HashMap(10);
-
+ private Map<ILaunchConfiguration, LaunchConfigurationInfo> fLaunchConfigurations = new HashMap<ILaunchConfiguration, LaunchConfigurationInfo>(10);
+
/**
* A cache of launch configuration names currently in the workspace.
*/
private String[] fSortedConfigNames = null;
-
+
/**
* Collection of all launch configurations in the workspace.
* <code>List</code> of <code>ILaunchConfiguration</code>.
*/
- private List fLaunchConfigurationIndex = null;
-
+ private List<ILaunchConfiguration> fLaunchConfigurationIndex = null;
+
/**
* Launch configuration comparator extensions,
* keyed by attribute name.
*/
- private Map fComparators = null;
-
+ private Map<String, LaunchConfigurationComparator> fComparators = null;
+
/**
* Registered launch modes, or <code>null</code> if not initialized.
* Keys are mode identifiers, values are <code>ILaunchMode</code>s.
*/
- private Map fLaunchModes = null;
-
+ private Map<String, ILaunchMode> fLaunchModes = null;
+
/**
* A map of LaunchDelegate objects stored by id of delegate, or launch config type
*/
- private HashMap fLaunchDelegates = null;
-
+ private HashMap<String, LaunchDelegate> fLaunchDelegates = null;
+
/**
* Initial startup cache of preferred delegate so that the debug preferences are only parsed once
- *
+ *
* @since 3.3
*/
- private Set fPreferredDelegates = null;
-
+ private Set<PreferredDelegate> fPreferredDelegates = null;
+
/**
* Collection of launches
*/
- private List fLaunches= new ArrayList(10);
+ private List<ILaunch> fLaunches = new ArrayList<ILaunch>(10);
/**
- * Set of launches for efficient 'isRegistered()' check
+ * Set of launches for efficient 'isRegistered()' check TODO remove this -
+ * Launches don't implement hashCode() or equals() - so its no more
+ * efficient than walking the other collection
*/
- private Set fLaunchSet = new HashSet(10);
-
+ private Set<ILaunch> fLaunchSet = new HashSet<ILaunch>(10);
+
/**
* Collection of listeners
*/
private ListenerList fListeners = new ListenerList();
-
+
/**
* Collection of "plural" listeners.
* @since 2.1
*/
- private ListenerList fLaunchesListeners = new ListenerList();
-
+ private ListenerList fLaunchesListeners = new ListenerList();
+
/**
* Visitor used to process resource deltas,
* to update launch configuration index.
*/
private LaunchManagerVisitor fgVisitor;
-
+
/**
* Visitor used to process a deleted resource,
* to remove mapped launch configurations in the event
* auto-removal of launch configurations is enabled
- *
+ *
* @since 3.4
*/
private MappedResourceVisitor fgMRVisitor;
-
+
/**
* Whether this manager is listening for resource change events
*/
private boolean fListening = false;
-
+
/**
* Launch configuration listeners
*/
private ListenerList fLaunchConfigurationListeners = new ListenerList();
-
+
/**
* Table of source locator extensions. Keys
* are identifiers, and values are associated
* configuration elements.
*/
- private Map fSourceLocators = null;
+ private Map<String, IConfigurationElement> fSourceLocators = null;
/**
* The handles of launch configurations being moved, or <code>null</code>
*/
private ILaunchConfiguration fFrom;
-
+
private ILaunchConfiguration fTo;
/**
* Map of source container type extensions. Keys are extension ids
* and values are associated configuration elements.
*/
- private Map sourceContainerTypes;
-
+ private Map<String, ISourceContainerType> sourceContainerTypes;
+
/**
* Map of source path computer extensions. Keys are extension ids
* and values are associated configuration elements.
*/
- private Map sourcePathComputers;
-
- private Set fActiveModes;
+ private Map<String, ISourcePathComputer> sourcePathComputers;
+
+ /**
+ * TODO, we can probably remove this too
+ */
+ private Set<String> fActiveModes;
/**
* @see ILaunchManager#addLaunch(ILaunch)
*/
+ @Override
public void addLaunch(ILaunch launch) {
if (internalAddLaunch(launch)) {
fireUpdate(launch, ADDED);
fireUpdate(new ILaunch[] {launch}, ADDED);
}
}
-
+
/**
* @see ILaunchManager#addLaunchConfigurationListener(ILaunchConfigurationListener)
*/
+ @Override
public void addLaunchConfigurationListener(ILaunchConfigurationListener listener) {
fLaunchConfigurationListeners.add(listener);
- }
-
+ }
+
/**
* @see org.eclipse.debug.core.ILaunchManager#addLaunches(org.eclipse.debug.core.ILaunch[])
*/
+ @Override
public void addLaunches(ILaunch[] launches) {
- List added = new ArrayList(launches.length);
+ List<ILaunch> added = new ArrayList<ILaunch>(launches.length);
for (int i = 0; i < launches.length; i++) {
if (internalAddLaunch(launches[i])) {
added.add(launches[i]);
}
}
if (!added.isEmpty()) {
- ILaunch[] addedLaunches = (ILaunch[])added.toArray(new ILaunch[added.size()]);
+ ILaunch[] addedLaunches = added.toArray(new ILaunch[added.size()]);
fireUpdate(addedLaunches, ADDED);
for (int i = 0; i < addedLaunches.length; i++) {
fireUpdate(launches[i], ADDED);
}
}
}
-
+
/**
* @see org.eclipse.debug.core.ILaunchManager#addLaunchListener(org.eclipse.debug.core.ILaunchesListener)
*/
+ @Override
public void addLaunchListener(ILaunchesListener listener) {
fLaunchesListeners.add(listener);
- }
-
+ }
+
/**
* @see ILaunchManager#addLaunchListener(ILaunchListener)
*/
+ @Override
public void addLaunchListener(ILaunchListener listener) {
fListeners.add(listener);
- }
-
+ }
+
/**
* Computes and caches the native system environment variables as a map of
* variable names and values (Strings) in the given map.
@@ -738,13 +762,13 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
* the case of variable names but is otherwise case insensitive.
* Depending on what you intend to do with the environment, the
* lack of normalization may or may not be create problems. This
- * method preserves mixed-case keys using the variable names
+ * method preserves mixed-case keys using the variable names
* recorded by the OS.
* </p>
* @param cache the map
* @since 3.1
- */
- private void cacheNativeEnvironment(Map cache) {
+ */
+ private void cacheNativeEnvironment(Map<String, String> cache) {
try {
String nativeCommand= null;
boolean isWin9xME= false; //see bug 50567
@@ -779,13 +803,13 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
if (!file.delete()) {
file.deleteOnExit(); // if delete() fails try again on VM close
}
- for (Enumeration enumeration = p.keys(); enumeration.hasMoreElements();) {
+ for (Entry<Object, Object> entry : p.entrySet()) {
// Win32's environment variables are case insensitive. Put everything
// to uppercase so that (for example) the "PATH" variable will match
// "pAtH" correctly on Windows.
- String key= (String) enumeration.nextElement();
+ String key = (String) entry.getKey();
//no need to cast value
- cache.put(key, p.get(key));
+ cache.put(key, (String) p.get(key));
}
} else {
//read process directly on other platforms
@@ -860,10 +884,11 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
fLaunchConfigurationIndex.clear();
}
}
-
+
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchManager#getEncoding(org.eclipse.debug.core.ILaunchConfiguration)
*/
+ @Override
public String getEncoding(ILaunchConfiguration configuration) throws CoreException {
String encoding = configuration.getAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, (String)null);
if(encoding == null) {
@@ -873,7 +898,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
if(res instanceof IFile) {
return ((IFile)res).getCharset();
}
- else if(res instanceof IContainer) {
+ else if(res instanceof IContainer) {
return ((IContainer)res).getDefaultCharset();
}
}
@@ -883,7 +908,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
return encoding;
}
-
+
/**
* The launch config name cache is cleared when a config is added, deleted or changed.
*/
@@ -901,17 +926,17 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
return new DebugException(
new Status(
IStatus.ERROR, DebugPlugin.getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, message, throwable
+ DebugException.REQUEST_FAILED, message, throwable
)
);
}
-
+
/**
* Return a LaunchConfigurationInfo object initialized from XML contained in
* the specified stream. Simply pass out any exceptions encountered so that
* caller can deal with them. This is important since caller may need access to the
* actual exception.
- *
+ *
* @param stream the {@link InputStream} to read from
* @return the new {@link LaunchConfigurationInfo}
* @throws CoreException if a problem is encountered
@@ -930,38 +955,36 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
LaunchConfigurationInfo info = new LaunchConfigurationInfo();
info.initializeFromXML(root);
return info;
- }
-
+ }
+
/**
* Finds and returns all launch configurations in the given
* container (and sub-containers)
- *
+ *
* @param container the container to search
* @return all launch configurations in the given container
*/
- protected List findLaunchConfigurations(IContainer container) {
- List list = new ArrayList(10);
+ protected List<ILaunchConfiguration> findLaunchConfigurations(IContainer container) {
if (container instanceof IProject && !((IProject)container).isOpen()) {
- return list;
+ return Collections.EMPTY_LIST;
}
+ List<IResource> list = new ArrayList<IResource>(10);
ResourceProxyVisitor visitor= new ResourceProxyVisitor(list);
try {
container.accept(visitor, IResource.NONE);
} catch (CoreException ce) {
//Closed project...should not be possible with previous check
}
- Iterator iter = list.iterator();
- List configs = new ArrayList(list.size());
- ILaunchConfiguration config = null;
- while (iter.hasNext()) {
- config = getLaunchConfiguration((IFile)iter.next());
+ List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>(list.size());
+ for (IResource resource : list) {
+ ILaunchConfiguration config = getLaunchConfiguration((IFile) resource);
if(config != null && config.exists()) {
configs.add(config);
}
}
return configs;
}
-
+
/**
* Searches for the {@link ILaunchConfiguration} with the given name
* @param name the name to search for
@@ -979,37 +1002,41 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
return null;
}
-
+
/**
* Finds and returns all local launch configurations.
*
* @return all local launch configurations
*/
- protected List findLocalLaunchConfigurations() {
+ protected List<ILaunchConfiguration> findLocalLaunchConfigurations() {
IPath containerPath = LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH;
- List configs = new ArrayList(10);
final File directory = containerPath.toFile();
if (directory.isDirectory()) {
FilenameFilter filter = new FilenameFilter() {
+ @Override
public boolean accept(File dir, String name) {
return dir.equals(directory) &&
name.endsWith(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION);
}
};
File[] files = directory.listFiles(filter);
- LaunchConfiguration config = null;
- for (int i = 0; i < files.length; i++) {
- config = new LaunchConfiguration(LaunchConfiguration.getSimpleName(files[i].getName()), null);
- configs.add(config);
+ if (files.length > 0) {
+ List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>(10);
+ LaunchConfiguration config = null;
+ for (int i = 0; i < files.length; i++) {
+ config = new LaunchConfiguration(LaunchConfiguration.getSimpleName(files[i].getName()), null);
+ configs.add(config);
+ }
+ return configs;
}
}
- return configs;
+ return Collections.EMPTY_LIST;
}
-
+
/**
* Fires notification to (single) listeners that a launch has been
* added/changed/removed.
- *
+ *
* @param launch launch that has changed
* @param update type of change
*/
@@ -1020,7 +1047,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
/**
* Fires notification to (plural) listeners that a launch has been
* added/changed/removed.
- *
+ *
* @param launches launches that have changed
* @param update type of change
*/
@@ -1031,47 +1058,50 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchManager#generateUniqueLaunchConfigurationNameFrom(java.lang.String)
*/
+ @Override
public String generateUniqueLaunchConfigurationNameFrom(String baseName) {
int index = 1;
- int length= baseName.length();
+ int length = baseName.length();
int copyIndex = baseName.lastIndexOf(" ("); //$NON-NLS-1$
+ String base = baseName;
if (copyIndex > -1 && length > copyIndex + 2 && baseName.charAt(length - 1) == ')') {
- String trailer = baseName.substring(copyIndex + 2, length -1);
+ String trailer = baseName.substring(copyIndex + 2, length - 1);
if (isNumber(trailer)) {
try {
index = Integer.parseInt(trailer);
- baseName = baseName.substring(0, copyIndex);
- }
+ base = baseName.substring(0, copyIndex);
+ }
catch (NumberFormatException nfe) {}
}
- }
- String newName = baseName;
+ }
+ String newName = base;
while (isExistingLaunchConfigurationName(newName)) {
- newName = MessageFormat.format(DebugCoreMessages.LaunchManager_31, new String[] {baseName, Integer.toString(index)});
+ newName = MessageFormat.format(DebugCoreMessages.LaunchManager_31, new Object[] {
+ base, Integer.toString(index) });
index++;
- }
+ }
return newName;
}
-
+
/**
* Return a String that can be used as the name of a launch configuration. The name
* is guaranteed to be unique (no existing or temporary launch configurations will have this name).
- * The name that is returned uses the <code>basename</code> as a starting point. If
+ * The name that is returned uses the <code>basename</code> as a starting point. If
* there is no existing launch configuration with this name, then <code>basename</code>
* is returned. Otherwise, the value returned consists of the specified base plus
* some suffix that guarantees uniqueness. Passing <code>null</code> as the set of reserved names will cause this
* method to return <code>generateUniqueLaunchConfigurationNameFrom(String baseName)</code>.
- *
+ *
* By specifying a set of reserved names, you can further constrain the name that will be generated
* by this method. For example you can give a base name of 'test' and a reserved set of [test(1), test(2)],
* which will result in a name of 'test(3)' being returned iff a configuration with the name 'test' already exists.
- *
+ *
* @return launch configuration name
* @param basename the String that the returned name must begin with
* @param reservednames a set of strings that is further used to constrain what names can be generated
* @since 3.3
*/
- public String generateUniqueLaunchConfigurationNameFrom(String basename, Set reservednames) {
+ public String generateUniqueLaunchConfigurationNameFrom(String basename, Set<String> reservednames) {
if(reservednames == null) {
return generateUniqueLaunchConfigurationNameFrom(basename);
}
@@ -1085,46 +1115,46 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
try {
index = Integer.parseInt(trailer);
base = base.substring(0, copyIndex);
- }
+ }
catch (NumberFormatException nfe) {}
}
- }
+ }
String newname = base;
StringBuffer buffer = null;
while (isExistingLaunchConfigurationName(newname) || reservednames.contains(newname)) {
buffer = new StringBuffer(base);
buffer.append(" ("); //$NON-NLS-1$
buffer.append(String.valueOf(index));
- index++;
+ index++;
buffer.append(')');
newname = buffer.toString();
- }
+ }
return newname;
}
-
+
/**
- * Returns a collection of all launch configuration handles in
+ * Returns a collection of all launch configuration handles in
* the workspace. This collection is initialized lazily.
- *
+ *
* @return all launch configuration handles
*/
- private synchronized List getAllLaunchConfigurations() {
+ private synchronized List<ILaunchConfiguration> getAllLaunchConfigurations() {
if (fLaunchConfigurationIndex == null) {
- try {
- fLaunchConfigurationIndex = new ArrayList(20);
- List configs = findLocalLaunchConfigurations();
+ try {
+ fLaunchConfigurationIndex = new ArrayList<ILaunchConfiguration>(20);
+ List<ILaunchConfiguration> configs = findLocalLaunchConfigurations();
verifyConfigurations(configs, fLaunchConfigurationIndex);
configs = findLaunchConfigurations(ResourcesPlugin.getWorkspace().getRoot());
verifyConfigurations(configs, fLaunchConfigurationIndex);
} finally {
- hookResourceChangeListener();
+ hookResourceChangeListener();
}
}
return fLaunchConfigurationIndex;
}
-
+
/**
- * Return a sorted array of the names of all <code>ILaunchConfiguration</code>s in
+ * 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.
* @return the sorted array of {@link ILaunchConfiguration} names
@@ -1140,51 +1170,51 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
return fSortedConfigNames;
}
-
+
/**
* Returns the comparator registered for the given attribute, or
* <code>null</code> if none.
- *
+ *
* @param attributeName attribute for which a comparator is required
* @return comparator, or <code>null</code> if none
*/
- protected Comparator getComparator(String attributeName) {
- Map map = getComparators();
- return (Comparator)map.get(attributeName);
+ protected Comparator<Object> getComparator(String attributeName) {
+ Map<String, LaunchConfigurationComparator> map = getComparators();
+ return map.get(attributeName);
}
-
+
/**
* Returns comparators, loading if required
* @return the complete map of {@link ILaunchConfiguration} {@link Comparator}s
*/
- protected Map getComparators() {
+ protected Map<String, LaunchConfigurationComparator> getComparators() {
initializeComparators();
return fComparators;
- }
-
+ }
+
/**
* Returns the launch configurations specified by the given
* XML document.
- *
+ *
* @param root XML document
* @return list of launch configurations
* @throws CoreException if a problem is encountered
- */
- protected List getConfigsFromXML(Element root) throws CoreException {
- DebugException invalidFormat =
+ */
+ protected List<ILaunchConfiguration> getConfigsFromXML(Element root) throws CoreException {
+ DebugException invalidFormat =
new DebugException(
new Status(
IStatus.ERROR, DebugPlugin.getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, DebugCoreMessages.LaunchManager_Invalid_launch_configuration_index__18, null
+ DebugException.REQUEST_FAILED, DebugCoreMessages.LaunchManager_Invalid_launch_configuration_index__18, null
)
- );
-
+ );
+
if (!root.getNodeName().equalsIgnoreCase("launchConfigurations")) { //$NON-NLS-1$
throw invalidFormat;
}
-
- // read each launch configuration
- List configs = new ArrayList(4);
+
+ // read each launch configuration
+ List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>(4);
NodeList list = root.getChildNodes();
int length = list.getLength();
Node node = null;
@@ -1207,34 +1237,32 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
return configs;
}
-
+
protected ConfigurationNotifier getConfigurationNotifier() {
return new ConfigurationNotifier();
- }
-
+ }
+
/**
* @see ILaunchManager#getDebugTargets()
*/
+ @Override
public IDebugTarget[] getDebugTargets() {
synchronized (fLaunches) {
- List allTargets= new ArrayList(fLaunches.size());
- if (fLaunches.size() > 0) {
- Iterator e = fLaunches.iterator();
- IDebugTarget[] targets = null;
- while (e.hasNext()) {
- targets = ((ILaunch) e.next()).getDebugTargets();
- for (int i = 0; i < targets.length; i++) {
- allTargets.add(targets[i]);
- }
+ List<IDebugTarget> allTargets = new ArrayList<IDebugTarget>(fLaunches.size());
+ IDebugTarget[] targets = null;
+ for (ILaunch launch : fLaunches) {
+ targets = launch.getDebugTargets();
+ for (int i = 0; i < targets.length; i++) {
+ allTargets.add(targets[i]);
}
}
- return (IDebugTarget[])allTargets.toArray(new IDebugTarget[allTargets.size()]);
+ return allTargets.toArray(new IDebugTarget[allTargets.size()]);
}
}
-
+
/**
* Returns the resource delta visitor for the launch manager.
- *
+ *
* @return the resource delta visitor for the launch manager
*/
private LaunchManagerVisitor getDeltaVisitor() {
@@ -1243,11 +1271,11 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
return fgVisitor;
}
-
+
/**
* Returns the resource delta visitor for auto-removal of mapped launch configurations
* @return the resource delta visitor for auto-removal of mapped launch configurations
- *
+ *
* @since 3.4
*/
private MappedResourceVisitor getMappedResourceVisitor() {
@@ -1260,32 +1288,28 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchManager#getEnvironment(org.eclipse.debug.core.ILaunchConfiguration)
*/
+ @Override
public String[] getEnvironment(ILaunchConfiguration configuration) throws CoreException {
- Map configEnv = configuration.getAttribute(ATTR_ENVIRONMENT_VARIABLES, (Map) null);
+ Map<String, String> configEnv = configuration.getAttribute(ATTR_ENVIRONMENT_VARIABLES, (Map<String, String>) null);
if (configEnv == null) {
return null;
}
- Map env = new HashMap();
+ Map<String, String> env = new HashMap<String, String>();
// build base environment
boolean append = configuration.getAttribute(ATTR_APPEND_ENVIRONMENT_VARIABLES, true);
if (append) {
env.putAll(getNativeEnvironmentCasePreserved());
}
-
+
// Add variables from config
- Iterator iter= configEnv.entrySet().iterator();
boolean win32= Platform.getOS().equals(Constants.OS_WIN32);
- Map.Entry entry = null;
String key = null;
String value = null;
Object nativeValue = null;
- Iterator envIter = null;
- Map.Entry nativeEntry = null;
String nativeKey = null;
- while (iter.hasNext()) {
- entry = (Map.Entry) iter.next();
- key = (String) entry.getKey();
- value = (String) entry.getValue();
+ for (Entry<String, String> entry : configEnv.entrySet()) {
+ key = entry.getKey();
+ value = entry.getValue();
// translate any string substitution variables
if (value != null) {
value = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(value);
@@ -1301,10 +1325,8 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
// Win32 variables are case-insensitive. If an exact match isn't found, iterate to
// check for a case-insensitive match. We maintain the key's case (see bug 86725),
// but do a case-insensitive comparison (for example, "pAtH" will still override "PATH").
- envIter = env.entrySet().iterator();
- while (envIter.hasNext()) {
- nativeEntry = (Map.Entry) envIter.next();
- nativeKey = (String) (nativeEntry).getKey();
+ for (Entry<String, String> nativeEntry : env.entrySet()) {
+ nativeKey = (nativeEntry).getKey();
if (nativeKey.equalsIgnoreCase(key)) {
nativeEntry.setValue(value);
added = true;
@@ -1316,34 +1338,31 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
if (!added) {
env.put(key, value);
}
- }
-
- iter = env.entrySet().iterator();
- List strings = new ArrayList(env.size());
+ }
+ List<String> strings = new ArrayList<String>(env.size());
StringBuffer buffer = null;
- while (iter.hasNext()) {
- entry = (Map.Entry) iter.next();
- buffer = new StringBuffer((String) entry.getKey());
- buffer.append('=').append((String) entry.getValue());
+ for (Entry<String, String> entry : env.entrySet()) {
+ buffer = new StringBuffer(entry.getKey());
+ buffer.append('=').append(entry.getValue());
strings.add(buffer.toString());
}
- return (String[]) strings.toArray(new String[strings.size()]);
+ return strings.toArray(new String[strings.size()]);
}
-
+
/**
* Returns the info object for the specified launch configuration.
* If the configuration exists, but is not yet in the cache,
* an info object is built and added to the cache.
* @param config the {@link ILaunchConfiguration} to get the info object from
* @return the {@link LaunchConfigurationInfo} object from the given {@link ILaunchConfiguration}
- *
+ *
* @exception CoreException if an exception occurs building
* the info object
* @exception DebugException if the config does not exist
* @since 3.5
*/
protected LaunchConfigurationInfo getInfo(LaunchConfiguration config) throws CoreException {
- LaunchConfigurationInfo info = (LaunchConfigurationInfo)fLaunchConfigurations.get(config);
+ LaunchConfigurationInfo info = fLaunchConfigurations.get(config);
if (info == null) {
IFileStore store = config.getFileStore();
if (config.exists()) {
@@ -1355,100 +1374,99 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
fLaunchConfigurations.put(config, info);
}
} catch (FileNotFoundException e) {
- throwException(config, e);
+ throwException(config, e);
} catch (SAXException e) {
- throwException(config, e);
+ throwException(config, e);
} catch (ParserConfigurationException e) {
- throwException(config, e);
+ throwException(config, e);
} catch (IOException e) {
- throwException(config, e);
+ throwException(config, e);
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
- throwException(config, e);
+ throwException(config, e);
}
}
}
-
+
} else {
if (store != null){
- throw createDebugException(MessageFormat.format(DebugCoreMessages.LaunchManager_does_not_exist, new String[]{config.getName(), store.toURI().toString()}), null);
+ throw createDebugException(MessageFormat.format(DebugCoreMessages.LaunchManager_does_not_exist, new Object[] {
+ config.getName(), store.toURI().toString() }), null);
} else {
- throw createDebugException(MessageFormat.format(DebugCoreMessages.LaunchManager_does_not_exist_no_store_found, new String[]{config.getName()}), null);
+ throw createDebugException(MessageFormat.format(DebugCoreMessages.LaunchManager_does_not_exist_no_store_found, new Object[] { config.getName() }), null);
}
}
}
return info;
}
-
+
/**
* @see ILaunchManager#getLaunchConfiguration(IFile)
*/
+ @Override
public ILaunchConfiguration getLaunchConfiguration(IFile file) {
hookResourceChangeListener();
return new LaunchConfiguration(file);
}
-
+
/**
* @see ILaunchManager#getLaunchConfiguration(String)
*/
+ @Override
public ILaunchConfiguration getLaunchConfiguration(String memento) throws CoreException {
hookResourceChangeListener();
return new LaunchConfiguration(memento);
}
-
+
/**
* @see ILaunchManager#getLaunchConfigurations()
*/
+ @Override
public synchronized ILaunchConfiguration[] getLaunchConfigurations() {
- List allConfigs = getAllLaunchConfigurations();
- return (ILaunchConfiguration[])allConfigs.toArray(new ILaunchConfiguration[allConfigs.size()]);
- }
-
+ List<ILaunchConfiguration> allConfigs = getAllLaunchConfigurations();
+ return allConfigs.toArray(new ILaunchConfiguration[allConfigs.size()]);
+ }
+
/**
* @see ILaunchManager#getLaunchConfigurations(ILaunchConfigurationType)
*/
+ @Override
public synchronized ILaunchConfiguration[] getLaunchConfigurations(ILaunchConfigurationType type) throws CoreException {
- Iterator iter = getAllLaunchConfigurations().iterator();
- List configs = new ArrayList();
- ILaunchConfiguration config = null;
- while (iter.hasNext()) {
- config = (ILaunchConfiguration)iter.next();
+ List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>();
+ for (ILaunchConfiguration config : getAllLaunchConfigurations()) {
if (config.getType().equals(type)) {
configs.add(config);
}
}
- return (ILaunchConfiguration[])configs.toArray(new ILaunchConfiguration[configs.size()]);
+ return configs.toArray(new ILaunchConfiguration[configs.size()]);
}
-
+
/**
* Returns all launch configurations that are stored as resources
* in the given project.
- *
+ *
* @param project a project
* @return collection of launch configurations that are stored as resources
* in the given project
*/
- protected synchronized List getLaunchConfigurations(IProject project) {
- Iterator iter = getAllLaunchConfigurations().iterator();
- List configs = new ArrayList();
- ILaunchConfiguration config = null;
- IFile file = null;
- while (iter.hasNext()) {
- config = (ILaunchConfiguration)iter.next();
- file = config.getFile();
+ protected synchronized List<ILaunchConfiguration> getLaunchConfigurations(IProject project) {
+ List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>();
+ for (ILaunchConfiguration config : getAllLaunchConfigurations()) {
+ IFile file = config.getFile();
if (file != null && file.getProject().equals(project)) {
configs.add(config);
}
}
return configs;
}
-
+
/**
* @see ILaunchManager#getLaunchConfigurationType(String)
*/
+ @Override
public ILaunchConfigurationType getLaunchConfigurationType(String id) {
ILaunchConfigurationType[] types = getLaunchConfigurationTypes();
for(int i = 0; i < types.length; i++) {
@@ -1462,79 +1480,82 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
/**
* @see ILaunchManager#getLaunchConfigurationTypes()
*/
+ @Override
public ILaunchConfigurationType[] getLaunchConfigurationTypes() {
initializeLaunchConfigurationTypes();
- return (ILaunchConfigurationType[])fLaunchConfigurationTypes.toArray(new ILaunchConfigurationType[fLaunchConfigurationTypes.size()]);
+ return fLaunchConfigurationTypes.toArray(new ILaunchConfigurationType[fLaunchConfigurationTypes.size()]);
}
-
+
/**
* @see ILaunchManager#getLaunches()
*/
+ @Override
public ILaunch[] getLaunches() {
synchronized (fLaunches) {
- return (ILaunch[])fLaunches.toArray(new ILaunch[fLaunches.size()]);
+ return fLaunches.toArray(new ILaunch[fLaunches.size()]);
}
}
-
+
/**)
* @see org.eclipse.debug.core.ILaunchManager#getLaunchMode(java.lang.String)
*/
+ @Override
public ILaunchMode getLaunchMode(String mode) {
initializeLaunchModes();
- return (ILaunchMode) fLaunchModes.get(mode);
+ return fLaunchModes.get(mode);
}
-
+
/**
* @see org.eclipse.debug.core.ILaunchManager#getLaunchModes()
*/
+ @Override
public ILaunchMode[] getLaunchModes() {
initializeLaunchModes();
- Collection collection = fLaunchModes.values();
- return (ILaunchMode[]) collection.toArray(new ILaunchMode[collection.size()]);
+ Collection<ILaunchMode> collection = fLaunchModes.values();
+ return collection.toArray(new ILaunchMode[collection.size()]);
}
-
+
/**
* Returns all of the launch delegates. The returned listing of delegates cannot be directly used to launch,
* instead the method <code>IlaunchDelegate.getDelegate</code> must be used to acquire an executable form of
* the delegate, allowing us to maintain lazy loading of the delegates themselves.
* @return all of the launch delegates
- *
+ *
* @since 3.3
*/
public ILaunchDelegate[] getLaunchDelegates() {
initializeLaunchDelegates();
- Collection col = fLaunchDelegates.values();
- return (ILaunchDelegate[]) col.toArray(new ILaunchDelegate[col.size()]);
+ Collection<LaunchDelegate> col = fLaunchDelegates.values();
+ return col.toArray(new ILaunchDelegate[col.size()]);
}
-
+
/**
- * Returns the listing of launch delegates that apply to the specified
+ * Returns the listing of launch delegates that apply to the specified
* <code>ILaunchConfigurationType</code> id
- * @param typeid the id of the launch configuration type to get delegates for
+ * @param typeid the id of the launch configuration type to get delegates for
* @return An array of <code>LaunchDelegate</code>s that apply to the specified launch configuration
* type, or an empty array, never <code>null</code>
- *
+ *
* @since 3.3
*/
public LaunchDelegate[] getLaunchDelegates(String typeid) {
initializeLaunchDelegates();
- ArrayList list = new ArrayList();
- LaunchDelegate ld = null;
- for(Iterator iter = fLaunchDelegates.keySet().iterator(); iter.hasNext();) {
- ld = (LaunchDelegate) fLaunchDelegates.get(iter.next());
- if(ld.getLaunchConfigurationTypeId().equals(typeid)) {
+ ArrayList<LaunchDelegate> list = new ArrayList<LaunchDelegate>();
+ for (Entry<String, LaunchDelegate> entry : fLaunchDelegates.entrySet()) {
+ LaunchDelegate ld = entry.getValue();
+ if (ld.getLaunchConfigurationTypeId().equals(typeid)) {
list.add(ld);
}
}
- return (LaunchDelegate[]) list.toArray(new LaunchDelegate[list.size()]);
+ return list.toArray(new LaunchDelegate[list.size()]);
}
-
+
/**
- * This method returns the <code>ILaunchDelegate</code> instance corresponding to the id
+ * This method returns the <code>ILaunchDelegate</code> instance corresponding to the id
* of the launch delegate specified
- * @param id the id of the <code>ILaunchDelegate</code> to find
+ * @param id the id of the <code>ILaunchDelegate</code> to find
* @return the <code>ILaunchDelegate</code> or <code>null</code> if not found
- *
+ *
* @since 3.3
*/
public ILaunchDelegate getLaunchDelegate(String id) {
@@ -1548,15 +1569,15 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
return null;
}
-
+
/**
* Initializes the listing of delegates available to the launching framework
- *
+ *
* @since 3.3
*/
private synchronized void initializeLaunchDelegates() {
if(fLaunchDelegates == null) {
- fLaunchDelegates = new HashMap();
+ fLaunchDelegates = new HashMap<String, LaunchDelegate>();
//get all launch delegate contributions
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(DebugPlugin.getUniqueIdentifier(), DebugPlugin.EXTENSION_POINT_LAUNCH_DELEGATES);
IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
@@ -1577,11 +1598,11 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
}
}
-
+
/**
* This method is used to initialize a simple listing of all preferred delegates, which is then used by each
* <code>ILaunchConfigurationType</code> to find if they have preferred delegates. Once an <code>ILaunchConfigurationType</code>
- * has used this listing to initialize its preferred delegates it will maintain changes to its preferred delegate, which are
+ * has used this listing to initialize its preferred delegates it will maintain changes to its preferred delegate, which are
* then written back to the preference store only when the launch manager shuts down.
* <p>
* This cache is not synchronized with the runtime preferred delegates stored in launch configuration types.
@@ -1590,7 +1611,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
*/
private synchronized void initializePreferredDelegates() {
if(fPreferredDelegates == null) {
- fPreferredDelegates = new HashSet();
+ fPreferredDelegates = new HashSet<PreferredDelegate>();
String preferred = Platform.getPreferencesService().getString(DebugPlugin.getUniqueIdentifier(), LaunchManager.PREF_PREFERRED_DELEGATES, IInternalDebugCoreConstants.EMPTY_STRING, null);
if(!IInternalDebugCoreConstants.EMPTY_STRING.equals(preferred)) {
try {
@@ -1598,13 +1619,13 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
NodeList nodes = root.getElementsByTagName(IConfigurationElementConstants.DELEGATE);
Element element = null;
String typeid = null;
- Set modeset = null;
+ Set<String> modeset = null;
for(int i = 0; i < nodes.getLength(); i++) {
element = (Element) nodes.item(i);
- String delegateid = element.getAttribute(IConfigurationElementConstants.ID);
+ String delegateid = element.getAttribute(IConfigurationElementConstants.ID);
typeid = element.getAttribute(IConfigurationElementConstants.TYPE_ID);
String[] modes = element.getAttribute(IConfigurationElementConstants.MODES).split(","); //$NON-NLS-1$
- modeset = new HashSet(Arrays.asList(modes));
+ modeset = new HashSet<String>(Arrays.asList(modes));
LaunchDelegate delegate = getLaunchDelegateExtension(typeid, delegateid, modeset);
if (delegate != null) {
//take type id, modeset, delegate and create entry
@@ -1614,51 +1635,49 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
}
}
- catch (CoreException e) {DebugPlugin.log(e);}
+ catch (CoreException e) {DebugPlugin.log(e);}
}
}
}
-
+
/**
- * Allows internal access to reset preferred delegates when re-importing
- * preferences.
- *
+ * Allows internal access to reset preferred delegates when re-importing
+ * preferences.
+ *
* @since 3.6
*/
protected void resetPreferredDelegates() {
fPreferredDelegates = null;
}
-
+
/**
* Allows internal access to a preferred delegate for a given type and mode set
* @param typeid the id of the <code>ILaunchConfigurationType</code> to find a delegate for
* @param modes the set of modes for the delegate
* @return the preferred delegate for the specified type id and mode set, or <code>null</code> if none
- *
+ *
* @since 3.3
*/
- protected ILaunchDelegate getPreferredDelegate(String typeid, Set modes) {
- // Retrieve preferred delegates using legacy mechanism for backward
+ protected ILaunchDelegate getPreferredDelegate(String typeid, Set<String> modes) {
+ // Retrieve preferred delegates using legacy mechanism for backward
// compatibility.
initializePreferredDelegates();
- PreferredDelegate pd = null;
- for(Iterator iter = fPreferredDelegates.iterator(); iter.hasNext();) {
- pd = (PreferredDelegate) iter.next();
+ for (PreferredDelegate pd : fPreferredDelegates) {
if(pd.getModes().equals(modes) & pd.getTypeId().equals(typeid)) {
return pd.getDelegate();
}
}
// @since 3.5
- // If the legacy mechanism didn't work, try the new preference name for
- // the given launch type.
+ // If the legacy mechanism didn't work, try the new preference name for
+ // the given launch type.
String preferred = Platform.getPreferencesService().getString(DebugPlugin.getUniqueIdentifier(), "//" + LaunchManager.PREF_PREFERRED_DELEGATES + '/' + typeid, IInternalDebugCoreConstants.EMPTY_STRING, null); //$NON-NLS-1$
if (preferred != null && preferred.length() != 0) {
StringTokenizer tokenizer = new StringTokenizer(preferred, ";"); //$NON-NLS-1$
while(tokenizer.hasMoreTokens()) {
StringTokenizer tokenizer2 = new StringTokenizer(tokenizer.nextToken(), ","); //$NON-NLS-1$
String delegateId = tokenizer2.nextToken();
- HashSet modeset = new HashSet();
+ HashSet<String> modeset = new HashSet<String>();
while(tokenizer2.hasMoreTokens()) {
modeset.add(tokenizer2.nextToken());
}
@@ -1667,28 +1686,28 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
return delegate;
}
}
-
+
}
return null;
}
-
+
/**
* Returns the launch delegate extension that matches the given type, delegate ID, and
* set of modes.
- *
+ *
* @param typeId Launch configuration type.
* @param id Launch delegate ID.
- * @param modeset Set of modes that the launch delegate applies to.
- * @return The launch delegate matching the specified parameters, or
+ * @param modeset Set of modes that the launch delegate applies to.
+ * @return The launch delegate matching the specified parameters, or
* <code>null</code> if not found.
- *
+ *
* @since 3.5
*/
- private LaunchDelegate getLaunchDelegateExtension(String typeId, String id, Set modeset) {
+ private LaunchDelegate getLaunchDelegateExtension(String typeId, String id, Set<String> modeset) {
LaunchDelegate[] extensions = getLaunchDelegates(typeId);
for(int j = 0; j < extensions.length; j++) {
- if(id.equals(extensions[j].getId())) {
- List modesets = extensions[j].getModes();
+ if(id.equals(extensions[j].getId())) {
+ List<Set<String>> modesets = extensions[j].getModes();
if(modesets.contains(modeset)) {
return extensions[j];
}
@@ -1696,25 +1715,22 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
return null;
}
-
+
/**
* Returns all launch configurations that are stored locally.
- *
+ *
* @return collection of launch configurations stored locally
*/
- protected synchronized List getLocalLaunchConfigurations() {
- Iterator iter = getAllLaunchConfigurations().iterator();
- List configs = new ArrayList();
- ILaunchConfiguration config = null;
- while (iter.hasNext()) {
- config = (ILaunchConfiguration)iter.next();
+ protected synchronized List<ILaunchConfiguration> getLocalLaunchConfigurations() {
+ List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>();
+ for (ILaunchConfiguration config : getAllLaunchConfigurations()) {
if (config.isLocal()) {
configs.add(config);
}
}
return configs;
}
-
+
/**
* Returns the launch configurations mapping to the specified resource
* @param resource the resource to collect mapped launch configurations for
@@ -1722,138 +1738,140 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
* @since 3.2
*/
public ILaunchConfiguration[] getMappedConfigurations(IResource resource) {
- List configurations = new ArrayList();
- try {
- ILaunchConfiguration[] configs = getLaunchConfigurations();
- IResource[] resources = null;
- for(int i = 0; i < configs.length; i++) {
- resources = configs[i].getMappedResources();
+ List<ILaunchConfiguration> configurations = new ArrayList<ILaunchConfiguration>();
+ for (ILaunchConfiguration config : getAllLaunchConfigurations()) {
+ try {
+ IResource[] resources = config.getMappedResources();
if(resources != null) {
for(int j = 0; j < resources.length; j++) {
if(resources[j].equals(resource)) {
- configurations.add(configs[i]);
+ configurations.add(config);
+ break;
}
}
}
+ } catch (CoreException ce) {
+ DebugPlugin.log(ce);
}
}
- catch(CoreException e) {DebugPlugin.log(e);}
- return (ILaunchConfiguration[])configurations.toArray(new ILaunchConfiguration[configurations.size()]);
+ return configurations.toArray(new ILaunchConfiguration[configurations.size()]);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchManager#getMigrationCandidates()
*/
+ @Override
public ILaunchConfiguration[] getMigrationCandidates() throws CoreException {
- List configs = new ArrayList();
- ILaunchConfiguration[] candidates = getLaunchConfigurations();
- for(int i = 0; i < candidates.length; i++) {
- if(!candidates[i].isReadOnly() && candidates[i].isMigrationCandidate()) {
- configs.add(candidates[i]);
+ List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>();
+ for (ILaunchConfiguration config : getAllLaunchConfigurations()) {
+ if (!config.isReadOnly() && config.isMigrationCandidate()) {
+ configs.add(config);
}
}
- return (ILaunchConfiguration[])configs.toArray(new ILaunchConfiguration[configs.size()]);
+ return configs.toArray(new ILaunchConfiguration[configs.size()]);
}
-
+
/**
* @see org.eclipse.debug.core.ILaunchManager#getMovedFrom(org.eclipse.debug.core.ILaunchConfiguration)
*/
+ @Override
public ILaunchConfiguration getMovedFrom(ILaunchConfiguration addedConfiguration) {
if (addedConfiguration.equals(fTo)) {
return fFrom;
}
return null;
}
-
+
/**
* @see org.eclipse.debug.core.ILaunchManager#getMovedTo(org.eclipse.debug.core.ILaunchConfiguration)
*/
+ @Override
public ILaunchConfiguration getMovedTo(ILaunchConfiguration removedConfiguration) {
if (removedConfiguration.equals(fFrom)) {
return fTo;
}
return null;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchManager#getNativeEnvironment()
*/
- public synchronized Map getNativeEnvironment() {
+ @Override
+ public synchronized Map<String, String> getNativeEnvironment() {
if (fgNativeEnv == null) {
- Map casePreserved = getNativeEnvironmentCasePreserved();
+ Map<String, String> casePreserved = getNativeEnvironmentCasePreserved();
if (Platform.getOS().equals(Constants.OS_WIN32)) {
- fgNativeEnv= new HashMap();
- Iterator entries = casePreserved.entrySet().iterator();
- Map.Entry entry = null;
- String key = null;
- while (entries.hasNext()) {
- entry = (Entry) entries.next();
- key = ((String)entry.getKey()).toUpperCase();
- fgNativeEnv.put(key, entry.getValue());
+ fgNativeEnv = new HashMap<String, String>();
+ for (Entry<String, String> entry : casePreserved.entrySet()) {
+ fgNativeEnv.put(entry.getKey().toUpperCase(), entry.getValue());
}
} else {
- fgNativeEnv = new HashMap(casePreserved);
+ fgNativeEnv = new HashMap<String, String>(casePreserved);
}
}
- return new HashMap(fgNativeEnv);
- }
-
+ return new HashMap<String, String>(fgNativeEnv);
+ }
+
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchManager#getNativeEnvironmentCasePreserved()
*/
- public synchronized Map getNativeEnvironmentCasePreserved() {
+ @Override
+ public synchronized Map<String, String> getNativeEnvironmentCasePreserved() {
if (fgNativeEnvCasePreserved == null) {
- fgNativeEnvCasePreserved= new HashMap();
+ fgNativeEnvCasePreserved = new HashMap<String, String>();
cacheNativeEnvironment(fgNativeEnvCasePreserved);
}
- return new HashMap(fgNativeEnvCasePreserved);
+ return new HashMap<String, String>(fgNativeEnvCasePreserved);
}
-
+
/**
* @see ILaunchManager#getProcesses()
*/
+ @Override
public IProcess[] getProcesses() {
synchronized (fLaunches) {
- List allProcesses = new ArrayList(fLaunches.size());
- Iterator e = fLaunches.iterator();
+ List<IProcess> allProcesses = new ArrayList<IProcess>(fLaunches.size());
IProcess[] processes = null;
- while (e.hasNext()) {
- processes = ((ILaunch) e.next()).getProcesses();
+ for (ILaunch launch : fLaunches) {
+ processes = launch.getProcesses();
for (int i= 0; i < processes.length; i++) {
allProcesses.add(processes[i]);
}
}
- return (IProcess[])allProcesses.toArray(new IProcess[allProcesses.size()]);
+ return allProcesses.toArray(new IProcess[allProcesses.size()]);
}
- }
-
+ }
+
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchManager#getSourceContainerType(java.lang.String)
*/
+ @Override
public ISourceContainerType getSourceContainerType(String id) {
initializeSourceContainerTypes();
- return (ISourceContainerType) sourceContainerTypes.get(id);
+ return sourceContainerTypes.get(id);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchManager#getSourceContainerTypes()
*/
+ @Override
public ISourceContainerType[] getSourceContainerTypes() {
initializeSourceContainerTypes();
- Collection containers = sourceContainerTypes.values();
- return (ISourceContainerType[]) containers.toArray(new ISourceContainerType[containers.size()]);
+ Collection<ISourceContainerType> containers = sourceContainerTypes.values();
+ return containers.toArray(new ISourceContainerType[containers.size()]);
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchManager#newSourcePathComputer(org.eclipse.debug.core.ILaunchConfiguration)
*/
+ @Override
public ISourcePathComputer getSourcePathComputer(ILaunchConfiguration configuration) throws CoreException {
String id = null;
id = configuration.getAttribute(ISourcePathComputer.ATTR_SOURCE_PATH_COMPUTER_ID, (String)null);
-
+
if (id == null) {
- //use default computer for configuration type, if any
- return configuration.getType().getSourcePathComputer();
+ //use default computer for configuration type, if any
+ return configuration.getType().getSourcePathComputer();
}
return getSourcePathComputer(id);
}
@@ -1861,9 +1879,10 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchManager#getSourcePathComputer(java.lang.String)
*/
+ @Override
public ISourcePathComputer getSourcePathComputer(String id) {
initializeSourceContainerTypes();
- return (ISourcePathComputer) sourcePathComputers.get(id);
+ return sourcePathComputers.get(id);
}
/**
@@ -1875,7 +1894,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
fListening = true;
}
}
-
+
/**
* Load comparator extensions.
*/
@@ -1883,18 +1902,18 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
if (fComparators == null) {
IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(DebugPlugin.getUniqueIdentifier(), DebugPlugin.EXTENSION_POINT_LAUNCH_CONFIGURATION_COMPARATORS);
IConfigurationElement[] infos= extensionPoint.getConfigurationElements();
- fComparators = new HashMap(infos.length);
+ fComparators = new HashMap<String, LaunchConfigurationComparator>(infos.length);
IConfigurationElement configurationElement = null;
String attr = null;
for (int i= 0; i < infos.length; i++) {
configurationElement = infos[i];
- attr = configurationElement.getAttribute("attribute"); //$NON-NLS-1$
+ attr = configurationElement.getAttribute("attribute"); //$NON-NLS-1$
if (attr != null) {
fComparators.put(attr, new LaunchConfigurationComparator(configurationElement));
} else {
// invalid status handler
IStatus s = new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR,
- MessageFormat.format("Invalid launch configuration comparator extension defined by plug-in {0} - attribute not specified.", new String[] {configurationElement.getContributor().getName()}), null); //$NON-NLS-1$
+ MessageFormat.format("Invalid launch configuration comparator extension defined by plug-in {0} - attribute not specified.", new Object[] { configurationElement.getContributor().getName() }), null); //$NON-NLS-1$
DebugPlugin.log(s);
}
}
@@ -1909,13 +1928,13 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
hookResourceChangeListener();
IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(DebugPlugin.getUniqueIdentifier(), DebugPlugin.EXTENSION_POINT_LAUNCH_CONFIGURATION_TYPES);
IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
- fLaunchConfigurationTypes = new ArrayList(infos.length);
- for (int i= 0; i < infos.length; i++) {
+ fLaunchConfigurationTypes = new ArrayList<ILaunchConfigurationType>(infos.length);
+ for (int i= 0; i < infos.length; i++) {
fLaunchConfigurationTypes.add(new LaunchConfigurationType(infos[i]));
}
}
}
-
+
/**
* Load comparator extensions.
*/
@@ -1924,17 +1943,17 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
try {
IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(DebugPlugin.getUniqueIdentifier(), DebugPlugin.EXTENSION_POINT_LAUNCH_MODES);
IConfigurationElement[] infos= extensionPoint.getConfigurationElements();
- fLaunchModes = new HashMap();
+ fLaunchModes = new HashMap<String, ILaunchMode>();
ILaunchMode mode = null;
for (int i= 0; i < infos.length; i++) {
mode = new LaunchMode(infos[i]);
fLaunchModes.put(mode.getIdentifier(), mode);
}
- }
+ }
catch (CoreException e) {DebugPlugin.log(e);}
}
}
-
+
/**
* Initializes source container type and source path computer extensions.
*/
@@ -1942,7 +1961,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
if (sourceContainerTypes == null) {
IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(DebugPlugin.getUniqueIdentifier(), DebugPlugin.EXTENSION_POINT_SOURCE_CONTAINER_TYPES);
IConfigurationElement[] extensions = extensionPoint.getConfigurationElements();
- sourceContainerTypes = new HashMap();
+ sourceContainerTypes = new HashMap<String, ISourceContainerType>();
for (int i = 0; i < extensions.length; i++) {
sourceContainerTypes.put(
extensions[i].getAttribute(IConfigurationElementConstants.ID),
@@ -1950,7 +1969,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(DebugPlugin.getUniqueIdentifier(), DebugPlugin.EXTENSION_POINT_SOURCE_PATH_COMPUTERS);
extensions = extensionPoint.getConfigurationElements();
- sourcePathComputers = new HashMap();
+ sourcePathComputers = new HashMap<String, ISourcePathComputer>();
for (int i = 0; i < extensions.length; i++) {
sourcePathComputers.put(
extensions[i].getAttribute(IConfigurationElementConstants.ID),
@@ -1966,18 +1985,18 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
if (fSourceLocators == null) {
IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(DebugPlugin.getUniqueIdentifier(), DebugPlugin.EXTENSION_POINT_SOURCE_LOCATORS);
IConfigurationElement[] infos= extensionPoint.getConfigurationElements();
- fSourceLocators= new HashMap(infos.length);
+ fSourceLocators = new HashMap<String, IConfigurationElement>(infos.length);
IConfigurationElement configurationElement = null;
String id = null;
for (int i= 0; i < infos.length; i++) {
configurationElement = infos[i];
- id = configurationElement.getAttribute(IConfigurationElementConstants.ID);
+ id = configurationElement.getAttribute(IConfigurationElementConstants.ID);
if (id != null) {
fSourceLocators.put(id,configurationElement);
} else {
// invalid status handler
IStatus s = new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR,
- MessageFormat.format("Invalid source locator extension defined by plug-in \"{0}\": \"id\" not specified.", new String[] {configurationElement.getContributor().getName()} ), null); //$NON-NLS-1$
+ MessageFormat.format("Invalid source locator extension defined by plug-in \"{0}\": \"id\" not specified.", new Object[] { configurationElement.getContributor().getName() }), null); //$NON-NLS-1$
DebugPlugin.log(s);
}
}
@@ -1987,7 +2006,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
/**
* Adds the given launch object to the list of registered launches,
* and returns whether the launch was added.
- *
+ *
* @param launch launch to register
* @return whether the launch was added
*/
@@ -2007,7 +2026,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
/**
* Removes the given launch object from the collection of registered
* launches. Returns whether the launch was removed.
- *
+ *
* @param launch the launch to remove
* @return whether the launch was removed
*/
@@ -2023,15 +2042,16 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
/**
* @see ILaunchManager#isExistingLaunchConfigurationName(String)
*/
+ @Override
public boolean isExistingLaunchConfigurationName(String name) {
String[] sortedConfigNames = getAllSortedConfigNames();
int index = Arrays.binarySearch(sortedConfigNames, name);
if (index < 0) {
return false;
- }
+ }
return true;
}
-
+
/**
* Returns whether the given String is composed solely of digits
* @param string the {@link String} to check
@@ -2049,20 +2069,21 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
return true;
}
-
+
/**
* Returns whether the user has selected to delete associated configurations when a
* project is deleted.
- *
+ *
* @return whether to auto-delete configurations
*/
private boolean isDeleteConfigurations() {
return Platform.getPreferencesService().getBoolean(DebugPlugin.getUniqueIdentifier(), DebugPlugin.PREF_DELETE_CONFIGS_ON_PROJECT_DELETE, true, null);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchManager#isRegistered(org.eclipse.debug.core.ILaunch)
*/
+ @Override
public boolean isRegistered(ILaunch launch) {
synchronized (fLaunches) {
return fLaunchSet.contains(launch);
@@ -2072,7 +2093,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
/**
* Returns whether the given launch configuration passes a basic
* integrity test by retrieving its type.
- *
+ *
* @param config the configuration to verify
* @return whether the config meets basic integrity constraints
*/
@@ -2089,26 +2110,26 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
return true;
}
-
+
/**
* Notifies the launch manager that a launch configuration
* has been added. The configuration is added to the index of
* configurations by project, and listeners are notified.
- *
+ *
* @param config the launch configuration that was added
*/
protected void launchConfigurationAdded(ILaunchConfiguration config) {
if (config.isWorkingCopy()) {
return;
}
- if (isValid(config)) {
+ if (isValid(config)) {
boolean added = false;
synchronized (this) {
- List allConfigs = getAllLaunchConfigurations();
+ List<ILaunchConfiguration> allConfigs = getAllLaunchConfigurations();
if (!allConfigs.contains(config)) {
allConfigs.add(config);
added = true;
- }
+ }
}
if (added) {
getConfigurationNotifier().notify(config, ADDED);
@@ -2118,14 +2139,14 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
launchConfigurationDeleted(config);
}
}
-
+
/**
* Notifies the launch manager that a launch configuration
* has been changed. The configuration is removed from the
* cache of info objects such that the new attributes will
* be updated on the next access. Listeners are notified of
* the change.
- *
+ *
* @param config the launch configuration that was changed
*/
protected void launchConfigurationChanged(ILaunchConfiguration config) {
@@ -2141,15 +2162,15 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
getConfigurationNotifier().notify(config, CHANGED);
} else {
launchConfigurationDeleted(config);
- }
+ }
}
-
+
/**
* Notifies the launch manager that a launch configuration
* has been deleted. The configuration is removed from the
* cache of info and from the index of configurations by
* project, and listeners are notified.
- *
+ *
* @param config the launch configuration that was deleted
*/
protected void launchConfigurationDeleted(ILaunchConfiguration config) {
@@ -2157,120 +2178,119 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
synchronized (this) {
Object key = fLaunchConfigurations.remove(config);
removed = key != null;
- getAllLaunchConfigurations().remove(config);
+ getAllLaunchConfigurations().remove(config);
}
if (removed) {
getConfigurationNotifier().notify(config, REMOVED);
clearConfigNameCache();
}
}
-
+
/**
* @see ILaunchManager#newSourceLocator(String)
*/
+ @Override
public IPersistableSourceLocator newSourceLocator(String identifier) throws CoreException {
initializeSourceLocators();
- IConfigurationElement config = (IConfigurationElement)fSourceLocators.get(identifier);
+ IConfigurationElement config = fSourceLocators.get(identifier);
if (config == null) {
throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR,
- MessageFormat.format(DebugCoreMessages.LaunchManager_Source_locator_does_not_exist___0__13, new String[] {identifier} ), null));
- }
+ MessageFormat.format(DebugCoreMessages.LaunchManager_Source_locator_does_not_exist___0__13, new Object[] { identifier }), null));
+ }
IPersistableSourceLocator sourceLocator = (IPersistableSourceLocator)config.createExecutableExtension("class"); //$NON-NLS-1$
if (sourceLocator instanceof AbstractSourceLookupDirector) {
((AbstractSourceLookupDirector)sourceLocator).setId(identifier);
}
return sourceLocator;
}
-
+
/**
* The specified project has just closed - remove its
* launch configurations from the cached index.
- *
+ *
* @param project the project that has been closed
*/
protected void projectClosed(IProject project) {
- List configs = getLaunchConfigurations(project);
- if (!configs.isEmpty()) {
- Iterator iterator = configs.iterator();
- while (iterator.hasNext()) {
- launchConfigurationDeleted((ILaunchConfiguration)iterator.next());
- }
+ for (ILaunchConfiguration config : getLaunchConfigurations(project)) {
+ launchConfigurationDeleted(config);
}
//bug 12134
terminateMappedConfigurations(project);
}
-
+
/**
* The specified project has just opened - add all launch
* configs in the project to the index of all configs.
- *
+ *
* @param project the project that has been opened
*/
protected void projectOpened(IProject project) {
- List configs = findLaunchConfigurations(project);
- if (!configs.isEmpty()) {
- Iterator iterator = configs.iterator();
- while (iterator.hasNext()) {
- launchConfigurationAdded((ILaunchConfiguration) iterator.next());
- }
+ for (ILaunchConfiguration config : findLaunchConfigurations(project)) {
+ launchConfigurationAdded(config);
}
}
-
+
/**
* @see ILaunchManager#removeLaunch(ILaunch)
*/
+ @Override
public void removeLaunch(final ILaunch launch) {
if (internalRemoveLaunch(launch)) {
fireUpdate(launch, REMOVED);
fireUpdate(new ILaunch[] {launch}, REMOVED);
}
}
-
+
/**
* @see ILaunchManager#removeLaunchConfigurationListener(ILaunchConfigurationListener)
*/
+ @Override
public void removeLaunchConfigurationListener(ILaunchConfigurationListener listener) {
fLaunchConfigurationListeners.remove(listener);
}
-
- /**
+
+ /**
* @see org.eclipse.debug.core.ILaunchManager#removeLaunches(org.eclipse.debug.core.ILaunch[])
*/
+ @Override
public void removeLaunches(ILaunch[] launches) {
- List removed = new ArrayList(launches.length);
+ List<ILaunch> removed = new ArrayList<ILaunch>(launches.length);
for (int i = 0; i < launches.length; i++) {
if (internalRemoveLaunch(launches[i])) {
removed.add(launches[i]);
}
}
if (!removed.isEmpty()) {
- ILaunch[] removedLaunches = (ILaunch[])removed.toArray(new ILaunch[removed.size()]);
+ ILaunch[] removedLaunches = removed.toArray(new ILaunch[removed.size()]);
fireUpdate(removedLaunches, REMOVED);
for (int i = 0; i < removedLaunches.length; i++) {
fireUpdate(removedLaunches[i], REMOVED);
}
}
- }
+ }
/**
* @see org.eclipse.debug.core.ILaunchManager#removeLaunchListener(org.eclipse.debug.core.ILaunchesListener)
*/
+ @Override
public void removeLaunchListener(ILaunchesListener listener) {
fLaunchesListeners.remove(listener);
}
-
+
/**
* @see ILaunchManager#removeLaunchListener(ILaunchListener)
*/
+ @Override
public void removeLaunchListener(ILaunchListener listener) {
fListeners.remove(listener);
}
-
+
/**
* Traverses the delta looking for added/removed/changed launch
* configuration files.
- *
+ *
* @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
*/
+ @Override
public void resourceChanged(IResourceChangeEvent event) {
IResourceDelta delta = event.getDelta();
if (delta != null) {
@@ -2289,18 +2309,18 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
}
}
-
+
/**
* Gets the launch configuration associated with the specified <code>IResource</code>.
- * This method relies on the resource mapping existing, if no such mapping
+ * This method relies on the resource mapping existing, if no such mapping
* exists the launch configuration is ignored.
- *
+ *
* @param resource the resource to collect launch configurations for
* @return the list of associated launch configurations
*/
- private ArrayList collectAssociatedLaunches(IResource resource) {
- ArrayList list = new ArrayList();
- try {
+ private ArrayList<ILaunchConfiguration> collectAssociatedLaunches(IResource resource) {
+ ArrayList<ILaunchConfiguration> list = new ArrayList<ILaunchConfiguration>();
+ try {
ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations();
IResource[] resources = null;
for(int i = 0; i < configs.length; i++) {
@@ -2308,7 +2328,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
resources = configs[i].getMappedResources();
if(resources != null) {
for(int j = 0; j < resources.length; j++){
- if(resource.equals(resources[j]) ||
+ if(resource.equals(resources[j]) ||
resource.getFullPath().isPrefixOf(resources[j].getFullPath())) {
list.add(configs[i]);
break;
@@ -2322,11 +2342,11 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
return list;
}
-
+
/**
* Indicates the given launch configuration is being moved from the given
* location to the new location.
- *
+ *
* @param from the location a launch configuration is being moved from, or
* <code>null</code>
* @param to the location a launch configuration is being moved to,
@@ -2364,7 +2384,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
}
}
-
+
persistPreferredLaunchDelegates();
clearAllLaunchConfigurations();
fStepFilterManager = null;
@@ -2373,7 +2393,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
/**
* Saves the listings of preferred launch delegates from all of the launch configuration types
- *
+ *
* @since 3.3
*/
public void persistPreferredLaunchDelegates() {
@@ -2384,31 +2404,26 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
/**
- * Persists the given launch configuration delegate.
+ * Persists the given launch configuration delegate.
* @param type Launch configuration type to persist
- *
+ *
* @since 3.6
*/
public void persistPreferredLaunchDelegate(LaunchConfigurationType type) {
String preferenceName = PREF_PREFERRED_DELEGATES + '/' + type.getIdentifier();
- Map preferred = type.getPreferredDelegates();
+ Map<Set<String>, ILaunchDelegate> preferred = type.getPreferredDelegates();
if(preferred != null && preferred.size() > 0) {
StringBuffer str = new StringBuffer();
- for(Iterator iter = preferred.keySet().iterator(); iter.hasNext();) {
- Set modes = (Set) iter.next();
- ILaunchDelegate delegate = (ILaunchDelegate) preferred.get(modes);
- if(delegate != null) {
+ for (Entry<Set<String>, ILaunchDelegate> entry : preferred.entrySet()) {
+ Set<String> modes = entry.getKey();
+ ILaunchDelegate delegate = entry.getValue();
+ if (delegate != null) {
str.append(delegate.getId());
str.append(',');
- for(Iterator iter2 = modes.iterator(); iter2.hasNext();) {
- str.append(iter2.next());
- if(iter2.hasNext()) {
- str.append(',');
- }
- }
- if (iter.hasNext()) {
- str.append(';');
+ for (String mode : modes) {
+ str.append(mode).append(',');
}
+ str.append(';');
}
}
Preferences.setString(DebugPlugin.getUniqueIdentifier(), preferenceName, str.toString(), null);
@@ -2439,7 +2454,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
catch(CoreException e) {DebugPlugin.log(e);}
}
-
+
/**
* Throws a debug exception with the given throwable that occurred
* while processing the given configuration.
@@ -2457,32 +2472,30 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
} catch (CoreException ce) {
}
- throw createDebugException(MessageFormat.format(DebugCoreMessages.LaunchManager__0__occurred_while_reading_launch_configuration_file__1___1, new String[]{e.toString(), uri}), e);
+ throw createDebugException(MessageFormat.format(DebugCoreMessages.LaunchManager__0__occurred_while_reading_launch_configuration_file__1___1, new Object[] {
+ e.toString(), uri }), e);
}
/**
* Verify basic integrity of launch configurations in the given list,
* adding valid configurations to the collection of all launch configurations.
* Exceptions are logged for invalid configurations.
- *
+ *
* @param verify the list of configurations to verify
* @param valid the list to place valid configurations in
*/
- protected void verifyConfigurations(List verify, List valid) {
- Iterator configs = verify.iterator();
- ILaunchConfiguration config = null;
- while (configs.hasNext()) {
- config = (ILaunchConfiguration)configs.next();
+ protected void verifyConfigurations(List<ILaunchConfiguration> verify, List<ILaunchConfiguration> valid) {
+ for (ILaunchConfiguration config : verify) {
if (!valid.contains(config) && isValid(config)) {
valid.add(config);
}
- }
+ }
}
-
+
/**
* Returns the name of the given launch mode with accelerators removed,
* or <code>null</code> if none.
- *
+ *
* @param id launch mode identifier
* @return launch mode name with accelerators removed or <code>null</code>
*/
@@ -2495,7 +2508,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
/**
* Returns the label with any accelerators removed.
- *
+ *
* @param label label to process
* @return label without accelerators
*/
@@ -2520,11 +2533,11 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
}
return title;
- }
-
+ }
+
/**
* Returns the singleton step filter manager.
- *
+ *
* @return the step filter manager
*/
public synchronized StepFilterManager getStepFilterManager() {
@@ -2532,8 +2545,8 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
fStepFilterManager = new StepFilterManager();
}
return fStepFilterManager;
- }
-
+ }
+
/**
* Imports launch configurations represented by the given local files, overwriting
* any existing configurations. Sends launch configuration change notification
@@ -2548,14 +2561,8 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
* @since 3.4.0
*/
public void importConfigurations(File[] files, IProgressMonitor monitor) throws CoreException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- Map sharedConfigs = new HashMap();
- List stati = null;
- Iterator iterator = getAllLaunchConfigurations().iterator();
- while (iterator.hasNext()) {
- ILaunchConfiguration config = (ILaunchConfiguration) iterator.next();
+ Map<String, ILaunchConfiguration> sharedConfigs = new HashMap<String, ILaunchConfiguration>();
+ for (ILaunchConfiguration config : getAllLaunchConfigurations()) {
if (!config.isLocal()) {
StringBuffer buf = new StringBuffer(config.getName());
buf.append('.');
@@ -2563,13 +2570,14 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
sharedConfigs.put(buf.toString(), config);
}
}
- monitor.beginTask(DebugCoreMessages.LaunchManager_29, files.length);
+ List<Status> stati = null;
+ SubMonitor lmonitor = SubMonitor.convert(monitor, DebugCoreMessages.LaunchManager_29, files.length);
for (int i = 0; i < files.length; i++) {
- if (monitor.isCanceled()) {
+ if (lmonitor.isCanceled()) {
break;
}
File source = files[i];
- monitor.subTask(MessageFormat.format(DebugCoreMessages.LaunchManager_28, new String[]{source.getName()}));
+ lmonitor.subTask(MessageFormat.format(DebugCoreMessages.LaunchManager_28, new Object[] { source.getName() }));
IPath location = new Path(LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH.toOSString()).append(source.getName());
File target = location.toFile();
IPath locationdir = location.removeLastSegments(1);
@@ -2580,7 +2588,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
try {
copyFile(source, target);
ILaunchConfiguration configuration = new LaunchConfiguration(LaunchConfiguration.getSimpleName(source.getName()), null);
- ILaunchConfiguration shared = (ILaunchConfiguration) sharedConfigs.get(target.getName());
+ ILaunchConfiguration shared = sharedConfigs.get(target.getName());
if (shared != null) {
setMovedFromTo(shared, configuration);
shared.delete();
@@ -2592,33 +2600,32 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
} catch (IOException e) {
if (stati == null) {
- stati = new ArrayList();
+ stati = new ArrayList<Status>();
}
stati.add(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.ERROR,
- MessageFormat.format(DebugCoreMessages.LaunchManager_27, new String[]{source.getPath()}), e));
+ MessageFormat.format(DebugCoreMessages.LaunchManager_27, new Object[] { source.getPath() }), e));
}
- monitor.worked(1);
+ lmonitor.worked(1);
}
- if (!monitor.isCanceled()) {
- monitor.done();
+ if (!lmonitor.isCanceled()) {
+ lmonitor.done();
}
if (stati != null) {
if (stati.size() > 1) {
MultiStatus multi = new MultiStatus(DebugPlugin.getUniqueIdentifier(), DebugPlugin.ERROR, DebugCoreMessages.LaunchManager_26, null);
- Iterator it = stati.iterator();
- while (it.hasNext()) {
- multi.add((IStatus) it.next());
+ for (Status status : stati) {
+ multi.add(status);
}
throw new CoreException(multi);
} else {
- throw new CoreException((IStatus) stati.get(0));
+ throw new CoreException(stati.get(0));
}
}
}
-
+
/**
* Copies a file from one location to another, replacing any existing file.
- *
+ *
* @param in the file to copy
* @param out the file to be copied out to
* @throws IOException if the file read fails
@@ -2634,11 +2641,11 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
fis.close();
fos.close();
- }
-
+ }
+
/**
* Returns whether any launch config supports the given mode.
- *
+ *
* @param mode launch mode
* @return whether any launch config supports the given mode
*/
@@ -2646,7 +2653,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
if (fActiveModes == null) {
ILaunchConfigurationType[] types = getLaunchConfigurationTypes();
ILaunchMode[] modes = getLaunchModes();
- fActiveModes = new HashSet(3);
+ fActiveModes = new HashSet<String>(3);
for (int i = 0; i < types.length; i++) {
for (int j = 0; j < modes.length; j++) {
if (types[i].supportsMode(modes[j].getIdentifier())) {
@@ -2661,6 +2668,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
/**
* @see org.eclipse.debug.core.ILaunchManager#generateLaunchConfigurationName(java.lang.String)
*/
+ @Override
public String generateLaunchConfigurationName(String namePrefix) {
String name = generateUniqueLaunchConfigurationNameFrom(namePrefix);
try {
@@ -2688,20 +2696,21 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
/**
* @see org.eclipse.debug.core.ILaunchManager#isValidLaunchConfigurationName(java.lang.String)
*/
+ @Override
public boolean isValidLaunchConfigurationName(String configname) throws IllegalArgumentException {
if(Platform.OS_WIN32.equals(Platform.getOS())) {
for(int i = 0; i < UNSUPPORTED_WIN32_CONFIG_NAMES.length; i++) {
if(configname.equals(UNSUPPORTED_WIN32_CONFIG_NAMES[i])) {
- throw new IllegalArgumentException(MessageFormat.format(DebugCoreMessages.LaunchManager_invalid_config_name, new String[] {configname}));
+ throw new IllegalArgumentException(MessageFormat.format(DebugCoreMessages.LaunchManager_invalid_config_name, new Object[] { configname }));
}
}
}
for (int i = 0; i < DISALLOWED_CONFIG_NAME_CHARS.length; i++) {
if (configname.indexOf(DISALLOWED_CONFIG_NAME_CHARS[i]) > -1) {
- throw new IllegalArgumentException(MessageFormat.format(DebugCoreMessages.LaunchManager_invalid_config_name_char, new String[] {String.valueOf(DISALLOWED_CONFIG_NAME_CHARS[i])}));
+ throw new IllegalArgumentException(MessageFormat.format(DebugCoreMessages.LaunchManager_invalid_config_name_char, new Object[] { String.valueOf(DISALLOWED_CONFIG_NAME_CHARS[i]) }));
}
}
return true;
- }
-
+ }
+
}

Back to the top