我正在制作一个支持nodeJS框架的IntelliJ插件。我正在尝试实现自动补全功能,但不知道如何在列表顶部设置自动补全位置。首先,我有其他的自动补全功能(mozilla等)。
下面是我的代码:
LookupElementBuilder
.create(completionString)
.withBoldness(true)
.withCaseSensitivity(false)
.withIcon(SailsJSIcons.SailsJS)
.withPresentableText("\t\t\t" + item)
.withAutoCompletionPolicy(AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE);我想handleInsert可以帮助我,但不知道如何使用它
发布于 2017-11-30 07:31:43
您可以在plugin.xml中的completion.contributor上设置order="first"。看起来它会让你的贡献者在其他来源的贡献者之前被调用,导致你的建议被放在第一位:
<extensions defaultExtensionNs="com.intellij">
<completion.contributor order="first" language="PHP" implementationClass="org.klesun.deep_assoc_completion.entry.DeepKeysCbtr"/>当您的贡献者第一次被调用时,您还可以编写代码来决定如何定位以下建议,或者使用CompletionResultSet::runRemainingContributes()和@peter-gromov建议的PrioritizedLookupElement::withPriority()完全排除其中一些建议:
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));
});
}发布于 2015-04-17 16:41:35
您可以尝试通过PrioritizedLookupElement#withPriority为查找元素指定显式的高优先级。
https://stackoverflow.com/questions/29693660
复制相似问题