Refactoring: make "loop to call chain" AbstractKotlinInspection

This commit is contained in:
Mikhail Glukhikh
2017-12-21 12:51:45 +03:00
parent f44fba746e
commit 3f1a3dfeb2
9 changed files with 147 additions and 129 deletions
@@ -1,3 +0,0 @@
fun foo(list: List<String>): String? {
<spot>return list.firstOrNull { it.length > 0 }</spot>
}
@@ -1,8 +0,0 @@
fun foo(list: List<String>): String? {
<spot>for (s in list) {
if (s.length > 0) {
return s
}
}
return null</spot>
}
@@ -1,5 +0,0 @@
<html>
<body>
This intention converts a for-loop into a sequence of stdlib-operations (like "map", "filter" etc)
</body>
</html>
@@ -1,7 +0,0 @@
fun foo(list: List<String>) {
val sum = <spot>list
.asSequence()
.map { it.calcSomething() }
.filter { it > 0 }
.sumBy { it }</spot>
}
@@ -1,9 +0,0 @@
fun foo(list: List<String>) {
val sum = 0
<spot>for (s in list) {
val x = s.calcSomething()
if (x > 0) {
sum += x
}
}</spot>
}
@@ -1,5 +0,0 @@
<html>
<body>
This intention converts a for-loop into a sequence of stdlib-operations (like "map", "filter" etc) with lazy evaluation (using 'asSequence()' method)
</body>
</html>