Simplify for intention: now is not active if map / data class properties aren't used in a loop #KT-11716 Fixed
This commit is contained in:
@@ -57,7 +57,8 @@ class SimplifyForIntention : SelfTargetingRangeIntention<KtForExpression>(
|
|||||||
override fun applicabilityRange(element: KtForExpression): TextRange? {
|
override fun applicabilityRange(element: KtForExpression): TextRange? {
|
||||||
if (element.destructuringParameter != null) return null
|
if (element.destructuringParameter != null) return null
|
||||||
|
|
||||||
if (collectPropertiesToRemove(element) != null) {
|
val propertiesToRemove = collectPropertiesToRemove(element)
|
||||||
|
if (propertiesToRemove != null && propertiesToRemove.first.isNotEmpty()) {
|
||||||
return element.loopParameter!!.textRange
|
return element.loopParameter!!.textRange
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
data class XY(val x: String, val y: String)
|
||||||
|
fun test(xys: Array<XY>) {
|
||||||
|
for (<caret>xy in xys) {}
|
||||||
|
}
|
||||||
@@ -6537,6 +6537,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("DataClassUnused.kt")
|
||||||
|
public void testDataClassUnused() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/iterationOverMap/DataClassUnused.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("EntriesCallIsMissing.kt")
|
@TestMetadata("EntriesCallIsMissing.kt")
|
||||||
public void testEntriesCallIsMissing() throws Exception {
|
public void testEntriesCallIsMissing() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/iterationOverMap/EntriesCallIsMissing.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/iterationOverMap/EntriesCallIsMissing.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user