Eclipse rename/refactoring override
I am new to eclipse plug-in development. I want to customize the renaming of a project. I need to validate the new name. So how can I override eclipse's rename/refactoring method?
I saw something related to RenameParticipant, but didn't understand clearly. It would be great if someone could explain me steps to override the renaming functionality.
Many 开发者_运维知识库Thanks, Ann
The rename refactoring has several processors that subclass org.eclipse.ltk.core.refactoring.participants.RenameProcessor
and are responsible for renaming different elements. For example, there is a processor for renaming Java projects org.eclipse.jdt.internal.corext.refactoring.rename.RenameJavaProjectProcessor
. A refactoring participant can participate in the condition checking and change creation of a refactoring processor. For example, to check some conditions during a rename refactoring, you should subclass org.eclipse.ltk.core.refactoring.participants.RenameParticipant
, override the method org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant.checkConditions(IProgressMonitor, CheckConditionsContext)
and register the participant via the extension point org.eclipse.ltk.core.refactoring.renameParticipants
. The participant org.eclipse.jdt.internal.corext.refactoring.nls.NLSAccessorFieldRenameParticipant
gives you a good example of how to participate in a rename refactoring.
When you declare your extension of the org.eclipse.ltk.core.refactoring.renameParticipants
extension point, you should specify the element you'd like your participant to get notified about. For example, see how the following use of the org.eclipse.ltk.core.refactoring.renameParticipants
extension point in org.eclipse.jdt.ui/plugin.xml
involves the participant in renaming fields.
<extension point="org.eclipse.ltk.core.refactoring.renameParticipants">
<renameParticipant class="org.eclipse.jdt.internal.corext.refactoring.nls.NLSAccessorFieldRenameParticipant" id="org.eclipse.jdt.ui.NLSFieldRenameParticipant" name="%Refactoring.NLSFieldRenameParticipant">
<enablement>
<with variable="affectedNatures">
<iterate operator="or">
<equals value="org.eclipse.jdt.core.javanature"/>
</iterate>
</with>
<with variable="element">
<instanceof value="org.eclipse.jdt.core.IField"/>
</with>
</enablement>
</renameParticipant>
</extension>
精彩评论