Eclipse PDE:自定义 QuickFix 仅在问题视图中可用?
我在自定义快速修复方面遇到了麻烦,我想在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有同样的问题,我不确定这是否是正确的方法,但至少它有效:
如果您想在源代码查看器中查看快速修复,您必须设置一个
QuickAssistAssistant
为了它。在实现SourceViewerConfiguration
的类中覆盖getQuickAssistAssistant
。您可以实例化 org.eclipse.jface.text.quickassist.QuickAssistAssistant,但必须设置一个 QuickAssistProcessor,因此实现 org.eclipse.jface.text .quickassist.IQuickAssistProcessor 接口,特别是computeQuickAssistProposals
返回您的快速修复建议。另请查看上一篇文章 这里,有点乱,但是你会明白的。看看这段代码此处 是
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 implementingSourceViewerConfiguration
overridegetQuickAssistAssistant
. You can instantiateorg.eclipse.jface.text.quickassist.QuickAssistAssistant
, but you have to set aQuickAssistProcessor
, so implement theorg.eclipse.jface.text.quickassist.IQuickAssistProcessor
interface, especiallycomputeQuickAssistProposals
to return your quick fix proposals.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 yourQuickAssistProcessor
.如果您只是向标记扩展点添加一行:
并向标记添加属性
marker.setAttribute(IMarker.CHAR_START, ...);
marker.setAttribute(IMarker.CHAR_END, ...);
您将能够得到这个:
但我仍然找不到如何更改标记图标(与灯泡变体)单击注释图标后也会显示可能的快速修复。
If you simply add one line to the marker extension point:
and add attributes to the marker
marker.setAttribute(IMarker.CHAR_START, ...);
marker.setAttribute(IMarker.CHAR_END, ...);
You will be able get this:
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.