Eclipse 插件中标记的悬停文本 [英] Hover text for Marker in Eclipse plugin

查看:17
本文介绍了Eclipse 插件中标记的悬停文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有问题标记的自定义编辑器.标记在问题"中正确显示.带有图标、位置和文本的视图,问题图标正确显示在编辑器的左边距.

I have a custom editor with problem markers. The markers display correctly in the "problems" view with icon, location and text, and the problem icons display correctly in the left margin of the editor.

我想在将鼠标悬停在边距中的问题标记图标上时在弹出窗口中显示相同的错误消息文本,就像在 Java 编辑器中发生的那样.现在没有弹出窗口.

I would like to display the same error message text in a popup when hovering over the problem marker icon in the margin, just as it happens in the Java editor. Right now there in no popup.

有没有简单的方法来实现这一点?

Is there an easy way to achieve this?

答案:

好的,看起来该功能不是内置在标记系统中的.好像已经提交了一个补丁,所以可能会在以后的版本中添加,但在此之前它也很容易手动创建.

OK, it doesn't look like the functionality is built-in in the marker-system. It seems a patch have been submitted, so it will probably be added in a later version, but until then it is also pretty easy create by hand.

  1. 创建一个实现IAnnotationHover的类并实现getHoverInfo().
  2. 返回SourceViewerConfigurationgetAnnotationHover()方法中的类.
  3. getHoverInfo()方法中,调用ISourceViewer.getAnnotationModel().getAnnotationIterator()获取所有标记.
  4. 选择与行号对应的标记,并返回标记文本.
  1. Create an class that implements IAnnotationHover and implement getHoverInfo().
  2. Return the class in getAnnotationHover() method in the SourceViewerConfiguration.
  3. In getHoverInfo() method, call ISourceViewer.getAnnotationModel().getAnnotationIterator() to get all markers.
  4. Select the marker(s) that correspond to the line number, and return the marker text.

推荐答案

这个 eclipse 插件 xtext 中的错误提出了一个补丁来在悬停和状态行上显示标记工具提示.如果您查看随附的补丁程序,您会找到您需要的答案.

This bug in eclipse plug-in xtext proposes a patch to show a marker tooltip on hover and status line. If you look at the attached patches you could find the answers you need.

这篇关于Eclipse 插件中标记的悬停文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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