Add indices: don't suggest if parameter is destructuring declaration
So #KT-22162 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
752c576e20
commit
fa58da85ee
@@ -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)
|
||||
|
||||
+7
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user