KT-34414 Make sure completion for suspend functional parameters works too
- Replace `isFunctionType` with `isBuiltinFunctionalType` where it is relevant - ^KT-34414 Fixed
This commit is contained in:
committed by
Roman Golyshev
parent
541ca31584
commit
6f234beb9c
+2
-2
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.idea.completion
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.util.SmartList
|
||||
import org.jetbrains.kotlin.builtins.isFunctionTypeOrSubtype
|
||||
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalTypeOrSubtype
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||
import org.jetbrains.kotlin.idea.codeInsight.ReferenceVariantsHelper
|
||||
import org.jetbrains.kotlin.idea.util.CallTypeAndReceiver
|
||||
@@ -39,7 +39,7 @@ class RealContextVariablesProvider(
|
||||
) : ContextVariablesProvider {
|
||||
|
||||
val allFunctionTypeVariables by lazy {
|
||||
collectVariables().filter { it.type.isFunctionTypeOrSubtype }
|
||||
collectVariables().filter { it.type.isBuiltinFunctionalTypeOrSubtype }
|
||||
}
|
||||
|
||||
private fun collectVariables(): Collection<VariableDescriptor> {
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.completion
|
||||
import com.intellij.codeInsight.completion.InsertHandler
|
||||
import com.intellij.codeInsight.lookup.LookupElement
|
||||
import org.jetbrains.kotlin.builtins.getReturnTypeFromFunctionType
|
||||
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType
|
||||
import org.jetbrains.kotlin.builtins.isFunctionType
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.idea.completion.handlers.*
|
||||
@@ -51,7 +52,7 @@ class InsertHandlerProvider(
|
||||
if (callType != CallType.SUPER_MEMBERS) { // for super call we don't suggest to generate "super.foo { ... }" (seems to be non-typical use)
|
||||
val parameter = parameters.single()
|
||||
val parameterType = parameter.type
|
||||
if (parameterType.isFunctionType) {
|
||||
if (parameterType.isBuiltinFunctionalType) {
|
||||
if (getValueParametersCountFromFunctionType(parameterType) <= 1 && !parameter.hasDefaultValue()) {
|
||||
// otherwise additional item with lambda template is to be added
|
||||
return KotlinFunctionInsertHandler.Normal(
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ class LookupElementFactory(
|
||||
companion object {
|
||||
fun hasSingleFunctionTypeParameter(descriptor: FunctionDescriptor): Boolean {
|
||||
val parameter = descriptor.original.valueParameters.singleOrNull() ?: return false
|
||||
return parameter.type.isFunctionType
|
||||
return parameter.type.isBuiltinFunctionalType
|
||||
}
|
||||
|
||||
val CAST_REQUIRED_COLOR = JBColor(0x4E4040, 0x969696)
|
||||
|
||||
+5
-2
@@ -1,9 +1,12 @@
|
||||
interface I : suspend () -> Unit
|
||||
|
||||
fun xfoo(p: suspend () -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
fun test(action: suspend () -> Unit, i: I, notSuspend: () -> Unit) {
|
||||
xf<caret>
|
||||
}
|
||||
|
||||
// EXIST: { itemText:"xfoo", tailText:" {...} (p: suspend () -> Unit) (<root>)", typeText:"Unit" }
|
||||
// EXIST: { itemText:"xfoo", tailText:"(p: suspend () -> Unit) (<root>)", typeText:"Unit" }
|
||||
// EXIST: { itemText:"xfoo", tailText:"(action) (<root>)", typeText:"Unit" }
|
||||
// EXIST: { itemText:"xfoo", tailText:"(i) (<root>)", typeText:"Unit" }
|
||||
// NOTHING_ELSE
|
||||
Reference in New Issue
Block a user