KT-12369 Completion: pressing dot after class name should not cause insertion of constructor call

#KT-12369 Fixed
This commit is contained in:
Valentin Kipyatkov
2016-06-16 21:19:34 +03:00
parent b9719bfe82
commit 0bc5007147
4 changed files with 43 additions and 1 deletions
@@ -180,6 +180,7 @@ object PreferMatchingItemWeigher : LookupElementWeigher("kotlin.preferMatching",
keywordExactMatch,
defaultExactMatch,
functionExactMatch,
specialExactMatch,
notExactMatch
}
@@ -192,7 +193,16 @@ object PreferMatchingItemWeigher : LookupElementWeigher("kotlin.preferMatching",
val o = element.`object`
return when (o) {
is KeywordLookupObject -> Weight.keywordExactMatch
is DeclarationLookupObject -> if (o.descriptor is FunctionDescriptor) Weight.functionExactMatch else Weight.defaultExactMatch
is DeclarationLookupObject -> {
val smartCompletionPriority = element.getUserData(SMART_COMPLETION_ITEM_PRIORITY_KEY)
when {
smartCompletionPriority != null && smartCompletionPriority != SmartCompletionItemPriority.DEFAULT -> Weight.specialExactMatch
o.descriptor is FunctionDescriptor -> Weight.functionExactMatch
else -> Weight.defaultExactMatch
}
}
else -> Weight.defaultExactMatch
}
}
@@ -0,0 +1,13 @@
class Color {
companion object {
val RED = Color()
}
}
fun getColor(): Color? {
return Color<caret>
}
// INVOCATION_COUNT: 0
// ELEMENT: *
// CHAR: '.'
@@ -0,0 +1,13 @@
class Color {
companion object {
val RED = Color()
}
}
fun getColor(): Color? {
return Color.<caret>
}
// INVOCATION_COUNT: 0
// ELEMENT: *
// CHAR: '.'
@@ -155,6 +155,12 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion
doTest(fileName);
}
@TestMetadata("PreferClassToConstructor.kt")
public void testPreferClassToConstructor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/PreferClassToConstructor.kt");
doTest(fileName);
}
@TestMetadata("PreferMatchingKeyword.kt")
public void testPreferMatchingKeyword() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/PreferMatchingKeyword.kt");