Kotlin auto-complete

Answered

I have tried using my own weigher and that did not work.  I am using the priority and proximity and I am not able to make my completions the highest likely match.  It works great in Java and Python.  But, Kotlin is giving me issues.  I always end up at the top or bottom and the highest likely match is in the middle.

Any help would be appreciated!  Thanks!

lookupElement = PrioritizedLookupElement.withGrouping(lookupElement, 79);
lookupElement = PrioritizedLookupElement.withPriority(lookupElement, 1000);
lookupElement = PrioritizedLookupElement.withExplicitProximity(lookupElement, 1);

result.addElement(lookupElement);
0
9 comments
PrioritizedLookupElement.withPriority

should work by itself. See also

* To debug the order of the completion items use '<code>Dump lookup element weights to log</code>' action when the completion lookup is
* shown (Ctrl+Alt+Shift+W / Cmd+Alt+Shift+W), the action also copies the debug info to the Clipboard.
0

Just wanted to say thanks!  That did the trick.  I also set my proximity to 0.

0

Hi, 

I'm hoping someone will respond to this same thread.  Everything worked fine with 2019 version of IntelliJ products.  But, it stopped working in Android Studio 4.0 and IntelliJ 2020.  My lookup items are now always at the bottom.  Thanks!

0

Did you accidentally switch on "sort by alphabet" in lookup list?

Do you have exact same set of plugins installed in both IDEs? Do you get general same set of lookup elements, just the ordering is "wrong"?

0

The plugin is unchanged.  I upgraded to Android 4.0 and with it there has been some Kotlin plugin updates.  Other than that, it is the same.  Our plugin is not tied to a particular Kotlin plugin version.  Also, there is no sort by name is not on.  Other than the order, everything looks fine.

0

Please attach results from "Dump lookup elements weights to log" (see above) from both versions to compare and clearly mark your items vs other/builtin

0

I will save you the extended list.  But, it appears that my sorter is always second now.  

Here is a working copy:

selected: LookupElementBuilder: string="new_flow"; handler=com.optimizely.intellij.plugin.contributor.kotlin.OptimizelyKotlinComplete$1$1@6b67525d

prefix:

weights:

"new_flow"      frozen=true, sorter=1, priority=10009.0, stats=0, ml_rank=NONE

"new_route"     frozen=false, sorter=1, priority=10000.0, stats=0, ml_rank=NONE

feature frozen=false, sorter=2, liftShorter=false, kotlin.deprecated=0, kotlin.smartInBasic=4294967296011, kotlin.kind=callable, kotlin.callableWeight=CompoundWeight(weight1=local, receiverIndex=2147483647, weight2=other), stats=0, kotlin.variableOrFunction=variable, kotlin.imported=null, proximity=[referenceList=unknown, samePsiMember=0, groovyReferenceListWeigher=unknown, javaInheritance=false, explicitlyImported=300, openedInEditor=true, sameDirectory=true, javaInheritance=null, sameLogicalRoot=true, sameModule=2, knownElement=0, inResolveScope=true, sdkOrLibrary=false], kotlin.preferContextElements=false, kotlin.proximity=[referenceList=unknown, samePsiMember=0, groovyReferenceListWeigher=unknown, javaInheritance=false, explicitlyImported=300, openedInEditor=true, sameDirectory=true, javaInheritance=null, sameLogicalRoot=true, sameModule=2, knownElement=0, inResolveScope=true, sdkOrLibrary=false], kotlin.byNameAlphabetical=feature, kotlin.preferLessParameters=null, ml_rank=NONE

and now it seems mine is sorter=2.  See below:


selected: LookupElementBuilder: string=feature; handler=org.jetbrains.kotlin.idea.completion.handlers.BaseDeclarationInsertHandler@1c400806

prefix:

weights:

feature frozen=true, sorter=1, liftShorter=false, kotlin.smartInBasic=4294967296010, kotlin.kind=callable, kotlin.callableWeight=CompoundWeight(weight1=local, receiverIndex=2147483647, weight2=other), stats=0, kotlin.variableOrFunction=variable, kotlin.imported=null, proximity=[referenceList=unknown, samePsiMember=0, groovyReferenceListWeigher=unknown, javaInheritance=false, explicitlyImported=300, openedInEditor=true, sameDirectory=true, javaInheritance=null, sameLogicalRoot=true, sameModule=2, knownElement=0, inResolveScope=true, sdkOrLibrary=false], kotlin.preferContextElements=false, kotlin.proximity=[referenceList=unknown, samePsiMember=0, groovyReferenceListWeigher=unknown, javaInheritance=false, explicitlyImported=300, openedInEditor=true, sameDirectory=true, javaInheritance=null, sameLogicalRoot=true, sameModule=2, knownElement=0, inResolveScope=true, sdkOrLibrary=false], kotlin.byNameAlphabetical=feature, kotlin.preferLessParameters=null

userId  frozen=true, sorter=1, liftShorter=false, kotlin.smartInBasic=11, kotlin.kind=callable, kotlin.callableWeight=CompoundWeight(weight1=local, receiverIndex=2147483647, weight2=other), stats=0, kotlin.variableOrFunction=variable, kotlin.imported=null, proximity=[referenceList=unknown, samePsiMember=0, groovyReferenceListWeigher=unknown, javaInheritance=false, explicitlyImported=300, openedInEditor=true, sameDirectory=true, javaInheritance=null, sameLogicalRoot=true, sameModule=2, knownElement=0, inResolveScope=true, sdkOrLibrary=false], kotlin.preferContextElements=false, kotlin.proximity=[referenceList=unknown, samePsiMember=0, groovyReferenceListWeigher=unknown, javaInheritance=false, explicitlyImported=300, openedInEditor=true, sameDirectory=true, javaInheritance=null, sameLogicalRoot=true, sameModule=2, knownElement=0, inResolveScope=true, sdkOrLibrary=false], kotlin.byNameAlphabetical=userId, kotlin.preferLessParameters=null

...

values-xlarge-land      frozen=false, sorter=1, liftShorter=false, kotlin.smartInBasic=0, kotlin.kind=packages, kotlin.callableWeight=null, stats=0, kotlin.variableOrFunction=null, kotlin.imported=null, proximity=null, kotlin.preferContextElements=false, kotlin.proximity=null, kotlin.byNameAlphabetical=values-xlarge-land, kotlin.preferLessParameters=null

"new_flow"      frozen=false, sorter=2, priority=10009.0, stats=9995

"new_route"     frozen=false, sorter=2, priority=10000.0, stats=9999

 

0

Can you please try and use

order="first, before KotlinCompletionContributor" 

for your completion contributor in your 'plugin.xml' configuration?

0

That fixed it.  I didn't know you could combine directives.  I tried "first" and "before KotlinCompletionContributor" but not the two combination.  Thanks!

0

Please sign in to leave a comment.