Supported mapIndexedTo and mapIndexedNotNullTo
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with '+= ...filterNot{}.mapIndexed{}'"
|
||||
// INTENTION_TEXT: "Replace with 'flatMap{}.filterNot{}.mapIndexedTo(){}'"
|
||||
fun foo(list: List<String>, target: MutableCollection<Int>) {
|
||||
var i = 0
|
||||
<caret>for (s in list) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with '+= ...filterNot{}.mapIndexed{}'"
|
||||
// INTENTION_TEXT: "Replace with 'flatMap{}.filterNot{}.mapIndexedTo(){}'"
|
||||
fun foo(list: List<String>, target: MutableCollection<Int>) {
|
||||
<caret>target += list
|
||||
<caret>list
|
||||
.flatMap { it.indices }
|
||||
.filterNot { it == 10 }
|
||||
.mapIndexed { i, j -> i + j }
|
||||
.mapIndexedTo(target) { i, j -> i + j }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexedNotNullTo(){}'"
|
||||
fun foo(list: List<String?>, target: MutableList<Int>) {
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
val length = s?.substring(index)?.length
|
||||
if (length == null) continue
|
||||
target.add(length)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexedNotNullTo(){}'"
|
||||
fun foo(list: List<String?>, target: MutableList<Int>) {
|
||||
<caret>list.mapIndexedNotNullTo(target) { index, s -> s?.substring(index)?.length }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexedNotNullTo(){}'"
|
||||
fun foo(list: List<String?>, target: MutableList<Int>) {
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
val length = s?.substring(index)?.length ?: continue
|
||||
target.add(length)
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexedNotNullTo(){}'"
|
||||
fun foo(list: List<String?>, target: MutableList<Int>) {
|
||||
<caret>list.mapIndexedNotNullTo(target) { index, s -> s?.substring(index)?.length }
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with '+= mapIndexed{}'"
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexedTo(){}'"
|
||||
fun foo(list: List<String>, target: MutableList<Int>) {
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
target.add(s.hashCode() * index)
|
||||
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexedTo(){}'"
|
||||
fun foo(list: List<String>, target: MutableList<Int>) {
|
||||
<caret>list.mapIndexedTo(target) { index, s -> s.hashCode() * index }
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with '+= mapIndexed{}'"
|
||||
fun foo(list: List<String>, target: MutableList<Int>) {
|
||||
<caret>target += list.mapIndexed { index, s -> s.hashCode() * index }
|
||||
}
|
||||
Reference in New Issue
Block a user