From f5f5b514d4da53757354001e58ee5f97f41f9854 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 20 Oct 2014 17:44:52 +0400 Subject: [PATCH] Ordering items in smart completion for nullable --- .../plugin/completion/smart/KeywordValues.kt | 2 +- .../jet/plugin/completion/smart/Utils.kt | 1 + .../weighers/smart/NullableExpected.kt | 20 +++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 idea/testData/completion/weighers/smart/NullableExpected.kt diff --git a/idea/src/org/jetbrains/jet/plugin/completion/smart/KeywordValues.kt b/idea/src/org/jetbrains/jet/plugin/completion/smart/KeywordValues.kt index 7f442244662..33a17d165f4 100644 --- a/idea/src/org/jetbrains/jet/plugin/completion/smart/KeywordValues.kt +++ b/idea/src/org/jetbrains/jet/plugin/completion/smart/KeywordValues.kt @@ -56,6 +56,6 @@ object KeywordValues { collection.addLookupElements(expectedInfos, { info -> if (info.type.isNullable()) ExpectedInfoClassification.MATCHES else ExpectedInfoClassification.NOT_MATCHES }, - { LookupElementBuilder.create("null").bold() }) + { LookupElementBuilder.create("null").bold().assignSmartCompletionPriority(SmartCompletionItemPriority.NULL) }) } } \ No newline at end of file diff --git a/idea/src/org/jetbrains/jet/plugin/completion/smart/Utils.kt b/idea/src/org/jetbrains/jet/plugin/completion/smart/Utils.kt index 49b753dbdec..34dcd9f7848 100644 --- a/idea/src/org/jetbrains/jet/plugin/completion/smart/Utils.kt +++ b/idea/src/org/jetbrains/jet/plugin/completion/smart/Utils.kt @@ -209,6 +209,7 @@ enum class SmartCompletionItemPriority { LAMBDA_NO_PARAMS LAMBDA FUNCTION_REFERENCE + NULL } val SMART_COMPLETION_ITEM_PRIORITY_KEY = Key("SMART_COMPLETION_ITEM_PRIORITY_KEY") diff --git a/idea/testData/completion/weighers/smart/NullableExpected.kt b/idea/testData/completion/weighers/smart/NullableExpected.kt new file mode 100644 index 00000000000..0c18bc04d77 --- /dev/null +++ b/idea/testData/completion/weighers/smart/NullableExpected.kt @@ -0,0 +1,20 @@ +var global: C = C() + +abstract class C { + class object { + val INSTANCE = C() + } +} + +fun foo(p: C?) { + val local = C() + foo() +} + + +// ORDER: p +// ORDER: local +// ORDER: global +// ORDER: C.INSTANCE +// ORDER: object +// ORDER: null