Eclipse编辑器悬停中的HTML标签 [英] HTML tags in Eclipse editor hover

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

问题描述

我在Eclipse中为自己的语言创建了一个编辑器。在这种语言中,有类似javadoc的文档注释。我在使用类 ITextHover 来显示此文档,当鼠标光标位于注释函数的名称之上时。



问题是我的文档包含基本的HTML标签(列表,表格,粗体),但悬停只显示纯文本。例如:





当然,我希望它看起来像这样:





我确定这种悬停的文本格式可以通过eclipse来处理,因为例如Java编辑器就是这样。



不幸的是,我发现的唯一线索是使用class IInformationPresenter ,而且我可以没有找到任何有关这个班级做什么或如何使用它的信息。有人可以帮忙吗?

解决方案

您的 ITextHover 类应该实现 ITextHoverExtension 并返回可以处理HTML的 IInformationControl 。标准 DefaultInformationControl 处理简单的HTML。



一个例子是来自标准文本编辑器的文本悬停:

  class TextHover extends DefaultTextHover implements ITextHoverExtension {
public TextHover(ISourceViewer sourceViewer){
super(sourceViewer);

$ b $ ...其他东西...
$ b $ @Override
public IInformationControlCreator getHoverControlCreator(){
return new IInformationControlCreator() {
@Override
public IInformationControl createInformationControl(Shell parent){
return new DefaultInformationControl(parent,EditorsUI.getTooltipAffordanceString());
}
};
}
}


I creating an editor for my own language in Eclipse. In this language, there are javadoc-like documentation comments. I'm using class ITextHover to show this documentation when the mouse cursor is above name of the commented function.

The problem is that my documentation contains basic HTML tags (list, table, bold) but the hover shows only plain text. For example:

Of course, I would like it to look like this:

I know for sure that this kind of text formatting in a hover can be handled by eclipse because e.g. Java editor does that.

Unfortunately, the only clue I found so far is to use class IInformationPresenter and I can't found any information about what this class does or how to use it. Can someone help?

解决方案

Your ITextHover class should implement ITextHoverExtension and return an IInformationControl that can handle HTML. The standard DefaultInformationControl handles simple HTML.

An example is the text hover from the standard text editor:

class TextHover extends DefaultTextHover implements ITextHoverExtension {
    public TextHover(ISourceViewer sourceViewer) {
        super(sourceViewer);
    }

    ... other stuff ...

    @Override
    public IInformationControlCreator getHoverControlCreator() {
        return new IInformationControlCreator() {
            @Override
            public IInformationControl createInformationControl(Shell parent) {
                return new DefaultInformationControl(parent, EditorsUI.getTooltipAffordanceString());
            }
        };
    }
}

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

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