Eclipse PDE:自定义 QuickFix 仅在问题视图中可用?

发布于 2024-12-27 04:54:37 字数 1158 浏览 1 评论 0原文

我在自定义快速修复方面遇到了麻烦,我想在 Eclipse 插件中提供这些修复,并且我希望在 Eclipse PDE 方面比我更有经验的人能够在这个问题上为我提供一些提示。

据我了解,我可以通过扩展扩展点 org.eclipse.ui.ide.markerResolution 来提供自定义的所谓“快速修复”(或“解决方案”,在 Eclipse 内部术语中)特定标记 ID,例如某些默认 Eclipse 标记,org.eclipse.core.resources.problemmarker

这对我来说适用于默认标记类型和自定义标记类型,但是: 我的 IMarkerResolutionGenerator 提供的 QuickFixes 只能从“问题”视图访问,而不能从显示我的标记的编辑器访问。

我所拥有的:我在默认文本编辑器中创建标记,这会导致 (1) 带有标记工具提示消息的图标显示在标记分配到的行的左侧编辑器标尺上,(2) 编辑器右侧的标记,(3) 编辑器中的一些带下划线的字符,以及 (4) “问题”视图中的条目。

我想要的:就像在 Java IDE 支持中一样,我想按 Strg+1,或上下文菜单 -> 快速修复,或单击左侧标尺上的错误图标,查看可用的快速修复并选择一个。

但是:只有在问题视图中,我才能通过按 Strg+1 或从上下文菜单中获得快速修复。

这是正常行为吗?我是否必须访问另一个扩展点或特定的编辑器功能才能将我的快速修复挂钩到其中?我还没有找到任何关于它的详细信息,除了每个人似乎都对我上面提到的这个唯一的扩展点非常满意。我缺少什么?

为了完整起见,这是我的扩展点定义:

<extension point="org.eclipse.ui.ide.markerResolution">
    <markerResolutionGenerator
        class="com.markers.test.MarkerResolutionGenerator"
        markerType="org.eclipse.core.resources.problemmarker">
    </markerResolutionGenerator>
</extension>

i am having trouble with custom quick-fixes, which i want to provide in my Eclipse plug-in, and i'm hoping for someone more experienced than me in Eclipse PDE to have some hints for me on this issue.

As i have understood, i can provide custom so-called "quick fixes" (or "resolutions", in Eclipse inside terminology), by extending the extension point org.eclipse.ui.ide.markerResolution for a specific marker id, such as for example some default Eclipse marker, org.eclipse.core.resources.problemmarker.

This works for me for the default marker types and for custom marker types, BUT:
The QuickFixes, which my IMarkerResolutionGenerator provides, are only accessible from the "Problems"-View, not from the Editor, in which my markers show up.

What i have: I create markers in the default text editor, which causes (1) an icon with the markers tooltip message to show up on the left editor ruler at the line, which the marker is assigned to, (2) a marker on the right side of the editor, (3) some underlined characters in the editor, and (4) an entry in the "Problems"-view.

What i want: Just like in Java IDE support, i want to press Strg+1, or Context-Menu->Quick Fix, or to click at the error icon on the left-side-ruler, to see the available quick-fixes and to select one.

However: Only in the Problems-View am i able to get the Quick-Fixes, by pressing Strg+1 or from the context menu.

Is this the normal behaviour, and do i have to access another extension point, or the specific editors features, to hook my quick fixes into them? I haven't found anything much detailed about it, except that everybody seems to be pretty happy with this only extension point that i have mentioned above. What am i missing?

For completion, here is my extension point definition:

<extension point="org.eclipse.ui.ide.markerResolution">
    <markerResolutionGenerator
        class="com.markers.test.MarkerResolutionGenerator"
        markerType="org.eclipse.core.resources.problemmarker">
    </markerResolutionGenerator>
</extension>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

皇甫轩 2025-01-03 04:54:37

我有同样的问题,我不确定这是否是正确的方法,但至少它有效:

如果您想在源代码查看器中查看快速修复,您必须设置一个 QuickAssistAssistant为了它。在实现 SourceViewerConfiguration 的类中覆盖 getQuickAssistAssistant。您可以实例化 org.eclipse.jface.text.quickassist.QuickAssistAssistant,但必须设置一个 QuickAssistProcessor,因此实现 org.eclipse.jface.text .quickassist.IQuickAssistProcessor 接口,特别是 computeQuickAssistProposals 返回您的快速修复建议。

public IQuickAssistAssistant getQuickAssistAssistant(ISourceViewer sourceViewer) {
  IQuickAssistAssistant quickAssist = new QuickAssistAssistant();
  quickAssist.setQuickAssistProcessor(new MyQuickAssistProcessor());
  quickAssist.setInformationControlCreator(getInformationControlCreator(sourceViewer));
  return quickAssist; 
}

另请查看上一篇文章 这里,有点乱,但是你会明白的。看看这段代码此处ICompletionProposal 的示例实现,您必须在您的QuickAssistProcessor

I have the same problem and I'm not sure, if this is the right way, but at least it works:

If you want to see your quick fixes in the source viewer you have to set an QuickAssistAssistant for it. In your class implementing SourceViewerConfiguration override getQuickAssistAssistant. You can instantiate org.eclipse.jface.text.quickassist.QuickAssistAssistant, but you have to set a QuickAssistProcessor, so implement the org.eclipse.jface.text.quickassist.IQuickAssistProcessor interface, especially computeQuickAssistProposals to return your quick fix proposals.

public IQuickAssistAssistant getQuickAssistAssistant(ISourceViewer sourceViewer) {
  IQuickAssistAssistant quickAssist = new QuickAssistAssistant();
  quickAssist.setQuickAssistProcessor(new MyQuickAssistProcessor());
  quickAssist.setInformationControlCreator(getInformationControlCreator(sourceViewer));
  return quickAssist; 
}

Also have a look at the code in the last post here, it is a bit messy, but you will get it. And look at this code here for an example implementation of ICompletionProposal, which you will have to return in your QuickAssistProcessor.

_失温 2025-01-03 04:54:37

如果您只是向标记扩展点添加一行:

<super type="org.eclipse.core.resources.textmarker"/>

并向标记添加属性
marker.setAttribute(IMarker.CHAR_START, ...);
marker.setAttribute(IMarker.CHAR_END, ...);

您将能够得到这个:

displayed fast fix as text hoover

但我仍然找不到如何更改标记图标(与灯泡变体)单击注释图标后也会显示可能的快速修复。

If you simply add one line to the marker extension point:

<super type="org.eclipse.core.resources.textmarker"/>

and add attributes to the marker
marker.setAttribute(IMarker.CHAR_START, ...);
marker.setAttribute(IMarker.CHAR_END, ...);

You will be able get this:

displayed quick fix as text hover

But I still can't found how to change marker icon (to variant with bulb) a show possible quick fix also after click on the annotation icon.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文