Refactoring of scripting infrastructure
diff --git a/org.eclipse.ltk.core.refactoring/buildnotes_ltk-core-refactoring.html b/org.eclipse.ltk.core.refactoring/buildnotes_ltk-core-refactoring.html
index b5121b3..6db48e6 100644
--- a/org.eclipse.ltk.core.refactoring/buildnotes_ltk-core-refactoring.html
+++ b/org.eclipse.ltk.core.refactoring/buildnotes_ltk-core-refactoring.html
@@ -24,8 +24,8 @@
<h4>Implementation Changes</h4>
The refactoring framework has been extended by scripting facilities. Refactorings which support scripting can now be exported
from the refactoring history and saved in a refactoring script. These scripts can then be reapplied on a remote workspace.<p>
-There is a new extension point <code>org.eclipse.ltk.core.refactoring.refactoringCreators</code> which allows refactoring implementors
-to contribute a refactoring instance creator, in order to make their refactorings scriptable. Refactorings contributed
+There is a new extension point <code>org.eclipse.ltk.core.refactoring.refactoringContributions</code> which allows refactoring implementors
+to contribute a refactoring contribution, in order to make their refactorings scriptable. Refactorings contributed
by this extension point appear in the platform refactoring history and are exportable in refactoring scripts.<p>
Please consult the documentation of the extension point for further information.
<h3>3.2 M4, December 7, 2005</h3>
diff --git a/org.eclipse.ltk.core.refactoring/plugin.properties b/org.eclipse.ltk.core.refactoring/plugin.properties
index 2a7c381..1255250 100644
--- a/org.eclipse.ltk.core.refactoring/plugin.properties
+++ b/org.eclipse.ltk.core.refactoring/plugin.properties
@@ -16,7 +16,7 @@
deleteParticipantsExtensionPoint= Delete Participants
moveParticipantsExtensionPoint= Move Participants
copyParticipantsExtensionPoint= Copy Participants
-refactoringCreatorsExtensionPoint= Refactoring Creators
+refactoringContributionsExtensionPoint= Refactoring Contributions
RefactoringHistoryContent.name= Refactoring History Index
RefactoringIndexContent.name= Refactoring History File
\ No newline at end of file
diff --git a/org.eclipse.ltk.core.refactoring/plugin.xml b/org.eclipse.ltk.core.refactoring/plugin.xml
index 48832e8..7ff5dbf 100644
--- a/org.eclipse.ltk.core.refactoring/plugin.xml
+++ b/org.eclipse.ltk.core.refactoring/plugin.xml
@@ -6,7 +6,7 @@
<extension-point id="createParticipants" name="%createParticipantsExtensionPoint" schema="schema/createParticipants.exsd"/>
<extension-point id="deleteParticipants" name="%deleteParticipantsExtensionPoint" schema="schema/deleteParticipants.exsd"/>
<extension-point id="copyParticipants" name="%copyParticipantsExtensionPoint" schema="schema/copyParticipants.exsd"/>
- <extension-point id="refactoringCreators" name="%refactoringCreatorsExtensionPoint" schema="schema/refactoringCreators.exsd"/>
+ <extension-point id="refactoringContributions" name="%refactoringContributionsExtensionPoint" schema="schema/refactoringContributions.exsd"/>
<extension
point="org.eclipse.team.core.fileTypes">
<fileTypes
diff --git a/org.eclipse.ltk.core.refactoring/schema/refactoringCreators.exsd b/org.eclipse.ltk.core.refactoring/schema/refactoringContributions.exsd
similarity index 70%
rename from org.eclipse.ltk.core.refactoring/schema/refactoringCreators.exsd
rename to org.eclipse.ltk.core.refactoring/schema/refactoringContributions.exsd
index c5680f7..2734a3c 100644
--- a/org.eclipse.ltk.core.refactoring/schema/refactoringCreators.exsd
+++ b/org.eclipse.ltk.core.refactoring/schema/refactoringContributions.exsd
@@ -3,17 +3,17 @@
<schema targetNamespace="org.eclipse.ltk.core.refactoring">
<annotation>
<appInfo>
- <meta.schema plugin="org.eclipse.ltk.core.refactoring" id="refactoringCreators" name="Refactoring Creators"/>
+ <meta.schema plugin="org.eclipse.ltk.core.refactoring" id="refactoringContributions" name="Refactoring Contributions"/>
</appInfo>
<documentation>
- The extension point is used to define refactoring instance creators. Refactoring instance creators provide a means to dynamically construct a ready-to-execute refactoring instance based on a <code>RefactoringDescriptor</code>.
+ The extension point is used to define refactoring contributions. Refactoring contributions provide a means to dynamically construct a ready-to-execute refactoring instance based on a <code>RefactoringDescriptor</code>.
</documentation>
</annotation>
<element name="extension">
<complexType>
<sequence>
- <element ref="creator" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="contribution" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
@@ -39,7 +39,7 @@
</complexType>
</element>
- <element name="creator">
+ <element name="contribution">
<complexType>
<attribute name="id" type="string" use="required">
<annotation>
@@ -51,10 +51,10 @@
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
- The fully qualified name of a refactoring instance creator implementation which implements <code>org.eclipse.ltk.core.refactoring.IRefactoringInstanceCreator</code>.
+ The fully qualified name of a refactoring contribution implementation which implements <code>org.eclipse.ltk.core.refactoring.IRefactoringContribution</code>.
</documentation>
<appInfo>
- <meta.attribute kind="java" basedOn="org.eclipse.ltk.core.refactoring.IRefactoringInstanceCreator"/>
+ <meta.attribute kind="java" basedOn="org.eclipse.ltk.core.refactoring.IRefactoringContribution"/>
</appInfo>
</annotation>
</attribute>
@@ -75,13 +75,13 @@
<meta.section type="examples"/>
</appInfo>
<documentation>
- The example below defines a refactoring instance creator implemented by class <code>RenameResourceRefactoringInstanceCreator</code> for the rename resource refactoring with unique id <code>org.eclipse.ltk.core.rename.resource</code>:
+ The example below defines a refactoring contribution implemented by class <code>RenameResourceRefactoringContribution</code> for the rename resource refactoring with unique id <code>org.eclipse.ltk.core.rename.resource</code>:
<pre>
<extension
- point="org.eclipse.ltk.core.refactoring.refactoringCreators">
- <creator
- class="org.eclipse.ltk.core.refactoring.scripting.RenameResourceRefactoringInstanceCreator"
+ point="org.eclipse.ltk.core.refactoring.refactoringContributions">
+ <contribution
+ class="org.eclipse.ltk.core.refactoring.RenameResourceRefactoringContribution"
id="org.eclipse.ltk.core.rename.resource"/>
</extension>
</pre>
@@ -93,7 +93,7 @@
<meta.section type="apiInfo"/>
</appInfo>
<documentation>
- The contributed class must implement <code>org.eclipse.ltk.core.refactoring.IRefactoringInstanceCreator</code>
+ The contributed class must implement <code>org.eclipse.ltk.core.refactoring.IRefactoringContribution</code>
</documentation>
</annotation>
@@ -102,7 +102,7 @@
<meta.section type="implementation"/>
</appInfo>
<documentation>
- This plugin offers a partial implementation <code>RefactoringInstanceCreator</code> of the interface <code>IRefactoringInstanceCreator</code>, which converts arguments from refactoring descriptors to generic refactoring arguments (class <code>GenericRefactoringArguments</code>).
+
</documentation>
</annotation>
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/IRefactoringContribution.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/IRefactoringContribution.java
new file mode 100644
index 0000000..ca905b9
--- /dev/null
+++ b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/IRefactoringContribution.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * 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
+ *******************************************************************************/
+package org.eclipse.ltk.core.refactoring;
+
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.ltk.core.refactoring.participants.RefactoringArguments;
+
+/**
+ * Interface for refactoring contribution objects which are capable of creating
+ * a specific refactoring instance and associated refactoring descriptors or
+ * arguments. Refactoring contributions are stateless objects. They are
+ * instantiated on demand by the refactoring framework. It is not guaranteed
+ * that the same refactoring contribution object will be used to create the
+ * arguments for a refactoring and to create the refactoring itself.
+ * <p>
+ * Note: this interface is intended to be implemented by clients.
+ * </p>
+ * <p>
+ * Note: This API is considered experimental and may change in the near future.
+ * </p>
+ *
+ * @since 3.2
+ */
+public interface IRefactoringContribution {
+
+ /**
+ * Creates the a refactoring arguments for the specified refactoring
+ * descriptor.
+ * <p>
+ * This method is used by the refactoring framework to create refactoring
+ * arguments for the refactoring instance represented by the specified
+ * descriptor. The result of this method is used as argument to initialize a
+ * refactoring using
+ * {@link IInitializableRefactoringComponent#initialize(RefactoringArguments)}.
+ * </p>
+ *
+ * @param descriptor
+ * the refactoring descriptor
+ * @return the refactoring arguments, or <code>null</code>
+ */
+ public RefactoringArguments createArguments(RefactoringDescriptor descriptor);
+
+ /**
+ * Creates a new refactoring descriptor for the specified input data.
+ * <p>
+ * This method is used by the refactoring framework to create a
+ * language-specific refactoring descriptor representing the refactoring
+ * instance corresponding to the input arguments.
+ * </p>
+ *
+ * @param id
+ * the unique id of the refactoring
+ * @param project
+ * the non-empty name of the project associated with this
+ * refactoring, or <code>null</code>
+ * @param description
+ * a non-empty human-readable description of the particular
+ * refactoring instance
+ * @param comment
+ * the comment associated with the refactoring, or
+ * <code>null</code> for no commment
+ * @param arguments
+ * the argument map (element type: <String, String>). The
+ * keys of the arguments are required to be non-empty strings
+ * which must not contain spaces. The values must be non-empty
+ * strings
+ * @param flags
+ * the flags of the refactoring descriptor
+ * @return the refactoring descriptor, or <code>null</code>
+ */
+ public RefactoringDescriptor createDescriptor(String id, String project, String description, String comment, Map arguments, int flags);
+
+ /**
+ * Creates the a refactoring instance for the specified refactoring
+ * descriptor.
+ * <p>
+ * This method is used by the refactoring framework to instantiate a
+ * refactoring from a refactoring descriptor, in order to apply it later on
+ * a local or remote workspace.
+ * </p>
+ *
+ * @param descriptor
+ * the refactoring descriptor
+ * @return the refactoring, or <code>null</code>
+ * @throws CoreException
+ * if the refactoring could not be created from the descriptor
+ */
+ public Refactoring createRefactoring(RefactoringDescriptor descriptor) throws CoreException;
+
+ /**
+ * Returns the argument map of the specified refactoring descriptor.
+ * <p>
+ * This method is used by the refactoring framework to obtain
+ * refactoring-specific arguments provided by the refactoring descriptor.
+ * </p>
+ *
+ * @param descriptor
+ * the refactoring descriptor
+ * @return the argument map of the specified refactoring descriptor
+ *
+ * @see #createDescriptor(String, String, String, String, Map, int)
+ */
+ public Map getArguments(RefactoringDescriptor descriptor);
+}
\ No newline at end of file
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/IRefactoringContributionManager.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/IRefactoringContributionManager.java
new file mode 100644
index 0000000..5990a7c
--- /dev/null
+++ b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/IRefactoringContributionManager.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * 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
+ *******************************************************************************/
+package org.eclipse.ltk.core.refactoring;
+
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.ltk.core.refactoring.participants.RefactoringArguments;
+
+/**
+ * Interface for refactoring contribution objects which are capable of creating
+ * a specific refactoring instance and associated refactoring descriptors or
+ * arguments. Refactoring contributions are stateless objects. They are
+ * instantiated on demand by the refactoring framework. It is not guaranteed
+ * that the same refactoring contribution object will be used to create the
+ * arguments for a refactoring and to create the refactoring itself.
+ * <p>
+ * Note: this interface is intended to be implemented by clients.
+ * </p>
+ * <p>
+ * Note: This API is considered experimental and may change in the near future.
+ * </p>
+ *
+ * @since 3.2
+ */
+public interface IRefactoringContributionManager {
+
+ /**
+ * Creates the a refactoring arguments for the specified refactoring
+ * descriptor.
+ * <p>
+ * This method is used by the refactoring framework to create refactoring
+ * arguments for the refactoring instance represented by the specified
+ * descriptor. The result of this method is used as argument to initialize a
+ * refactoring using
+ * {@link IInitializableRefactoringComponent#initialize(RefactoringArguments)}.
+ * </p>
+ *
+ * @param descriptor
+ * the refactoring descriptor
+ * @return the refactoring arguments, or <code>null</code>
+ */
+ public RefactoringArguments createArguments(RefactoringDescriptor descriptor);
+
+ /**
+ * Creates a new refactoring descriptor for the specified input data.
+ * <p>
+ * This method is used by the refactoring framework to create a
+ * language-specific refactoring descriptor representing the refactoring
+ * instance corresponding to the input arguments.
+ * </p>
+ *
+ * @param id
+ * the unique id of the refactoring
+ * @param project
+ * the non-empty name of the project associated with this
+ * refactoring, or <code>null</code>
+ * @param description
+ * a non-empty human-readable description of the particular
+ * refactoring instance
+ * @param comment
+ * the comment associated with the refactoring, or
+ * <code>null</code> for no commment
+ * @param arguments
+ * the argument map (element type: <String, String>). The
+ * keys of the arguments are required to be non-empty strings
+ * which must not contain spaces. The values must be non-empty
+ * strings
+ * @param flags
+ * the flags of the refactoring descriptor
+ * @return the refactoring descriptor, or <code>null</code>
+ */
+ public RefactoringDescriptor createDescriptor(String id, String project, String description, String comment, Map arguments, int flags);
+
+ /**
+ * Creates the a refactoring instance for the specified refactoring
+ * descriptor.
+ * <p>
+ * This method is used by the refactoring framework to instantiate a
+ * refactoring from a refactoring descriptor, in order to apply it later on
+ * a local or remote workspace.
+ * </p>
+ *
+ * @param descriptor
+ * the refactoring descriptor
+ * @return the refactoring, or <code>null</code>
+ * @throws CoreException
+ * if the refactoring could not be created from the descriptor
+ */
+ public Refactoring createRefactoring(RefactoringDescriptor descriptor) throws CoreException;
+
+ /**
+ * Returns the refactoring contribution for the refactoring with the
+ * specified id.
+ *
+ * @param id
+ * the unique id of the refactoring
+ * @return the refactoring contribution, or <code>null</code>
+ */
+ public IRefactoringContribution getRefactoringContribution(String id);
+}
\ No newline at end of file
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/IRefactoringInstanceCreator.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/IRefactoringInstanceCreator.java
deleted file mode 100644
index 3c789fc..0000000
--- a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/IRefactoringInstanceCreator.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * 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
- *******************************************************************************/
-package org.eclipse.ltk.core.refactoring;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.ltk.core.refactoring.participants.RefactoringArguments;
-
-/**
- * Interface for objects which are capable of creating a specific refactoring
- * instance. Refactoring instance creators are stateless objects. They are
- * instantiated on demand by the refactoring framework. It is not guaranteed
- * that the same refactoring instance creator object will be used to create the
- * arguments for a refactoring and to create the refactoring itself.
- * <p>
- * Note: this interface is not intended to be implemented by clients.
- * </p>
- * <p>
- * Note: This API is considered experimental and may change in the near future.
- * </p>
- *
- * @since 3.2
- */
-public interface IRefactoringInstanceCreator {
-
- /**
- * Creates the a refactoring arguments for the specified refactoring
- * descriptor.
- *
- * @param descriptor
- * the refactoring descriptor
- * @return the refactoring arguments, or <code>null</code>
- */
- public RefactoringArguments createArguments(RefactoringDescriptor descriptor);
-
- /**
- * Creates the a refactoring instance for the specified refactoring
- * descriptor.
- *
- * @param descriptor
- * the refactoring descriptor
- * @return the refactoring, or <code>null</code>
- * @throws CoreException
- * if the refactoring could not be created from the descriptor
- */
- public Refactoring createRefactoring(RefactoringDescriptor descriptor) throws CoreException;
-}
\ No newline at end of file
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/PerformRefactoringHistoryOperation.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/PerformRefactoringHistoryOperation.java
index 0c05707..aced1f3 100644
--- a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/PerformRefactoringHistoryOperation.java
+++ b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/PerformRefactoringHistoryOperation.java
@@ -26,7 +26,7 @@
import org.eclipse.ltk.internal.core.refactoring.Messages;
import org.eclipse.ltk.internal.core.refactoring.RefactoringCoreMessages;
import org.eclipse.ltk.internal.core.refactoring.history.RefactoringHistoryService;
-import org.eclipse.ltk.internal.core.refactoring.history.RefactoringInstanceFactory;
+import org.eclipse.ltk.internal.core.refactoring.history.RefactoringContributionManager;
/**
* Operation that, when run, executes a series of refactoring sequentially.
@@ -87,7 +87,7 @@
final RefactoringStatus status= new RefactoringStatus();
if (refactoring instanceof IInitializableRefactoringComponent) {
final IInitializableRefactoringComponent component= (IInitializableRefactoringComponent) refactoring;
- final RefactoringArguments arguments= RefactoringInstanceFactory.getInstance().createArguments(descriptor);
+ final RefactoringArguments arguments= RefactoringContributionManager.getInstance().createArguments(descriptor);
if (arguments != null)
status.merge(component.initialize(arguments));
else
@@ -126,14 +126,14 @@
fExecutionStatus= new RefactoringStatus();
final RefactoringDescriptorProxy[] proxies= fRefactoringHistory.getDescriptors();
monitor.beginTask(RefactoringCoreMessages.PerformRefactoringHistoryOperation_perform_refactorings, 160 * proxies.length);
- final RefactoringInstanceFactory factory= RefactoringInstanceFactory.getInstance();
+ final RefactoringContributionManager manager= RefactoringContributionManager.getInstance();
final IRefactoringHistoryService service= RefactoringCore.getRefactoringHistoryService();
try {
service.connect();
for (int index= 0; index < proxies.length && !fExecutionStatus.hasFatalError(); index++) {
final RefactoringDescriptor descriptor= proxies[index].requestDescriptor(new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
if (descriptor != null && !descriptor.isUnknown()) {
- final Refactoring refactoring= factory.createRefactoring(descriptor);
+ final Refactoring refactoring= manager.createRefactoring(descriptor);
if (refactoring != null) {
final PerformRefactoringOperation operation= new PerformRefactoringOperation(refactoring, CheckConditionsOperation.ALL_CONDITIONS);
try {
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/RefactoringCore.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/RefactoringCore.java
index 1e153ab..cf6a263 100644
--- a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/RefactoringCore.java
+++ b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/RefactoringCore.java
@@ -16,8 +16,8 @@
import org.eclipse.ltk.internal.core.refactoring.RefactoringCorePlugin;
import org.eclipse.ltk.internal.core.refactoring.RefactoringCorePreferences;
+import org.eclipse.ltk.internal.core.refactoring.history.RefactoringContributionManager;
import org.eclipse.ltk.internal.core.refactoring.history.RefactoringHistoryService;
-import org.eclipse.ltk.internal.core.refactoring.history.RefactoringInstanceFactory;
/**
* Central access point to access resources managed by the refactoring
@@ -84,18 +84,18 @@
}
/**
- * Returns the singleton refactoring instance creator.
+ * Returns the singleton refactoring contribution manager.
* <p>
* Note: This API is considered experimental and may change in the near
* future.
* </p>
*
- * @return the refactoring instance creator
+ * @return the refactoring contribution manager
*
* @since 3.2
*/
- public static IRefactoringInstanceCreator getRefactoringInstanceCreator() {
- return RefactoringInstanceFactory.getInstance();
+ public static IRefactoringContributionManager getRefactoringContributionManager() {
+ return RefactoringContributionManager.getInstance();
}
/**
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/RefactoringDescriptor.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/RefactoringDescriptor.java
index e3551ae..b082573 100644
--- a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/RefactoringDescriptor.java
+++ b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/RefactoringDescriptor.java
@@ -10,10 +10,6 @@
*******************************************************************************/
package org.eclipse.ltk.core.refactoring;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
import org.eclipse.core.runtime.Assert;
import org.eclipse.ltk.core.refactoring.history.IRefactoringHistoryService;
@@ -38,13 +34,8 @@
* refactoring instance and pass appropriate descriptor flags to the
* constructor. In particular, if a refactoring descriptor represents a
* refactoring which renames a project resource, the descriptor should have the
- * flag {@link #PROJECT_CHANGE} set and a valid argument {@link #NAME}. The
- * arguments {@link #INPUT} or {@link #ELEMENT} are reserved to specify the
- * input arguments of a particular refactoring. The format of the values of
- * these arguments is langugage-dependent, but should be standardized for a
- * particular programming language. These arguments may be preprocessed by
- * language-specific tools such as wizards to import refactoring information
- * into the local workspace.
+ * flag {@link #PROJECT_CHANGE} set and return a non-null new name for the
+ * project being renamed.
* </p>
* <p>
* All time stamps are measured in UTC milliseconds from the epoch (see
@@ -63,7 +54,7 @@
*
* @since 3.2
*/
-public class RefactoringDescriptor implements Comparable {
+public abstract class RefactoringDescriptor implements Comparable {
/**
* Constant describing the API change flag (value: 1)
@@ -77,35 +68,6 @@
public static final int BREAKING_CHANGE= 1 << 0;
/**
- * Predefined argument called <code>element<Number></code>.
- * <p>
- * This argument should be used to describe the elements being refactored.
- * The value of this argument does not necessarily have to uniquely identify
- * the elements. However, it must be possible to uniquely identify the
- * elements using the value of this argument in conjunction with the values
- * of the other user-defined attributes.
- * </p>
- * <p>
- * The element arguments are simply distinguished by appending a number to
- * the argument name, eg. element1. The indices of this argument are non
- * zero-based.
- * </p>
- */
- public static final String ELEMENT= "element"; //$NON-NLS-1$
-
- /**
- * Predefined argument called <code>input</code>.
- * <p>
- * This argument should be used to describe the element being refactored.
- * The value of this argument does not necessarily have to uniquely identify
- * the input element. However, it must be possible to uniquely identify the
- * input element using the value of this argument in conjunction with the
- * values of the other user-defined attributes.
- * </p>
- */
- public static final String INPUT= "input"; //$NON-NLS-1$
-
- /**
* Constant describing the multi change flag (value: 4)
* <p>
* Clients should set this flag to indicate that the change created by the
@@ -116,16 +78,6 @@
*/
public static final int MULTI_CHANGE= 1 << 2;
- /**
- * Predefined argument called <code>name</code>.
- * <p>
- * This argument should be used to describe the name of the element being
- * refactored. The value of this argument may be displayed in the user
- * interface.
- * </p>
- */
- public static final String NAME= "name"; //$NON-NLS-1$
-
/** Constant describing the absence of any flags (value: 0) */
public static final int NONE= 0;
@@ -135,8 +87,8 @@
* Clients should set this flag to indicate that the represented refactoring
* renames a project resource in the workspace. If this flag is set for a
* particular descriptor, the refactoring history service assumes that the
- * argument {@link #NAME} of the refactoring descriptor denotes the new name
- * of the project being renamed.
+ * method {@link #getNewName()} denotes the non-empty new name of the
+ * project being refactored.
* </p>
*/
public static final int PROJECT_CHANGE= 1 << 3;
@@ -161,9 +113,6 @@
*/
public static final int USER_CHANGE= 1 << 8;
- /** The map of arguments (element type: <String, String>) */
- private final Map fArguments;
-
/** The comment associated with this refactoring, or <code>null</code> */
private String fComment;
@@ -202,25 +151,18 @@
* @param comment
* the comment associated with the refactoring, or
* <code>null</code> for no commment
- * @param arguments
- * the argument map (element type: <String, String>). The
- * keys of the arguments are required to be non-empty strings
- * which must not contain spaces. The values must be non-empty
- * strings
* @param flags
* the flags of the refactoring descriptor
*/
- public RefactoringDescriptor(final String id, final String project, final String description, final String comment, final Map arguments, final int flags) {
+ protected RefactoringDescriptor(final String id, final String project, final String description, final String comment, final int flags) {
Assert.isTrue(id != null && !"".equals(id)); //$NON-NLS-1$
Assert.isTrue(description != null && !"".equals(description)); //$NON-NLS-1$
Assert.isTrue(project == null || !"".equals(project)); //$NON-NLS-1$
- Assert.isNotNull(arguments);
Assert.isTrue(flags >= NONE);
fID= id;
fProject= project;
fDescription= description;
fComment= comment;
- fArguments= Collections.unmodifiableMap(new HashMap(arguments));
fFlags= flags;
}
@@ -247,16 +189,6 @@
}
/**
- * Returns the arguments describing the refactoring, in no particular order.
- *
- * @return the argument map (element type: <String, String>). The
- * resulting map cannot be modified.
- */
- public final Map getArguments() {
- return fArguments;
- }
-
- /**
* Returns the comment associated with this refactoring.
*
* @return the associated comment, or the empty string
@@ -293,6 +225,19 @@
}
/**
+ * Returns the new name of the element being refactored.
+ * <p>
+ * This method is used in particular to determine the new name of a project
+ * which is being renamed. The refactoring history service assumes that this
+ * method returns a non-null result if the project change flag
+ * {@link #PROJECT_CHANGE} is set on a descriptor.
+ * </p>
+ *
+ * @return the non-empty new name of the element, or <code>null</code>
+ */
+ public abstract String getNewName();
+
+ /**
* Returns the name of the associated project.
*
* @return the non-empty name of the project, or <code>null</code>
@@ -381,8 +326,6 @@
buffer.append(fDescription);
buffer.append(",project="); //$NON-NLS-1$
buffer.append(fProject);
- buffer.append(",arguments="); //$NON-NLS-1$
- buffer.append(fArguments);
buffer.append(",comment="); //$NON-NLS-1$
buffer.append(fComment);
buffer.append(",flags="); //$NON-NLS-1$
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/RefactoringInstanceCreator.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/RefactoringInstanceCreator.java
deleted file mode 100644
index 7688faa..0000000
--- a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/RefactoringInstanceCreator.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * 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
- *******************************************************************************/
-package org.eclipse.ltk.core.refactoring;
-
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.core.runtime.Assert;
-
-import org.eclipse.ltk.core.refactoring.participants.GenericRefactoringArguments;
-import org.eclipse.ltk.core.refactoring.participants.RefactoringArguments;
-
-/**
- * Partial implementation of a refactoring instance creator.
- *
- * @since 3.2
- */
-public abstract class RefactoringInstanceCreator implements IRefactoringInstanceCreator {
-
- /**
- * {@inheritDoc}
- */
- public RefactoringArguments createArguments(final RefactoringDescriptor descriptor) {
- Assert.isNotNull(descriptor);
- final GenericRefactoringArguments arguments= new GenericRefactoringArguments();
- final Map map= descriptor.getArguments();
- for (final Iterator iterator= map.entrySet().iterator(); iterator.hasNext();) {
- final Map.Entry entry= (Entry) iterator.next();
- final String name= (String) entry.getKey();
- final String value= (String) entry.getValue();
- if (name != null && !"".equals(name) && value != null) //$NON-NLS-1$
- arguments.setAttribute(name, value);
- }
- return arguments;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/participants/GenericRefactoringArguments.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/participants/GenericRefactoringArguments.java
deleted file mode 100644
index 0b22a43..0000000
--- a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/participants/GenericRefactoringArguments.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * 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
- *******************************************************************************/
-package org.eclipse.ltk.core.refactoring.participants;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-
-import org.eclipse.ltk.core.refactoring.IRefactoringInstanceCreator;
-import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
-
-/**
- * Refactoring arguments which provide the ability to set arguments using
- * key-value pairs of strings.
- * <p>
- * Note: This API is considered experimental and may change in the near future.
- * </p>
- *
- * @see IRefactoringInstanceCreator
- * @see RefactoringDescriptor
- *
- * @since 3.2
- */
-public final class GenericRefactoringArguments extends RefactoringArguments {
-
- /** The attribute map (element type: <code><String, String></code>) */
- private final Map fAttributes= new HashMap(2);
-
- /**
- * Returns the attribute with the specified name.
- *
- * @param name
- * the name of the attribute
- * @return the attribute value, or <code>null</code>
- */
- public String getAttribute(final String name) {
- return (String) fAttributes.get(name);
- }
-
- /**
- * Sets the attribute with the specified name to the indicated value.
- *
- * @param name
- * the name of the attribute
- * @param value
- * the value of the attribute
- */
- public void setAttribute(final String name, final String value) {
- Assert.isNotNull(name);
- Assert.isNotNull(value);
- fAttributes.put(name, value);
- }
-
- /**
- * {@inheritDoc}
- */
- public String toString() {
- return getClass().getName() + fAttributes.toString();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/IRefactoringSerializationConstants.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/IRefactoringSerializationConstants.java
similarity index 96%
rename from org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/IRefactoringSerializationConstants.java
rename to org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/IRefactoringSerializationConstants.java
index ba910c8..c343771 100644
--- a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/IRefactoringSerializationConstants.java
+++ b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/IRefactoringSerializationConstants.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.ltk.internal.core.refactoring.history;
+package org.eclipse.ltk.internal.core.refactoring;
import org.eclipse.ltk.core.refactoring.RefactoringSessionDescriptor;
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/RefactoringCorePlugin.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/RefactoringCorePlugin.java
index 8971b2a..ff0a6c4 100644
--- a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/RefactoringCorePlugin.java
+++ b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/RefactoringCorePlugin.java
@@ -28,7 +28,7 @@
import org.eclipse.ltk.internal.core.refactoring.history.RefactoringHistorySerializer;
import org.eclipse.ltk.internal.core.refactoring.history.RefactoringHistoryService;
-import org.eclipse.ltk.internal.core.refactoring.history.RefactoringInstanceFactory;
+import org.eclipse.ltk.internal.core.refactoring.history.RefactoringContributionManager;
import org.osgi.framework.BundleContext;
@@ -111,7 +111,7 @@
public void start(BundleContext context) throws Exception {
super.start(context);
- RefactoringInstanceFactory.getInstance().connect();
+ RefactoringContributionManager.getInstance().connect();
final RefactoringHistoryService service= RefactoringHistoryService.getInstance();
service.connect();
fRefactoringHistoryListener= new RefactoringHistorySerializer();
@@ -131,7 +131,7 @@
service.disconnect();
if (fRefactoringHistoryListener != null)
service.removeHistoryListener(fRefactoringHistoryListener);
- RefactoringInstanceFactory.getInstance().disconnect();
+ RefactoringContributionManager.getInstance().disconnect();
super.stop(context);
}
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringSessionReader.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/RefactoringSessionReader.java
similarity index 90%
rename from org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringSessionReader.java
rename to org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/RefactoringSessionReader.java
index d6e6506..d98c4fa 100644
--- a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringSessionReader.java
+++ b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/RefactoringSessionReader.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.ltk.internal.core.refactoring.history;
+package org.eclipse.ltk.internal.core.refactoring;
import java.io.IOException;
import java.util.ArrayList;
@@ -28,8 +28,7 @@
import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
import org.eclipse.ltk.core.refactoring.RefactoringSessionDescriptor;
-import org.eclipse.ltk.internal.core.refactoring.RefactoringCoreMessages;
-import org.eclipse.ltk.internal.core.refactoring.RefactoringCorePlugin;
+import org.eclipse.ltk.internal.core.refactoring.history.RefactoringContributionManager;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
@@ -44,7 +43,7 @@
*
* @since 3.2
*/
-final class RefactoringSessionReader extends DefaultHandler {
+public final class RefactoringSessionReader extends DefaultHandler {
/** The comment of the refactoring session, or <code>null</code> */
private String fComment= null;
@@ -156,18 +155,21 @@
int flag= 0;
try {
flag= Integer.parseInt(flags);
- } catch (NumberFormatException exception1) {
- // Do nothing
- }
- final RefactoringDescriptor descriptor= new RefactoringDescriptor(id, project, description, comment, map, flag);
- try {
- descriptor.setTimeStamp(Long.valueOf(stamp).longValue());
} catch (NumberFormatException exception) {
// Do nothing
}
- if (fRefactoringDescriptors == null)
- fRefactoringDescriptors= new ArrayList();
- fRefactoringDescriptors.add(descriptor);
+
+ final RefactoringDescriptor descriptor= RefactoringContributionManager.getInstance().createDescriptor(id, project, description, comment, map, flag);
+ if (descriptor != null) {
+ try {
+ descriptor.setTimeStamp(Long.valueOf(stamp).longValue());
+ } catch (NumberFormatException exception) {
+ // Do nothing
+ }
+ if (fRefactoringDescriptors == null)
+ fRefactoringDescriptors= new ArrayList();
+ fRefactoringDescriptors.add(descriptor);
+ }
} else if (IRefactoringSerializationConstants.ELEMENT_SESSION.equals(qualifiedName)) {
final String version= attributes.getValue(IRefactoringSerializationConstants.ATTRIBUTE_VERSION);
if (version != null && !"".equals(version)) //$NON-NLS-1$
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringSessionTransformer.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/RefactoringSessionTransformer.java
similarity index 97%
rename from org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringSessionTransformer.java
rename to org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/RefactoringSessionTransformer.java
index 2ffa69b..c22421d 100644
--- a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringSessionTransformer.java
+++ b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/RefactoringSessionTransformer.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.ltk.internal.core.refactoring.history;
+package org.eclipse.ltk.internal.core.refactoring;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
@@ -22,7 +22,6 @@
import org.eclipse.ltk.core.refactoring.IRefactoringCoreStatusCodes;
import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
-import org.eclipse.ltk.internal.core.refactoring.RefactoringCorePlugin;
import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
@@ -35,7 +34,7 @@
*
* @since 3.2
*/
-final class RefactoringSessionTransformer {
+public final class RefactoringSessionTransformer {
/** The current document, or <code>null</code> */
private Document fDocument= null;
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringInstanceFactory.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringContributionManager.java
similarity index 62%
rename from org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringInstanceFactory.java
rename to org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringContributionManager.java
index 52b8a2b..5dba098 100644
--- a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringInstanceFactory.java
+++ b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringContributionManager.java
@@ -20,7 +20,8 @@
import org.eclipse.core.runtime.IRegistryChangeListener;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.ltk.core.refactoring.IRefactoringInstanceCreator;
+import org.eclipse.ltk.core.refactoring.IRefactoringContribution;
+import org.eclipse.ltk.core.refactoring.IRefactoringContributionManager;
import org.eclipse.ltk.core.refactoring.Refactoring;
import org.eclipse.ltk.core.refactoring.RefactoringCore;
import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
@@ -32,11 +33,11 @@
import org.eclipse.ltk.internal.core.refactoring.RefactoringCorePlugin;
/**
- * Factory class to create refactoring instances from refactoring descriptors.
+ * Contribution manager for refactorings.
*
* @since 3.2
*/
-public final class RefactoringInstanceFactory implements IRegistryChangeListener, IRefactoringInstanceCreator {
+public final class RefactoringContributionManager implements IRegistryChangeListener, IRefactoringContributionManager {
/** The class attribute */
private static final String ATTRIBUTE_CLASS= "class"; //$NON-NLS-1$
@@ -45,37 +46,37 @@
private static final String ATTRIBUTE_ID= "id"; //$NON-NLS-1$
/** The singleton instance */
- private static RefactoringInstanceFactory fInstance= null;
+ private static RefactoringContributionManager fInstance= null;
- /** The refactoring creators extension point */
- private static final String REFACTORING_CREATORS_EXTENSION_POINT= "refactoringCreators"; //$NON-NLS-1$
+ /** The refactoring contributions extension point */
+ private static final String REFACTORING_CONTRIBUTIONS_EXTENSION_POINT= "refactoringContributions"; //$NON-NLS-1$
/**
- * Returns the singleton instance of the refactoring instance factory.
+ * Returns the singleton instance of the refactoring contribution manager.
*
* @return the singleton instance
*/
- public static RefactoringInstanceFactory getInstance() {
+ public static RefactoringContributionManager getInstance() {
if (fInstance == null)
- fInstance= new RefactoringInstanceFactory();
+ fInstance= new RefactoringContributionManager();
return fInstance;
}
/**
- * The refactoring creator cache (element type: <String,
- * <code>IRefactoringInstanceCreator></code>)
+ * The refactoring contribution cache (element type: <String,
+ * <code>IRefactoringContribution></code>)
*/
- private Map fCreatorCache= null;
+ private Map fContributionCache= null;
/**
- * Creates a new refactoring instance factory.
+ * Creates a new refactoring contribution manager.
*/
- private RefactoringInstanceFactory() {
+ private RefactoringContributionManager() {
// Not instantiatable
}
/**
- * Connects this factory to the platform's extension registry.
+ * Connects this manager to the platform's extension registry.
*/
public void connect() {
Platform.getExtensionRegistry().addRegistryChangeListener(this, RefactoringCore.ID_PLUGIN);
@@ -88,9 +89,9 @@
Assert.isNotNull(descriptor);
final String id= descriptor.getID();
if (id != null) {
- final IRefactoringInstanceCreator creator= createRefactoringCreator(id);
- if (creator != null)
- return creator.createArguments(descriptor);
+ final IRefactoringContribution contribution= getRefactoringContribution(id);
+ if (contribution != null)
+ return contribution.createArguments(descriptor);
}
return null;
}
@@ -98,43 +99,60 @@
/**
* {@inheritDoc}
*/
+ public RefactoringDescriptor createDescriptor(final String id, final String project, final String description, final String comment, final Map arguments, final int flags) {
+ Assert.isNotNull(id);
+ Assert.isNotNull(description);
+ Assert.isNotNull(arguments);
+ Assert.isLegal(flags >= RefactoringDescriptor.NONE);
+ final IRefactoringContribution contribution= getRefactoringContribution(id);
+ if (contribution != null)
+ return contribution.createDescriptor(id, project, description, comment, arguments, flags);
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Refactoring createRefactoring(final RefactoringDescriptor descriptor) throws CoreException {
Assert.isNotNull(descriptor);
final String id= descriptor.getID();
if (id != null) {
- final IRefactoringInstanceCreator creator= createRefactoringCreator(id);
- if (creator != null)
- return creator.createRefactoring(descriptor);
+ final IRefactoringContribution contribution= getRefactoringContribution(id);
+ if (contribution != null)
+ return contribution.createRefactoring(descriptor);
}
return null;
}
/**
- * Creates a refactoring instance creator for the specified id.
- *
- * @param id
- * the refactoring id
- * @return the refactoring instance creator, or <code>null</code>
+ * Disconnects this manager from the platform's extension registry.
*/
- private IRefactoringInstanceCreator createRefactoringCreator(final String id) {
+ public void disconnect() {
+ Platform.getExtensionRegistry().removeRegistryChangeListener(this);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public IRefactoringContribution getRefactoringContribution(final String id) {
Assert.isNotNull(id);
Assert.isTrue(!"".equals(id)); //$NON-NLS-1$
- if (fCreatorCache == null) {
- fCreatorCache= new HashMap();
- final IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(RefactoringCore.ID_PLUGIN, REFACTORING_CREATORS_EXTENSION_POINT);
+ if (fContributionCache == null) {
+ fContributionCache= new HashMap();
+ final IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(RefactoringCore.ID_PLUGIN, REFACTORING_CONTRIBUTIONS_EXTENSION_POINT);
for (int index= 0; index < elements.length; index++) {
final IConfigurationElement element= elements[index];
final String attributeId= element.getAttribute(ATTRIBUTE_ID);
- final String point= RefactoringCore.ID_PLUGIN + "." + REFACTORING_CREATORS_EXTENSION_POINT; //$NON-NLS-1$
+ final String point= RefactoringCore.ID_PLUGIN + "." + REFACTORING_CONTRIBUTIONS_EXTENSION_POINT; //$NON-NLS-1$
if (attributeId != null && !"".equals(attributeId)) { //$NON-NLS-1$
final String className= element.getAttribute(ATTRIBUTE_CLASS);
if (className != null && !"".equals(className)) { //$NON-NLS-1$
try {
final Object implementation= element.createExecutableExtension(ATTRIBUTE_CLASS);
- if (implementation instanceof IRefactoringInstanceCreator) {
- if (fCreatorCache.get(attributeId) != null)
+ if (implementation instanceof IRefactoringContribution) {
+ if (fContributionCache.get(attributeId) != null)
RefactoringCorePlugin.logErrorMessage(Messages.format(RefactoringCoreMessages.RefactoringCorePlugin_duplicate_warning, new String[] { attributeId, point}));
- fCreatorCache.put(attributeId, implementation);
+ fContributionCache.put(attributeId, implementation);
} else
RefactoringCorePlugin.logErrorMessage(Messages.format(RefactoringCoreMessages.RefactoringCorePlugin_creation_error, new String[] { point, attributeId}));
} catch (CoreException exception) {
@@ -146,20 +164,13 @@
RefactoringCorePlugin.logErrorMessage(Messages.format(RefactoringCoreMessages.RefactoringCorePlugin_missing_attribute, new String[] { point, ATTRIBUTE_ID}));
}
}
- return (IRefactoringInstanceCreator) fCreatorCache.get(id);
- }
-
- /**
- * Disconnects this factory from the platform's extensionr registry.
- */
- public void disconnect() {
- Platform.getExtensionRegistry().removeRegistryChangeListener(this);
+ return (IRefactoringContribution) fContributionCache.get(id);
}
/**
* {@inheritDoc}
*/
public void registryChanged(final IRegistryChangeEvent event) {
- fCreatorCache= null;
+ fContributionCache= null;
}
}
\ No newline at end of file
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringHistoryManager.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringHistoryManager.java
index 7daaa9b..e1b20b9 100644
--- a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringHistoryManager.java
+++ b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringHistoryManager.java
@@ -57,6 +57,7 @@
import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.ltk.core.refactoring.IRefactoringContribution;
import org.eclipse.ltk.core.refactoring.IRefactoringCoreStatusCodes;
import org.eclipse.ltk.core.refactoring.RefactoringCore;
import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
@@ -64,8 +65,11 @@
import org.eclipse.ltk.core.refactoring.RefactoringSessionDescriptor;
import org.eclipse.ltk.core.refactoring.history.RefactoringHistory;
+import org.eclipse.ltk.internal.core.refactoring.IRefactoringSerializationConstants;
import org.eclipse.ltk.internal.core.refactoring.RefactoringCoreMessages;
import org.eclipse.ltk.internal.core.refactoring.RefactoringCorePlugin;
+import org.eclipse.ltk.internal.core.refactoring.RefactoringSessionReader;
+import org.eclipse.ltk.internal.core.refactoring.RefactoringSessionTransformer;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -441,10 +445,17 @@
try {
transformer.beginSession(null);
try {
- transformer.beginRefactoring(descriptor.getID(), descriptor.getTimeStamp(), descriptor.getProject(), descriptor.getDescription(), descriptor.getComment(), descriptor.getFlags());
- for (final Iterator iterator= descriptor.getArguments().entrySet().iterator(); iterator.hasNext();) {
- final Map.Entry entry= (Entry) iterator.next();
- transformer.createArgument((String) entry.getKey(), (String) entry.getValue());
+ final String id= descriptor.getID();
+ transformer.beginRefactoring(id, descriptor.getTimeStamp(), descriptor.getProject(), descriptor.getDescription(), descriptor.getComment(), descriptor.getFlags());
+ final IRefactoringContribution contribution= RefactoringContributionManager.getInstance().getRefactoringContribution(id);
+ if (contribution != null) {
+ final Map arguments= contribution.getArguments(descriptor);
+ if (arguments != null) {
+ for (final Iterator iterator= arguments.entrySet().iterator(); iterator.hasNext();) {
+ final Map.Entry entry= (Entry) iterator.next();
+ transformer.createArgument((String) entry.getKey(), (String) entry.getValue());
+ }
+ }
}
} finally {
transformer.endRefactoring();
@@ -523,10 +534,17 @@
if (current != null) {
try {
long stamp= stamps ? current.getTimeStamp() : -1;
- transformer.beginRefactoring(current.getID(), stamp, current.getProject(), current.getDescription(), current.getComment(), current.getFlags());
- for (final Iterator iterator= current.getArguments().entrySet().iterator(); iterator.hasNext();) {
- final Map.Entry entry= (Entry) iterator.next();
- transformer.createArgument((String) entry.getKey(), (String) entry.getValue());
+ final String id= current.getID();
+ transformer.beginRefactoring(id, stamp, current.getProject(), current.getDescription(), current.getComment(), current.getFlags());
+ final IRefactoringContribution contribution= RefactoringContributionManager.getInstance().getRefactoringContribution(id);
+ if (contribution != null) {
+ final Map arguments= contribution.getArguments(current);
+ if (arguments != null) {
+ for (final Iterator iterator= arguments.entrySet().iterator(); iterator.hasNext();) {
+ final Map.Entry entry= (Entry) iterator.next();
+ transformer.createArgument((String) entry.getKey(), (String) entry.getValue());
+ }
+ }
}
} finally {
transformer.endRefactoring();
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringHistoryService.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringHistoryService.java
index 2ba3b6f..76ff7da 100644
--- a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringHistoryService.java
+++ b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringHistoryService.java
@@ -16,7 +16,6 @@
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.EmptyStackException;
import java.util.HashSet;
import java.util.Iterator;
@@ -34,6 +33,7 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.preferences.IScopeContext;
@@ -69,6 +69,7 @@
import org.eclipse.ltk.internal.core.refactoring.RefactoringCoreMessages;
import org.eclipse.ltk.internal.core.refactoring.RefactoringCorePlugin;
import org.eclipse.ltk.internal.core.refactoring.RefactoringPreferenceConstants;
+import org.eclipse.ltk.internal.core.refactoring.RefactoringSessionReader;
import org.eclipse.ltk.internal.core.refactoring.UndoableOperation2ChangeAdapter;
import org.xml.sax.InputSource;
@@ -178,7 +179,7 @@
throw new EmptyStackException();
for (int index= 0; index < fHistoryListeners.size(); index++) {
final IRefactoringHistoryListener listener= (IRefactoringHistoryListener) fHistoryListeners.get(index);
- Platform.run(new ISafeRunnable() {
+ SafeRunner.run(new ISafeRunnable() {
public void handleException(final Throwable throwable) {
RefactoringCorePlugin.log(throwable);
@@ -205,7 +206,7 @@
fImplementation.removeLast();
for (int index= 0; index < fHistoryListeners.size(); index++) {
final IRefactoringHistoryListener listener= (IRefactoringHistoryListener) fHistoryListeners.get(index);
- Platform.run(new ISafeRunnable() {
+ SafeRunner.run(new ISafeRunnable() {
public void handleException(final Throwable throwable) {
RefactoringCorePlugin.log(throwable);
@@ -404,7 +405,14 @@
* Creates a new unknown refactoring descriptor.
*/
private UnknownRefactoringDescriptor() {
- super(UNKNOWN_REFACTORING_ID, null, RefactoringCoreMessages.RefactoringHistoryService_unknown_refactoring_description, null, Collections.EMPTY_MAP, RefactoringDescriptor.NONE);
+ super(UNKNOWN_REFACTORING_ID, null, RefactoringCoreMessages.RefactoringHistoryService_unknown_refactoring_description, null, RefactoringDescriptor.NONE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getNewName() {
+ return null;
}
}
@@ -695,7 +703,7 @@
Assert.isNotNull(proxy);
for (int index= 0; index < fExecutionListeners.size(); index++) {
final IRefactoringExecutionListener listener= (IRefactoringExecutionListener) fExecutionListeners.get(index);
- Platform.run(new ISafeRunnable() {
+ SafeRunner.run(new ISafeRunnable() {
public final void handleException(final Throwable throwable) {
RefactoringCorePlugin.log(throwable);
@@ -718,7 +726,7 @@
Assert.isNotNull(proxy);
for (int index= 0; index < fExecutionListeners.size(); index++) {
final IRefactoringExecutionListener listener= (IRefactoringExecutionListener) fExecutionListeners.get(index);
- Platform.run(new ISafeRunnable() {
+ SafeRunner.run(new ISafeRunnable() {
public void handleException(final Throwable throwable) {
RefactoringCorePlugin.log(throwable);
@@ -741,7 +749,7 @@
Assert.isNotNull(proxy);
for (int index= 0; index < fExecutionListeners.size(); index++) {
final IRefactoringExecutionListener listener= (IRefactoringExecutionListener) fExecutionListeners.get(index);
- Platform.run(new ISafeRunnable() {
+ SafeRunner.run(new ISafeRunnable() {
public void handleException(final Throwable throwable) {
RefactoringCorePlugin.log(throwable);
@@ -764,7 +772,7 @@
Assert.isNotNull(proxy);
for (int index= 0; index < fHistoryListeners.size(); index++) {
final IRefactoringHistoryListener listener= (IRefactoringHistoryListener) fHistoryListeners.get(index);
- Platform.run(new ISafeRunnable() {
+ SafeRunner.run(new ISafeRunnable() {
public void handleException(final Throwable throwable) {
RefactoringCorePlugin.log(throwable);
@@ -787,7 +795,7 @@
Assert.isNotNull(proxy);
for (int index= 0; index < fExecutionListeners.size(); index++) {
final IRefactoringExecutionListener listener= (IRefactoringExecutionListener) fExecutionListeners.get(index);
- Platform.run(new ISafeRunnable() {
+ SafeRunner.run(new ISafeRunnable() {
public void handleException(final Throwable throwable) {
RefactoringCorePlugin.log(throwable);
@@ -810,7 +818,7 @@
Assert.isNotNull(proxy);
for (int index= 0; index < fExecutionListeners.size(); index++) {
final IRefactoringExecutionListener listener= (IRefactoringExecutionListener) fExecutionListeners.get(index);
- Platform.run(new ISafeRunnable() {
+ SafeRunner.run(new ISafeRunnable() {
public void handleException(final Throwable throwable) {
RefactoringCorePlugin.log(throwable);
@@ -833,7 +841,7 @@
Assert.isNotNull(proxy);
for (int index= 0; index < fExecutionListeners.size(); index++) {
final IRefactoringExecutionListener listener= (IRefactoringExecutionListener) fExecutionListeners.get(index);
- Platform.run(new ISafeRunnable() {
+ SafeRunner.run(new ISafeRunnable() {
public void handleException(final Throwable throwable) {
RefactoringCorePlugin.log(throwable);
diff --git a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/history/RefactoringHistoryWizard.java b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/history/RefactoringHistoryWizard.java
index 0f6ab55..31d2bd1 100644
--- a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/history/RefactoringHistoryWizard.java
+++ b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/history/RefactoringHistoryWizard.java
@@ -23,7 +23,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
@@ -33,7 +33,7 @@
import org.eclipse.ltk.core.refactoring.CheckConditionsOperation;
import org.eclipse.ltk.core.refactoring.CreateChangeOperation;
import org.eclipse.ltk.core.refactoring.IInitializableRefactoringComponent;
-import org.eclipse.ltk.core.refactoring.IRefactoringInstanceCreator;
+import org.eclipse.ltk.core.refactoring.IRefactoringContributionManager;
import org.eclipse.ltk.core.refactoring.PerformChangeOperation;
import org.eclipse.ltk.core.refactoring.PerformRefactoringHistoryOperation;
import org.eclipse.ltk.core.refactoring.Refactoring;
@@ -262,7 +262,7 @@
final RefactoringStatus status= new RefactoringStatus();
if (refactoring instanceof IInitializableRefactoringComponent) {
final IInitializableRefactoringComponent component= (IInitializableRefactoringComponent) refactoring;
- final RefactoringArguments arguments= RefactoringCore.getRefactoringInstanceCreator().createArguments(descriptor);
+ final RefactoringArguments arguments= RefactoringCore.getRefactoringContributionManager().createArguments(descriptor);
if (arguments != null)
status.merge(component.initialize(arguments));
else
@@ -379,7 +379,7 @@
* {@inheritDoc}
*/
public void dispose() {
- Platform.run(new ISafeRunnable() {
+ SafeRunner.run(new ISafeRunnable() {
public void handleException(final Throwable exception) {
RefactoringUIPlugin.log(exception);
@@ -406,8 +406,7 @@
*/
private RefactoringStatus fireAboutToPerformHistory(final IProgressMonitor monitor) {
final RefactoringStatus status= new RefactoringStatus();
-
- Platform.run(new ISafeRunnable() {
+ SafeRunner.run(new ISafeRunnable() {
public void handleException(final Throwable exception) {
RefactoringUIPlugin.log(exception);
@@ -418,7 +417,6 @@
status.merge(aboutToPerformHistory(monitor));
}
});
-
return status;
}
@@ -450,8 +448,8 @@
* if an error occurs while creating the refactoring
*/
private Refactoring getCurrentRefactoring(final RefactoringDescriptor descriptor, final RefactoringStatus status, final IProgressMonitor monitor) throws CoreException {
- final IRefactoringInstanceCreator factory= RefactoringCore.getRefactoringInstanceCreator();
- final Refactoring refactoring= factory.createRefactoring(descriptor);
+ final IRefactoringContributionManager manager= RefactoringCore.getRefactoringContributionManager();
+ final Refactoring refactoring= manager.createRefactoring(descriptor);
if (refactoring != null) {
status.merge(aboutToPerformRefactoring(refactoring, descriptor, monitor));
if (!status.hasFatalError())
@@ -471,6 +469,24 @@
}
/**
+ * Converts a button label to pure text.
+ *
+ * @param label
+ * the button label
+ * @return the resulting text
+ */
+ protected String getLabelAsText(final String label) {
+ Assert.isNotNull(label);
+ StringBuffer buffer= new StringBuffer(label.length());
+ for (int index= 0; index < label.length(); index++) {
+ char character= label.charAt(index);
+ if (character != '&')
+ buffer.append(character);
+ }
+ return buffer.toString();
+ }
+
+ /**
* {@inheritDoc}
*/
public IWizardPage getNextPage(final IWizardPage page) {
@@ -778,7 +794,7 @@
protected RefactoringStatus aboutToPerformRefactoring(final Refactoring refactoring, final RefactoringDescriptor descriptor, final IProgressMonitor monitor) {
final RefactoringStatus[] result= { new RefactoringStatus()};
- Platform.run(new ISafeRunnable() {
+ SafeRunner.run(new ISafeRunnable() {
public void handleException(final Throwable exception) {
RefactoringUIPlugin.log(exception);
@@ -792,7 +808,7 @@
}
protected void refactoringPerformed(final Refactoring refactoring, final IProgressMonitor monitor) {
- Platform.run(new ISafeRunnable() {
+ SafeRunner.run(new ISafeRunnable() {
public void handleException(final Throwable exception) {
RefactoringUIPlugin.log(exception);
@@ -846,22 +862,6 @@
}
/**
- * Converts a button label to pure text.
- * @param label the button label
- * @return the resulting text
- */
- protected String getLabelAsText(final String label) {
- Assert.isNotNull(label);
- StringBuffer buffer= new StringBuffer(label.length());
- for (int index= 0; index < label.length(); index++) {
- char character= label.charAt(index);
- if (character != '&')
- buffer.append(character);
- }
- return buffer.toString();
- }
-
- /**
* Performs the change previously displayed in the preview.
* <p>
* This method is NOT official API. It is used by the refactoring UI plug-in