Supported filterIndexedTo
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexedTo(){}'"
|
||||
fun foo(list: List<String>, target: MutableList<String>) {
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
if (s.length > index)
|
||||
target.add(s)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexedTo(){}'"
|
||||
fun foo(list: List<String>, target: MutableList<String>) {
|
||||
<caret>list.filterIndexedTo(target) { index, s -> s.length > index }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexedTo(){}'"
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): List<String> {
|
||||
val result = ArrayList<String>(1000)
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
if (s.length > index)
|
||||
result.add(s)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexedTo(){}'"
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): List<String> {
|
||||
val <caret>result = list.filterIndexedTo(ArrayList<String>(1000)) { index, s -> s.length > index }
|
||||
return result
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with '+= filterIndexed{}.filterIndexed{}'"
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexed{}.filterIndexedTo(){}'"
|
||||
fun foo(list: List<String>, target: MutableCollection<String>) {
|
||||
var j = 0
|
||||
<caret>for ((i, s) in list.withIndex()) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with '+= filterIndexed{}.filterIndexed{}'"
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexed{}.filterIndexedTo(){}'"
|
||||
fun foo(list: List<String>, target: MutableCollection<String>) {
|
||||
<caret>target += list
|
||||
<caret>list
|
||||
.filterIndexed { i, s -> s.length <= i }
|
||||
.filterIndexed { j, s -> s.length % j == 0 }
|
||||
.filterIndexedTo(target) { j, s -> s.length % j == 0 }
|
||||
}
|
||||
Reference in New Issue
Block a user