Plugins IntelliJ插件自动完成

Plugins IntelliJ插件自动完成,plugins,intellij-idea,autocomplete,intellij-plugin,Plugins,Intellij Idea,Autocomplete,Intellij Plugin,我正在制作一个IntelliJ插件来支持nodeJS框架。 我正在尝试实现自动完成功能,但不知道如何设置列表顶部的自动完成位置。首先,我有其他自动完成功能(mozilla等) 这是我的密码: LookupElementBuilder .create(completionString) .withBoldness(true) .withCaseSensitivity(false)

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

这是我的密码:

LookupElementBuilder
                .create(completionString)
                .withBoldness(true)
                .withCaseSensitivity(false)
                .withIcon(SailsJSIcons.SailsJS)
                .withPresentableText("\t\t\t" + item)
                .withAutoCompletionPolicy(AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE);

我想
handleInsert
可以帮助我,但找不到如何使用它

您可以尝试通过prioritydlookupelement#with priority为查找元素指定明确的高优先级。

您可以在
plugin.xml
中的
completion.contributor
上设置
顺序=“first”
。看起来它会使您的贡献者在其他来源的贡献者之前被调用,从而使您的建议排在第一位:


首先调用贡献者时,您还可以编写代码来决定如何定位以下建议或使用@peter gromov建议的
CompletionResultSet::RunRemainingContributions()
PrioritizedLookupElement::withPriority()
将其中一些建议排除在外:

受保护的void addCompletions(CompletionParameters参数、ProcessingContext ProcessingContext、CompletionResultSet结果)
{
//…这里有些代码。。。
result.runRemainingContributors(参数,otherSourceResult->{
//2000是任何数字-使其小于您的建议,将此建议放低
addElement(PrioritizedLookupElement.withPriority(otherSourceResult.getLookupElement(),2000));
});
}

我只是尝试了一下,但位置是一样的,使用PrioritizedLookupElement时它们根本不会移动。使用Priority(lookup,LookupValueWithPriority.HIGHER)或High则需要更多信息。例如,由DumpLookupElementWeights操作打印的项目权重(打开查找列表时ctrl/command+alt+shift+w)