org.eclipse.xtext.ui.refactoring.impl
Class RenameElementProcessor

java.lang.Object
  extended by org.eclipse.core.runtime.PlatformObject
      extended by org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor
          extended by org.eclipse.ltk.core.refactoring.participants.RenameProcessor
              extended by org.eclipse.xtext.ui.refactoring.impl.AbstractRenameProcessor
                  extended by org.eclipse.xtext.ui.refactoring.impl.RenameElementProcessor
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable, IRenameProcessorAdapter
Direct Known Subclasses:
JvmReferenceUpdateRenameProcessor

public class RenameElementProcessor
extends AbstractRenameProcessor

LTK RefactoringProcessor for an Xtext element rename refactoring.

Author:
Jan Koehnlein - Initial contribution and API, Holger Schill

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.xtext.ui.refactoring.IRenameProcessorAdapter
IRenameProcessorAdapter.DefaultFactory, IRenameProcessorAdapter.Factory
 
Field Summary
protected static org.apache.log4j.Logger LOG
           
 
Constructor Summary
RenameElementProcessor()
           
 
Method Summary
 org.eclipse.ltk.core.refactoring.RefactoringStatus checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext context)
          Checks the final conditions based on the element to be refactored.
 org.eclipse.ltk.core.refactoring.RefactoringStatus checkInitialConditions(org.eclipse.core.runtime.IProgressMonitor pm)
          Checks some initial conditions based on the element to be refactored.
protected  void checkTargetFile(org.eclipse.emf.ecore.resource.Resource resource)
           
 org.eclipse.ltk.core.refactoring.Change createChange(org.eclipse.core.runtime.IProgressMonitor monitor)
          Creates a Change object describing the workspace modifications the processor contributes to the overall refactoring.
protected  IRenameStrategy createRenameElementStrategy(org.eclipse.emf.ecore.EObject targetElement, IRenameElementContext renameElementContext)
           
protected  org.eclipse.emf.ecore.resource.ResourceSet createResourceSet(IRenameElementContext renameElementContext)
           
 java.lang.Object[] getElements()
          Returns an array containing the elements to be refactored.
 java.lang.String getIdentifier()
          Returns the unique identifier of the refactoring processor.
protected  java.lang.String getLanguageName()
           
 java.lang.String getNewName()
           
 java.lang.String getOriginalName()
           
 java.lang.String getProcessorName()
          Returns a human readable name.
 IRenameStrategy getRenameElementStrategy()
           
protected  RefactoringResourceSetProvider getResourceSetProvider()
           
 void handleException(org.eclipse.ltk.core.refactoring.RefactoringStatus status, java.lang.Exception exc)
           
 boolean initialize(IRenameElementContext renameElementContext)
           
 boolean isApplicable()
          Checks whether the processor is applicable to the elements to be refactored or not.
 org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant[] loadParticipants(org.eclipse.ltk.core.refactoring.RefactoringStatus status, org.eclipse.ltk.core.refactoring.participants.SharableParticipants sharedParticipants)
          Returns the array of participants.
 void setNewName(java.lang.String newName)
           
 org.eclipse.ltk.core.refactoring.RefactoringStatus validateNewName(java.lang.String newName)
           
 
Methods inherited from class org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor
getRefactoring, postCreateChange
 
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
 

Field Detail

LOG

protected static final org.apache.log4j.Logger LOG
Constructor Detail

RenameElementProcessor

public RenameElementProcessor()
Method Detail

initialize

public boolean initialize(IRenameElementContext renameElementContext)
Specified by:
initialize in class AbstractRenameProcessor

createResourceSet

protected org.eclipse.emf.ecore.resource.ResourceSet createResourceSet(IRenameElementContext renameElementContext)

checkTargetFile

protected void checkTargetFile(org.eclipse.emf.ecore.resource.Resource resource)

createRenameElementStrategy

protected IRenameStrategy createRenameElementStrategy(org.eclipse.emf.ecore.EObject targetElement,
                                                      IRenameElementContext renameElementContext)

getRenameElementStrategy

public IRenameStrategy getRenameElementStrategy()
Specified by:
getRenameElementStrategy in class AbstractRenameProcessor

getElements

public java.lang.Object[] getElements()
Description copied from class: org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor
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.

Specified by:
getElements in class org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor
Returns:
an array containing the elements to be refactored

getOriginalName

public java.lang.String getOriginalName()

validateNewName

public org.eclipse.ltk.core.refactoring.RefactoringStatus validateNewName(java.lang.String newName)

getLanguageName

protected java.lang.String getLanguageName()

getIdentifier

public java.lang.String getIdentifier()
Description copied from class: org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor
Returns the unique identifier of the refactoring processor. The identifier must not be null.

Specified by:
getIdentifier in class org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor
Returns:
a unique identifier.

getProcessorName

public java.lang.String getProcessorName()
Description copied from class: org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor
Returns a human readable name. The name will be displayed to users. The name must not be null.

Specified by:
getProcessorName in class org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor
Returns:
a human readable name

isApplicable

public boolean isApplicable()
                     throws org.eclipse.core.runtime.CoreException
Description copied from class: org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor
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.

Specified by:
isApplicable in class org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor
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

setNewName

public void setNewName(java.lang.String newName)
Specified by:
setNewName in interface IRenameProcessorAdapter
Specified by:
setNewName in class AbstractRenameProcessor

getNewName

public java.lang.String getNewName()
Specified by:
getNewName in interface IRenameProcessorAdapter
Specified by:
getNewName in class AbstractRenameProcessor

checkInitialConditions

public org.eclipse.ltk.core.refactoring.RefactoringStatus checkInitialConditions(org.eclipse.core.runtime.IProgressMonitor pm)
                                                                          throws org.eclipse.core.runtime.CoreException,
                                                                                 org.eclipse.core.runtime.OperationCanceledException
Description copied from class: org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor
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.

Specified by:
checkInitialConditions in interface IRenameProcessorAdapter
Specified by:
checkInitialConditions in class org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor
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 canceled
See Also:
Refactoring.checkInitialConditions(IProgressMonitor), RefactoringStatus.FATAL

checkFinalConditions

public org.eclipse.ltk.core.refactoring.RefactoringStatus checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor monitor,
                                                                               org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext context)
                                                                        throws org.eclipse.core.runtime.CoreException,
                                                                               org.eclipse.core.runtime.OperationCanceledException
Description copied from class: org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor
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.

Specified by:
checkFinalConditions in interface IRenameProcessorAdapter
Specified by:
checkFinalConditions in class org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor
Parameters:
monitor - 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 canceled
See Also:
Refactoring.checkFinalConditions(IProgressMonitor), RefactoringStatus.FATAL

createChange

public org.eclipse.ltk.core.refactoring.Change createChange(org.eclipse.core.runtime.IProgressMonitor monitor)
                                                     throws org.eclipse.core.runtime.CoreException,
                                                            org.eclipse.core.runtime.OperationCanceledException
Description copied from class: org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor
Creates a Change object describing the workspace modifications the processor contributes to the overall refactoring.

Specified by:
createChange in interface IRenameProcessorAdapter
Specified by:
createChange in class org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor
Parameters:
monitor - 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 canceled
See Also:
Refactoring.createChange(IProgressMonitor)

loadParticipants

public org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant[] loadParticipants(org.eclipse.ltk.core.refactoring.RefactoringStatus status,
                                                                                               org.eclipse.ltk.core.refactoring.participants.SharableParticipants sharedParticipants)
                                                                                        throws org.eclipse.core.runtime.CoreException
Description copied from class: org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor
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 RefactoringProcessor.checkFinalConditions(IProgressMonitor, CheckConditionsContext)has been called on the processor itself.

Specified by:
loadParticipants in class org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor
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

handleException

public void handleException(org.eclipse.ltk.core.refactoring.RefactoringStatus status,
                            java.lang.Exception exc)

getResourceSetProvider

protected RefactoringResourceSetProvider getResourceSetProvider()