Class JavaRefactoringDescriptor
- java.lang.Object
-
- org.eclipse.ltk.core.refactoring.RefactoringDescriptor
-
- org.eclipse.jdt.core.refactoring.descriptors.JavaRefactoringDescriptor
-
- All Implemented Interfaces:
Comparable<RefactoringDescriptor>
- Direct Known Subclasses:
ChangeMethodSignatureDescriptor,ConvertAnonymousDescriptor,ConvertLocalVariableDescriptor,ConvertMemberTypeDescriptor,CopyDescriptor,DeleteDescriptor,EncapsulateFieldDescriptor,ExtractClassDescriptor,ExtractConstantDescriptor,ExtractInterfaceDescriptor,ExtractLocalDescriptor,ExtractMethodDescriptor,ExtractSuperclassDescriptor,GeneralizeTypeDescriptor,InferTypeArgumentsDescriptor,InlineConstantDescriptor,InlineLocalVariableDescriptor,InlineMethodDescriptor,IntroduceFactoryDescriptor,IntroduceIndirectionDescriptor,IntroduceParameterDescriptor,IntroduceParameterObjectDescriptor,MoveDescriptor,MoveMethodDescriptor,MoveStaticMembersDescriptor,PullUpDescriptor,PushDownDescriptor,RenameJavaElementDescriptor,RenameLocalVariableDescriptor,RenameResourceDescriptor,UseSupertypeDescriptor
public abstract class JavaRefactoringDescriptor extends RefactoringDescriptor
Partial implementation of a java refactoring descriptor.This class provides features common to all Java refactorings.
Note: this class is not intended to be extended outside the refactoring framework.
- Since:
- 1.1
- Restriction:
- This class is not intended to be subclassed by clients outside JDT.
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringATTRIBUTE_ELEMENTPredefined argument calledelement<Number>.protected static StringATTRIBUTE_INPUTPredefined argument calledinput.protected static StringATTRIBUTE_NAMEPredefined argument calledname.protected static StringATTRIBUTE_REFERENCESPredefined argument calledreferences.protected static StringATTRIBUTE_SELECTIONPredefined argument calledselection.protected static StringATTRIBUTE_VERSIONThe version attributeprotected Map<String,String>fArgumentsstatic intJAR_MIGRATIONConstant describing the jar migration flag (value:65536).static intJAR_REFACTORINGConstant describing the jar refactoring flag (value:524288).static intJAR_SOURCE_ATTACHMENTConstant describing the jar source attachment flag (value:262144).protected static StringVALUE_VERSION_1_0The version value1.0-
Fields inherited from class org.eclipse.ltk.core.refactoring.RefactoringDescriptor
BREAKING_CHANGE, ID_UNKNOWN, MULTI_CHANGE, NONE, STRUCTURAL_CHANGE, USER_CHANGE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedJavaRefactoringDescriptor(String id)Creates a new java refactoring descriptor.JavaRefactoringDescriptor(String id, String project, String description, String comment, Map<String,String> arguments, int flags)Creates a new Java refactoring descriptor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RefactoringcreateRefactoring(RefactoringStatus status)protected static StringelementToHandle(String project, IJavaElement element)Converts the specified element to an input handle.protected Map<String,String>getArguments()Returns the argument map of this refactoring descriptor.protected static IJavaElementhandleToElement(String project, String handle)Converts an input handle back to the corresponding java element.protected static IJavaElementhandleToElement(String project, String handle, boolean check)Converts an input handle back to the corresponding java element.protected static IJavaElementhandleToElement(WorkingCopyOwner owner, String project, String handle, boolean check)Converts an input handle back to the corresponding java element.protected static IResourcehandleToResource(String project, String handle)Converts an input handle with the given prefix back to the corresponding resource.protected voidpopulateArgumentMap()Populates the refactoring descriptor argument map based on the specified arguments.protected static StringresourceToHandle(String project, IResource resource)Converts the specified resource to an input handle.voidsetComment(String comment)Sets the details comment of this refactoring.voidsetDescription(String description)Sets the description of this refactoring.voidsetFlags(int flags)Sets the flags of this refactoring.voidsetProject(String project)Sets the project name of this refactoring.RefactoringStatusvalidateDescriptor()Validates the refactoring descriptor with respect to the constraints imposed by the represented refactoring.-
Methods inherited from class org.eclipse.ltk.core.refactoring.RefactoringDescriptor
compareTo, createRefactoringContext, equals, getComment, getDescription, getFlags, getID, getProject, getTimeStamp, hashCode, setTimeStamp, toString
-
-
-
-
Field Detail
-
ATTRIBUTE_ELEMENT
protected static final String ATTRIBUTE_ELEMENT
Predefined argument calledelement<Number>.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.
The element arguments are simply distinguished by appending a number to the argument name, e.g. element1. The indices of this argument are one-based.
- See Also:
- Constant Field Values
-
ATTRIBUTE_INPUT
protected static final String ATTRIBUTE_INPUT
Predefined argument calledinput.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.
- See Also:
- Constant Field Values
-
ATTRIBUTE_NAME
protected static final String ATTRIBUTE_NAME
Predefined argument calledname.This argument should be used to name the element being refactored. The value of this argument may be shown in the user interface.
- See Also:
- Constant Field Values
-
ATTRIBUTE_REFERENCES
protected static final String ATTRIBUTE_REFERENCES
Predefined argument calledreferences.This argument should be used to describe whether references to the elements being refactored should be updated as well. The value of this argument is either
"true"or"false".- See Also:
- Constant Field Values
-
ATTRIBUTE_SELECTION
protected static final String ATTRIBUTE_SELECTION
Predefined argument calledselection.This argument should be used to describe user input selections within a text file. The value of this argument has the format "offset length".
- See Also:
- Constant Field Values
-
ATTRIBUTE_VERSION
protected static final String ATTRIBUTE_VERSION
The version attribute- See Also:
- Constant Field Values
-
JAR_MIGRATION
public static final int JAR_MIGRATION
Constant describing the jar migration flag (value:65536).Clients should set this flag to indicate that the refactoring can be stored to a JAR file in order to be accessible to the Migrate JAR File refactoring, regardless whether there is a source attachment to the JAR file or not. If this flag is set,
JAR_REFACTORINGshould be set as well.- See Also:
JAR_REFACTORING, Constant Field Values
-
JAR_REFACTORING
public static final int JAR_REFACTORING
Constant describing the jar refactoring flag (value:524288).Clients should set this flag to indicate that the refactoring in principle can be performed on binary elements originating from a JAR file. Refactorings which are able to run on binary elements, but require a correctly configured source attachment to work must set the
JAR_SOURCE_ATTACHMENTflag as well.- See Also:
JAR_SOURCE_ATTACHMENT, Constant Field Values
-
JAR_SOURCE_ATTACHMENT
public static final int JAR_SOURCE_ATTACHMENT
Constant describing the jar source attachment flag (value:262144).Clients should set this flag to indicate that the refactoring can be performed on binary elements originating from a JAR file if and only if it has a correctly configured source attachment.
- See Also:
JAR_REFACTORING, Constant Field Values
-
VALUE_VERSION_1_0
protected static final String VALUE_VERSION_1_0
The version value1.0- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JavaRefactoringDescriptor
protected JavaRefactoringDescriptor(String id)
Creates a new java refactoring descriptor.- Parameters:
id- the unique id of the refactoring
-
JavaRefactoringDescriptor
public JavaRefactoringDescriptor(String id, String project, String description, String comment, Map<String,String> arguments, int flags)
Creates a new Java refactoring descriptor.- Parameters:
id- the unique id of the refactoringproject- the non-empty name of the project associated with this refactoring, ornullfor a workspace refactoringdescription- a non-empty human-readable description of the particular refactoring instancecomment- the human-readable comment of the particular refactoring instance, ornullfor no commentarguments- a map of arguments that will be persisted and describes all settings for this refactoringflags- the flags of the refactoring descriptor- Since:
- 1.2
-
-
Method Detail
-
elementToHandle
protected static String elementToHandle(String project, IJavaElement element)
Converts the specified element to an input handle.- Parameters:
project- the project, ornullfor the workspaceelement- the element- Returns:
- a corresponding input handle
-
handleToElement
protected static IJavaElement handleToElement(String project, String handle)
Converts an input handle back to the corresponding java element.- Parameters:
project- the project, ornullfor the workspacehandle- the input handle- Returns:
- the corresponding java element, or
nullif no such element exists
-
handleToElement
protected static IJavaElement handleToElement(String project, String handle, boolean check)
Converts an input handle back to the corresponding java element.- Parameters:
project- the project, ornullfor the workspacehandle- the input handlecheck-trueto check for existence of the element,falseotherwise- Returns:
- the corresponding java element, or
nullif no such element exists
-
handleToElement
protected static IJavaElement handleToElement(WorkingCopyOwner owner, String project, String handle, boolean check)
Converts an input handle back to the corresponding java element.- Parameters:
owner- the working copy ownerproject- the project, ornullfor the workspacehandle- the input handlecheck-trueto check for existence of the element,falseotherwise- Returns:
- the corresponding java element, or
nullif no such element exists
-
handleToResource
protected static IResource handleToResource(String project, String handle)
Converts an input handle with the given prefix back to the corresponding resource.- Parameters:
project- the project, ornullfor the workspacehandle- the input handle- Returns:
- the corresponding resource, or
nullif no such resource exists
-
resourceToHandle
protected static String resourceToHandle(String project, IResource resource)
Converts the specified resource to an input handle.- Parameters:
project- the project, ornullfor the workspaceresource- the resource- Returns:
- the input handle
-
createRefactoring
public Refactoring createRefactoring(RefactoringStatus status) throws CoreException
- Specified by:
createRefactoringin classRefactoringDescriptor- Throws:
CoreException
-
getArguments
protected Map<String,String> getArguments()
Returns the argument map of this refactoring descriptor.The returned map is a copy of the argument map. Modifying the result does not change the refactoring descriptor itself.
Note: This API must not be extended or reimplemented and should not be called from outside the refactoring framework.
-
populateArgumentMap
protected void populateArgumentMap()
Populates the refactoring descriptor argument map based on the specified arguments. Subclasses should extend and add their arguments tofArguments.
-
setComment
public void setComment(String comment)
Sets the details comment of this refactoring.This information is used in the user interface to show additional details about the performed refactoring. The default is to use no details comment.
- Overrides:
setCommentin classRefactoringDescriptor- Parameters:
comment- the details comment to set, ornullto set no details comment- See Also:
RefactoringDescriptor.getComment()
-
setDescription
public void setDescription(String description)
Sets the description of this refactoring.This information is used to label a refactoring in the user interface. The default is an unspecified, but legal description.
- Overrides:
setDescriptionin classRefactoringDescriptor- Parameters:
description- the non-empty description of the refactoring to set- See Also:
RefactoringDescriptor.getDescription()
-
setFlags
public void setFlags(int flags)
Sets the flags of this refactoring.The default is
RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE, unless overridden by a concrete subclass. Clients may use refactoring flags to indicate special capabilities of Java refactorings.- Overrides:
setFlagsin classRefactoringDescriptor- Parameters:
flags- the flags to set, orRefactoringDescriptor.NONEto clear the flags- See Also:
RefactoringDescriptor.getFlags(),RefactoringDescriptor.NONE,RefactoringDescriptor.STRUCTURAL_CHANGE,RefactoringDescriptor.BREAKING_CHANGE,RefactoringDescriptor.MULTI_CHANGE,JAR_MIGRATION,JAR_REFACTORING,JAR_SOURCE_ATTACHMENT
-
setProject
public void setProject(String project)
Sets the project name of this refactoring.The default is to associate the refactoring with the workspace. Subclasses should call this method with the project name associated with the refactoring's input elements, if available.
- Overrides:
setProjectin classRefactoringDescriptor- Parameters:
project- the non-empty project name to set, ornullfor the workspace- See Also:
RefactoringDescriptor.getProject()
-
validateDescriptor
public RefactoringStatus validateDescriptor()
Validates the refactoring descriptor with respect to the constraints imposed by the represented refactoring.Clients must call this method to verify that all arguments have been correctly set and that they satisfy the constraints imposed by specific refactorings. Returning a refactoring status of severity
RefactoringStatus.FATALindicates that the refactoring descriptor cannot be used to create a refactoring instance.- Returns:
- a refactoring status describing the outcome of the validation
-
-