From 927df1c4cd78a4b8ce144c0d96337f1f79930f40 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 13 Nov 2015 19:42:43 +0300 Subject: [PATCH] KT-5072 Values of extension function type are not seen in completion #KT-5072 Fixed --- .../kotlin/idea/util/extensionsUtils.kt | 18 ++-- .../idea/completion/BasicCompletionSession.kt | 9 ++ .../completion/ContextVariablesProvider.kt | 5 +- .../ExtensionFunctionTypeValueCompletion.kt | 95 +++++++++++++++++++ .../smart/SmartCompletionSession.kt | 8 ++ .../ImplicitReceiver.kt | 8 ++ .../extensionFunctionTypeValues/SafeCall.kt | 5 + .../extensionFunctionTypeValues/Simple.kt | 6 ++ .../extensionFunctionTypeValues/SmartCast.kt | 11 +++ .../basic/ExtensionFunctionTypeVariable1.kt | 5 + .../ExtensionFunctionTypeVariable1.kt.after | 5 + .../basic/ExtensionFunctionTypeVariable2.kt | 5 + .../ExtensionFunctionTypeVariable2.kt.after | 5 + .../smart/ExtensionFunctionTypeVariable1.kt | 7 ++ .../ExtensionFunctionTypeVariable1.kt.after | 7 ++ .../smart/ExtensionFunctionTypeVariable2.kt | 7 ++ .../ExtensionFunctionTypeVariable2.kt.after | 7 ++ .../smart/ExtensionFunctionTypeVariables.kt | 7 ++ .../test/JSBasicCompletionTestGenerated.java | 33 +++++++ .../test/JvmBasicCompletionTestGenerated.java | 33 +++++++ .../test/JvmSmartCompletionTestGenerated.java | 6 ++ .../BasicCompletionHandlerTestGenerated.java | 12 +++ .../SmartCompletionHandlerTestGenerated.java | 12 +++ 23 files changed, 305 insertions(+), 11 deletions(-) create mode 100644 idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ExtensionFunctionTypeValueCompletion.kt create mode 100644 idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/ImplicitReceiver.kt create mode 100644 idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/SafeCall.kt create mode 100644 idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/Simple.kt create mode 100644 idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/SmartCast.kt create mode 100644 idea/idea-completion/testData/handlers/basic/ExtensionFunctionTypeVariable1.kt create mode 100644 idea/idea-completion/testData/handlers/basic/ExtensionFunctionTypeVariable1.kt.after create mode 100644 idea/idea-completion/testData/handlers/basic/ExtensionFunctionTypeVariable2.kt create mode 100644 idea/idea-completion/testData/handlers/basic/ExtensionFunctionTypeVariable2.kt.after create mode 100644 idea/idea-completion/testData/handlers/smart/ExtensionFunctionTypeVariable1.kt create mode 100644 idea/idea-completion/testData/handlers/smart/ExtensionFunctionTypeVariable1.kt.after create mode 100644 idea/idea-completion/testData/handlers/smart/ExtensionFunctionTypeVariable2.kt create mode 100644 idea/idea-completion/testData/handlers/smart/ExtensionFunctionTypeVariable2.kt.after create mode 100644 idea/idea-completion/testData/smart/ExtensionFunctionTypeVariables.kt diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt index c32781282ad..4eb27803d5f 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt @@ -34,13 +34,13 @@ import org.jetbrains.kotlin.types.typeUtil.TypeNullability import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.types.typeUtil.nullability -public fun CallableDescriptor.substituteExtensionIfCallable( +public fun TCallable.substituteExtensionIfCallable( receivers: Collection, context: BindingContext, dataFlowInfo: DataFlowInfo, callType: CallType<*>, containingDeclarationOrModule: DeclarationDescriptor -): Collection { +): Collection { val sequence = receivers.asSequence().flatMap { substituteExtensionIfCallable(it, callType, context, dataFlowInfo, containingDeclarationOrModule).asSequence() } if (getTypeParameters().isEmpty()) { // optimization for non-generic callables return sequence.firstOrNull()?.let { listOf(it) } ?: listOf() @@ -50,32 +50,32 @@ public fun CallableDescriptor.substituteExtensionIfCallable( } } -public fun CallableDescriptor.substituteExtensionIfCallableWithImplicitReceiver( +public fun TCallable.substituteExtensionIfCallableWithImplicitReceiver( scope: LexicalScope, context: BindingContext, dataFlowInfo: DataFlowInfo -): Collection { +): Collection { val receiverValues = scope.getImplicitReceiversWithInstance().map { it.getValue() } return substituteExtensionIfCallable(receiverValues, context, dataFlowInfo, CallType.DEFAULT, scope.ownerDescriptor) } -public fun CallableDescriptor.substituteExtensionIfCallable( +public fun TCallable.substituteExtensionIfCallable( receiver: ReceiverValue, callType: CallType<*>, bindingContext: BindingContext, dataFlowInfo: DataFlowInfo, containingDeclarationOrModule: DeclarationDescriptor -): Collection { +): Collection { if (!receiver.exists()) return listOf() var types = SmartCastManager().getSmartCastVariants(receiver, bindingContext, containingDeclarationOrModule, dataFlowInfo) return substituteExtensionIfCallable(types, callType) } -public fun CallableDescriptor.substituteExtensionIfCallable( +public fun TCallable.substituteExtensionIfCallable( receiverTypes: Collection, callType: CallType<*> -): Collection { +): Collection { if (!callType.descriptorKindFilter.accepts(this)) return listOf() var types = receiverTypes.asSequence() @@ -98,7 +98,7 @@ public fun CallableDescriptor.substituteExtensionIfCallable( return if (substitutors.any()) listOf(this) else listOf() } else { - return substitutors.map { substitute(it)!! }.toList() + return substitutors.map { @Suppress("UNCHECKED_CAST") (substitute(it) as TCallable) }.toList() } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt index cd4ac67fe8f..8570bebac13 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt @@ -207,6 +207,15 @@ class BasicCompletionSession( val contextVariablesProvider = RealContextVariablesProvider(referenceVariantsHelper, position) withContextVariablesProvider(contextVariablesProvider) { lookupElementFactory -> + if (receiverTypes != null) { + ExtensionFunctionTypeValueCompletion(receiverTypes, callTypeAndReceiver.callType, lookupElementFactory) + .processVariables(contextVariablesProvider) + .forEach { + val lookupElements = it.factory.createStandardLookupElementsForDescriptor(it.invokeDescriptor, useReceiverTypes = true) + collector.addElements(lookupElements) + } + } + if (contextVariableTypesForSmartCompletion.any { contextVariablesProvider.functionTypeVariables(it).isNotEmpty() }) { completeWithSmartCompletion(lookupElementFactory) } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ContextVariablesProvider.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ContextVariablesProvider.kt index 1d443870c66..40e3da194d0 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ContextVariablesProvider.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ContextVariablesProvider.kt @@ -37,7 +37,8 @@ class RealContextVariablesProvider( private val referenceVariantsHelper: ReferenceVariantsHelper, private val contextElement: PsiElement ) : ContextVariablesProvider { - private val functionTypeVariables by lazy { + + val allFunctionTypeVariables by lazy { collectVariables().filter { KotlinBuiltIns.isFunctionOrExtensionFunctionType(it.type) } } @@ -49,7 +50,7 @@ class RealContextVariablesProvider( override fun functionTypeVariables(requiredType: FuzzyType): Collection> { val result = SmartList>() - for (variable in functionTypeVariables) { + for (variable in allFunctionTypeVariables) { val substitutor = variable.fuzzyReturnType()?.checkIsSubtypeOf(requiredType) ?: continue result.add(variable to substitutor) } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ExtensionFunctionTypeValueCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ExtensionFunctionTypeValueCompletion.kt new file mode 100644 index 00000000000..184140bfb69 --- /dev/null +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ExtensionFunctionTypeValueCompletion.kt @@ -0,0 +1,95 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.completion + +import com.intellij.codeInsight.completion.InsertionContext +import com.intellij.codeInsight.lookup.LookupElement +import com.intellij.codeInsight.lookup.LookupElementDecorator +import com.intellij.codeInsight.lookup.LookupElementPresentation +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.FunctionDescriptor +import org.jetbrains.kotlin.idea.util.CallType +import org.jetbrains.kotlin.idea.util.substituteExtensionIfCallable +import org.jetbrains.kotlin.incremental.components.NoLookupLocation +import org.jetbrains.kotlin.resolve.calls.tasks.createSynthesizedInvokes +import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.util.OperatorNameConventions +import java.util.* + +class ExtensionFunctionTypeValueCompletion( + private val receiverTypes: Collection, + private val callType: CallType<*>, + private val lookupElementFactory: LookupElementFactory +) { + data class Result(val invokeDescriptor: FunctionDescriptor, val factory: AbstractLookupElementFactory) + + fun processVariables(variablesProvider: RealContextVariablesProvider): Collection { + if (callType != CallType.DOT && callType != CallType.SAFE) return emptyList() + + val results = ArrayList() + + for (variable in variablesProvider.allFunctionTypeVariables) { + val variableType = variable.type + if (!KotlinBuiltIns.isExtensionFunctionType(variableType)) continue + + val invokes = variableType.memberScope.getContributedFunctions(OperatorNameConventions.INVOKE, NoLookupLocation.FROM_IDE) + for (invoke in createSynthesizedInvokes(invokes)) { + for (substituted in invoke.substituteExtensionIfCallable(receiverTypes, callType)) { + val factory = object : AbstractLookupElementFactory { + override fun createStandardLookupElementsForDescriptor(descriptor: DeclarationDescriptor, useReceiverTypes: Boolean): Collection { + if (!useReceiverTypes) return emptyList() + descriptor as FunctionDescriptor // should be descriptor for "invoke" + + val invokeLookupElement = lookupElementFactory.createLookupElement(substituted, useReceiverTypes = true) + val variableLookupElement = lookupElementFactory.createLookupElement(variable, useReceiverTypes = false) + val insertHandler = lookupElementFactory.insertHandlerProvider.insertHandler(invoke) + + val lookupElement = object : LookupElementDecorator(variableLookupElement) { + override fun renderElement(presentation: LookupElementPresentation) { + invokeLookupElement.renderElement(presentation) + + presentation.itemText = variable.name.asString() + + val parameterTail = presentation.tailFragments.first() + presentation.clearTail() + presentation.appendTailText(parameterTail.text, false) + } + + override fun handleInsert(context: InsertionContext?) { + insertHandler.handleInsert(context, this) + } + } + return listOf(lookupElement) + } + + override fun createLookupElement( + descriptor: DeclarationDescriptor, + useReceiverTypes: Boolean, + qualifyNestedClasses: Boolean, + includeClassTypeArguments: Boolean, + parametersAndTypeGrayed: Boolean): LookupElement? = null + } + + results.add(Result(substituted, factory)) + } + } + } + + return results + } +} \ No newline at end of file diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletionSession.kt index b177228b78c..1fd9cda1b32 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletionSession.kt @@ -97,6 +97,14 @@ class SmartCompletionSession( val contextVariablesProvider = RealContextVariablesProvider(referenceVariantsHelper, position) withContextVariablesProvider(contextVariablesProvider) { lookupElementFactory -> + if (filter != null && receiverTypes != null) { + val results = ExtensionFunctionTypeValueCompletion(receiverTypes, callTypeAndReceiver.callType, lookupElementFactory) + .processVariables(contextVariablesProvider) + for ((invokeDescriptor, factory) in results) { + collector.addElements(filter(invokeDescriptor, factory)) + } + } + if (contextVariableTypesForAdditionalItems.any { contextVariablesProvider.functionTypeVariables(it).isNotEmpty() }) { val additionalItems = smartCompletion!!.additionalItems(lookupElementFactory).first collector.addElements(additionalItems) diff --git a/idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/ImplicitReceiver.kt b/idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/ImplicitReceiver.kt new file mode 100644 index 00000000000..19407ccacb1 --- /dev/null +++ b/idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/ImplicitReceiver.kt @@ -0,0 +1,8 @@ +class C + +fun C.test(foo: C.() -> Unit) { + fo +} + +// EXIST: { lookupString: "foo", itemText: "foo", tailText: null, typeText: "C.() -> Unit" } +// ABSENT: { itemText: "foo", typeText: "Unit" } diff --git a/idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/SafeCall.kt b/idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/SafeCall.kt new file mode 100644 index 00000000000..0bf0fdb8852 --- /dev/null +++ b/idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/SafeCall.kt @@ -0,0 +1,5 @@ +fun test(i: Int?, foo: Int.(String) -> Char) { + i?.fo +} + +// EXIST: { lookupString: "foo", itemText: "foo", tailText: "(String)", typeText: "Char", attributes: "bold" } \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/Simple.kt b/idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/Simple.kt new file mode 100644 index 00000000000..c134efe05ca --- /dev/null +++ b/idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/Simple.kt @@ -0,0 +1,6 @@ +fun test(i: Int, foo: Int.(String) -> Char, fooAny: Any.() -> Unit) { + i.fo +} + +// EXIST: { lookupString: "foo", itemText: "foo", tailText: "(String)", typeText: "Char", attributes: "bold" } +// EXIST: { lookupString: "fooAny", itemText: "fooAny", tailText: "()", typeText: "Unit", attributes: "" } \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/SmartCast.kt b/idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/SmartCast.kt new file mode 100644 index 00000000000..3fae464de8d --- /dev/null +++ b/idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/SmartCast.kt @@ -0,0 +1,11 @@ +interface I +interface J + +fun test(p: I, fooI: I.() -> Unit, fooJ: J.() -> Unit) { + if (p is J) { + p.fo + } +} + +// EXIST: { lookupString: "fooI", itemText: "fooI", tailText: "()", typeText: "Unit", attributes: "bold" } +// EXIST: { lookupString: "fooJ", itemText: "fooJ", tailText: "()", typeText: "Unit", attributes: "bold" } \ No newline at end of file diff --git a/idea/idea-completion/testData/handlers/basic/ExtensionFunctionTypeVariable1.kt b/idea/idea-completion/testData/handlers/basic/ExtensionFunctionTypeVariable1.kt new file mode 100644 index 00000000000..5ca3c21efa4 --- /dev/null +++ b/idea/idea-completion/testData/handlers/basic/ExtensionFunctionTypeVariable1.kt @@ -0,0 +1,5 @@ +fun test(i: Int, foo: Int.() -> Char) { + i. +} + +// ELEMENT: foo diff --git a/idea/idea-completion/testData/handlers/basic/ExtensionFunctionTypeVariable1.kt.after b/idea/idea-completion/testData/handlers/basic/ExtensionFunctionTypeVariable1.kt.after new file mode 100644 index 00000000000..21e1231d840 --- /dev/null +++ b/idea/idea-completion/testData/handlers/basic/ExtensionFunctionTypeVariable1.kt.after @@ -0,0 +1,5 @@ +fun test(i: Int, foo: Int.() -> Char) { + i.foo() +} + +// ELEMENT: foo diff --git a/idea/idea-completion/testData/handlers/basic/ExtensionFunctionTypeVariable2.kt b/idea/idea-completion/testData/handlers/basic/ExtensionFunctionTypeVariable2.kt new file mode 100644 index 00000000000..5e1e9e76116 --- /dev/null +++ b/idea/idea-completion/testData/handlers/basic/ExtensionFunctionTypeVariable2.kt @@ -0,0 +1,5 @@ +fun test(i: Int, foo: Int.(String) -> Char) { + i. +} + +// ELEMENT: foo diff --git a/idea/idea-completion/testData/handlers/basic/ExtensionFunctionTypeVariable2.kt.after b/idea/idea-completion/testData/handlers/basic/ExtensionFunctionTypeVariable2.kt.after new file mode 100644 index 00000000000..aeee01bdcbb --- /dev/null +++ b/idea/idea-completion/testData/handlers/basic/ExtensionFunctionTypeVariable2.kt.after @@ -0,0 +1,5 @@ +fun test(i: Int, foo: Int.(String) -> Char) { + i.foo() +} + +// ELEMENT: foo diff --git a/idea/idea-completion/testData/handlers/smart/ExtensionFunctionTypeVariable1.kt b/idea/idea-completion/testData/handlers/smart/ExtensionFunctionTypeVariable1.kt new file mode 100644 index 00000000000..27d5058f879 --- /dev/null +++ b/idea/idea-completion/testData/handlers/smart/ExtensionFunctionTypeVariable1.kt @@ -0,0 +1,7 @@ +fun test(i: Int, foo: Int.() -> Char) { + bar(i.) +} + +fun bar(p1: Char, p2: Int){} + +// ELEMENT: foo \ No newline at end of file diff --git a/idea/idea-completion/testData/handlers/smart/ExtensionFunctionTypeVariable1.kt.after b/idea/idea-completion/testData/handlers/smart/ExtensionFunctionTypeVariable1.kt.after new file mode 100644 index 00000000000..044ac77bfb8 --- /dev/null +++ b/idea/idea-completion/testData/handlers/smart/ExtensionFunctionTypeVariable1.kt.after @@ -0,0 +1,7 @@ +fun test(i: Int, foo: Int.() -> Char) { + bar(i.foo(), ) +} + +fun bar(p1: Char, p2: Int){} + +// ELEMENT: foo \ No newline at end of file diff --git a/idea/idea-completion/testData/handlers/smart/ExtensionFunctionTypeVariable2.kt b/idea/idea-completion/testData/handlers/smart/ExtensionFunctionTypeVariable2.kt new file mode 100644 index 00000000000..5b9e1034afd --- /dev/null +++ b/idea/idea-completion/testData/handlers/smart/ExtensionFunctionTypeVariable2.kt @@ -0,0 +1,7 @@ +fun test(i: Int, foo: Int.(String) -> Char) { + bar(i.) +} + +fun bar(p1: Char, p2: Int){} + +// ELEMENT: foo \ No newline at end of file diff --git a/idea/idea-completion/testData/handlers/smart/ExtensionFunctionTypeVariable2.kt.after b/idea/idea-completion/testData/handlers/smart/ExtensionFunctionTypeVariable2.kt.after new file mode 100644 index 00000000000..4c489fd2c5c --- /dev/null +++ b/idea/idea-completion/testData/handlers/smart/ExtensionFunctionTypeVariable2.kt.after @@ -0,0 +1,7 @@ +fun test(i: Int, foo: Int.(String) -> Char) { + bar(i.foo(), ) +} + +fun bar(p1: Char, p2: Int){} + +// ELEMENT: foo \ No newline at end of file diff --git a/idea/idea-completion/testData/smart/ExtensionFunctionTypeVariables.kt b/idea/idea-completion/testData/smart/ExtensionFunctionTypeVariables.kt new file mode 100644 index 00000000000..a70a122ea9e --- /dev/null +++ b/idea/idea-completion/testData/smart/ExtensionFunctionTypeVariables.kt @@ -0,0 +1,7 @@ +fun test(i: Int, foo1: Int.(String) -> Char, foo2: Int.() -> Int, foo3: String.() -> Char): Char { + return i. +} + +// EXIST: { lookupString: "foo1", itemText: "foo1", tailText: "(String)", typeText: "Char", attributes: "bold" } +// ABSENT: foo2 +// ABSENT: foo3 diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java index 40443634b98..2346ccdde51 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java @@ -1201,6 +1201,39 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes } } + @TestMetadata("idea/idea-completion/testData/basic/common/extensionFunctionTypeValues") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ExtensionFunctionTypeValues extends AbstractJSBasicCompletionTest { + public void testAllFilesPresentInExtensionFunctionTypeValues() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/basic/common/extensionFunctionTypeValues"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("ImplicitReceiver.kt") + public void testImplicitReceiver() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/ImplicitReceiver.kt"); + doTest(fileName); + } + + @TestMetadata("SafeCall.kt") + public void testSafeCall() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/SafeCall.kt"); + doTest(fileName); + } + + @TestMetadata("Simple.kt") + public void testSimple() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/Simple.kt"); + doTest(fileName); + } + + @TestMetadata("SmartCast.kt") + public void testSmartCast() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/SmartCast.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/idea-completion/testData/basic/common/extensions") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java index 3834172832a..5ca852ab0fc 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java @@ -1201,6 +1201,39 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT } } + @TestMetadata("idea/idea-completion/testData/basic/common/extensionFunctionTypeValues") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ExtensionFunctionTypeValues extends AbstractJvmBasicCompletionTest { + public void testAllFilesPresentInExtensionFunctionTypeValues() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/basic/common/extensionFunctionTypeValues"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("ImplicitReceiver.kt") + public void testImplicitReceiver() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/ImplicitReceiver.kt"); + doTest(fileName); + } + + @TestMetadata("SafeCall.kt") + public void testSafeCall() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/SafeCall.kt"); + doTest(fileName); + } + + @TestMetadata("Simple.kt") + public void testSimple() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/Simple.kt"); + doTest(fileName); + } + + @TestMetadata("SmartCast.kt") + public void testSmartCast() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensionFunctionTypeValues/SmartCast.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/idea-completion/testData/basic/common/extensions") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java index baec6954797..8e86c62984e 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java @@ -131,6 +131,12 @@ public class JvmSmartCompletionTestGenerated extends AbstractJvmSmartCompletionT doTest(fileName); } + @TestMetadata("ExtensionFunctionTypeVariables.kt") + public void testExtensionFunctionTypeVariables() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/smart/ExtensionFunctionTypeVariables.kt"); + doTest(fileName); + } + @TestMetadata("FilterTo.kt") public void testFilterTo() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/smart/FilterTo.kt"); diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTestGenerated.java index 9d27b9ae15c..2170250f97b 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTestGenerated.java @@ -71,6 +71,18 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion doTest(fileName); } + @TestMetadata("ExtensionFunctionTypeVariable1.kt") + public void testExtensionFunctionTypeVariable1() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/ExtensionFunctionTypeVariable1.kt"); + doTest(fileName); + } + + @TestMetadata("ExtensionFunctionTypeVariable2.kt") + public void testExtensionFunctionTypeVariable2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/ExtensionFunctionTypeVariable2.kt"); + doTest(fileName); + } + @TestMetadata("ExtensionReceiverTypeArg.kt") public void testExtensionReceiverTypeArg() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/ExtensionReceiverTypeArg.kt"); diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/SmartCompletionHandlerTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/SmartCompletionHandlerTestGenerated.java index f3a53ffe555..3c93cbf4c0d 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/SmartCompletionHandlerTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/SmartCompletionHandlerTestGenerated.java @@ -383,6 +383,18 @@ public class SmartCompletionHandlerTestGenerated extends AbstractSmartCompletion doTest(fileName); } + @TestMetadata("ExtensionFunctionTypeVariable1.kt") + public void testExtensionFunctionTypeVariable1() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/smart/ExtensionFunctionTypeVariable1.kt"); + doTest(fileName); + } + + @TestMetadata("ExtensionFunctionTypeVariable2.kt") + public void testExtensionFunctionTypeVariable2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/smart/ExtensionFunctionTypeVariable2.kt"); + doTest(fileName); + } + @TestMetadata("ForLoopRange.kt") public void testForLoopRange() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/smart/ForLoopRange.kt");