diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AssignOperatorAmbiguityFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AssignOperatorAmbiguityFactory.kt new file mode 100644 index 00000000000..b70ac48e5fe --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AssignOperatorAmbiguityFactory.kt @@ -0,0 +1,76 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.idea.quickfix + +import com.intellij.codeInsight.intention.IntentionAction +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.project.Project +import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap +import org.jetbrains.kotlin.diagnostics.Diagnostic +import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.idea.references.mainReference +import org.jetbrains.kotlin.lexer.KtTokens +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.endOffset +import org.jetbrains.kotlin.resolve.calls.callUtil.getType +import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode +import org.jetbrains.kotlin.types.KotlinType + +object AssignOperatorAmbiguityFactory : KotlinIntentionActionsFactory() { + override fun doCreateActions(diagnostic: Diagnostic): List { + val fixes = mutableListOf() + val element = diagnostic.psiElement.parent + if (element is KtBinaryExpression) { + val left = element.left + val right = element.right + val operationText = when (element.operationToken) { + KtTokens.PLUSEQ -> "plus" + KtTokens.MINUSEQ -> "minus" + else -> null + } + if (left != null && right != null && operationText != null) { + val context = element.analyze(BodyResolveMode.PARTIAL) + if (left.getType(context).isMutableCollection()) { + val property = left.mainReference?.resolve() as? KtProperty + val propertyName = property?.name + if (property != null && propertyName != null && property.isLocal) { + fixes.add(ChangeVariableMutabilityFix(property, false, "Change '$propertyName' to val")) + } + fixes.add(ReplaceWithAssignFunctionCallFix(element, operationText)) + } + } + } + return fixes + } +} + +private fun KotlinType?.isMutableCollection(): Boolean { + if (this == null) return false + return JavaToKotlinClassMap.isMutable(this) || constructor.supertypes.reversed().any { JavaToKotlinClassMap.isMutable(it) } +} + +private class ReplaceWithAssignFunctionCallFix( + element: KtBinaryExpression, + private val operationText: String +) : KotlinQuickFixAction(element) { + override fun getText() = "Replace with '${operationText}Assign()' call" + + override fun getFamilyName() = text + + override fun invoke(project: Project, editor: Editor?, file: KtFile) { + val binaryExpression = element ?: return + val left = binaryExpression.left ?: return + val right = binaryExpression.right ?: return + val replaced = binaryExpression.replace( + KtPsiFactory(binaryExpression).createExpressionByPattern("$0.${operationText}Assign($1)", left, right) + ) + editor?.caretModel?.moveToOffset(replaced.endOffset) + } +} + + + + diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt index 43e6b178559..19c0e042243 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt @@ -578,5 +578,7 @@ class QuickFixRegistrar : QuickFixContributor { NOTHING_TO_INLINE.registerFactory(RemoveModifierFix.createRemoveModifierFactory(isRedundant = false)) DECLARATION_CANT_BE_INLINED.registerFactory(DeclarationCantBeInlinedFactory) + + ASSIGN_OPERATOR_AMBIGUITY.registerFactory(AssignOperatorAmbiguityFactory) } } diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/arrayList.kt b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/arrayList.kt new file mode 100644 index 00000000000..c900e2a5832 --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/arrayList.kt @@ -0,0 +1,7 @@ +// "Change 'list' to val" "true" +// WITH_RUNTIME + +fun test() { + var list = ArrayList() + list -= 2 +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/arrayList.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/arrayList.kt.after new file mode 100644 index 00000000000..39847df38f3 --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/arrayList.kt.after @@ -0,0 +1,7 @@ +// "Change 'list' to val" "true" +// WITH_RUNTIME + +fun test() { + val list = ArrayList() + list -= 2 +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/classVariable.kt b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/classVariable.kt new file mode 100644 index 00000000000..0d22ef6d1df --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/classVariable.kt @@ -0,0 +1,14 @@ +// "Change 'list' to val" "false" +// ACTION: Replace overloaded operator with function call +// ACTION: Replace with 'plusAssign()' call +// ACTION: Replace with ordinary assignment +// ERROR: Assignment operators ambiguity:
public operator fun Collection.plus(element: Int): List defined in kotlin.collections
@InlineOnly public inline operator fun MutableCollection.plusAssign(element: Int): Unit defined in kotlin.collections +// WITH_RUNTIME + +class Test { + var list = mutableListOf(1) + + fun test() { + list += 2 + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashMap.kt b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashMap.kt new file mode 100644 index 00000000000..6612a6a9668 --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashMap.kt @@ -0,0 +1,7 @@ +// "Change 'set' to val" "true" +// WITH_RUNTIME + +fun test() { + var set = HashMap() + set += 2 to 2 +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashMap.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashMap.kt.after new file mode 100644 index 00000000000..a06e0582ccf --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashMap.kt.after @@ -0,0 +1,7 @@ +// "Change 'set' to val" "true" +// WITH_RUNTIME + +fun test() { + val set = HashMap() + set += 2 to 2 +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashSet.kt b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashSet.kt new file mode 100644 index 00000000000..bf1d53e7977 --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashSet.kt @@ -0,0 +1,7 @@ +// "Change 'set' to val" "true" +// WITH_RUNTIME + +fun test() { + var set = HashSet() + set -= 2 +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashSet.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashSet.kt.after new file mode 100644 index 00000000000..ce9f2687a03 --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashSet.kt.after @@ -0,0 +1,7 @@ +// "Change 'set' to val" "true" +// WITH_RUNTIME + +fun test() { + val set = HashSet() + set -= 2 +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableList.kt b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableList.kt new file mode 100644 index 00000000000..283c8c7ac84 --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableList.kt @@ -0,0 +1,7 @@ +// "Change 'list' to val" "true" +// WITH_RUNTIME + +fun test() { + var list = mutableListOf(1) + list += 2 +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableList.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableList.kt.after new file mode 100644 index 00000000000..cb011859d16 --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableList.kt.after @@ -0,0 +1,7 @@ +// "Change 'list' to val" "true" +// WITH_RUNTIME + +fun test() { + val list = mutableListOf(1) + list += 2 +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableMap.kt b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableMap.kt new file mode 100644 index 00000000000..32791b97092 --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableMap.kt @@ -0,0 +1,7 @@ +// "Change 'map' to val" "true" +// WITH_RUNTIME + +fun test() { + var map = mutableMapOf(1 to 1) + map += 2 to 2 +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableMap.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableMap.kt.after new file mode 100644 index 00000000000..1c914036f5f --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableMap.kt.after @@ -0,0 +1,7 @@ +// "Change 'map' to val" "true" +// WITH_RUNTIME + +fun test() { + val map = mutableMapOf(1 to 1) + map += 2 to 2 +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableSet.kt b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableSet.kt new file mode 100644 index 00000000000..31f037b82a2 --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableSet.kt @@ -0,0 +1,7 @@ +// "Change 'set' to val" "true" +// WITH_RUNTIME + +fun test() { + var set = mutableSetOf(1) + set += 2 +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableSet.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableSet.kt.after new file mode 100644 index 00000000000..84c720a8006 --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableSet.kt.after @@ -0,0 +1,7 @@ +// "Change 'set' to val" "true" +// WITH_RUNTIME + +fun test() { + val set = mutableSetOf(1) + set += 2 +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/arrayList.kt b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/arrayList.kt new file mode 100644 index 00000000000..a9de5690e1c --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/arrayList.kt @@ -0,0 +1,7 @@ +// "Replace with 'minusAssign()' call" "true" +// WITH_RUNTIME + +fun test() { + var list = ArrayList() + list -= 2 +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/arrayList.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/arrayList.kt.after new file mode 100644 index 00000000000..b16b2d15a36 --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/arrayList.kt.after @@ -0,0 +1,7 @@ +// "Replace with 'minusAssign()' call" "true" +// WITH_RUNTIME + +fun test() { + var list = ArrayList() + list.minusAssign(2) +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashMap.kt b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashMap.kt new file mode 100644 index 00000000000..5d1b92dd6a0 --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashMap.kt @@ -0,0 +1,7 @@ +// "Replace with 'plusAssign()' call" "true" +// WITH_RUNTIME + +fun test() { + var set = HashMap() + set += 2 to 2 +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashMap.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashMap.kt.after new file mode 100644 index 00000000000..adb873157d5 --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashMap.kt.after @@ -0,0 +1,7 @@ +// "Replace with 'plusAssign()' call" "true" +// WITH_RUNTIME + +fun test() { + var set = HashMap() + set.plusAssign(2 to 2) +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashSet.kt b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashSet.kt new file mode 100644 index 00000000000..46b4fff36df --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashSet.kt @@ -0,0 +1,7 @@ +// "Replace with 'minusAssign()' call" "true" +// WITH_RUNTIME + +fun test() { + var set = HashSet() + set -= 2 +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashSet.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashSet.kt.after new file mode 100644 index 00000000000..81c6bd046cb --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashSet.kt.after @@ -0,0 +1,7 @@ +// "Replace with 'minusAssign()' call" "true" +// WITH_RUNTIME + +fun test() { + var set = HashSet() + set.minusAssign(2) +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableList.kt b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableList.kt new file mode 100644 index 00000000000..fe454153c94 --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableList.kt @@ -0,0 +1,7 @@ +// "Replace with 'plusAssign()' call" "true" +// WITH_RUNTIME + +fun test() { + var list = mutableListOf(1) + list += 2 +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableList.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableList.kt.after new file mode 100644 index 00000000000..ed092503640 --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableList.kt.after @@ -0,0 +1,7 @@ +// "Replace with 'plusAssign()' call" "true" +// WITH_RUNTIME + +fun test() { + var list = mutableListOf(1) + list.plusAssign(2) +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableMap.kt b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableMap.kt new file mode 100644 index 00000000000..42db4a6e15a --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableMap.kt @@ -0,0 +1,7 @@ +// "Replace with 'plusAssign()' call" "true" +// WITH_RUNTIME + +fun test() { + var map = mutableMapOf(1 to 1) + map += 2 to 2 +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableMap.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableMap.kt.after new file mode 100644 index 00000000000..8cf53f69210 --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableMap.kt.after @@ -0,0 +1,7 @@ +// "Replace with 'plusAssign()' call" "true" +// WITH_RUNTIME + +fun test() { + var map = mutableMapOf(1 to 1) + map.plusAssign(2 to 2) +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableSet.kt b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableSet.kt new file mode 100644 index 00000000000..e12e96d3ba4 --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableSet.kt @@ -0,0 +1,7 @@ +// "Replace with 'plusAssign()' call" "true" +// WITH_RUNTIME + +fun test() { + var set = mutableSetOf(1) + set += 2 +} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableSet.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableSet.kt.after new file mode 100644 index 00000000000..6191d03a02c --- /dev/null +++ b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableSet.kt.after @@ -0,0 +1,7 @@ +// "Replace with 'plusAssign()' call" "true" +// WITH_RUNTIME + +fun test() { + var set = mutableSetOf(1) + set.plusAssign(2) +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java index 989eb23149f..e7ce615fc68 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java @@ -364,6 +364,45 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes } } + @TestMetadata("idea/testData/quickfix/assignOperatorAmbiguity") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class AssignOperatorAmbiguity extends AbstractQuickFixMultiFileTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestWithExtraFile, TargetBackend.ANY, testDataFilePath); + } + + public void testAllFilesPresentInAssignOperatorAmbiguity() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/assignOperatorAmbiguity"), Pattern.compile("^(\\w+)\\.((before\\.Main\\.\\w+)|(test))$"), TargetBackend.ANY, true); + } + + @TestMetadata("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ChangeToVal extends AbstractQuickFixMultiFileTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestWithExtraFile, TargetBackend.ANY, testDataFilePath); + } + + public void testAllFilesPresentInChangeToVal() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal"), Pattern.compile("^(\\w+)\\.((before\\.Main\\.\\w+)|(test))$"), TargetBackend.ANY, true); + } + } + + @TestMetadata("idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ReplaceWithAssignCall extends AbstractQuickFixMultiFileTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestWithExtraFile, TargetBackend.ANY, testDataFilePath); + } + + public void testAllFilesPresentInReplaceWithAssignCall() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall"), Pattern.compile("^(\\w+)\\.((before\\.Main\\.\\w+)|(test))$"), TargetBackend.ANY, true); + } + } + } + @TestMetadata("idea/testData/quickfix/assignToProperty") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java index ec662d77db7..a2f1c63f492 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java @@ -1224,6 +1224,110 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { } } + @TestMetadata("idea/testData/quickfix/assignOperatorAmbiguity") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class AssignOperatorAmbiguity extends AbstractQuickFixTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); + } + + public void testAllFilesPresentInAssignOperatorAmbiguity() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/assignOperatorAmbiguity"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ChangeToVal extends AbstractQuickFixTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); + } + + public void testAllFilesPresentInChangeToVal() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("arrayList.kt") + public void testArrayList() throws Exception { + runTest("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/arrayList.kt"); + } + + @TestMetadata("classVariable.kt") + public void testClassVariable() throws Exception { + runTest("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/classVariable.kt"); + } + + @TestMetadata("hashMap.kt") + public void testHashMap() throws Exception { + runTest("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashMap.kt"); + } + + @TestMetadata("hashSet.kt") + public void testHashSet() throws Exception { + runTest("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashSet.kt"); + } + + @TestMetadata("mutableList.kt") + public void testMutableList() throws Exception { + runTest("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableList.kt"); + } + + @TestMetadata("mutableMap.kt") + public void testMutableMap() throws Exception { + runTest("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableMap.kt"); + } + + @TestMetadata("mutableSet.kt") + public void testMutableSet() throws Exception { + runTest("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableSet.kt"); + } + } + + @TestMetadata("idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ReplaceWithAssignCall extends AbstractQuickFixTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); + } + + public void testAllFilesPresentInReplaceWithAssignCall() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("arrayList.kt") + public void testArrayList() throws Exception { + runTest("idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/arrayList.kt"); + } + + @TestMetadata("hashMap.kt") + public void testHashMap() throws Exception { + runTest("idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashMap.kt"); + } + + @TestMetadata("hashSet.kt") + public void testHashSet() throws Exception { + runTest("idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashSet.kt"); + } + + @TestMetadata("mutableList.kt") + public void testMutableList() throws Exception { + runTest("idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableList.kt"); + } + + @TestMetadata("mutableMap.kt") + public void testMutableMap() throws Exception { + runTest("idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableMap.kt"); + } + + @TestMetadata("mutableSet.kt") + public void testMutableSet() throws Exception { + runTest("idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableSet.kt"); + } + } + } + @TestMetadata("idea/testData/quickfix/assignToProperty") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)