IntelliJ Plugin AutoFill

I am creating an IntelliJ plugin to support nodeJS infrastructure. I am trying to implement an autocomplete function, but I don’t know how to set the autocomplete position at the top of the list. First I have another autocomplete (mozilla ect ..).

Here is my code:

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

I suppose handleInsert might help me, but can't find how to use it

+5
source share
2 answers

You can try to specify an explicit high priority for your search items through PrioritizedLookupElement # withPriority.

0
source

You can set order="first" to completion.contributor in plugin.xml . It seems that your contributor will be called in front of participants from other sources, as a result your suggestions will be the first:

 <extensions defaultExtensionNs="com.intellij"> <completion.contributor order="first" language="PHP" implementationClass="org.klesun.deep_assoc_completion.entry.DeepKeysCbtr"/> 

When your contributor is called first, you can also write code to decide how to post the following sentences or exclude some of them using CompletionResultSet::runRemainingContributes() and PrioritizedLookupElement::withPriority() suggested by @ peter-gromov:

 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)); }); } 
0
source

All Articles