Background/Situation
Sometimes, code completion suggests inappropriate default or incorrect expected order. The support/dev team might want detailed info about the completion ranking dump. Usually, the IDEs' log find didn't contain details about this.
Question
How to dump code completion ranking and save it?
Answer
There is an IDE's internal action named Dump Lookup Element Weights to Log, which requires enabling the IDE's Internal mode first. However, this action must be called when the completion popup is visible, so you can only invoke this by using the keyboard, so pressing Ctrl+Alt+Shift+W(⌥⇧⌘W on macOS) when the completion popup is on the screen, pasting the clipboard content to a text editor will save it.
This applies to all JetBrains IDEs such as IDEA, WebStorm, etc.
The final output might be like this:
selected: super
prefix: s
weights:
super frozen=true, sorter=1, stats=0, explicitProximity=0, proximity=[accessibility=NORMAL, referenceList=unknown, samePsiMember=0, explicitlyImported=UNKNOWN, javaInheritance=false, groovyReferenceListWeigher=unknown, openedInEditor=false, sameDirectory=false, sameLogicalRoot=false, sameModule=0, kotlin.preferKotlinx=null, knownElement=0, inResolveScope=false, directoryType=0, sdkOrLibrary=false], ml_weigh=[java_keyword_name=super,common_item_class=LightKeyword,common_contributor=JavaCompletionContributor,ngram_recent_files=0.05531536291055828], ml_rank=5.605883358704432, before_rerank_order=2
showFocusedBrowserSearchToolbar frozen=true, sorter=1, stats=0, explicitProximity=1, proximity=[accessibility=NORMAL, referenceList=unknown, samePsiMember=2, explicitlyImported=DECLARED_IN_SAME_FILE, javaInheritance=false, groovyReferenceListWeigher=unknown, openedInEditor=true, sameDirectory=true, sameLogicalRoot=true, sameModule=2, kotlin.preferKotlinx=null, knownElement=0, inResolveScope=true, directoryType=3, sdkOrLibrary=false], ml_weigh=[java_is_public=1,java_is_static=1,java_args_count=0.0,java_args_vars_names_matches=0.0,java_args_vars_types_matches=0.0,java_args_vars_names_types_matches=0.0,java_return_type=VOID,common_lines_diff=12.0,common_item_class=PsiMethodImpl,common_contributor=JavaCompletionContributor,ngram_file=5.420054200542006E-4,ngram_file_reversed=5.420054200542006E-4,common_similarity_parent_mean=0.7,common_similarity_parent_max=1.0,common_similarity_parent_full=1.0,common_similarity_parent_stemmed_mean=0.7,common_similarity_parent_stemmed_max=1.0,recent_places_contains=1], ml_rank=5.0996414910037515, before_rerank_order=0
short frozen=true, sorter=1, stats=0, explicitProximity=0, proximity=[accessibility=NORMAL, referenceList=unknown, samePsiMember=0, explicitlyImported=UNKNOWN, javaInheritance=false, groovyReferenceListWeigher=unknown, openedInEditor=false, sameDirectory=false, sameLogicalRoot=false, sameModule=0, kotlin.preferKotlinx=null, knownElement=0, inResolveScope=false, directoryType=0, sdkOrLibrary=false], ml_weigh=[common_item_class=LightKeyword,common_contributor=JavaCompletionContributor], ml_rank=3.7346703738285214, before_rerank_order=1
switch frozen=true, sorter=1, stats=0, explicitProximity=0, proximity=[accessibility=NORMAL, referenceList=unknown, samePsiMember=0, explicitlyImported=UNKNOWN, javaInheritance=false, groovyReferenceListWeigher=unknown, openedInEditor=false, sameDirectory=false, sameLogicalRoot=false, sameModule=0, kotlin.preferKotlinx=null, knownElement=0, inResolveScope=false, directoryType=0, sdkOrLibrary=false], ml_weigh=[java_keyword_name=switch,common_item_class=LightKeyword,common_contributor=JavaCompletionContributor], ml_rank=3.0984666223516797, before_rerank_order=3
synchronized frozen=true, sorter=1, stats=0, explicitProximity=0, proximity=[accessibility=NORMAL, referenceList=unknown, samePsiMember=0, explicitlyImported=UNKNOWN, javaInheritance=false, groovyReferenceListWeigher=unknown, openedInEditor=false, sameDirectory=false, sameLogicalRoot=false, sameModule=0, kotlin.preferKotlinx=null, knownElement=0, inResolveScope=false, directoryType=0, sdkOrLibrary=false], ml_weigh=[common_item_class=LightKeyword,common_contributor=JavaCompletionContributor,ngram_recent_files=2.331517565102848E-4], ml_rank=3.0977302730744327, before_rerank_order=4
serr frozen=false, sorter=2, stats=0, ml_weigh=[common_contributor=LiveTemplateCompletionContributor,template_previously_used=0,template_recent_use_count=0.0], ml_rank=2.36369747898857, before_rerank_order=5
souf frozen=false, sorter=2, stats=0, ml_weigh=[common_contributor=LiveTemplateCompletionContributor,template_previously_used=0,template_recent_use_count=0.0], ml_rank=2.1653386836667323, before_rerank_order=6
sout frozen=false, sorter=2, stats=0, ml_weigh=[common_contributor=LiveTemplateCompletionContributor,template_previously_used=0,template_recent_use_count=0.0], ml_rank=1.97021480944818, before_rerank_order=7
soutm frozen=false, sorter=2, stats=0, ml_weigh=[common_contributor=LiveTemplateCompletionContributor,template_previously_used=0,template_recent_use_count=0.0], ml_rank=1.5190070933592779, before_rerank_order=8
soutp frozen=false, sorter=2, stats=0, ml_weigh=[common_contributor=LiveTemplateCompletionContributor,template_previously_used=0,template_recent_use_count=0.0], ml_rank=1.5430891486746532, before_rerank_order=9
soutv frozen=false, sorter=2, stats=0, ml_weigh=[common_contributor=LiveTemplateCompletionContributor,template_previously_used=0,template_recent_use_count=0.0], ml_rank=1.480286468696022, before_rerank_order=10
Comments
0 comments
Please sign in to leave a comment.