Add indices: don't suggest if parameter is destructuring declaration

So #KT-22162 Fixed
This commit is contained in:
Toshiaki Kameyama
2018-06-02 08:48:28 +03:00
committed by Mikhail Glukhikh
parent 752c576e20
commit fa58da85ee
3 changed files with 13 additions and 0 deletions
@@ -38,6 +38,7 @@ class AddForLoopIndicesIntention : SelfTargetingRangeIntention<KtForExpression>(
override fun applicabilityRange(element: KtForExpression): TextRange? {
if (element.loopParameter == null) return null
if (element.loopParameter?.destructuringDeclaration != null) return null
val loopRange = element.loopRange ?: return null
val bindingContext = element.analyze(BodyResolveMode.PARTIAL_WITH_CFA)
@@ -0,0 +1,7 @@
// IS_APPLICABLE: false
// WITH_RUNTIME
fun test() {
val list = listOf(Pair("foo", "bar"))
for ((x, y) <caret>in list) {
}
}
@@ -801,6 +801,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
runTest("idea/testData/intentions/addForLoopIndices/explicitParamType.kt");
}
@TestMetadata("inapplicableDestructuringDeclaration.kt")
public void testInapplicableDestructuringDeclaration() throws Exception {
runTest("idea/testData/intentions/addForLoopIndices/inapplicableDestructuringDeclaration.kt");
}
@TestMetadata("inapplicableExistingIndices.kt")
public void testInapplicableExistingIndices() throws Exception {
runTest("idea/testData/intentions/addForLoopIndices/inapplicableExistingIndices.kt");