如何在eclipse文本编辑器中覆盖SourceViewerConfiguration

时间:2016-05-25 10:02:01

标签: java eclipse eclipse-plugin hover

我正在制作从日食文本悬停延伸的eclipse插件文本悬停。 我正在努力创造自己的设计"对于使用方法

的文本悬停
public IInformationControlCreator getHoverControlCreator() 

在我自己的TextHover类中,但是当我专注于我的悬停时,我在函数中给出的信息会返回默认值。 我读到我需要使用以下函数在SourceViewerConfiguration类中设置IInformationControlCreator:

getInformationControlCreator

但是,我无法覆盖SourceViewerConfiguration。

这是我的覆盖功能:

package TextHoverPackage;
import org.eclipse.jface.text.ITextHover;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
public class TextHoverSourceViewerConfig extends SourceViewerConfiguration {
    public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
        System.out.println("I am in other place!!!");
        return new JavaTextHover();
    }
}

"我在其他地方!!!"消息未打印 我试图在plugin.xml页面的扩展点编写这个类,但是我得到了这个类的扩展点错误:

org.eclipse.jface.text.source.SourceViewerConfiguration

无法创建。

所以我很乐意知道如何覆盖SourceViewerConfiguration类。

1 个答案:

答案 0 :(得分:0)

您无法更改现有编辑器的主SourceViewerConfiguration

设置不同SourceViewerConfiguration的唯一方法是创建一个新的编辑器。