public abstract class JavaScriptRefactoringDescriptor
extends RefactoringDescriptor
This class provides features common to all Java refactorings.
Note: this class is not intended to be extended outside the refactoring framework.
Provisional API: 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.Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
ATTRIBUTE_ELEMENT
Predefined argument called
element<Number> . |
protected static java.lang.String |
ATTRIBUTE_INPUT
Predefined argument called
input . |
protected static java.lang.String |
ATTRIBUTE_NAME
Predefined argument called
name . |
protected static java.lang.String |
ATTRIBUTE_REFERENCES
Predefined argument called
references . |
protected static java.lang.String |
ATTRIBUTE_SELECTION
Predefined argument called
selection . |
protected static java.lang.String |
ATTRIBUTE_VERSION
The version attribute
|
protected java.util.Map |
fArguments
The argument map
|
static int |
JAR_MIGRATION
Constant describing the jar migration flag (value:
65536 ). |
static int |
JAR_REFACTORING
Constant describing the jar refactoring flag (value:
524288 ). |
static int |
JAR_SOURCE_ATTACHMENT
Constant describing the jar source attachment flag (value:
262144 ). |
protected static java.lang.String |
VALUE_VERSION_1_0
The version value
1.0 |
Modifier | Constructor and Description |
---|---|
protected |
JavaScriptRefactoringDescriptor(java.lang.String id)
Creates a new java refactoring descriptor.
|
protected |
JavaScriptRefactoringDescriptor(java.lang.String id,
java.util.Map arguments)
Creates a new java refactoring descriptor.
|
Modifier and Type | Method and Description |
---|---|
Refactoring |
createRefactoring(RefactoringStatus status) |
protected static java.lang.String |
elementToHandle(java.lang.String project,
IJavaScriptElement element)
Converts the specified element to an input handle.
|
protected java.util.Map |
getArguments()
Returns the argument map of this refactoring descriptor.
|
protected static IJavaScriptElement |
handleToElement(java.lang.String project,
java.lang.String handle)
Converts an input handle back to the corresponding java element.
|
protected static IJavaScriptElement |
handleToElement(java.lang.String project,
java.lang.String handle,
boolean check)
Converts an input handle back to the corresponding java element.
|
protected static IJavaScriptElement |
handleToElement(WorkingCopyOwner owner,
java.lang.String project,
java.lang.String handle,
boolean check)
Converts an input handle back to the corresponding java element.
|
protected static IResource |
handleToResource(java.lang.String project,
java.lang.String handle)
Converts an input handle with the given prefix back to the corresponding
resource.
|
protected void |
populateArgumentMap()
Populates the refactoring descriptor argument map based on the specified
arguments.
|
protected static java.lang.String |
resourceToHandle(java.lang.String project,
IResource resource)
Converts the specified resource to an input handle.
|
void |
setComment(java.lang.String comment)
Sets the details comment of this refactoring.
|
void |
setDescription(java.lang.String description)
Sets the description of this refactoring.
|
void |
setFlags(int flags)
Sets the flags of this refactoring.
|
void |
setProject(java.lang.String project)
Sets the project name of this refactoring.
|
RefactoringStatus |
validateDescriptor()
Validates the refactoring descriptor with respect to the constraints
imposed by the represented refactoring.
|
protected static final java.lang.String ATTRIBUTE_ELEMENT
element<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.
protected static final java.lang.String ATTRIBUTE_INPUT
input
.
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.
protected static final java.lang.String ATTRIBUTE_NAME
name
.
This argument should be used to name the element being refactored. The value of this argument may be shown in the user interface.
protected static final java.lang.String ATTRIBUTE_REFERENCES
references
.
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"
.
protected static final java.lang.String ATTRIBUTE_SELECTION
selection
.
This argument should be used to describe user input selections within a text file. The value of this argument has the format "offset length".
protected static final java.lang.String ATTRIBUTE_VERSION
public static final int JAR_MIGRATION
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_REFACTORING
should
be set as well.
JAR_REFACTORING
,
Constant Field Valuespublic static final int JAR_REFACTORING
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_ATTACHMENT
flag as well.
JAR_SOURCE_ATTACHMENT
,
Constant Field Valuespublic static final int JAR_SOURCE_ATTACHMENT
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.
JAR_REFACTORING
,
Constant Field Valuesprotected static final java.lang.String VALUE_VERSION_1_0
1.0
protected final java.util.Map fArguments
protected JavaScriptRefactoringDescriptor(java.lang.String id)
id
- the unique id of the refactoringprotected JavaScriptRefactoringDescriptor(java.lang.String id, java.util.Map arguments)
id
- the unique id of the refactoringarguments
- the argument map to useprotected static java.lang.String elementToHandle(java.lang.String project, IJavaScriptElement element)
project
- the project, or null
for the workspaceelement
- the elementprotected static IJavaScriptElement handleToElement(java.lang.String project, java.lang.String handle)
project
- the project, or null
for the workspacehandle
- the input handlenull
if no such
element existsprotected static IJavaScriptElement handleToElement(java.lang.String project, java.lang.String handle, boolean check)
project
- the project, or null
for the workspacehandle
- the input handlecheck
- true
to check for existence of the element,
false
otherwisenull
if no such
element existsprotected static IJavaScriptElement handleToElement(WorkingCopyOwner owner, java.lang.String project, java.lang.String handle, boolean check)
owner
- the working copy ownerproject
- the project, or null
for the workspacehandle
- the input handlecheck
- true
to check for existence of the element,
false
otherwisenull
if no such
element existsprotected static IResource handleToResource(java.lang.String project, java.lang.String handle)
project
- the project, or null
for the workspacehandle
- the input handlenull
if no such
resource existsprotected static java.lang.String resourceToHandle(java.lang.String project, IResource resource)
project
- the project, or null
for the workspaceresource
- the resourcepublic Refactoring createRefactoring(RefactoringStatus status) throws CoreException
CoreException
protected java.util.Map getArguments()
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.
protected void populateArgumentMap()
public void setComment(java.lang.String comment)
This information is used in the user interface to show additional details about the performed refactoring. The default is to use no details comment.
comment
- the details comment to set, or null
to set no
details comment#getComment()
public void setDescription(java.lang.String description)
This information is used to label a refactoring in the user interface. The default is an unspecified, but legal description.
description
- the non-empty description of the refactoring to set#getDescription()
public void setFlags(int flags)
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.
flags
- the flags to set, or RefactoringDescriptor.NONE
to clear the flags#getFlags()
,
RefactoringDescriptor#NONE
,
RefactoringDescriptor#STRUCTURAL_CHANGE
,
RefactoringDescriptor#BREAKING_CHANGE
,
RefactoringDescriptor#MULTI_CHANGE
,
JAR_MIGRATION
,
JAR_REFACTORING
,
JAR_SOURCE_ATTACHMENT
public void setProject(java.lang.String project)
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.
project
- the non-empty project name to set, or null
for
the workspace#getProject()
public RefactoringStatus validateDescriptor()
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#FATAL
indicates that the refactoring descriptor
cannot be used to create a refactoring instance.
Copyright (c) IBM Corp. and others 2000, 2016. All Rights Reserved.