Eclipse JDT
Release 3.0

org.eclipse.ltk.core.refactoring.participants
Class RefactoringProcessor

java.lang.Object
  extended byorg.eclipse.core.runtime.PlatformObject
      extended byorg.eclipse.ltk.core.refactoring.participants.RefactoringProcessor
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable
Direct Known Subclasses:
DeleteProcessor, MoveProcessor, RenameProcessor

public abstract class RefactoringProcessor
extends org.eclipse.core.runtime.PlatformObject

An abstract base class defining the protocol between a refactoring and its associated processor. The API is very similar to the one of a Refactoring. Implementors of this class should therefore study the interface of the refactoring class as well.

A refactoring processor is responsible for:

A refactoring processor can not assume that all resources are saved before any methods are called on it. Therefore a processor must be able to deal with unsaved resources.

This class should be subclassed by clients wishing to provide special refactoring processor.

Since:
3.0

Constructor Summary
RefactoringProcessor()
           
 
Method Summary
abstract  RefactoringStatus checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor pm, CheckConditionsContext context)
          Checks the final conditions based on the element to be refactored.
abstract  RefactoringStatus checkInitialConditions(org.eclipse.core.runtime.IProgressMonitor pm)
          Checks some initial conditions based on the element to be refactored.
abstract  Change createChange(org.eclipse.core.runtime.IProgressMonitor pm)
          Creates a Change object describing the workspace modifications the processor contributes to the overall refactoring.
abstract  Object[] getElements()
          Returns an array containing the elements to be refactored.
abstract  String getIdentifier()
          Returns the unique identifier of the refactoring processor.
abstract  String getProcessorName()
          Returns a human readable name.
abstract  boolean isApplicable()
          Checks whether the processor is applicable to the elements to be refactored or not.
abstract  RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants sharedParticipants)
          Returns the array of participants.
 Change postCreateChange(Change[] participantChanges, org.eclipse.core.runtime.IProgressMonitor pm)
          Additional hook allowing processor's to add changes to the set of workspace modifications after all participant changes have been created.
 
Methods inherited from class org.eclipse.core.runtime.PlatformObject
getAdapter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RefactoringProcessor

public RefactoringProcessor()
Method Detail

getElements

public abstract Object[] getElements()
Returns an array containing the elements to be refactored. The concrete type of the elements depend on the concrete refactoring processor. For example a processor responsible for renaming Java methods returns the method to be renamed via this call.

Returns:
an array containing the element to be refactored

getIdentifier

public abstract String getIdentifier()
Returns the unique identifier of the refactoring processor. The identifier must not be null.

Returns:
a unique identifier.

getProcessorName

public abstract String getProcessorName()
Returns a human readable name. The name will be displayed to users. The name must not be null.

Returns:
a human readable name

isApplicable

public abstract boolean isApplicable()
                              throws org.eclipse.core.runtime.CoreException
Checks whether the processor is applicable to the elements to be refactored or not. If false is returned the processor is interpreted to be unusable.

Returns:
true if the processor is applicable to the elements; otherwise false is returned.
Throws:
org.eclipse.core.runtime.CoreException - is the test fails. The processor is treated as unusable if this method throws an exception

checkInitialConditions

public abstract RefactoringStatus checkInitialConditions(org.eclipse.core.runtime.IProgressMonitor pm)
                                                  throws org.eclipse.core.runtime.CoreException,
                                                         org.eclipse.core.runtime.OperationCanceledException
Checks some initial conditions based on the element to be refactored.

The refactoring using this processor is considered as not being executable if the returned status has the severity of RefactoringStatus#FATAL.

This method can be called more than once.

Parameters:
pm - a progress monitor to report progress. Although availability 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 is considered as not being executable.
Throws:
org.eclipse.core.runtime.CoreException - if an exception occurred during initial condition checking. If this happens the initial condition checking is interpreted as failed.
org.eclipse.core.runtime.OperationCanceledException - if the condition checking got cancelled
See Also:
Refactoring.checkInitialConditions(IProgressMonitor), RefactoringStatus.FATAL

checkFinalConditions

public abstract RefactoringStatus checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor pm,
                                                       CheckConditionsContext context)
                                                throws org.eclipse.core.runtime.CoreException,
                                                       org.eclipse.core.runtime.OperationCanceledException
Checks the final conditions based on the element to be refactored.

The refactoring using this processor is considered as not being executable if the returned status has the severity of RefactoringStatus#FATAL.

This method can be called more than once.

Parameters:
pm - a progress monitor to report progress
context - a condition checking context to collect shared condition checks
Returns:
a refactoring status. If the status is RefactoringStatus#FATAL the refactoring is considered as not being executable.
Throws:
org.eclipse.core.runtime.CoreException - if an exception occurred during final condition checking. If this happens the final condition checking is interpreted as failed.
org.eclipse.core.runtime.OperationCanceledException - if the condition checking got cancelled
See Also:
Refactoring.checkFinalConditions(IProgressMonitor), RefactoringStatus.FATAL

createChange

public abstract Change createChange(org.eclipse.core.runtime.IProgressMonitor pm)
                             throws org.eclipse.core.runtime.CoreException,
                                    org.eclipse.core.runtime.OperationCanceledException
Creates a Change object describing the workspace modifications the processor contributes to the overall refactoring.

Parameters:
pm - a progress monitor to report progress
Returns:
the change representing the workspace modifications of the processor
Throws:
org.eclipse.core.runtime.CoreException - if an error occurred while creating the change
org.eclipse.core.runtime.OperationCanceledException - if the condition checking got cancelled
See Also:
Refactoring.createChange(IProgressMonitor)

postCreateChange

public Change postCreateChange(Change[] participantChanges,
                               org.eclipse.core.runtime.IProgressMonitor pm)
                        throws org.eclipse.core.runtime.CoreException,
                               org.eclipse.core.runtime.OperationCanceledException
Additional hook allowing processor's to add changes to the set of workspace modifications after all participant changes have been created.

Parameters:
participantChanges - an array containing the changes created by the participants
pm - a progress monitor to report progress
Returns:
change representing additional workspace modifications
Throws:
org.eclipse.core.runtime.CoreException - if an error occurred while creating the post change
org.eclipse.core.runtime.OperationCanceledException - if the condition checking got cancelled
See Also:
createChange(IProgressMonitor)

loadParticipants

public abstract RefactoringParticipant[] loadParticipants(RefactoringStatus status,
                                                          SharableParticipants sharedParticipants)
                                                   throws org.eclipse.core.runtime.CoreException
Returns the array of participants. It is up to the implementor of a concrete processor to define which participants are loaded. In general, three different kinds of participants can be distinguished:

Implementors are responsible to initialize the created participants with the right arguments. The method is called after checkFinalConditions(IProgressMonitor, CheckConditionsContext)has been called on the processor itself.

Parameters:
status - a refactoring status to report status if problems occur while loading the participants
sharedParticipants - a list of sharable participants. Implementors of this method can simply pass this instance to the corresponding participant loading methods defined in ParticipantManager.
Returns:
an array of participants or null or an empty array if no participants are loaded
Throws:
org.eclipse.core.runtime.CoreException - if creating or loading of the participants failed
See Also:
ISharableParticipant

Eclipse JDT
Release 3.0

Copyright (c) IBM Corp. and others 2000, 2004. All Rights Reserved.