我已经实现我的自己的编辑和加入一个代码完成的功能。我的内容助理注册源观结构是这样的:

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 + 空间 内部所需要的分区,完成的弹出窗口和按预期工作。

这里是我的问题..我怎么落实/登记文件弹出现下完成的弹出窗口?(例如在editor)

有帮助吗?

解决方案

好了,

我会answear问题我自己;-)

你必须添加这个线

assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));

配置上。然后当时创造的 CompletionProposals, 的第八次(最后一)参数所谓 additionalProposalInfo 构造正的文本,这将显示文档中弹出式窗口。

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

更多的信息,可以发现 在这里,.

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

其他提示

对于样式信息框(就像 JDT 中一样)。

Styled additionnal information


  • 默认信息控件 实例需要收到 HTMLTextPresenter.
  • import org.eclipse.jface.internal.text.html.HTMLTextPresenter;
    
    public class MyConfiguration extends SourceViewerConfiguration {
    
    
        [...]
        public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
            if (assistant == null) {
                [...]
                assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
            }
            return assistant;
        }
    
        @Override
        public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
            return new IInformationControlCreator() {
                public IInformationControl createInformationControl(Shell parent) {
                    return new DefaultInformationControl(parent,new HTMLTextPresenter(false));
                }
            };
        }
    }
    

  • 然后,提案可以在方法字符串中使用基本 HTML 标签 获取附加提案信息().
  • public class MyProposal implements ICompletionProposal {
        [...]
        @Override
        public String getAdditionalProposalInfo() {
            return "<b>Hello</b> <i>World</i>!";
        }
    }
    
    许可以下: CC-BY-SA归因
    不隶属于 StackOverflow
    scroll top