Removed InvokeOnExtensionFunctionWithExplicitReceiverFix
This commit is contained in:
@@ -98,7 +98,6 @@ public class KotlinCleanupInspection(): LocalInspectionTool(), CleanupLocalInspe
|
|||||||
Errors.CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS,
|
Errors.CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS,
|
||||||
Errors.DEPRECATED_TYPE_PARAMETER_SYNTAX,
|
Errors.DEPRECATED_TYPE_PARAMETER_SYNTAX,
|
||||||
Errors.MISPLACED_TYPE_PARAMETER_CONSTRAINTS,
|
Errors.MISPLACED_TYPE_PARAMETER_CONSTRAINTS,
|
||||||
Errors.INVOKE_ON_EXTENSION_FUNCTION_WITH_EXPLICIT_DISPATCH_RECEIVER,
|
|
||||||
Errors.COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT
|
Errors.COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -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.CreateLocalVariableActionFactory
|
||||||
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateParameterByNamedArgumentActionFactory
|
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateParameterByNamedArgumentActionFactory
|
||||||
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateParameterByRefActionFactory
|
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.migration.MigrateTypeParameterListFix
|
||||||
import org.jetbrains.kotlin.idea.quickfix.replaceWith.DeprecatedSymbolUsageFix
|
import org.jetbrains.kotlin.idea.quickfix.replaceWith.DeprecatedSymbolUsageFix
|
||||||
import org.jetbrains.kotlin.idea.quickfix.replaceWith.DeprecatedSymbolUsageInWholeProjectFix
|
import org.jetbrains.kotlin.idea.quickfix.replaceWith.DeprecatedSymbolUsageInWholeProjectFix
|
||||||
@@ -355,8 +354,6 @@ public class QuickFixRegistrar : QuickFixContributor {
|
|||||||
DELEGATE_RESOLVED_TO_DEPRECATED_CONVENTION.registerFactory(DeprecatedFunctionConventionFix)
|
DELEGATE_RESOLVED_TO_DEPRECATED_CONVENTION.registerFactory(DeprecatedFunctionConventionFix)
|
||||||
DEPRECATED_UNARY_PLUS_MINUS.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)
|
COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT.registerFactory(CommaInWhenConditionWithoutArgumentFix)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-50
@@ -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<KtDotQualifiedExpression>(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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-12
@@ -73,18 +73,6 @@ fun <T : Cloneable> withTypeParameters() where T : Comparable<T> {
|
|||||||
|
|
||||||
val x = C() willBeInfix 1
|
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() {
|
fun infixTest() {
|
||||||
arrayListOf(1, 2, 3) map { it }
|
arrayListOf(1, 2, 3) map { it }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,18 +72,6 @@ fun <T> withTypeParameters() where T : Cloneable, T : Comparable<T> {
|
|||||||
|
|
||||||
val x = C() willBeInfix 1
|
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() {
|
fun infixTest() {
|
||||||
arrayListOf(1, 2, 3).map { it }
|
arrayListOf(1, 2, 3).map { it }
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
-18
@@ -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().<caret>foo("", 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public inline fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
|
|
||||||
idea/testData/quickfix/migration/invokeOnExtensionFunctionWithExplicitReceiverFix/notSimple.kt.after
Vendored
-18
@@ -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 <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
|
|
||||||
Vendored
-15
@@ -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.<caret>foo()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public inline fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
|
|
||||||
Vendored
-15
@@ -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 <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
|
|
||||||
@@ -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")
|
@TestMetadata("idea/testData/quickfix/migration/missingConstructorKeyword")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user