Status Update
Comments
ba...@google.com <ba...@google.com>
al...@rockettrade.com <al...@rockettrade.com> #2
Also the autogenerating functions (create member...), the IDE fills in an extreme amount of boilerplate code that I need to go and manually remove each time.
example:
fun doSomething(value: Boolean, anotherValue: String): Float { }
becomes:
fun doSomething(value: kotlin.Boolean, anotherValue: kotlin.String): kotlin.Float { }
an...@google.com <an...@google.com> #3
Thanks for the feedback. To help us troubleshoot this issue further, we will need more information.
Please share diagnostic logs, which can be found by going to Help
> Collect Logs and Diagnostic Data
.
ey...@gmail.com <ey...@gmail.com> #4
I imagine #2 is a separate issue, but there is something fundamentally wrong with autocomplete suggestions in Android Studio. I don't know if this is an Android Studio thing, or an Intellij thing, but it is very annoying.
My latest example is typing emptyLis
shows the emptyList
function as the last item, and all of the androidx.collections
suggestions wouldn't even match the type that I'm setting the value for.
I will attach the logs and diagnostic data in a separate comment.
ey...@gmail.com <ey...@gmail.com> #5 Restricted
an...@google.com <an...@google.com> #6
Please check whether the ML-Assisted completion setting is enabled:
- Go to
Settings
>Editor
>General
>Code Completion
- Find the "Machine Learning-Assisted Completion" section.
- Enable "Sort completion suggestions based on machine learning".
I suspect this feature is turned off; I can reproduce your problem (sometimes) when I disable that function, but not otherwise.
If you're interested in seeing what this is actually doing, enable the following "Mark position changes" setting. That will show you something like the attached screenshot, where you can see the ML-Assist is what's pushing null
up to its "correct" position.
ey...@gmail.com <ey...@gmail.com> #7
I thought that might be it, but it was enabled. I tested with it enabled and disabled and the results were the same.
an...@google.com <an...@google.com> #8
Alright, then let's try to get some debug info:
- Trigger a completion so that misordered items are there.
- While the suggestion popup is open, press Ctrl+Alt+Shift+W. This should copy debug info to the clipboard.
Go ahead and attach that here. It will give us information about why the items are ranked the way they are.
ey...@gmail.com <ey...@gmail.com> #9
The emptyList
case isn't happening anymore, although I did recently invalidate caches for an unrelated reason.
I got the debug info for the false
, true
, and null
scenarios though, and attached them.
an...@google.com <an...@google.com> #10
This does appear to be a Kotlin plugin issue from what I can tell. This is from the true
set, although the same happened in the other two:
trace frozen=true, sorter=1, prefix=-1152, middleMatching=false, liftShorter=false, prefix=-1152, kotlin.deprecated=0, kotlin.notImported=notImported, kotlin.smartInBasic=0, kotlin.kind=callable, kotlin.callableWeight=CompoundWeight(weight1=globalOrStatic, receiverIndex=2147483647, weight2=other), stats=0, kotlin.variableOrFunction=function, kotlin.imported=null, proximity=[accessibility=NORMAL, referenceList=unknown, samePsiMember=0, groovyReferenceListWeigher=unknown, composeProximityWeigher=0, javaInheritance=false, explicitlyImported=UNKNOWN, openedInEditor=false, sameDirectory=false, javaInheritance=false, sameLogicalRoot=false, sameModule=0, kotlin.preferKotlinx=OTHER, knownElement=0, inResolveScope=true, directoryType=0, sdkOrLibrary=false], kotlin.proximity=[accessibility=NORMAL, referenceList=unknown, samePsiMember=0, groovyReferenceListWeigher=unknown, composeProximityWeigher=0, javaInheritance=false, explicitlyImported=UNKNOWN, openedInEditor=false, sameDirectory=false, javaInheritance=false, sameLogicalRoot=false, sameModule=0, kotlin.preferKotlinx=OTHER, knownElement=0, inResolveScope=true, directoryType=0, sdkOrLibrary=false], kotlin.byNameAlphabetical=trace, kotlin.preferKotlinClasses=KOTLIN, kotlin.preferLessParameters=2, ml_weigh=[common_item_class=KtNamedFunction,common_contributor=KotlinCompletionContributor,completion_kind_common_is_name=NON_IMPORTED,completion_kind_usage_correct_prob=0.0,completion_kind_usage_correct_in_row=0.0,completion_kind_usage_incorrect_in_row=27.0], ml_rank=0.4733134974291981, before_rerank_order=3
truncate frozen=true, sorter=1, prefix=-1152, middleMatching=false, liftShorter=false, prefix=-1152, kotlin.deprecated=0, kotlin.notImported=notImported, kotlin.smartInBasic=0, kotlin.kind=callable, kotlin.callableWeight=CompoundWeight(weight1=globalOrStatic, receiverIndex=2147483647, weight2=other), stats=0, kotlin.variableOrFunction=function, kotlin.imported=null, proximity=[accessibility=NORMAL, referenceList=unknown, samePsiMember=0, groovyReferenceListWeigher=unknown, composeProximityWeigher=0, javaInheritance=false, explicitlyImported=UNKNOWN, openedInEditor=false, sameDirectory=false, javaInheritance=false, sameLogicalRoot=false, sameModule=0, kotlin.preferKotlinx=OTHER, knownElement=0, inResolveScope=true, directoryType=0, sdkOrLibrary=false], kotlin.proximity=[accessibility=NORMAL, referenceList=unknown, samePsiMember=0, groovyReferenceListWeigher=unknown, composeProximityWeigher=0, javaInheritance=false, explicitlyImported=UNKNOWN, openedInEditor=false, sameDirectory=false, javaInheritance=false, sameLogicalRoot=false, sameModule=0, kotlin.preferKotlinx=OTHER, knownElement=0, inResolveScope=true, directoryType=0, sdkOrLibrary=false], kotlin.byNameAlphabetical=truncate, kotlin.preferKotlinClasses=KOTLIN, kotlin.preferLessParameters=1, ml_weigh=[common_item_class=KtNamedFunction,common_contributor=KotlinCompletionContributor,completion_kind_common_is_name=NON_IMPORTED,completion_kind_usage_correct_prob=0.0,completion_kind_usage_correct_in_row=0.0,completion_kind_usage_incorrect_in_row=27.0], ml_rank=0.4360058319724232, before_rerank_order=8
truncate frozen=true, sorter=1, prefix=-1152, middleMatching=false, liftShorter=false, prefix=-1152, kotlin.deprecated=0, kotlin.notImported=notImported, kotlin.smartInBasic=0, kotlin.kind=callable, kotlin.callableWeight=CompoundWeight(weight1=globalOrStatic, receiverIndex=2147483647, weight2=other), stats=0, kotlin.variableOrFunction=function, kotlin.imported=null, proximity=[accessibility=NORMAL, referenceList=unknown, samePsiMember=0, groovyReferenceListWeigher=unknown, composeProximityWeigher=0, javaInheritance=false, explicitlyImported=UNKNOWN, openedInEditor=false, sameDirectory=false, javaInheritance=false, sameLogicalRoot=false, sameModule=0, kotlin.preferKotlinx=OTHER, knownElement=0, inResolveScope=true, directoryType=0, sdkOrLibrary=false], kotlin.proximity=[accessibility=NORMAL, referenceList=unknown, samePsiMember=0, groovyReferenceListWeigher=unknown, composeProximityWeigher=0, javaInheritance=false, explicitlyImported=UNKNOWN, openedInEditor=false, sameDirectory=false, javaInheritance=false, sameLogicalRoot=false, sameModule=0, kotlin.preferKotlinx=OTHER, knownElement=0, inResolveScope=true, directoryType=0, sdkOrLibrary=false], kotlin.byNameAlphabetical=truncate, kotlin.preferKotlinClasses=KOTLIN, kotlin.preferLessParameters=1, ml_weigh=[common_item_class=KtNamedFunction,common_contributor=KotlinCompletionContributor,completion_kind_common_is_name=NON_IMPORTED,completion_kind_usage_correct_prob=0.0,completion_kind_usage_correct_in_row=0.0,completion_kind_usage_incorrect_in_row=27.0], ml_rank=0.4360058319724232, before_rerank_order=9
traceEventEnd frozen=true, sorter=1, prefix=-1152, middleMatching=false, liftShorter=false, prefix=-1152, kotlin.deprecated=0, kotlin.notImported=notImported, kotlin.smartInBasic=0, kotlin.kind=callable, kotlin.callableWeight=CompoundWeight(weight1=globalOrStatic, receiverIndex=2147483647, weight2=other), stats=0, kotlin.variableOrFunction=function, kotlin.imported=null, proximity=[accessibility=NORMAL, referenceList=unknown, samePsiMember=0, groovyReferenceListWeigher=unknown, composeProximityWeigher=0, javaInheritance=false, explicitlyImported=UNKNOWN, openedInEditor=false, sameDirectory=false, javaInheritance=false, sameLogicalRoot=false, sameModule=0, kotlin.preferKotlinx=OTHER, knownElement=0, inResolveScope=true, directoryType=0, sdkOrLibrary=false], kotlin.proximity=[accessibility=NORMAL, referenceList=unknown, samePsiMember=0, groovyReferenceListWeigher=unknown, composeProximityWeigher=0, javaInheritance=false, explicitlyImported=UNKNOWN, openedInEditor=false, sameDirectory=false, javaInheritance=false, sameLogicalRoot=false, sameModule=0, kotlin.preferKotlinx=OTHER, knownElement=0, inResolveScope=true, directoryType=0, sdkOrLibrary=false], kotlin.byNameAlphabetical=traceEventEnd, kotlin.preferKotlinClasses=KOTLIN, kotlin.preferLessParameters=0, ml_weigh=[common_item_class=KtNamedFunction,common_contributor=KotlinCompletionContributor,completion_kind_common_is_name=NON_IMPORTED,completion_kind_usage_correct_prob=0.0,completion_kind_usage_correct_in_row=0.0,completion_kind_usage_incorrect_in_row=27.0], ml_rank=-0.3385155434566393, before_rerank_order=4
translationMatrix frozen=true, sorter=1, prefix=-1152, middleMatching=false, liftShorter=false, prefix=-1152, kotlin.deprecated=0, kotlin.notImported=notImported, kotlin.smartInBasic=0, kotlin.kind=callable, kotlin.callableWeight=CompoundWeight(weight1=globalOrStatic, receiverIndex=2147483647, weight2=other), stats=0, kotlin.variableOrFunction=function, kotlin.imported=null, proximity=[accessibility=NORMAL, referenceList=unknown, samePsiMember=0, groovyReferenceListWeigher=unknown, composeProximityWeigher=0, javaInheritance=false, explicitlyImported=UNKNOWN, openedInEditor=false, sameDirectory=false, javaInheritance=false, sameLogicalRoot=false, sameModule=0, kotlin.preferKotlinx=OTHER, knownElement=0, inResolveScope=true, directoryType=0, sdkOrLibrary=false], kotlin.proximity=[accessibility=NORMAL, referenceList=unknown, samePsiMember=0, groovyReferenceListWeigher=unknown, composeProximityWeigher=0, javaInheritance=false, explicitlyImported=UNKNOWN, openedInEditor=false, sameDirectory=false, javaInheritance=false, sameLogicalRoot=false, sameModule=0, kotlin.preferKotlinx=OTHER, knownElement=0, inResolveScope=true, directoryType=0, sdkOrLibrary=false], kotlin.byNameAlphabetical=translationMatrix, kotlin.preferKotlinClasses=KOTLIN, kotlin.preferLessParameters=2, ml_weigh=[common_item_class=KtNamedFunction,common_contributor=KotlinCompletionContributor,completion_kind_common_is_name=NON_IMPORTED,completion_kind_usage_correct_prob=0.0,completion_kind_usage_correct_in_row=0.0,completion_kind_usage_incorrect_in_row=27.0], ml_rank=-0.6182458964983449, before_rerank_order=7
true frozen=false, sorter=1, prefix=-1152, middleMatching=false, liftShorter=false, prefix=-1152, kotlin.deprecated=0, kotlin.notImported=default, kotlin.smartInBasic=19, kotlin.kind=keyword, kotlin.callableWeight=null, stats=9989, kotlin.variableOrFunction=null, kotlin.imported=null, proximity=null, kotlin.proximity=null, kotlin.byNameAlphabetical=null, kotlin.preferKotlinClasses=OTHER, kotlin.preferLessParameters=null, ml_weigh=[common_contributor=KotlinCompletionContributor,ngram_recent_files=0.8025309588016981,completion_kind_common_is_name=KEYWORD_ONLY,completion_kind_usage_correct_prob=0.0,completion_kind_usage_correct_in_row=0.0,completion_kind_usage_incorrect_in_row=30.0], ml_rank=12.948607291726876, before_rerank_order=0
There's a few things I can glean from this:
true
has a higherml_rank
than anything else, so all other things being equal it should be at the top of the list. (Spoiler alert, all other things are not equal.)true
is ranked at the top even before ML re-ranking (it hasbefore_rerank_order=0
).- The results before
true
are marked withfrozen=true
. This indicates they were the first items to be displayed, and thus their order is not going to be changed after initial rendering so that the UI doesn't jump.- There's a short amount of time given before the first results are displayed, so this implies that for some reason
true
is taking longer to be generated as a suggestion.
- There's a short amount of time given before the first results are displayed, so this implies that for some reason
- All of the above results come from
KotlinCompletionContributor
, which is the Kotlin plugin's built in suggestion provider.
Given all of that (especially the last point), I think this is something that needs to be filed with the Kotlin plugin at
If you can file and add the YouTrack link to this bug, I'll CC myself and can help track and push it as needed.
Description
I've noticed 3 particularly unhelpful autocomplete suggestions for:
null
: when I start typingnull
for the value of a nullable property I get the suggestionsnullsLast
,nullsFirst
,nullsLast
,nullsFirst
, and finallynull
false
: when I start typingfalse
for the value of aBoolean
property I get the suggestionsfloatArrayOf
,fixme
,flow {}
,flowOf
,floor
, and finallyfalse
. If I continue typing (fa
), the suggestions are nowfloatArrayOf
,fastCbrt
,fadeIn
,fadeOut
,fastMaxOf
, and finallyfalse
true
: when I start typingtrue
for the value of aBoolean
property I get the suggestionstoString
,todo
,traceEventEnd
,isSystemInDarkTheme
,tan
, and finallytrue