首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >IntelliJ插件自动完成

IntelliJ插件自动完成
EN

Stack Overflow用户
提问于 2015-04-17 16:07:16
回答 2查看 671关注 0票数 5

我正在制作一个支持nodeJS框架的IntelliJ插件。我正在尝试实现自动补全功能,但不知道如何在列表顶部设置自动补全位置。首先,我有其他的自动补全功能(mozilla等)。

下面是我的代码:

代码语言:javascript
复制
LookupElementBuilder
                .create(completionString)
                .withBoldness(true)
                .withCaseSensitivity(false)
                .withIcon(SailsJSIcons.SailsJS)
                .withPresentableText("\t\t\t" + item)
                .withAutoCompletionPolicy(AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE);

我想handleInsert可以帮助我,但不知道如何使用它

EN

回答 2

Stack Overflow用户

发布于 2017-11-30 07:31:43

您可以在plugin.xml中的completion.contributor上设置order="first"。看起来它会让你的贡献者在其他来源的贡献者之前被调用,导致你的建议被放在第一位:

代码语言:javascript
复制
<extensions defaultExtensionNs="com.intellij">
    <completion.contributor order="first" language="PHP" implementationClass="org.klesun.deep_assoc_completion.entry.DeepKeysCbtr"/>

当您的贡献者第一次被调用时,您还可以编写代码来决定如何定位以下建议,或者使用CompletionResultSet::runRemainingContributes()和@peter-gromov建议的PrioritizedLookupElement::withPriority()完全排除其中一些建议:

代码语言:javascript
复制
protected void addCompletions(CompletionParameters parameters, ProcessingContext processingContext, CompletionResultSet result) 
{
    // ... some of your code here ...

    result.runRemainingContributors(parameters, otherSourceResult -> {
        // 2000 is any number - make it smaller than on your suggestion to position this suggestion lower
        result.addElement(PrioritizedLookupElement.withPriority(otherSourceResult.getLookupElement(), 2000));
    });
}
票数 1
EN

Stack Overflow用户

发布于 2015-04-17 16:41:35

您可以尝试通过PrioritizedLookupElement#withPriority为查找元素指定显式的高优先级。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29693660

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档