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
Ctrl + z have you tried?
Refactoring a method name is just as easy. For example, select the printem method and then select Refactor→ Rename, or right-click the variable and select Refactor→ Rename. This opens the Rename Method dialog shown in Figure 4-3, in which we're renaming the method to display .
Use the Rename refactoring to change names of symbols, files, directories, packages, modules and all the references to them throughout code. Renaming local variables or private methods can be done easily inline since only the limited scope is affected.
Select the variable you with to change, right click, and select Refactor->Rename. This will highlight all instances of the variable. Changing the variable name is automatically propagated to all of the instances. Thanks.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With