Eclipse重命名/重构覆盖 [英] Eclipse rename/refactoring override

查看:199
本文介绍了Eclipse重命名/重构覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是eclipse插件开发的新手。我想定制一个项目的重命名。我需要验证新的名称。那么我如何覆盖eclipse的重命名/重构方法?



我看到与RenameParticipant相关的内容,但是不明白。如果有人可以向我解释重写功能的步骤,那将是很棒的。



许多谢谢,
Ann

解决方案

重命名重构有几个处理器,分类为 org.eclipse .ltk.core.refactoring.participants.RenameProcessor ,并负责重命名不同的元素。例如,有一个处理器用于重命名Java项目 org.eclipse.jdt.internal.corext.refactoring.rename。 RenameJavaProjectProcessor 。重构参与者可以参与重构处理器的状态检查和更改创建。例如,要在重命名重构期间检查某些条件,您应该将 org.eclipse.ltk.core.refactoring。参与者.RenameParticipant ,覆盖方法 org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant.checkConditions(IProgressMonitor,CheckConditionsContext) 并通过扩展点 org.eclipse注册参与者。 ltk.core.refactoring.renameParticipants 。参与者 org.eclipse.jdt.internal.corext.refactoring.nls.NLSAccessorFieldRenameParticipant 给你一个很好的例子,说明如何参与重命名重构。



当你宣布你的扩展名为 org.eclipse.ltk .core.refactoring.renameParticipants 扩展点,您应该指定要让参与者获得通知的元素。例如,请参阅 org.eclipse.ltk.core.refactoring.renameParticipants 扩展点file / repository.grepcode.com / java / eclipse.org / 3.6.1 / org.eclipse.jdt / ui / 3.6.1 / plugin.xml /?v = sourcerel =noreferrer> org.eclipse.jdt.ui / plugin.xml 涉及参与者重命名字段。

 < extension point =org.eclipse.ltk.core.refactoring.renameParticipants> 
< renameParticipant class =org.eclipse.jdt.internal.corext.refactoring.nls.NLSAccessorFieldRenameParticipantid =org.eclipse.jdt.ui.NLSFieldRenameParticipantname =%Refactoring.NLSFieldRenameParticipant>
< enablement>
< with variable =affectedNatures>
< iterate operator =或>
< equals value =org.eclipse.jdt.core.javanature/>
< / iterate>
< / with>
< with variable =element>
< instanceof value =org.eclipse.jdt.core.IField/>
< / with>
< / enablement>
< / renameParticipant>
< / extension>


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>

这篇关于Eclipse重命名/重构覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆