mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-30 15:51:53 +00:00
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? {
|
||||
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 null
|
||||
|
||||
7
idea/testData/intentions/iterationOverMap/DataClassUnused.kt
vendored
Normal file
7
idea/testData/intentions/iterationOverMap/DataClassUnused.kt
vendored
Normal file
@@ -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);
|
||||
}
|
||||
|
||||
@TestMetadata("DataClassUnused.kt")
|
||||
public void testDataClassUnused() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/iterationOverMap/DataClassUnused.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("EntriesCallIsMissing.kt")
|
||||
public void testEntriesCallIsMissing() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/iterationOverMap/EntriesCallIsMissing.kt");
|
||||
|
||||
Reference in New Issue
Block a user