Class ProcessorBasedRefactoring
- All Implemented Interfaces:
IAdaptable
- Direct Known Subclasses:
CopyRefactoring
,DeleteRefactoring
,MoveRefactoring
,RenameRefactoring
This class can be subclassed by clients wishing to provide a special refactoring which uses a processor/participant architecture.
Since 3.4, this class is non abstract and can be instantiated. getProcessor()
will
return the processor passed in ProcessorBasedRefactoring(RefactoringProcessor)
or
the processor set by setProcessor(RefactoringProcessor)
.
- Since:
- 3.0
-
Constructor Summary
ModifierConstructorDescriptionprotected
Deprecated.ProcessorBasedRefactoring
(RefactoringProcessor processor) Creates a new processor based refactoring. -
Method Summary
Modifier and TypeMethodDescriptionAftercheckInitialConditions
has been performed and the user has provided all input necessary to perform the refactoring this method is called to check the remaining preconditions.Checks some initial conditions based on the element to be refactored.Creates aChange
object that performs the actual workspace transformation.<T> T
getAdapter
(Class<T> clazz) Adapts the refactoring to the given type.getName()
Returns the refactoring's name.Return the processor associated with this refactoring.getTextChange
(Object element) Returns the text change for the given element ornull
if a text change doesn't exist.final boolean
Checks whether the refactoring is applicable to the elements to be refactored or not.void
setProcessor
(RefactoringProcessor processor) Sets the processor associated with this refactoring.toString()
Methods inherited from class org.eclipse.ltk.core.refactoring.Refactoring
checkAllConditions, doGetRefactoringTickProvider, getRefactoringTickProvider, getValidationContext, setValidationContext
-
Constructor Details
-
ProcessorBasedRefactoring
Deprecated.useProcessorBasedRefactoring(RefactoringProcessor)
insteadCreates a new processor based refactoring. Clients must overridegetProcessor()
to return a processor or set the processor withsetProcessor(RefactoringProcessor)
. -
ProcessorBasedRefactoring
Creates a new processor based refactoring.- Parameters:
processor
- the refactoring's main processor- Since:
- 3.4 public, was added in 3.1 as protected method
-
-
Method Details
-
getProcessor
Return the processor associated with this refactoring. The method must not returnnull
. Implementors can override this method to return the processor to be used by this refactoring. Since 3.4, this method returns the processor passed inProcessorBasedRefactoring(RefactoringProcessor)
or bysetProcessor(RefactoringProcessor)
.- Returns:
- the processor associated with this refactoring
-
setProcessor
Sets the processor associated with this refactoring. The processor must not benull
.- Parameters:
processor
- the processor associated with this refactoring- Since:
- 3.4
-
isApplicable
Checks whether the refactoring is applicable to the elements to be refactored or not.This default implementation forwards the call to the refactoring processor.
- Returns:
true
if the refactoring is applicable to the elements; otherwisefalse
is returned.- Throws:
CoreException
- if the test fails
-
getName
Description copied from class:Refactoring
Returns the refactoring's name.- Specified by:
getName
in classRefactoring
- Returns:
- the refactoring's human readable name. Must not be
null
-
checkInitialConditions
Description copied from class:Refactoring
Checks some initial conditions based on the element to be refactored. The method is typically called by the UI to perform an initial checks after an action has been executed.The refactoring has to be considered as not being executable if the returned status has the severity of
RefactoringStatus#FATAL
.This method can be called more than once.
- Specified by:
checkInitialConditions
in classRefactoring
- Parameters:
pm
- a progress monitor to report progress. Although initial checks are supposed to execute fast, there can be certain situations where progress reporting is necessary. For example rebuilding a corrupted index may report progress.- Returns:
- a refactoring status. If the status is
RefactoringStatus#FATAL
the refactoring has to be considered as not being executable. - Throws:
CoreException
- if an exception occurred during initial condition checking. If this happens then the initial condition checking has to be interpreted as failed- See Also:
-
checkFinalConditions
Description copied from class:Refactoring
AftercheckInitialConditions
has been performed and the user has provided all input necessary to perform the refactoring this method is called to check the remaining preconditions.The refactoring has to be considered as not being executable if the returned status has the severity of
RefactoringStatus#FATAL
.This method can be called more than once.
- Specified by:
checkFinalConditions
in classRefactoring
- Parameters:
pm
- a progress monitor to report progress- Returns:
- a refactoring status. If the status is
RefactoringStatus#FATAL
the refactoring is considered as not being executable. - Throws:
CoreException
- if an exception occurred during final condition checking If this happens then the final condition checking is interpreted as failed- See Also:
-
createChange
Description copied from class:Refactoring
Creates aChange
object that performs the actual workspace transformation.- Specified by:
createChange
in classRefactoring
- Parameters:
pm
- a progress monitor to report progress- Returns:
- the change representing the workspace modifications of the refactoring
- Throws:
CoreException
- if an error occurred while creating the change
-
getTextChange
Returns the text change for the given element ornull
if a text change doesn't exist. This method only returns a valid result during change creation. Outside of change creation alwaysnull
is returned.- Parameters:
element
- the element to be modified for which a text change is requested- Returns:
- the text change or
null
if no text change exists for the element - Since:
- 3.1
-
getAdapter
Adapts the refactoring to the given type. The adapter is resolved as follows:- the refactoring itself is checked whether it is an instance of the requested type.
- its processor is checked whether it is an instance of the requested type.
- the request is delegated to the super class.
- Specified by:
getAdapter
in interfaceIAdaptable
- Overrides:
getAdapter
in classRefactoring
- Type Parameters:
T
- the class type- Parameters:
clazz
- the adapter class to look up- Returns:
- the requested adapter or
null
if no adapter exists. - See Also:
-
toString
- Overrides:
toString
in classRefactoring
-
ProcessorBasedRefactoring(RefactoringProcessor)
instead