Eclipse:在独立 SourceViewer 小部件中启用 Java 错误标记
因此,我正在使用 Eclipse,并尝试在独立的 SourceViewer 中启用 Java 错误突出显示。我在网上搜索了很多,但似乎没有任何结果。我已经研究过处理注释、标记等...出现的所有内容似乎都是为了实现自定义方法。
http://wiki.eclipse.org/Platform_Text
有所帮助,但似乎并不完全是什么我想。
SourceViewer 将是一个基本的 Java 编辑器,因此可以假设所有内容都是 Java 代码。我只是希望红色波浪线出现在语法错误下,也许侧面的标尺上也有红色框。应该有一个默认的简单方法来启用此功能,但我找不到它。
提前致谢!
So I am working with Eclipse, and am trying to enable Java error highlighting inside of a standalone SourceViewer. I have done quite a bit of searching the web, but nothing seems to come up. I have looked into dealing with Annotations, Markers, etc... Everything that comes up seems to be for implementing custom methods.
http://wiki.eclipse.org/Platform_Text
has helped a bit, but seems to be not exactly what I want.
The SourceViewer is going to be a basic Java editor, so it can be assumed that everything will be java code. I would just like the red squiggly lines to appear under syntax errors, maybe also have the red boxes on a ruler on the side. There should be a default easy way to enable this, but I cannot find it.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是可行的,但可能需要一些工作。困难在于,独立的 SourceViewer 小部件不支持执行大量工作的 IDocumentProvider 接口,因此您必须自己完成所有这些工作。
我发现这篇文章在添加红色波浪线方面很有帮助:
http://www.eclipsezone.com/eclipse/forums/t30082.html
对于波浪线,您需要设置一个 AnnotationPainter。
如果您想要标尺上的红色框,请使用接受
IOverviewRuler
的 SourceViewer 构造函数。有一个标准的 OverviewRuler 应该适合您。It is doable, but it can be a bit of work. What makes it difficult is that a standalone
SourceViewer
widget doesn't support theIDocumentProvider
interface that does a lot of the work so you have to do all of that yourself.I found this post helpful as far as adding the red squiggly lines is concerned:
http://www.eclipsezone.com/eclipse/forums/t30082.html
For the squiggly lines you want to set up an
AnnotationPainter
.If you want the red boxes on a ruler, use the SourceViewer constructor that accepts an
IOverviewRuler
. There's a standard OverviewRuler that should work for you.+1 为thehiatus。
注释的东西真的很复杂。一段时间前,我尝试将编辑器转换为
IViewPart
...花了很长时间才让它工作...好吧几乎...几乎,但很像真实的东西:- )(有点像 Swing 和 Microsoft Vista)。另请查看
TextEditor
以及方法createAnnotationAccess()
和configureSourceViewerDecorationSupport(...)
。+1 for thehiatus.
The annotation stuff is really complicated. I tried to convert an editor to a
IViewPart
some time back... It took at long time to get it to work... well almost... almost, but quite like the real thing :-) (A bit like Swing and Microsoft Vista).Also have a look at
TextEditor
and the the methodscreateAnnotationAccess()
andconfigureSourceViewerDecorationSupport(...)
.