From b83991daa5fef1969e38ca1d4273bc0b80387423 Mon Sep 17 00:00:00 2001 From: John Cortell Date: Fri, 11 Dec 2009 13:42:36 +0000 Subject: [PATCH] [273502] Allow third party launch configurations to participate in refactoring. --- launch/org.eclipse.cdt.launch/plugin.xml | 1 + .../schema/launchConfigAffinity.exsd | 107 ++++++++++++++++++ .../LaunchConfigAffinityExtensionPoint.java | 43 +++++++ .../ResourceRenameParticipant.java | 11 +- 4 files changed, 160 insertions(+), 2 deletions(-) create mode 100644 launch/org.eclipse.cdt.launch/schema/launchConfigAffinity.exsd create mode 100644 launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LaunchConfigAffinityExtensionPoint.java diff --git a/launch/org.eclipse.cdt.launch/plugin.xml b/launch/org.eclipse.cdt.launch/plugin.xml index cd7d9fde661..871c0094320 100644 --- a/launch/org.eclipse.cdt.launch/plugin.xml +++ b/launch/org.eclipse.cdt.launch/plugin.xml @@ -1,6 +1,7 @@ + diff --git a/launch/org.eclipse.cdt.launch/schema/launchConfigAffinity.exsd b/launch/org.eclipse.cdt.launch/schema/launchConfigAffinity.exsd new file mode 100644 index 00000000000..1cc9274219d --- /dev/null +++ b/launch/org.eclipse.cdt.launch/schema/launchConfigAffinity.exsd @@ -0,0 +1,107 @@ + + + + + + + + + CDT adopters can extend this extension point to declare that their launch configurations are CDT-ish. CDT features that manipulate CDT launch configurations in a generic enough way to make them equally applicable to third-party solutions will look at this extension point to see what additional configurations to operate on. + +Adopters that contribute launch configurations that are vastly different from the standard CDT ones should not declare an affinity, as it's unlikely CDT features would know what to do with them. + +One feature that uses this extension point (as a consumer) is CDT's support for adjusting a launch configuration when the user renames the project. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + launch configuration type ID + + + + + + + + + + + + 7.0 + + + + + + + + + <extension + point="org.eclipse.cdt.launch.launchConfigAffinity"> + <launchConfigTypeId id="com.acme.launchTypeAttach"/> + <launchConfigTypeId id="com.acme.launchTypeCreateProcess"/> +</extension> + + + + + + + + + There is no API associated with this extension point. + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LaunchConfigAffinityExtensionPoint.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LaunchConfigAffinityExtensionPoint.java new file mode 100644 index 00000000000..89872f4ceb3 --- /dev/null +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LaunchConfigAffinityExtensionPoint.java @@ -0,0 +1,43 @@ +package org.eclipse.cdt.launch.internal; + +import java.util.Collection; + +import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.Platform; + +/** + * Encapsulates logic to get the launchConfigAffinity extensions information. + * The extension point is very simple. Basically, it allows an extension to + * provide a collection of strings (launch configuration type IDs). + */ +public class LaunchConfigAffinityExtensionPoint { + + static private final String EXTENSION_POINT_NAME = "launchConfigAffinity"; //$NON-NLS-1$ + static private final String EXTENSION_ELEMENT_NAME = "launchConfigTypeId"; //$NON-NLS-1$ + static private final String EXTENSION_ELEMENT_ATTR = "id"; //$NON-NLS-1$ + + /** + * Returns all launch configuration type IDs registered via the extension + * point. + * + * @param ids + * Caller provides the collection. We just add to it. We do not + * clear it. Caller can provide any type of collection. + */ + static public > void getLaunchConfigTypeIds(T ids) { + IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(LaunchUIPlugin.PLUGIN_ID, EXTENSION_POINT_NAME).getExtensions(); + for (IExtension extension : extensions) { + IConfigurationElement[] elements = extension.getConfigurationElements(); + for (IConfigurationElement element : elements) { + if (element.getName().equals(EXTENSION_ELEMENT_NAME)) { + String id = element.getAttribute(EXTENSION_ELEMENT_ATTR); + if (id != null) { + ids.add(id); + } + } + } + } + } +} diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/refactoring/ResourceRenameParticipant.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/refactoring/ResourceRenameParticipant.java index 4451ec320d8..343c35e1ef3 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/refactoring/ResourceRenameParticipant.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/refactoring/ResourceRenameParticipant.java @@ -12,9 +12,11 @@ package org.eclipse.cdt.launch.internal.refactoring; import java.util.Collection; +import java.util.HashSet; import java.util.Set; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; +import org.eclipse.cdt.launch.internal.LaunchConfigAffinityExtensionPoint; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; @@ -111,10 +113,15 @@ public class ResourceRenameParticipant extends RenameParticipant implements static Collection getCLaunchConfigTypes() { Set result = new java.util.HashSet(); + // Get launch config types registered by CDT adopters + Set thirdPartyConfgTypeIds = new HashSet(5); + LaunchConfigAffinityExtensionPoint.getLaunchConfigTypeIds(thirdPartyConfgTypeIds); + ILaunchManager mgr = DebugPlugin.getDefault().getLaunchManager(); for (ILaunchConfigurationType next : mgr.getLaunchConfigurationTypes()) { - // is it a CDT launch type? - if (next.getPluginIdentifier().startsWith("org.eclipse.cdt.")) { //$NON-NLS-1$ + // is it a CDT launch type or a third party one that is CDT-ish? + if (next.getPluginIdentifier().startsWith("org.eclipse.cdt.") || //$NON-NLS-1$ + thirdPartyConfgTypeIds.contains(next.getIdentifier())) { result.add(next); } }