如何在eclipse编辑器插件中提供链接?

时间:2021-11-11 06:16:27

I'm writing an eclipse editor plugin for a custom file format and want to offer a way to quickly jump to the definition of an entity from a named reference to it - basically the "open declaration" functionality of the eclipse Java editor.

我正在为自定义文件格式编写一个eclipse编辑器插件,并希望提供一种方法,从命名引用快速跳转到实体的定义 - 基本上是eclipse Java编辑器的“开放声明”功能。

I know I can do this by registering an editor action and putting it in the context menu, but I'd really like the way all Java identifiers turn into links to their declaration when you press CTRL in the Java editor - how can I do that? I can't find anything about it in the documentation.

我知道我可以通过注册编辑器操作并将其放在上下文菜单中来实现这一点,但是当我在Java编辑器中按CTRL时,我真的很喜欢所有Java标识符转换成声明链接的方式 - 我该怎么做?我在文档中找不到任何相关内容。

1 个解决方案

#1


I think you are looking for hyper link detectors. Extension point is: org.eclipse.ui.workbench.texteditor.hyperlinkDetectors, Here is snippet from Mylyn plugin.xml:

我想你正在寻找超链接探测器。扩展点是:org.eclipse.ui.workbench.texteditor.hyperlinkDetectors,这是来自Mylyn plugin.xml的片段:

<extension point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors">
  <hyperlinkDetector            
        class="org.eclipse.mylyn.internal.tasks.ui.editors.TaskHyperlinkDetector"
        id="org.eclipse.mylyn.tasks.ui.hyperlinks.detectors.task"
        name="%TaskHyperlinkDetector.name"
        targetId="org.eclipse.ui.DefaultTextEditor">
  </hyperlinkDetector>

Also check out AbstractHyperlinkDetector, useful abstract class you can extend to provide your custom detector.

另请查看AbstractHyperlinkDetector,您可以扩展有用的抽象类以提供自定义检测器。

#1


I think you are looking for hyper link detectors. Extension point is: org.eclipse.ui.workbench.texteditor.hyperlinkDetectors, Here is snippet from Mylyn plugin.xml:

我想你正在寻找超链接探测器。扩展点是:org.eclipse.ui.workbench.texteditor.hyperlinkDetectors,这是来自Mylyn plugin.xml的片段:

<extension point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors">
  <hyperlinkDetector            
        class="org.eclipse.mylyn.internal.tasks.ui.editors.TaskHyperlinkDetector"
        id="org.eclipse.mylyn.tasks.ui.hyperlinks.detectors.task"
        name="%TaskHyperlinkDetector.name"
        targetId="org.eclipse.ui.DefaultTextEditor">
  </hyperlinkDetector>

Also check out AbstractHyperlinkDetector, useful abstract class you can extend to provide your custom detector.

另请查看AbstractHyperlinkDetector,您可以扩展有用的抽象类以提供自定义检测器。