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

java.lang.Object
  extended by org.eclipse.core.runtime.PlatformObject
      extended by org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant
          extended by org.eclipse.ltk.core.refactoring.participants.RenameParticipant
              extended by org.eclipse.xtext.ui.refactoring.impl.AbstractProcessorBasedRenameParticipant
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable
Direct Known Subclasses:
EcoreRefactoringParticipant, JDTRenamePartcipant, OverridingRuleRefactoringParticipant

public abstract class AbstractProcessorBasedRenameParticipant
extends org.eclipse.ltk.core.refactoring.participants.RenameParticipant

Author:
Jan Koehnlein - Initial contribution and API

Constructor Summary
AbstractProcessorBasedRenameParticipant()
           
 
Method Summary
 org.eclipse.ltk.core.refactoring.RefactoringStatus checkConditions(org.eclipse.core.runtime.IProgressMonitor pm, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext context)
          Checks the conditions of the refactoring participant.
 org.eclipse.ltk.core.refactoring.Change createChange(org.eclipse.core.runtime.IProgressMonitor pm)
          Creates a Change object that contains the workspace modifications of this participant to be executed after the changes from the refactoring are executed.
protected  java.util.List<? extends IRenameElementContext> createRenameElementContexts(java.lang.Object element)
           
protected  IGlobalServiceProvider getGlobalServiceProvider()
           
 java.lang.String getName()
          Returns a human readable name of this participant.
protected  java.lang.String getNewName()
           
protected abstract  java.util.List<org.eclipse.emf.ecore.EObject> getRenamedElementsOrProxies(org.eclipse.emf.ecore.EObject originalTarget)
           
protected  java.util.List<IRenameProcessorAdapter> getRenameProcessors(java.lang.Object element)
           
protected  IRenameRefactoringProvider getRenameRefactoringProvider(IRenameElementContext renameElementContext)
           
protected  org.eclipse.ltk.core.refactoring.RefactoringStatus getStatus()
           
protected  boolean initialize(java.lang.Object element)
          Initializes the participant with the element to be refactored.
 
Methods inherited from class org.eclipse.ltk.core.refactoring.participants.RenameParticipant
getArguments, initialize
 
Methods inherited from class org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant
createPreChange, getProcessor, getTextChange, initialize
 
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

AbstractProcessorBasedRenameParticipant

public AbstractProcessorBasedRenameParticipant()
Method Detail

initialize

protected boolean initialize(java.lang.Object element)
Description copied from class: org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant
Initializes the participant with the element to be refactored. If this method returns false then the framework will consider the participant as not being initialized and the participant will be dropped by the framework.

Specified by:
initialize in class org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant
Parameters:
element - the element to be refactored
Returns:
true if the participant could be initialized; otherwise false is returned.

getRenameProcessors

protected java.util.List<IRenameProcessorAdapter> getRenameProcessors(java.lang.Object element)

getRenameRefactoringProvider

protected IRenameRefactoringProvider getRenameRefactoringProvider(IRenameElementContext renameElementContext)

getName

public java.lang.String getName()
Description copied from class: org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant
Returns a human readable name of this participant.

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

checkConditions

public org.eclipse.ltk.core.refactoring.RefactoringStatus checkConditions(org.eclipse.core.runtime.IProgressMonitor pm,
                                                                          org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext context)
                                                                   throws org.eclipse.core.runtime.OperationCanceledException
Description copied from class: org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant
Checks the conditions of the refactoring participant.

The refactoring is considered as not being executable if the returned status has the severity of RefactoringStatus#FATAL. Note that this blocks the whole refactoring operation!

Clients should use the passed CheckConditionsContext to validate the changes they generate. If the generated changes include workspace resource modifications, clients should call ...

 (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class);
 IResourceChangeDescriptionFactory deltaFactory= checker.getDeltaFactory();
... and use the delta factory to describe all resource modifications in advance.

This method can be called more than once.

Specified by:
checkConditions in class org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant
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.OperationCanceledException - if the condition checking got canceled
See Also:
Refactoring.checkInitialConditions(IProgressMonitor), RefactoringStatus

createChange

public org.eclipse.ltk.core.refactoring.Change createChange(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.RefactoringParticipant
Creates a Change object that contains the workspace modifications of this participant to be executed after the changes from the refactoring are executed. Note that this implies that the undo change of the returned Change object will be executed before the undo changes from the refactoring have been executed.

The changes provided by a participant must not conflict with any change provided by other participants or by the refactoring itself.

If the change conflicts with any change provided by other participants or by the refactoring itself, then change execution will fail and the participant will be disabled for the rest of the eclipse session.

If an exception occurs while creating the change, the refactoring can not be carried out, and the participant will be disabled for the rest of the eclipse session.

As of 3.1, a participant can manipulate text resources already manipulated by the processor as long as the textual manipulations don't conflict (i.e. the participant manipulates a different region of the text resource). The method must not return those changes in its change tree since the change is already part of another change tree. If the participant only manipulates shared changes, then it can return null to indicate that it didn't create own changes. A shared text change can be accessed via the method RefactoringParticipant.getTextChange(Object).

Specified by:
createChange in class org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant
Parameters:
pm - a progress monitor to report progress
Returns:
the change representing the workspace modifications to be executed after the refactoring change or null if no changes are made
Throws:
org.eclipse.core.runtime.CoreException - if an error occurred while creating the change
org.eclipse.core.runtime.OperationCanceledException - if the change creation got canceled
See Also:
RefactoringParticipant.createPreChange(IProgressMonitor)

createRenameElementContexts

protected java.util.List<? extends IRenameElementContext> createRenameElementContexts(java.lang.Object element)

getRenamedElementsOrProxies

protected abstract java.util.List<org.eclipse.emf.ecore.EObject> getRenamedElementsOrProxies(org.eclipse.emf.ecore.EObject originalTarget)

getNewName

protected java.lang.String getNewName()

getStatus

protected org.eclipse.ltk.core.refactoring.RefactoringStatus getStatus()

getGlobalServiceProvider

protected IGlobalServiceProvider getGlobalServiceProvider()