diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/KotlinCleanupInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/KotlinCleanupInspection.kt index a12c3a38a12..5d9279082dc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/KotlinCleanupInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/KotlinCleanupInspection.kt @@ -98,7 +98,6 @@ public class KotlinCleanupInspection(): LocalInspectionTool(), CleanupLocalInspe Errors.CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS, Errors.DEPRECATED_TYPE_PARAMETER_SYNTAX, Errors.MISPLACED_TYPE_PARAMETER_CONSTRAINTS, - Errors.INVOKE_ON_EXTENSION_FUNCTION_WITH_EXPLICIT_DISPATCH_RECEIVER, Errors.COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT ) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt index 9fd567d6a30..fb1fc0c0582 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt @@ -31,7 +31,6 @@ import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass.CreateClas import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateLocalVariableActionFactory import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateParameterByNamedArgumentActionFactory import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateParameterByRefActionFactory -import org.jetbrains.kotlin.idea.quickfix.migration.InvokeOnExtensionFunctionWithExplicitReceiverFix import org.jetbrains.kotlin.idea.quickfix.migration.MigrateTypeParameterListFix import org.jetbrains.kotlin.idea.quickfix.replaceWith.DeprecatedSymbolUsageFix import org.jetbrains.kotlin.idea.quickfix.replaceWith.DeprecatedSymbolUsageInWholeProjectFix @@ -355,8 +354,6 @@ public class QuickFixRegistrar : QuickFixContributor { DELEGATE_RESOLVED_TO_DEPRECATED_CONVENTION.registerFactory(DeprecatedFunctionConventionFix) DEPRECATED_UNARY_PLUS_MINUS.registerFactory(DeprecatedFunctionConventionFix) - INVOKE_ON_EXTENSION_FUNCTION_WITH_EXPLICIT_DISPATCH_RECEIVER.registerFactory(InvokeOnExtensionFunctionWithExplicitReceiverFix) - COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT.registerFactory(CommaInWhenConditionWithoutArgumentFix) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/migration/InvokeOnExtensionFunctionWithExplicitReceiverFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/migration/InvokeOnExtensionFunctionWithExplicitReceiverFix.kt deleted file mode 100644 index 6b47a795dbf..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/migration/InvokeOnExtensionFunctionWithExplicitReceiverFix.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.quickfix.migration - -import com.intellij.codeInsight.intention.IntentionAction -import com.intellij.openapi.editor.Editor -import com.intellij.openapi.project.Project -import org.jetbrains.kotlin.diagnostics.Diagnostic -import org.jetbrains.kotlin.diagnostics.Errors -import org.jetbrains.kotlin.idea.core.replaced -import org.jetbrains.kotlin.idea.quickfix.CleanupFix -import org.jetbrains.kotlin.idea.quickfix.KotlinQuickFixAction -import org.jetbrains.kotlin.idea.quickfix.KotlinSingleIntentionActionFactory -import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelector - -class InvokeOnExtensionFunctionWithExplicitReceiverFix(qualifiedExpression: KtDotQualifiedExpression) : KotlinQuickFixAction(qualifiedExpression), CleanupFix { - override fun getFamilyName() = "Surround callee with parenthesis" - override fun getText() = familyName - - override fun invoke(project: Project, editor: Editor?, file: KtFile) { - val callExpression = element.selectorExpression as KtCallExpression - val newCallee = KtPsiFactory(file).createExpressionByPattern("($0.$1)", element.receiverExpression, callExpression.calleeExpression!!) - val newCallExpression = element.replaced(callExpression) - newCallExpression.calleeExpression!!.replace(newCallee) - } - - companion object : KotlinSingleIntentionActionFactory() { - override fun createAction(diagnostic: Diagnostic): IntentionAction? { - val callee = Errors.INVOKE_ON_EXTENSION_FUNCTION_WITH_EXPLICIT_DISPATCH_RECEIVER.cast(diagnostic).psiElement as? KtNameReferenceExpression ?: return null - val callExpression = callee.parent as? KtCallExpression ?: return null - val qualifiedExpression = callExpression.getQualifiedExpressionForSelector() as? KtDotQualifiedExpression ?: return null - return InvokeOnExtensionFunctionWithExplicitReceiverFix(qualifiedExpression) - } - } -} \ No newline at end of file diff --git a/idea/testData/inspections/cleanup/cleanup.kt b/idea/testData/inspections/cleanup/cleanup.kt index 62591c17ab1..5abf82198a1 100644 --- a/idea/testData/inspections/cleanup/cleanup.kt +++ b/idea/testData/inspections/cleanup/cleanup.kt @@ -73,18 +73,6 @@ fun withTypeParameters() where T : Comparable { val x = C() willBeInfix 1 -class AAA { - val foo: BBB.() -> Unit get() = null!! -} - -class BBB - -fun test(a: AAA, b: BBB) { - with(b) { - a.foo() - } -} - fun infixTest() { arrayListOf(1, 2, 3) map { it } } diff --git a/idea/testData/inspections/cleanup/cleanup.kt.after b/idea/testData/inspections/cleanup/cleanup.kt.after index 87888468d65..83d35fdcb9a 100644 --- a/idea/testData/inspections/cleanup/cleanup.kt.after +++ b/idea/testData/inspections/cleanup/cleanup.kt.after @@ -72,18 +72,6 @@ fun withTypeParameters() where T : Cloneable, T : Comparable { val x = C() willBeInfix 1 -class AAA { - val foo: BBB.() -> Unit get() = null!! -} - -class BBB - -fun test(a: AAA, b: BBB) { - with(b) { - (a.foo)() - } -} - fun infixTest() { arrayListOf(1, 2, 3).map { it } } diff --git a/idea/testData/quickfix/migration/invokeOnExtensionFunctionWithExplicitReceiverFix/notSimple.kt b/idea/testData/quickfix/migration/invokeOnExtensionFunctionWithExplicitReceiverFix/notSimple.kt deleted file mode 100644 index ea3455d5c53..00000000000 --- a/idea/testData/quickfix/migration/invokeOnExtensionFunctionWithExplicitReceiverFix/notSimple.kt +++ /dev/null @@ -1,18 +0,0 @@ -// "Surround callee with parenthesis" "true" - -class A { - val foo: B.(String, Int) -> Unit get() = null!! -} - -class B { - fun getA() = A() -} - - -fun test(b: B) { - with(b) { - b.getA().foo("", 1) - } -} - -public inline fun with(receiver: T, f: T.() -> R): R = receiver.f() \ No newline at end of file diff --git a/idea/testData/quickfix/migration/invokeOnExtensionFunctionWithExplicitReceiverFix/notSimple.kt.after b/idea/testData/quickfix/migration/invokeOnExtensionFunctionWithExplicitReceiverFix/notSimple.kt.after deleted file mode 100644 index e633d174a7e..00000000000 --- a/idea/testData/quickfix/migration/invokeOnExtensionFunctionWithExplicitReceiverFix/notSimple.kt.after +++ /dev/null @@ -1,18 +0,0 @@ -// "Surround callee with parenthesis" "true" - -class A { - val foo: B.(String, Int) -> Unit get() = null!! -} - -class B { - fun getA() = A() -} - - -fun test(b: B) { - with(b) { - (b.getA().foo)("", 1) - } -} - -public inline fun with(receiver: T, f: T.() -> R): R = receiver.f() \ No newline at end of file diff --git a/idea/testData/quickfix/migration/invokeOnExtensionFunctionWithExplicitReceiverFix/simple.kt b/idea/testData/quickfix/migration/invokeOnExtensionFunctionWithExplicitReceiverFix/simple.kt deleted file mode 100644 index 187c8c91bb0..00000000000 --- a/idea/testData/quickfix/migration/invokeOnExtensionFunctionWithExplicitReceiverFix/simple.kt +++ /dev/null @@ -1,15 +0,0 @@ -// "Surround callee with parenthesis" "true" - -class A { - val foo: B.() -> Unit get() = null!! -} - -class B - -fun test(a: A, b: B) { - with(b) { - a.foo() - } -} - -public inline fun with(receiver: T, f: T.() -> R): R = receiver.f() \ No newline at end of file diff --git a/idea/testData/quickfix/migration/invokeOnExtensionFunctionWithExplicitReceiverFix/simple.kt.after b/idea/testData/quickfix/migration/invokeOnExtensionFunctionWithExplicitReceiverFix/simple.kt.after deleted file mode 100644 index 6b2ecc7acf0..00000000000 --- a/idea/testData/quickfix/migration/invokeOnExtensionFunctionWithExplicitReceiverFix/simple.kt.after +++ /dev/null @@ -1,15 +0,0 @@ -// "Surround callee with parenthesis" "true" - -class A { - val foo: B.() -> Unit get() = null!! -} - -class B - -fun test(a: A, b: B) { - with(b) { - (a.foo)() - } -} - -public inline fun with(receiver: T, f: T.() -> R): R = receiver.f() \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java index 4a46c411647..a5392a0ac9e 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java @@ -4724,27 +4724,6 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { } } - @TestMetadata("idea/testData/quickfix/migration/invokeOnExtensionFunctionWithExplicitReceiverFix") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class InvokeOnExtensionFunctionWithExplicitReceiverFix extends AbstractQuickFixTest { - public void testAllFilesPresentInInvokeOnExtensionFunctionWithExplicitReceiverFix() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/migration/invokeOnExtensionFunctionWithExplicitReceiverFix"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true); - } - - @TestMetadata("notSimple.kt") - public void testNotSimple() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/migration/invokeOnExtensionFunctionWithExplicitReceiverFix/notSimple.kt"); - doTest(fileName); - } - - @TestMetadata("simple.kt") - public void testSimple() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/migration/invokeOnExtensionFunctionWithExplicitReceiverFix/simple.kt"); - doTest(fileName); - } - } - @TestMetadata("idea/testData/quickfix/migration/missingConstructorKeyword") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)