Ordering items in smart completion for function type
This commit is contained in:
@@ -37,6 +37,7 @@ object LambdaItems {
|
|||||||
val lookupElement = LookupElementBuilder.create("{...}")
|
val lookupElement = LookupElementBuilder.create("{...}")
|
||||||
.withInsertHandler(ArtificialElementInsertHandler("{ ", " }", false))
|
.withInsertHandler(ArtificialElementInsertHandler("{ ", " }", false))
|
||||||
.suppressAutoInsertion()
|
.suppressAutoInsertion()
|
||||||
|
.assignSmartCompletionPriority(SmartCompletionItemPriority.LAMBDA_NO_PARAMS)
|
||||||
.addTailAndNameSimilarity(functionExpectedInfos)
|
.addTailAndNameSimilarity(functionExpectedInfos)
|
||||||
lookupElement.putUserData(KotlinCompletionCharFilter.ACCEPT_OPENING_BRACE, true)
|
lookupElement.putUserData(KotlinCompletionCharFilter.ACCEPT_OPENING_BRACE, true)
|
||||||
collection.add(lookupElement)
|
collection.add(lookupElement)
|
||||||
@@ -53,6 +54,7 @@ object LambdaItems {
|
|||||||
insertLambdaTemplate(context, TextRange(offset, offset + placeholder.length), functionType)
|
insertLambdaTemplate(context, TextRange(offset, offset + placeholder.length), functionType)
|
||||||
})
|
})
|
||||||
.suppressAutoInsertion()
|
.suppressAutoInsertion()
|
||||||
|
.assignSmartCompletionPriority(SmartCompletionItemPriority.LAMBDA)
|
||||||
.addTailAndNameSimilarity(functionExpectedInfos.filter { it.type == functionType })
|
.addTailAndNameSimilarity(functionExpectedInfos.filter { it.type == functionType })
|
||||||
lookupElement.putUserData(KotlinCompletionCharFilter.ACCEPT_OPENING_BRACE, true)
|
lookupElement.putUserData(KotlinCompletionCharFilter.ACCEPT_OPENING_BRACE, true)
|
||||||
collection.add(lookupElement)
|
collection.add(lookupElement)
|
||||||
|
|||||||
@@ -251,7 +251,9 @@ class SmartCompletion(val expression: JetSimpleNameExpression,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return lookupElement.addTailAndNameSimilarity(matchedExpectedInfos)
|
return lookupElement
|
||||||
|
.assignSmartCompletionPriority(SmartCompletionItemPriority.FUNCTION_REFERENCE)
|
||||||
|
.addTailAndNameSimilarity(matchedExpectedInfos)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (descriptor is SimpleFunctionDescriptor) {
|
if (descriptor is SimpleFunctionDescriptor) {
|
||||||
|
|||||||
@@ -204,6 +204,9 @@ enum class SmartCompletionItemPriority {
|
|||||||
STATIC_MEMBER
|
STATIC_MEMBER
|
||||||
INSTANTIATION
|
INSTANTIATION
|
||||||
ANONYMOUS_OBJECT
|
ANONYMOUS_OBJECT
|
||||||
|
LAMBDA_NO_PARAMS
|
||||||
|
LAMBDA
|
||||||
|
FUNCTION_REFERENCE
|
||||||
}
|
}
|
||||||
|
|
||||||
val SMART_COMPLETION_ITEM_PRIORITY_KEY = Key<SmartCompletionItemPriority>("SMART_COMPLETION_ITEM_PRIORITY_KEY")
|
val SMART_COMPLETION_ITEM_PRIORITY_KEY = Key<SmartCompletionItemPriority>("SMART_COMPLETION_ITEM_PRIORITY_KEY")
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
fun foo(filter: (String) -> Boolean) {}
|
||||||
|
|
||||||
|
fun doFilter(s: String): Boolean = true
|
||||||
|
fun x(s: String): Boolean = true
|
||||||
|
|
||||||
|
fun bar(p: (String) -> Boolean) {
|
||||||
|
foo(<caret>)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ORDER: ::doFilter
|
||||||
|
// ORDER: p
|
||||||
|
// ORDER: {...}
|
||||||
|
// ORDER: { String -> ... }
|
||||||
|
// ORDER: ::error
|
||||||
|
// ORDER: ::x
|
||||||
+6
@@ -36,6 +36,12 @@ public class SmartCompletionWeigherTestGenerated extends AbstractSmartCompletion
|
|||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/completion/weighers/smart"), Pattern.compile("^([^\\.]+)\\.kt$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/completion/weighers/smart"), Pattern.compile("^([^\\.]+)\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("FunctionExpected.kt")
|
||||||
|
public void testFunctionExpected() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/smart/FunctionExpected.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("MultipleArgsItem.kt")
|
@TestMetadata("MultipleArgsItem.kt")
|
||||||
public void testMultipleArgsItem() throws Exception {
|
public void testMultipleArgsItem() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/smart/MultipleArgsItem.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/smart/MultipleArgsItem.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user