Simplify for intention: applicable of any numbers of properties used #KT-10779 Fixed

This commit is contained in:
Mikhail Glukhikh
2016-05-27 15:49:25 +03:00
parent 68c5e8e190
commit 792b37bce4
11 changed files with 141 additions and 23 deletions
@@ -0,0 +1,9 @@
// WITH_RUNTIME
data class My(val first: String, val second: Int)
fun foo(list: List<My>) {
for (<caret>my in list) {
println(my.second)
}
}
@@ -0,0 +1,9 @@
// WITH_RUNTIME
data class My(val first: String, val second: Int)
fun foo(list: List<My>) {
for ((first, second) in list) {
println(second)
}
}
@@ -1,4 +1,3 @@
// IS_APPLICABLE: false
// WITH_RUNTIME
fun main(args: Array<String>) {
@@ -6,6 +5,7 @@ fun main(args: Array<String>) {
for (<caret>klass in list) {
val a = klass.a
val c = klass.c
println("$a$c")
}
}
@@ -0,0 +1,10 @@
// WITH_RUNTIME
fun main(args: Array<String>) {
val list = listOf(MyClass(1, 2, 3, 4))
for ((a, b, c) in list) {
println("$a$c")
}
}
data class MyClass(val a: Int, val b: Int, val c: Int, val d: Int)
+8
View File
@@ -0,0 +1,8 @@
// WITH_RUNTIME
fun main(args: Array<String>) {
val map = hashMapOf(1 to 1)
for (<caret>entry in map) {
println(entry.key)
}
}
@@ -0,0 +1,8 @@
// WITH_RUNTIME
fun main(args: Array<String>) {
val map = hashMapOf(1 to 1)
for ((key) in map) {
println(key)
}
}
@@ -0,0 +1,8 @@
// WITH_RUNTIME
fun main(args: Array<String>) {
val map = hashMapOf(1 to 1)
for (<caret>entry in map) {
println(entry.value)
}
}
@@ -0,0 +1,8 @@
// WITH_RUNTIME
fun main(args: Array<String>) {
val map = hashMapOf(1 to 1)
for ((key, value) in map) {
println(value)
}
}
@@ -135,4 +135,36 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'for' that can be simplified using destructing declaration</problem_class>
<description>Simplify 'for' using destructing declaration</description>
</problem>
<problem>
<file>ValueOnly.kt</file>
<line>5</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/ValueOnly.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'for' that can be simplified using destructing declaration</problem_class>
<description>Simplify 'for' using destructing declaration</description>
</problem>
<problem>
<file>KeyOnly.kt</file>
<line>5</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/KeyOnly.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'for' that can be simplified using destructing declaration</problem_class>
<description>Simplify 'for' using destructing declaration</description>
</problem>
<problem>
<file>DataClassNotAllPropertiesUsed.kt</file>
<line>5</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/DataClassNotAllPropertiesUsed.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'for' that can be simplified using destructing declaration</problem_class>
<description>Simplify 'for' using destructing declaration</description>
</problem>
<problem>
<file>DataClassLast.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/DataClassLast.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'for' that can be simplified using destructing declaration</problem_class>
<description>Simplify 'for' using destructing declaration</description>
</problem>
</problems>