From 21e25e8509375dc55bb3d4f621c7f49248bacc54 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 2 Jul 2015 13:16:34 +0200 Subject: [PATCH] KT-4820: Intention to introduce/remove indices from a for-loop (update to modern Kotlin) --- idea/src/META-INF/plugin.xml | 5 - .../intentions/AddForLoopIndicesIntention.kt | 61 +++++----- .../RemoveForLoopIndicesIntention.kt | 53 ++++---- .../addForLoopIndicesIntention/.intention | 1 + .../inapplicableExistingIndices.kt | 2 +- .../inapplicableOverridenFunction.kt | 2 +- .../intArray.kt.after | 2 +- .../iterable.kt.after | 2 +- .../listWithType.kt.after | 2 +- .../objectArray.kt.after | 2 +- .../simpleIntList.kt.after | 2 +- .../stream.kt.after | 2 +- .../string.kt.after | 2 +- .../removeForLoopIndicesIntention/.intention | 1 + .../inapplicableIndexUse.kt | 2 +- .../inapplicableOverridenFunction.kt | 5 +- .../loopWithType.kt | 2 +- .../simpleLoopWithIndices.kt | 2 +- .../intentions/IntentionTestGenerated.java | 114 ++++++++++++++++++ 19 files changed, 184 insertions(+), 80 deletions(-) diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index fa8065d6150..27eeb9b18f4 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -803,11 +803,6 @@ Kotlin S - - org.jetbrains.jet.plugin.intentions.SwapBinaryExpression - Kotlin - - org.jetbrains.kotlin.idea.intentions.SwapBinaryExpressionIntention Kotlin diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/AddForLoopIndicesIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/AddForLoopIndicesIntention.kt index 5030329a8d2..05fd49970d3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/AddForLoopIndicesIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/AddForLoopIndicesIntention.kt @@ -16,34 +16,33 @@ package org.jetbrains.kotlin.idea.intentions -import com.intellij.openapi.editor.Editor -import org.jetbrains.jet.lang.psi.JetForExpression -import org.jetbrains.jet.lang.psi.JetPsiFactory -import org.jetbrains.jet.lang.psi.JetDotQualifiedExpression -import com.intellij.psi.util.PsiTreeUtil -import com.intellij.psi.PsiDocumentManager -import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache -import org.jetbrains.jet.lang.resolve.BindingContext -import org.jetbrains.jet.lang.psi.JetParenthesizedExpression import com.intellij.codeInsight.template.TemplateBuilderImpl +import com.intellij.codeInsight.template.TemplateManager import com.intellij.codeInsight.template.impl.TemplateManagerImpl -import org.jetbrains.jet.lang.resolve.DescriptorUtils -import org.jetbrains.jet.analyzer.analyzeInContext -import org.jetbrains.jet.lang.psi.JetCallExpression +import com.intellij.openapi.editor.Editor +import com.intellij.psi.PsiDocumentManager +import com.intellij.psi.util.PsiTreeUtil +import org.jetbrains.kotlin.analyzer.analyzeInContext +import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.DescriptorUtils public class AddForLoopIndicesIntention : JetSelfTargetingIntention( - "add.for.loop.indices", javaClass()) { + javaClass(), "Add indices to 'for' loop") { override fun applyTo(element: JetForExpression, editor: Editor) { val loopRange = element.getLoopRange()!! - val newRangeText = "${loopRange.getText()}.withIndices()" - val newRange = JetPsiFactory.createExpression(editor.getProject(), newRangeText) + val newRangeText = "${loopRange.getText()}.withIndex()" + val project = editor.getProject()!! + val psiFactory = JetPsiFactory(project) + val newRange = psiFactory.createExpression(newRangeText) //Roundabout way to create new multiparameter element so as not to incorrectly trigger syntax error highlighting val loopParameter = element.getLoopParameter()!! - val parenthesizedParam = JetPsiFactory.createExpression(editor.getProject(), "(index)") as JetParenthesizedExpression + val parenthesizedParam = psiFactory.createExpression("(index)") as JetParenthesizedExpression val indexElement = parenthesizedParam.getExpression()!! - val comma = JetPsiFactory.createComma(editor.getProject()) - val newParamElement = JetPsiFactory.createExpression(editor.getProject(), " ${loopParameter.getText()}") + val comma = psiFactory.createComma() + val newParamElement = psiFactory.createExpression(loopParameter.getText()) parenthesizedParam.addAfter(newParamElement, indexElement) parenthesizedParam.addAfter(comma, indexElement) @@ -55,29 +54,31 @@ public class AddForLoopIndicesIntention : JetSelfTargetingIntention= body.getTextRange().getStartOffset()) return false + val range = element.getLoopRange() ?: return false if (range is JetDotQualifiedExpression) { val selector = range.getSelectorExpression() ?: return true - if (selector.getText() == "withIndices()") return false + if (selector.getText() == "withIndex()") return false } - val potentialExpression = JetPsiFactory.createExpression(element.getProject(), - "${range.getText()}.withIndices()") as JetDotQualifiedExpression + val psiFactory = JetPsiFactory(element.getProject()) + val potentialExpression = psiFactory.createExpression("${range.getText()}.withIndex()") as JetDotQualifiedExpression - val bindingContext = AnalyzerFacadeWithCache.getContextForElement(element) + val bindingContext = element.analyze() val scope = bindingContext[BindingContext.RESOLUTION_SCOPE, element] ?: return false val functionSelector = potentialExpression.getSelectorExpression() as JetCallExpression val updatedContext = potentialExpression.analyzeInContext(scope) - val callScope = updatedContext[BindingContext.RESOLVED_CALL, functionSelector.getCalleeExpression()!!] ?: return false + val call = updatedContext[BindingContext.CALL, functionSelector.getCalleeExpression()] ?: return false + val callScope = updatedContext[BindingContext.RESOLVED_CALL, call] ?: return false val callFqName = DescriptorUtils.getFqNameSafe(callScope.getCandidateDescriptor()) - return callFqName.toString() == "kotlin.withIndices" + return callFqName.toString() == "kotlin.withIndex" } - -} \ No newline at end of file +} diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveForLoopIndicesIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveForLoopIndicesIntention.kt index 638781790ef..649db97d58f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveForLoopIndicesIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveForLoopIndicesIntention.kt @@ -16,55 +16,48 @@ package org.jetbrains.kotlin.idea.intentions -import org.jetbrains.jet.lang.psi.JetForExpression -import com.intellij.openapi.editor.Editor -import org.jetbrains.jet.lang.psi.JetDotQualifiedExpression -import org.jetbrains.jet.lang.psi.JetPsiUtil -import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache import com.intellij.find.FindManager import com.intellij.find.impl.FindManagerImpl +import com.intellij.openapi.editor.Editor +import com.intellij.psi.search.searches.ReferencesSearch import com.intellij.usageView.UsageInfo -import org.jetbrains.jet.plugin.findUsages.KotlinPropertyFindUsagesOptions -import org.jetbrains.jet.lang.resolve.BindingContext -import org.jetbrains.jet.lang.psi.JetCallExpression -import org.jetbrains.jet.lang.resolve.DescriptorUtils +import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.idea.findUsages.KotlinPropertyFindUsagesOptions +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.DescriptorUtils public class RemoveForLoopIndicesIntention : JetSelfTargetingIntention( - "remove.for.loop.indices", javaClass()) { + javaClass(), "Remove indices in 'for' loop") { override fun applyTo(element: JetForExpression, editor: Editor) { val parameter = element.getMultiParameter()!! val range = element.getLoopRange() as JetDotQualifiedExpression val parameters = parameter.getEntries() - if (parameters.size() == 2) { - parameter.replace(parameters[1]) - } - else { - JetPsiUtil.deleteElementWithDelimiters(parameters[0]) - } + + val loop = JetPsiFactory(element).createExpression("for (${parameters[1].getText()} in _) {}") as JetForExpression + parameter.replace(loop.getLoopParameter()!!) range.replace(range.getReceiverExpression()) } - override fun isApplicableTo(element: JetForExpression): Boolean { + override fun isApplicableTo(element: JetForExpression, caretOffset: Int): Boolean { val multiParameter = element.getMultiParameter() ?: return false + if (multiParameter.getEntries().size() != 2) return false val range = element.getLoopRange() as? JetDotQualifiedExpression ?: return false val selector = range.getSelectorExpression() as? JetCallExpression ?: return false - if (!selector.textMatches("withIndices()")) return false + if (!selector.textMatches("withIndex()")) return false - val bindingContext = AnalyzerFacadeWithCache.getContextForElement(element) - val callResolution = bindingContext[BindingContext.RESOLVED_CALL, selector.getCalleeExpression()!!] ?: return false + val body = element.getBody() + if (body != null && caretOffset >= body.getTextRange().getStartOffset()) return false + + val bindingContext = element.analyze() + val call = bindingContext[BindingContext.CALL, selector.getCalleeExpression()] ?: return false + val callResolution = bindingContext[BindingContext.RESOLVED_CALL, call] ?: return false val fqName = DescriptorUtils.getFqNameSafe(callResolution.getCandidateDescriptor()) - if (fqName.toString() != "kotlin.withIndices") return false + if (fqName.toString() != "kotlin.withIndex") return false val indexVar = multiParameter.getEntries()[0] - val findManager = FindManager.getInstance(element.getProject()) as FindManagerImpl - val findHandler = findManager.getFindUsagesManager().getFindUsagesHandler(indexVar, false) ?: return false - val options = KotlinPropertyFindUsagesOptions(element.getProject()) - var usageCount = 0 - val processorLambda: (UsageInfo?) -> Boolean = { t -> usageCount++; false } - findHandler.processElementUsages(indexVar, processorLambda, options) - return usageCount == 0 + return ReferencesSearch.search(indexVar).findFirst() == null } - -} \ No newline at end of file +} diff --git a/idea/testData/intentions/addForLoopIndicesIntention/.intention b/idea/testData/intentions/addForLoopIndicesIntention/.intention index e69de29bb2d..8e1d6530547 100644 --- a/idea/testData/intentions/addForLoopIndicesIntention/.intention +++ b/idea/testData/intentions/addForLoopIndicesIntention/.intention @@ -0,0 +1 @@ +org.jetbrains.kotlin.idea.intentions.AddForLoopIndicesIntention \ No newline at end of file diff --git a/idea/testData/intentions/addForLoopIndicesIntention/inapplicableExistingIndices.kt b/idea/testData/intentions/addForLoopIndicesIntention/inapplicableExistingIndices.kt index b9b2b899071..08b3a0ec6c9 100644 --- a/idea/testData/intentions/addForLoopIndicesIntention/inapplicableExistingIndices.kt +++ b/idea/testData/intentions/addForLoopIndicesIntention/inapplicableExistingIndices.kt @@ -1,7 +1,7 @@ //IS_APPLICABLE: FALSE // WITH_RUNTIME fun b(c: List) { - for ((indexVariable, d) in c.withIndices()) { + for ((indexVariable, d) in c.withIndex()) { } } \ No newline at end of file diff --git a/idea/testData/intentions/addForLoopIndicesIntention/inapplicableOverridenFunction.kt b/idea/testData/intentions/addForLoopIndicesIntention/inapplicableOverridenFunction.kt index c16ceeb8a97..5ce28ace4b3 100644 --- a/idea/testData/intentions/addForLoopIndicesIntention/inapplicableOverridenFunction.kt +++ b/idea/testData/intentions/addForLoopIndicesIntention/inapplicableOverridenFunction.kt @@ -1,6 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: FALSE -fun String.withIndices(): Int = 42 +fun String.withIndex(): Int = 42 fun foo(s: String) { for (a in s) { diff --git a/idea/testData/intentions/addForLoopIndicesIntention/intArray.kt.after b/idea/testData/intentions/addForLoopIndicesIntention/intArray.kt.after index 317eb113f87..b4ab124628b 100644 --- a/idea/testData/intentions/addForLoopIndicesIntention/intArray.kt.after +++ b/idea/testData/intentions/addForLoopIndicesIntention/intArray.kt.after @@ -1,6 +1,6 @@ //WITH_RUNTIME fun foo(bar: IntArray) { - for ((index, a) in bar.withIndices()) { + for ((index, a) in bar.withIndex()) { } } \ No newline at end of file diff --git a/idea/testData/intentions/addForLoopIndicesIntention/iterable.kt.after b/idea/testData/intentions/addForLoopIndicesIntention/iterable.kt.after index 4351c3856a9..902f7c2661f 100644 --- a/idea/testData/intentions/addForLoopIndicesIntention/iterable.kt.after +++ b/idea/testData/intentions/addForLoopIndicesIntention/iterable.kt.after @@ -1,6 +1,6 @@ //WITH_RUNTIME fun foo(bar: Iterable) { - for ((index, a) in bar.withIndices()) { + for ((index, a) in bar.withIndex()) { } } \ No newline at end of file diff --git a/idea/testData/intentions/addForLoopIndicesIntention/listWithType.kt.after b/idea/testData/intentions/addForLoopIndicesIntention/listWithType.kt.after index 633543f3ffe..09d634c6844 100644 --- a/idea/testData/intentions/addForLoopIndicesIntention/listWithType.kt.after +++ b/idea/testData/intentions/addForLoopIndicesIntention/listWithType.kt.after @@ -1,7 +1,7 @@ // WITH_RUNTIME fun a() { val b = listOf(1,2,3,4,5) - for ((index, c : Int) in b.withIndices()) { + for ((index, c : Int) in b.withIndex()) { } } \ No newline at end of file diff --git a/idea/testData/intentions/addForLoopIndicesIntention/objectArray.kt.after b/idea/testData/intentions/addForLoopIndicesIntention/objectArray.kt.after index 07f226b0945..3a439a7c204 100644 --- a/idea/testData/intentions/addForLoopIndicesIntention/objectArray.kt.after +++ b/idea/testData/intentions/addForLoopIndicesIntention/objectArray.kt.after @@ -1,6 +1,6 @@ //WITH_RUNTIME fun foo(bar: Array) { - for ((index, a) in bar.withIndices()) { + for ((index, a) in bar.withIndex()) { } } \ No newline at end of file diff --git a/idea/testData/intentions/addForLoopIndicesIntention/simpleIntList.kt.after b/idea/testData/intentions/addForLoopIndicesIntention/simpleIntList.kt.after index 68e44be3929..72b7ca64e6e 100644 --- a/idea/testData/intentions/addForLoopIndicesIntention/simpleIntList.kt.after +++ b/idea/testData/intentions/addForLoopIndicesIntention/simpleIntList.kt.after @@ -1,7 +1,7 @@ // WITH_RUNTIME fun a() { val b = listOf(1,2,3,4,5) - for ((index, c) in b.withIndices()) { + for ((index, c) in b.withIndex()) { } } \ No newline at end of file diff --git a/idea/testData/intentions/addForLoopIndicesIntention/stream.kt.after b/idea/testData/intentions/addForLoopIndicesIntention/stream.kt.after index 15ba5726654..65080a14bda 100644 --- a/idea/testData/intentions/addForLoopIndicesIntention/stream.kt.after +++ b/idea/testData/intentions/addForLoopIndicesIntention/stream.kt.after @@ -1,6 +1,6 @@ //WITH_RUNTIME fun foo(bar: Stream) { - for ((index, a) in bar.withIndices()) { + for ((index, a) in bar.withIndex()) { } } \ No newline at end of file diff --git a/idea/testData/intentions/addForLoopIndicesIntention/string.kt.after b/idea/testData/intentions/addForLoopIndicesIntention/string.kt.after index 1d015a4fd97..7d5610a30fd 100644 --- a/idea/testData/intentions/addForLoopIndicesIntention/string.kt.after +++ b/idea/testData/intentions/addForLoopIndicesIntention/string.kt.after @@ -1,6 +1,6 @@ //WITH_RUNTIME fun foo(bar: String) { - for ((index, a) in bar.withIndices()) { + for ((index, a) in bar.withIndex()) { } } \ No newline at end of file diff --git a/idea/testData/intentions/removeForLoopIndicesIntention/.intention b/idea/testData/intentions/removeForLoopIndicesIntention/.intention index e69de29bb2d..013371784a9 100644 --- a/idea/testData/intentions/removeForLoopIndicesIntention/.intention +++ b/idea/testData/intentions/removeForLoopIndicesIntention/.intention @@ -0,0 +1 @@ +org.jetbrains.kotlin.idea.intentions.RemoveForLoopIndicesIntention \ No newline at end of file diff --git a/idea/testData/intentions/removeForLoopIndicesIntention/inapplicableIndexUse.kt b/idea/testData/intentions/removeForLoopIndicesIntention/inapplicableIndexUse.kt index 9f043ae07e4..6d6948cb0c6 100644 --- a/idea/testData/intentions/removeForLoopIndicesIntention/inapplicableIndexUse.kt +++ b/idea/testData/intentions/removeForLoopIndicesIntention/inapplicableIndexUse.kt @@ -2,7 +2,7 @@ //WITH_RUNTIME fun foo(b: List) : Int { - for ((i, c) in b.withIndices()) { + for ((i, c) in b.withIndex()) { return i } return 0 diff --git a/idea/testData/intentions/removeForLoopIndicesIntention/inapplicableOverridenFunction.kt b/idea/testData/intentions/removeForLoopIndicesIntention/inapplicableOverridenFunction.kt index 7f3a7fd589d..1442ced4db1 100644 --- a/idea/testData/intentions/removeForLoopIndicesIntention/inapplicableOverridenFunction.kt +++ b/idea/testData/intentions/removeForLoopIndicesIntention/inapplicableOverridenFunction.kt @@ -1,11 +1,10 @@ // WITH_RUNTIME // IS_APPLICABLE: FALSE -import java.util.LinkedList -fun Int.withIndices(): List> = LinkedList>() +fun Int.withIndex(): List> = linkedListOf>() fun foo(s: Int) { - for ((index, a) in s.withIndices()) { + for ((index, a) in s.withIndex()) { } } \ No newline at end of file diff --git a/idea/testData/intentions/removeForLoopIndicesIntention/loopWithType.kt b/idea/testData/intentions/removeForLoopIndicesIntention/loopWithType.kt index 116f672c62a..9ad127ad0b0 100644 --- a/idea/testData/intentions/removeForLoopIndicesIntention/loopWithType.kt +++ b/idea/testData/intentions/removeForLoopIndicesIntention/loopWithType.kt @@ -1,6 +1,6 @@ //WITH_RUNTIME fun foo(bar: List) { - for ((i : Int, b: Int) in bar.withIndices()) { + for ((i : Int, b: Int) in bar.withIndex()) { } } \ No newline at end of file diff --git a/idea/testData/intentions/removeForLoopIndicesIntention/simpleLoopWithIndices.kt b/idea/testData/intentions/removeForLoopIndicesIntention/simpleLoopWithIndices.kt index f734f259947..187c87358a6 100644 --- a/idea/testData/intentions/removeForLoopIndicesIntention/simpleLoopWithIndices.kt +++ b/idea/testData/intentions/removeForLoopIndicesIntention/simpleLoopWithIndices.kt @@ -1,6 +1,6 @@ //WITH_RUNTIME fun foo(bar: List) { - for ((i,a) in bar.withIndices()) { + for ((i,a) in bar.withIndex()) { } } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index f068e1782f7..ab1120754ac 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -92,6 +92,81 @@ public class IntentionTestGenerated extends AbstractIntentionTest { } } + @TestMetadata("idea/testData/intentions/addForLoopIndicesIntention") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class AddForLoopIndicesIntention extends AbstractIntentionTest { + public void testAllFilesPresentInAddForLoopIndicesIntention() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/addForLoopIndicesIntention"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true); + } + + @TestMetadata("inapplicableExistingIndices.kt") + public void testInapplicableExistingIndices() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addForLoopIndicesIntention/inapplicableExistingIndices.kt"); + doTest(fileName); + } + + @TestMetadata("inapplicableOverridenFunction.kt") + public void testInapplicableOverridenFunction() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addForLoopIndicesIntention/inapplicableOverridenFunction.kt"); + doTest(fileName); + } + + @TestMetadata("inapplicableSyntaxError.kt") + public void testInapplicableSyntaxError() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addForLoopIndicesIntention/inapplicableSyntaxError.kt"); + doTest(fileName); + } + + @TestMetadata("inapplicableUnorderedCollection.kt") + public void testInapplicableUnorderedCollection() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addForLoopIndicesIntention/inapplicableUnorderedCollection.kt"); + doTest(fileName); + } + + @TestMetadata("intArray.kt") + public void testIntArray() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addForLoopIndicesIntention/intArray.kt"); + doTest(fileName); + } + + @TestMetadata("iterable.kt") + public void testIterable() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addForLoopIndicesIntention/iterable.kt"); + doTest(fileName); + } + + @TestMetadata("listWithType.kt") + public void testListWithType() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addForLoopIndicesIntention/listWithType.kt"); + doTest(fileName); + } + + @TestMetadata("objectArray.kt") + public void testObjectArray() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addForLoopIndicesIntention/objectArray.kt"); + doTest(fileName); + } + + @TestMetadata("simpleIntList.kt") + public void testSimpleIntList() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addForLoopIndicesIntention/simpleIntList.kt"); + doTest(fileName); + } + + @TestMetadata("stream.kt") + public void testStream() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addForLoopIndicesIntention/stream.kt"); + doTest(fileName); + } + + @TestMetadata("string.kt") + public void testString() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addForLoopIndicesIntention/string.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/testData/intentions/addNameToArgument") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -6089,6 +6164,45 @@ public class IntentionTestGenerated extends AbstractIntentionTest { } + @TestMetadata("idea/testData/intentions/removeForLoopIndicesIntention") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class RemoveForLoopIndicesIntention extends AbstractIntentionTest { + public void testAllFilesPresentInRemoveForLoopIndicesIntention() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/removeForLoopIndicesIntention"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true); + } + + @TestMetadata("inapplicableForLoop.kt") + public void testInapplicableForLoop() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/removeForLoopIndicesIntention/inapplicableForLoop.kt"); + doTest(fileName); + } + + @TestMetadata("inapplicableIndexUse.kt") + public void testInapplicableIndexUse() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/removeForLoopIndicesIntention/inapplicableIndexUse.kt"); + doTest(fileName); + } + + @TestMetadata("inapplicableOverridenFunction.kt") + public void testInapplicableOverridenFunction() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/removeForLoopIndicesIntention/inapplicableOverridenFunction.kt"); + doTest(fileName); + } + + @TestMetadata("loopWithType.kt") + public void testLoopWithType() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/removeForLoopIndicesIntention/loopWithType.kt"); + doTest(fileName); + } + + @TestMetadata("simpleLoopWithIndices.kt") + public void testSimpleLoopWithIndices() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/removeForLoopIndicesIntention/simpleLoopWithIndices.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/testData/intentions/removeUnnecessaryParentheses") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)