Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2002-03-13 14:38:07 +0000
committerDarin Wright2002-03-13 14:38:07 +0000
commiteba0509e6e86222b2e2255d08fe6fd44cad327a3 (patch)
tree040c8dc84e2b9685e945bc1efe57c638d1163eb5 /org.eclipse.debug.core/core
parentf498559c053c2f4ae7f9a1158ca2d354458b3b0d (diff)
downloadeclipse.platform.debug-eba0509e6e86222b2e2255d08fe6fd44cad327a3.tar.gz
eclipse.platform.debug-eba0509e6e86222b2e2255d08fe6fd44cad327a3.tar.xz
eclipse.platform.debug-eba0509e6e86222b2e2255d08fe6fd44cad327a3.zip
persistable source locators
Diffstat (limited to 'org.eclipse.debug.core/core')
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java8
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java28
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java14
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/model/IPersistableSourceLocator.java84
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java24
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java50
6 files changed, 207 insertions, 1 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java
index 039d17842..fa6c65a53 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java
@@ -80,7 +80,13 @@ public class DebugPlugin extends Plugin {
* (value <code>"statusHandlers"</code>).
*/
public static final String EXTENSION_POINT_STATUS_HANDLERS= "statusHandlers"; //$NON-NLS-1$
-
+
+ /**
+ * Source locator extension point identifier
+ * (value <code>"sourceLocators"</code>).
+ */
+ public static final String EXTENSION_POINT_SOURCE_LOCATORS= "sourceLocators"; //$NON-NLS-1$
+
/**
* Status code indicating an unexpected internal error.
*/
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java
index cde4df66f..fcb457985 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java
@@ -13,6 +13,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.model.IPersistableSourceLocator;
/**
* Note: This interface is yet experimental.
@@ -63,9 +64,36 @@ public interface ILaunchConfiguration extends IAdaptable {
public static final String LAUNCH_CONFIGURATION_FILE_EXTENSION = "launch"; //$NON-NLS-1$
/**
+ * Launch configuration attribute storing an identifier of
+ * a persistable source locator extension. When this attribute is
+ * specified, a new source locator will automatically be created and
+ * associted with the launch for this configuration.
+ *
+ * @see IPersistableSourceLocator
+ */
+ public static final String ATTR_SOURCE_LOCATOR_ID = DebugPlugin.PLUGIN_ID + ".source_locator_id"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute storing a memento of a
+ * source locator. When this attribute is specified in
+ * conjunction with a source locator id, the soure locator
+ * created for a launch will be initialized with this memento.
+ * When not specified, but a source locator id is specified,
+ * the source locator will be intialized to default values.
+ *
+ * @see IPersistableSourceLocator
+ */
+ public static final String ATTR_SOURCE_LOCATOR_MEMENTO = DebugPlugin.PLUGIN_ID + ".source_locator_memento"; //$NON-NLS-1$
+
+ /**
* Launches this configuration in the specified mode by delegating to
* this configuration's launch configuration delegate, and returns the
* resulting launch object that describes the launched configuration.
+ * An appropriate source locator is created and associated with the
+ * resulting launch based on the values of <code>ATTR_SOURCE_LOCAOTOR_ID</code>
+ * and <code>ATTR_SOURCE_LOCATOR_MEMENTO</code>. If the launch returned
+ * from by the delegate already specifies a source locator, that
+ * source locator is used.
* The resulting launch object is registered with the launch manager.
* Returns <code>null</code> if the launch is not completed.
* This causes the underlying launch configuration delegate
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java
index 47225a8bd..259a207b3 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java
@@ -6,6 +6,7 @@ package org.eclipse.debug.core;
*/
import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IPersistableSourceLocator;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -346,6 +347,19 @@ public interface ILaunchManager {
* @since 2.0
*/
public ILaunchConfiguration getDefaultLaunchConfiguration(IResource resource, String configTypeID) throws CoreException;
+
+ /**
+ * Creates and returns a new source locator of the specified
+ * type.
+ *
+ * @param identifier the identifier associated with a
+ * persistable source locator extension
+ * @return a source locator
+ * @exception CoreException if an exception occurrs creating
+ * the source locator
+ * @since 2.0
+ */
+ public IPersistableSourceLocator newSourceLocator(String identifier) throws CoreException;
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/IPersistableSourceLocator.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/IPersistableSourceLocator.java
new file mode 100644
index 000000000..e8c9399b0
--- /dev/null
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/IPersistableSourceLocator.java
@@ -0,0 +1,84 @@
+package org.eclipse.debug.core.model;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+
+/**
+ * A source locator that can be persisted and restored,
+ * to be used with a specfic launch configuration.
+ * The debug plug-in defines source locator extension
+ * point for persistable source locators.
+ * <p>
+ * A source locator extension is defined in <code>plugin.xml</code>.
+ * Following is an example definition of a source locator extension.
+ * <pre>
+ * &lt;extension point="org.eclipse.debug.core.sourceLocators"&gt;
+ * &lt;sourceLocator
+ * id="com.example.ExampleIdentifier"
+ * class="com.example.ExampleSourceLocator"
+ * name="Example Source Locator"
+ * &lt;/sourceLocator&gt;
+ * &lt;/extension&gt;
+ * </pre>
+ * The attributes are specified as follows:
+ * <ul>
+ * <li><code>id</code> specifies a unique identifier for this source locator.</li>
+ * <li><code>class</code> specifies the fully qualified name of the Java class
+ * that implements <code>IPersistableSourceLocator</code>.</li>
+ * <li><code>name</code> a human readable name, describing the type of
+ * this source locator.</li>
+ * </ul>
+ * </p>
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ * <p>
+ * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to
+ * change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+ * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+ * (repeatedly) as the API evolves.
+ * </p>
+ * @see org.eclipse.debug.core.ILaunch
+ * @see IStackFrame
+ * @see org.eclipse.debug.ui.IDebugModelPresentation
+ * @since 2.0
+ */
+public interface IPersistableSourceLocator extends ISourceLocator {
+
+ /**
+ * Returns a memento that can be used to reconstruct
+ * this source locator
+ *
+ * @return a memento that can be used to reconstruct
+ * this source locator
+ * @exception CoreException if unable to construct a memento
+ */
+ public String getMemento() throws CoreException;
+
+ /**
+ * Initializes this source locator based on the given
+ * memento.
+ *
+ * @param memento a memento to initialize this source locator
+ * @exception CoreException on failure to initialize
+ */
+ public void initiatlizeFromMemento(String memento) throws CoreException;
+
+ /**
+ * Initializes this source locator to perform default
+ * source lookup for the given launch configuration.
+ *
+ * @param configuration launch configuration this source locator
+ * will be performing souce lookup for
+ * @exception CoreException on failure to initialize
+ */
+ public void initializeDefaults(ILaunchConfiguration configuration) throws CoreException;
+
+}
+
+
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java
index 3a9a6e474..f0c118eb4 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java
@@ -24,6 +24,7 @@ import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
+import org.eclipse.debug.core.model.IPersistableSourceLocator;
/**
* Launch configuration handle.
@@ -56,8 +57,31 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
if (launch != null) {
getLaunchManager().addLaunch(launch);
}
+ initializeSourceLocator(launch);
return launch;
}
+
+ /**
+ * Set the source locator to use with the launch, if specified
+ * by this configuration.
+ *
+ * @param launch the launch on which to set the source locator
+ */
+ protected void initializeSourceLocator(ILaunch launch) throws CoreException {
+ if (launch.getSourceLocator() == null) {
+ String type = getAttribute(ATTR_SOURCE_LOCATOR_ID, (String)null);
+ if (type != null) {
+ IPersistableSourceLocator locator = getLaunchManager().newSourceLocator(type);
+ String memento = getAttribute(ATTR_SOURCE_LOCATOR_MEMENTO, (String)null);
+ if (memento == null) {
+ locator.initializeDefaults(this);
+ } else {
+ locator.initiatlizeFromMemento(memento);
+ }
+ launch.setSourceLocator(locator);
+ }
+ }
+ }
/**
* @see ILaunchConfiguration#supportsMode(String)
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 305d3312b..0854a8369 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
@@ -20,6 +20,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Vector;
import javax.xml.parsers.DocumentBuilder;
@@ -45,6 +46,7 @@ import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IPluginDescriptor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.QualifiedName;
@@ -60,6 +62,7 @@ import org.eclipse.debug.core.ILaunchListener;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.ILauncher;
import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IPersistableSourceLocator;
import org.eclipse.debug.core.model.IProcess;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -160,6 +163,13 @@ public class LaunchManager implements ILaunchManager, IResourceChangeListener {
private ListenerList fLaunchConfigurationListeners = new ListenerList(5);
/**
+ * Table of source locator extensions. Keys
+ * are identifiers, and values are associated
+ * configuration elements.
+ */
+ private Map fSourceLocators = new HashMap(10);
+
+ /**
* Path to the local directory where local launch configurations
* are stored with the workspace.
*/
@@ -553,6 +563,8 @@ public class LaunchManager implements ILaunchManager, IResourceChangeListener {
DebugPlugin.log(e.getStatus());
}
}
+
+ initializeSourceLocators();
}
/**
@@ -1510,4 +1522,42 @@ public class LaunchManager implements ILaunchManager, IResourceChangeListener {
fLaunchConfigurationListeners.remove(listener);
}
+ /**
+ * Register source locators.
+ *
+ * @exception CoreException if an exception occurrs reading
+ * the extensions
+ */
+ private void initializeSourceLocators() throws CoreException {
+ IPluginDescriptor descriptor= DebugPlugin.getDefault().getDescriptor();
+ IExtensionPoint extensionPoint= descriptor.getExtensionPoint(DebugPlugin.EXTENSION_POINT_SOURCE_LOCATORS);
+ IConfigurationElement[] infos= extensionPoint.getConfigurationElements();
+ for (int i= 0; i < infos.length; i++) {
+ IConfigurationElement configurationElement = infos[i];
+ String id = configurationElement.getAttribute("id"); //$NON-NLS-1$
+ if (id != null) {
+ fSourceLocators.put(id,configurationElement);
+ } else {
+ // invalid status handler
+ IStatus s = new Status(IStatus.ERROR, DebugPlugin.PLUGIN_ID, DebugException.INTERNAL_ERROR,
+ MessageFormat.format("Invalid source locator extentsion defined by plug-in '{0}': 'id' not specified.", new String[] {configurationElement.getDeclaringExtension().getDeclaringPluginDescriptor().getUniqueIdentifier()} ), null);
+ DebugPlugin.getDefault().log(s);
+ }
+ }
+ }
+
+ /**
+ * @see ILaunchManager#newSourceLocator(String)
+ */
+ public IPersistableSourceLocator newSourceLocator(String identifier) throws CoreException {
+ IConfigurationElement config = (IConfigurationElement)fSourceLocators.get(identifier);
+ if (config == null) {
+ throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.PLUGIN_ID, DebugException.INTERNAL_ERROR,
+ MessageFormat.format("Source locator does not exist: {0}", new String[] {identifier} ), null));
+ } else {
+ return (IPersistableSourceLocator)config.createExecutableExtension("class");
+ }
+
+ }
+
}

Back to the top