Advance enum entries in smart completion list
^KT-22579 Fixed
This commit is contained in:
+6
-1
@@ -91,7 +91,7 @@ class StaticMembers(
|
|||||||
expectedInfos: Collection<ExpectedInfo>,
|
expectedInfos: Collection<ExpectedInfo>,
|
||||||
context: KtSimpleNameExpression,
|
context: KtSimpleNameExpression,
|
||||||
enumEntriesToSkip: Set<DeclarationDescriptor>,
|
enumEntriesToSkip: Set<DeclarationDescriptor>,
|
||||||
priority: SmartCompletionItemPriority
|
defaultPriority: SmartCompletionItemPriority
|
||||||
) {
|
) {
|
||||||
fun processMember(descriptor: DeclarationDescriptor) {
|
fun processMember(descriptor: DeclarationDescriptor) {
|
||||||
if (descriptor is DeclarationDescriptorWithVisibility && !descriptor.isVisible(
|
if (descriptor is DeclarationDescriptorWithVisibility && !descriptor.isVisible(
|
||||||
@@ -114,6 +114,11 @@ class StaticMembers(
|
|||||||
else -> return
|
else -> return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val priority = when {
|
||||||
|
DescriptorUtils.isEnumEntry(descriptor) -> SmartCompletionItemPriority.ENUM_ENTRIES
|
||||||
|
else -> defaultPriority
|
||||||
|
}
|
||||||
|
|
||||||
collection.addLookupElements(descriptor, expectedInfos, matcher) { createLookupElements(it, priority) }
|
collection.addLookupElements(descriptor, expectedInfos, matcher) { createLookupElements(it, priority) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -277,6 +277,7 @@ enum class SmartCompletionItemPriority {
|
|||||||
CLASS_LITERAL,
|
CLASS_LITERAL,
|
||||||
THIS,
|
THIS,
|
||||||
DELEGATES_STATIC_MEMBER,
|
DELEGATES_STATIC_MEMBER,
|
||||||
|
ENUM_ENTRIES,
|
||||||
DEFAULT,
|
DEFAULT,
|
||||||
NULLABLE,
|
NULLABLE,
|
||||||
INSTANTIATION,
|
INSTANTIATION,
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package sample
|
||||||
|
|
||||||
|
enum class Foo {
|
||||||
|
X, Y
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo(){
|
||||||
|
val f : Foo = <caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// WITH_ORDER
|
||||||
|
// EXIST: { lookupString:"X", itemText:"Foo.X", tailText:" (sample)", typeText:"Foo" }
|
||||||
|
// EXIST: { lookupString:"Y", itemText:"Foo.Y", tailText:" (sample)", typeText:"Foo" }
|
||||||
|
// EXIST: {"lookupString":"enumValueOf","tailText":"(name: String) (kotlin)","typeText":"Foo","attributes":"","allLookupStrings":"enumValueOf","itemText":"enumValueOf"}
|
||||||
|
// EXIST: {"lookupString":"maxOf","tailText":"(a: Foo, b: Foo) (kotlin.comparisons)","typeText":"Foo","attributes":"","allLookupStrings":"maxOf","itemText":"maxOf"}
|
||||||
|
// EXIST: {"lookupString":"maxOf","tailText":"(a: Foo, b: Foo, c: Foo) (kotlin.comparisons)","typeText":"Foo","attributes":"","allLookupStrings":"maxOf","itemText":"maxOf"}
|
||||||
|
// EXIST: {"lookupString":"minOf","tailText":"(a: Foo, b: Foo) (kotlin.comparisons)","typeText":"Foo","attributes":"","allLookupStrings":"minOf","itemText":"minOf"}
|
||||||
|
// EXIST: {"lookupString":"minOf","tailText":"(a: Foo, b: Foo, c: Foo) (kotlin.comparisons)","typeText":"Foo","attributes":"","allLookupStrings":"minOf","itemText":"minOf"}
|
||||||
|
// EXIST: {"lookupString":"valueOf","tailText":"(value: String) (sample)","typeText":"Foo","module":"light_idea_test_case","attributes":"","allLookupStrings":"Foo, valueOf","itemText":"Foo.valueOf"}
|
||||||
|
|
||||||
|
// NOTHING_ELSE
|
||||||
+5
@@ -114,6 +114,11 @@ public class JvmSmartCompletionTestGenerated extends AbstractJvmSmartCompletionT
|
|||||||
runTest("idea/idea-completion/testData/smart/EmptyPrefix.kt");
|
runTest("idea/idea-completion/testData/smart/EmptyPrefix.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("EnumExpected.kt")
|
||||||
|
public void testEnumExpected() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/smart/EnumExpected.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("EnumMembers.kt")
|
@TestMetadata("EnumMembers.kt")
|
||||||
public void testEnumMembers() throws Exception {
|
public void testEnumMembers() throws Exception {
|
||||||
runTest("idea/idea-completion/testData/smart/EnumMembers.kt");
|
runTest("idea/idea-completion/testData/smart/EnumMembers.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user