public class ProcessorBasedRefactoring extends Refactoring
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)
.
Modifier | Constructor and Description |
---|---|
protected |
ProcessorBasedRefactoring()
Deprecated.
use
ProcessorBasedRefactoring(RefactoringProcessor) instead |
|
ProcessorBasedRefactoring(RefactoringProcessor processor)
Creates a new processor based refactoring.
|
Modifier and Type | Method and Description |
---|---|
RefactoringStatus |
checkFinalConditions(IProgressMonitor pm)
After
checkInitialConditions has been performed and the user has
provided all input necessary to perform the refactoring this method is called
to check the remaining preconditions. |
RefactoringStatus |
checkInitialConditions(IProgressMonitor pm)
Checks some initial conditions based on the element to be refactored.
|
Change |
createChange(IProgressMonitor pm)
Creates a
Change object that performs the actual workspace
transformation. |
Object |
getAdapter(Class clazz)
Adapts the refactoring to the given type.
|
String |
getName()
Returns the refactoring's name.
|
RefactoringProcessor |
getProcessor()
Return the processor associated with this refactoring.
|
TextChange |
getTextChange(Object element)
Returns the text change for the given element or
null
if a text change doesn't exist. |
boolean |
isApplicable()
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.
|
String |
toString() |
checkAllConditions, doGetRefactoringTickProvider, getRefactoringTickProvider, getValidationContext, setValidationContext
protected ProcessorBasedRefactoring()
ProcessorBasedRefactoring(RefactoringProcessor)
insteadgetProcessor()
to return a processor or set the
processor with setProcessor(RefactoringProcessor)
.public ProcessorBasedRefactoring(RefactoringProcessor processor)
processor
- the refactoring's main processorpublic RefactoringProcessor getProcessor()
null
. Implementors can override this method
to return the processor to be used by this refactoring. Since 3.4, this method returns the processor passed in
ProcessorBasedRefactoring(RefactoringProcessor)
or by setProcessor(RefactoringProcessor)
.public void setProcessor(RefactoringProcessor processor)
null
.processor
- the processor associated with this refactoringpublic final boolean isApplicable() throws CoreException
This default implementation forwards the call to the refactoring processor.
true
if the refactoring is applicable to the
elements; otherwise false
is returned.CoreException
- if the test failspublic String getName()
getName
in class Refactoring
null
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException
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.
checkInitialConditions
in class Refactoring
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.RefactoringStatus#FATAL
the refactoring has to be considered as not being executable.CoreException
- if an exception occurred during initial condition checking.
If this happens then the initial condition checking has to be interpreted as failedRefactoring.checkFinalConditions(IProgressMonitor)
,
RefactoringStatus.FATAL
public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException
checkInitialConditions
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.
checkFinalConditions
in class Refactoring
pm
- a progress monitor to report progressRefactoringStatus#FATAL
the refactoring is considered as not being executable.CoreException
- if an exception occurred during final condition checking
If this happens then the final condition checking is interpreted as failedRefactoring.checkInitialConditions(IProgressMonitor)
,
RefactoringStatus.FATAL
public Change createChange(IProgressMonitor pm) throws CoreException
Change
object that performs the actual workspace
transformation.createChange
in class Refactoring
pm
- a progress monitor to report progressCoreException
- if an error occurred while creating the changepublic TextChange getTextChange(Object element)
null
if a text change doesn't exist. This method only returns a valid
result during change creation. Outside of change creation always
null
is returned.element
- the element to be modified for which a text change
is requestednull
if no text change exists
for the elementpublic Object getAdapter(Class clazz)
getAdapter
in interface IAdaptable
getAdapter
in class Refactoring
clazz
- the adapter class to look upnull
if no adapter
exists.IAdaptable.getAdapter(Class)
public String toString()
toString
in class Refactoring
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.