我已经实现了自己的编辑器并为其添加了代码完成功能。我的内容助理在源查看器配置中注册,如下所示:
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;
}
When I press Ctrl + SPACE inside the desired partition, the completion popup appears and works as expected.
这是我的问题.. 如何实现/注册出现在完成弹出窗口旁边的文档弹出窗口? (例如在java编辑器中)
Well,
我自己来回答这个问题;-)
你必须添加这一行
assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
到上面的配置。然后创建的时候完成建议,第八个(最后一个)参数称为附加提案信息构造函数的文本是文本,它将显示在文档弹出窗口中。
new CompletionProposal(replacementString,
replacementOffset,
replacementLength,
cursorPosition,
image,
displayString,
contextInformation,
additionalProposalInfo);
更多相关信息可以找到here http://www.50001.com/language/javaside/lec/java_ibm/Equipping%20SWT%20%BE%D6%C7%C3%B8%AE%C4%C9%C0%CC%BC%C7%BF%A1%20content%20assistants%20%C3%DF%B0%A1%C7%CF%B1%E2%20(%BF%B5%B9%AE).htm.
很简单,不是吗……如果你知道怎么做的话;)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)