Eclipse PDE:Custom QuickFix仅在问题视图中可用? [英] Eclipse PDE: Custom QuickFix only available in Problems View?

查看:208
本文介绍了Eclipse PDE:Custom QuickFix仅在问题视图中可用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Eclipse插件中提供了自定义快速修复的麻烦,我希望在Eclipse PDE中比我更有经验的人在这个问题上为我提供一些提示。 / p>

正如我所理解的,我可以通过扩展扩展点来提供定制所谓的快速修复(或分辨率,在Eclipse里面的术语) org.eclipse.ui.ide.markerResolution 针对特定的标记标识,例如一些默认的Eclipse标记, org.eclipse.core.resources.problemmarker



这适用于我的默认标记类型和自定义标记类型, BUT
QuickFixes,我的IMarkerResolutionGenerator 提供,只能从我的标记显示的问题 - 查看而不是编辑器访问。



我有什么:我在默认文本编辑器中创建标记,这会导致(1)一个带有标记工具提示消息的图标,显示在(2)编辑器右侧的标记,(3)编辑器中的一些带下划线的字符,以及(4)问题中的条目 - 查看。



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



但是

strong>:只有在问题 - 查看中,我可以通过按Strg + 1或从上下文菜单中获取快速修复。



这是正常的行为,我是否必须访问另一个扩展点或特定的编辑器功能,将我的快速修复挂钩到它们中?我没有发现任何有关它的细节,除了每个人似乎都很高兴与我上面提到的这个唯一的扩展点。我缺少什么?



要完成,这里是我的扩展点定义:

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


解决方案

我有同样的问题,我不知道如果这是正确的方法,但至少它是有效的:



如果你想在源代码查看器中看到你的快速修复,你必须设置一个 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 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>

解决方案

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.

这篇关于Eclipse PDE:Custom QuickFix仅在问题视图中可用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆