如何为“开放声明”定义自定义操作Eclipse 中的(快捷键 F3)
如何在插件中为“开放声明”(又名 F3)注册附加处理程序/操作/命令?
我想在 Java 代码中的字符串文字上使用 F3 来导航到声明资源包键的文件。我已经准备好了一个上下文菜单操作来完成这项工作。所缺少的只是一种将其绑定到用户习惯的密钥的方法。
完整的扩展点带注释列表的额外奖励。我厌倦了必须花半天时间才能找到我必须用于某个功能的扩展点。我所说的“带注释”的意思不仅仅是
Identifier: org.eclipse.ui.workbench.texteditor.quickdiffReferenceProvider
Description: Allows contributors to add reference providers for the quick diff display.
How do I register an additional handler/action/command for "Open Declaration" (aka F3) in a plugin?
I want to use F3 on String literals in Java code to navigate to the files declaring resource bundle keys. I already have a context menu action ready that does the job. All that's missing is a way to bind it to the key that users are used to.
Extra credit for a complete annotated list of extension points. I'm getting tired of having to spend half a day to find the extension point I have to use for a feature. And by "annotated" I mean more than
Identifier: org.eclipse.ui.workbench.texteditor.quickdiffReferenceProvider
Description: Allows contributors to add reference providers for the quick diff display.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(3)
不幸的是,没有扩展点可供您扩展此功能。我建议您停止尝试使用 Eclipse 命令框架。 JavaEditor 不使用该框架来注册其命令,而是在打开编辑器时注册命令。第三方没有简单的方法来扩展/改变这一点。
按下 F3 时运行的操作是 org.eclipse.jdt.ui.actions.OpenAction。
尽管没有简单的方法来扩展或更改 JavaEditor,但有一些方法可以做到这一点。我针对您的情况推荐的一种方法是通过 Equinox Aspects (http://www.eclipse.org/equinox/incubator/aspects/)。这允许您使用 AspectJ 融入 Eclipse 并根据需要进行更改。
这就是 AJDT (http://eclipse.org/ajdt) 能够改变 JDT 工作方式的方式。
在您的特定情况下,我建议创建一个针对 OpenAction 类实例化的切入点,并将其替换为您创建的实现。它通常委托给 JDT 的实现,或者在您需要时运行您的命令。
如果这就是您正在寻找的解决方案,那么我可以详细说明如何做到这一点。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
有关如何实现的详细说明,请参阅 Eclipse 命令教程中有关键绑定的部分命令处理程序并将它们绑定到按键、菜单和工具栏。
有一个 Eclipse 帮助中提供了完整的扩展点列表,但您必须深入了解才能获得完整的描述和代码示例。插件编辑器中还有一个“添加扩展点”向导,其中显示了简要说明、完整帮助的链接,对于某些扩展点甚至有预定义的模板。
See section on keybindings in Eclipse Commands tutorial for detailed instructions how to implement command handlers and bind them to keys, menus and toolbars.
There is a full list of extension points provided in Eclipse help, though you have to drill down to get the full description and code samples. There is also an "Add extension point" wizard in plugin editor, which shows a brief description, link to the full help and for some extension points even have predefined templates.