如何在Eclipse RCP中实现内容帮助的文档弹出窗口 [英] How to implement content assist's documentation popup in Eclipse RCP

查看:160
本文介绍了如何在Eclipse RCP中实现内容帮助的文档弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了自己的编辑器并添加了一个代码完成功能。我的内容助手在源代码查看器配置中注册:

I have implemented my own editor and added a code completion functionality to it. My content assistant is registered in source viewer configuration like this:

public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
    if (assistant == null) {
        assistant = new ContentAssistant();
        assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
        assistant.setContentAssistProcessor(getMyAssistProcessor(),
                MyPartitionScanner.DESIRED_PARTITION_FOR_MY_ASSISTANCE);
        assistant.enableAutoActivation(true);
        assistant.setAutoActivationDelay(500);
        assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
        assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
    }
    return assistant;
}

当我按 Ctrl + SPACE

When I press Ctrl + SPACE inside the desired partition, the completion popup appears and works as expected.

这是我的问题..如何实现/注册出现的文档弹出窗口旁边完成弹出窗口? (例如在java编辑器中)

And here's my question.. How do I implement/register a documentation popup that appears next to completion popup? (For example in java editor)

推荐答案

嗯,

我自己会问这个问题; - )

I'll answear the question myself ;-)

你必须添加这一行

assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));

到上面的配置。然后,当创建 CompletionProposals 时,构造函数的第八个(最后一个)参数称为 additionalProposalInfo ,该文本将显示在文档弹出窗口中。

to the configuration above. Then when creating CompletionProposals, the eighth (last) parameter called additionalProposalInfo of the constructor is the text, which will be shown in the documentation popup.

new CompletionProposal(replacementString,
                          replacementOffset,
                          replacementLength,
                          cursorPosition,
                          image,
                          displayString,
                          contextInformation,
                          additionalProposalInfo);

有关更多信息可以找到这里

More information about can be found here.

容易,不是吗?如果你知道该怎么做;)

Easy, isn't it.. if you know how to do it ;)

这篇关于如何在Eclipse RCP中实现内容帮助的文档弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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