diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java index cb0eeef5e6f..c54d8f14632 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java @@ -6,14 +6,21 @@ package org.eclipse.cdt.debug.core; -import org.eclipse.cdt.debug.internal.core.CDebuggerManager; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import org.eclipse.cdt.debug.internal.core.DebugConfiguration; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IPluginDescriptor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.DebugPlugin; /** * The main plugin class to be used in the desktop. @@ -28,7 +35,7 @@ public class CDebugCorePlugin extends Plugin //The shared instance. private static CDebugCorePlugin plugin; - private CDebuggerManager debuggerManager; + private HashMap fDebugConfigurations; /** * The constructor. @@ -108,10 +115,29 @@ public class CDebugCorePlugin extends Plugin getDefault().getLog().log( status ); } - public ICDebuggerManager getDebuggerManager() { - if ( debuggerManager == null ) { - debuggerManager = new CDebuggerManager(); - } - return debuggerManager; + private void initializeDebugConfiguration() { + IPluginDescriptor descriptor= getDefault().getDescriptor(); + IExtensionPoint extensionPoint= descriptor.getExtensionPoint("CDebugger"); + IConfigurationElement[] infos= extensionPoint.getConfigurationElements(); + fDebugConfigurations = new HashMap(infos.length); + for (int i= 0; i < infos.length; i++) { + IConfigurationElement configurationElement = infos[i]; + DebugConfiguration configType = new DebugConfiguration(configurationElement); + fDebugConfigurations.put(configType.getID(), configType); + } + } + + public ICDebugConfiguration[] getDebugConfigurations() { + if (fDebugConfigurations == null) { + initializeDebugConfiguration(); + } + return (ICDebugConfiguration[]) fDebugConfigurations.values().toArray(new ICDebugConfiguration[0]); + } + + public ICDebugConfiguration getDebugConfiguration(String id) { + if (fDebugConfigurations == null) { + initializeDebugConfiguration(); + } + return (ICDebugConfiguration) fDebugConfigurations.get(id); } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDebugConfiguration.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDebugConfiguration.java new file mode 100644 index 00000000000..1c383eb772c --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDebugConfiguration.java @@ -0,0 +1,14 @@ +/* + * (c) Copyright QNX Software System Ltd. 2002. + * All Rights Reserved. + */ +package org.eclipse.cdt.debug.core; + +import org.eclipse.core.runtime.CoreException; + +public interface ICDebugConfiguration { + public ICDebugger getDebugger() throws CoreException; + public String getName(); + public String getID(); + public String[] getPlatforms(); +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDebuggerInfo.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDebuggerInfo.java deleted file mode 100644 index 3003e65dbaa..00000000000 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDebuggerInfo.java +++ /dev/null @@ -1,10 +0,0 @@ -/* - * (c) Copyright QNX Software System Ltd. 2002. - * All Rights Reserved. - */package org.eclipse.cdt.debug.core; - -public interface ICDebuggerInfo { - String getID(); - String getName(); - String[] getSupportedPlatforms(); -} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDebuggerManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDebuggerManager.java deleted file mode 100644 index c3da115b0aa..00000000000 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDebuggerManager.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * (c) Copyright QNX Software System Ltd. 2002. - * All Rights Reserved. - */ -package org.eclipse.cdt.debug.core; - -import org.eclipse.core.runtime.CoreException; - -public interface ICDebuggerManager { - public ICDebugger createDebugger(String id) throws CoreException; - public ICDebuggerInfo[] queryDebuggers(String platform_id); -} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebuggerManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebuggerManager.java deleted file mode 100644 index d4a49fb7d2a..00000000000 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebuggerManager.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * (c) Copyright QNX Software System Ltd. 2002. - * All Rights Reserved. - */ -package org.eclipse.cdt.debug.internal.core; - -import java.util.ArrayList; -import java.util.StringTokenizer; - -import org.eclipse.cdt.debug.core.CDebugCorePlugin; -import org.eclipse.cdt.debug.core.ICDebugger; -import org.eclipse.cdt.debug.core.ICDebuggerManager; -import org.eclipse.cdt.debug.core.ICDebuggerInfo; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; - -public class CDebuggerManager implements ICDebuggerManager { - - public CDebuggerManager() { - } - - public ICDebugger createDebugger(String id) throws CoreException { - ICDebugger debugger = null; - - IExtensionPoint extension = CDebugCorePlugin.getDefault().getDescriptor().getExtensionPoint("CDebugger"); - if (extension != null) { - IExtension[] extensions = extension.getExtensions(); - for(int i = 0; i < extensions.length; i++){ - if ( id.equals(extensions[i].getUniqueIdentifier()) ) { - IConfigurationElement [] configElements = extensions[i].getConfigurationElements(); - debugger = (ICDebugger)configElements[0].createExecutableExtension("class"); - } - } - } - return debugger; - } - - public ICDebuggerInfo[] queryDebuggers(String platform_id) { - IExtensionPoint extension = CDebugCorePlugin.getDefault().getDescriptor().getExtensionPoint("CDebugger"); - if (extension != null) { - IExtension[] extensions = extension.getExtensions(); - CDebuggerInfo dinfo; - ArrayList dlist = new ArrayList(extensions.length); - for(int i = 0; i < extensions.length; i++){ - IConfigurationElement [] configElements = extensions[i].getConfigurationElements(); - String platform = configElements[0].getAttribute("platform"); - if ( platform == null || platform.equals("*") || platform.indexOf(platform_id) != -1 ) { - dlist.add(dinfo = new CDebuggerInfo()); - dinfo.name = extensions[i].getLabel(); - dinfo.id = extensions[i].getUniqueIdentifier(); - dinfo.platforms = platform; - } - } - return (ICDebuggerInfo[]) dlist.toArray(new ICDebuggerInfo[dlist.size()]); - } - return new ICDebuggerInfo[0]; - } - - class CDebuggerInfo implements ICDebuggerInfo { - String id; - String name; - String platforms; - - public String getID() { - return id; - } - - public String getName() { - return name; - } - - public String[] getSupportedPlatforms() { - StringTokenizer stoken = new StringTokenizer(platforms, ","); - String[] platforms = new String[stoken.countTokens()]; - for( int i = 0; i < platforms.length; i++ ) { - platforms[i] = stoken.nextToken(); - } - return platforms; - } - } -} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DebugConfiguration.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DebugConfiguration.java new file mode 100644 index 00000000000..ab4698dc85f --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DebugConfiguration.java @@ -0,0 +1,56 @@ +/* + * (c) Copyright QNX Software System Ltd. 2002. + * All Rights Reserved. + */ +package org.eclipse.cdt.debug.internal.core; + +import java.util.StringTokenizer; + +import org.eclipse.cdt.debug.core.ICDebugConfiguration; +import org.eclipse.cdt.debug.core.ICDebugger; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; + +public class DebugConfiguration implements ICDebugConfiguration { + + /** + * The configuration element of the extension. + */ + private IConfigurationElement fElement; + + public DebugConfiguration(IConfigurationElement element) { + fElement = element; + } + + private IConfigurationElement getConfigurationElement() { + return fElement; + } + + public ICDebugger getDebugger() throws CoreException { + return (ICDebugger)getConfigurationElement().createExecutableExtension("class"); + } + + public String getName() { + return getConfigurationElement().getAttribute("name"); //$NON-NLS-1$ + } + + public String getID() { + return getConfigurationElement().getAttribute("id"); //$NON-NLS-1$ + } + + public String[] getPlatforms() { + String platform = getConfigurationElement().getAttribute("platform"); + if ( platform == null ) { + return new String[] {"*"}; + } + StringTokenizer stoken = new StringTokenizer(platform, ","); + String[] platforms = new String[stoken.countTokens()]; + for( int i = 0; i < platforms.length; i++ ) { + platforms[i] = stoken.nextToken(); + } + return platforms; + + + } + +}