简体   繁体   English

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

[英]Eclipse PDE: Custom QuickFix only available in Problems View?

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. 我在自定义快速修复方面遇到了麻烦,我希望在我的Eclipse插件中提供,我希望Eclipse PDE中比我更有经验的人在这个问题上给我一些提示。

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 . 据我了解,我可以通过扩展特定标记id的扩展点org.eclipse.ui.ide.markerResolution来提供定制的所谓“快速修复”(或“解决方案”,在Eclipse内部术语中),例如例如一些默认的Eclipse标记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. 这适用于我的默认标记类型和自定义标记类型, 但是 :我的IMarkerResolutionGenerator提供的QuickFix只能从“Problems”-View访问,而不能从我的标记显示的编辑器中访问。

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

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

However : Only in the Problems-View am i able to get the Quick-Fixes, by pressing Strg+1 or from the context menu. 但是 :只有在问题 - 视图中我才能通过按Strg + 1或从上下文菜单中获得快速修复。

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>

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. 如果要在源查看器中查看快速修复,则必须为其设置QuickAssistAssistant In your class implementing SourceViewerConfiguration override getQuickAssistAssistant . 在您的类中实现SourceViewerConfiguration覆盖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. 您可以实例化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; 
}

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 . 这里查看此代码以获取ICompletionProposal的示例实现,您必须在QuickAssistProcessor返回该实现。

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_START,...); marker.setAttribute(IMarker.CHAR_END, ...); 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. 但我仍然无法找到如何更改标记图标(与灯泡变体)一个节目可能快速修复也点击注释图标后。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM