我如何在Eclipse编辑器插件中指示语法错误(例如非法的令牌序列),就像在Eclipse Java编辑器中一样,即通过红色波浪线、滚动条上的红色标记(可跳转)和当您将鼠标悬停在其中一个时出现的说明性消息?
我正在编写一款用于定制文件格式的 Eclipse 编辑器插件(具体来说,是用于 Shark3D 游戏引擎中的“蛇文件格式”)。我已经实现了一个扫描仪以实现语法高亮和大纲。
- For the underlines, do I simply have the scanner return an
IToken
with a "wriggly underline"TextAttribute
instead of the normal one, or is there a specific mechanism for marking syntax errors? - How do I implement the scrollbar markers? Is
IAnnotationModel
the relevant interface here? If so, where do I register the implementation so that the markers appear? - I ve only found
SourceViewerConfiguration.getAnnotationHover()
, which would allow me to implement the hover behaviour, but only for the "annotation", which I suppose means the scrollbar markers - how do I implement the hover behaviour for the text itself?
我会很高兴得到具体建议,以及涵盖这个主题的教程URL - Eclipse帮助文档和示例似乎没有涉及到。
Edit:
Markers are the best solutions to this. A working example of how to use them can be found in the plugin example code in org.eclipse.ui.examples.readmetool.AddReadmeMarkerAction