Groupped tests by folders
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.map{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.map{}.toList()'"
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): List<Int> {
|
||||
val result = ArrayList<Int>()
|
||||
<caret>for (s in list) {
|
||||
if (s.length > 0)
|
||||
result.add(s.hashCode())
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.map{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.map{}.toList()'"
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): List<Int> {
|
||||
val result = list
|
||||
.filter { it.length > 0 }
|
||||
.map { it.hashCode() }
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.map{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.map{}.toList()'"
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): List<Int> {
|
||||
val result = list
|
||||
.asSequence()
|
||||
.filter { it.length > 0 }
|
||||
.map { it.hashCode() }
|
||||
.toList()
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.map{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.map{}.toList()'"
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): List<Int> {
|
||||
val result = ArrayList<Int>()
|
||||
<caret>for (s in list) {
|
||||
if (s.length > 0) {
|
||||
val h = s.hashCode()
|
||||
result.add(h)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.map{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.map{}.toList()'"
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): List<Int> {
|
||||
val <caret>result = list
|
||||
.filter { it.length > 0 }
|
||||
.map { it.hashCode() }
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.map{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.map{}.toList()'"
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): List<Int> {
|
||||
val <caret>result = list
|
||||
.asSequence()
|
||||
.filter { it.length > 0 }
|
||||
.map { it.hashCode() }
|
||||
.toList()
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'map{}.firstOrNull{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.firstOrNull{}'"
|
||||
fun foo(list: List<String>): Int? {
|
||||
<caret>for (s in list) {
|
||||
val length = s.length
|
||||
if (length > 0) return length
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'map{}.firstOrNull{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.firstOrNull{}'"
|
||||
fun foo(list: List<String>): Int? {
|
||||
<caret>return list
|
||||
.map { it.length }
|
||||
.firstOrNull { it > 0 }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'map{}.firstOrNull{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.firstOrNull{}'"
|
||||
fun foo(list: List<String>): Int? {
|
||||
<caret>return list
|
||||
.asSequence()
|
||||
.map { it.length }
|
||||
.firstOrNull { it > 0 }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'map{}.filterIndexed{}.firstOrNull()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.filterIndexed{}.firstOrNull()'"
|
||||
fun foo(list: List<String>): Int? {
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
val l = s.length
|
||||
if (l > index) {
|
||||
return l
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'map{}.filterIndexed{}.firstOrNull()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.filterIndexed{}.firstOrNull()'"
|
||||
fun foo(list: List<String>): Int? {
|
||||
<caret>return list
|
||||
.map { it.length }
|
||||
.filterIndexed { index, l -> l > index }
|
||||
.firstOrNull()
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'map{}.filterIndexed{}.firstOrNull()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.filterIndexed{}.firstOrNull()'"
|
||||
fun foo(list: List<String>): Int? {
|
||||
<caret>return list
|
||||
.asSequence()
|
||||
.map { it.length }
|
||||
.filterIndexed { index, l -> l > index }
|
||||
.firstOrNull()
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexed{}.firstOrNull{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.firstOrNull{}'"
|
||||
fun foo(list: List<String>): Int? {
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
val x = s.length * index
|
||||
if (x > 0) return x
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexed{}.firstOrNull{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.firstOrNull{}'"
|
||||
fun foo(list: List<String>): Int? {
|
||||
<caret>return list
|
||||
.mapIndexed { index, s -> s.length * index }
|
||||
.firstOrNull { it > 0 }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexed{}.firstOrNull{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.firstOrNull{}'"
|
||||
fun foo(list: List<String>): Int? {
|
||||
<caret>return list
|
||||
.asSequence()
|
||||
.mapIndexed { index, s -> s.length * index }
|
||||
.firstOrNull { it > 0 }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexedNotNull{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexedNotNull{}.mapTo(){}'"
|
||||
fun foo(list: List<String?>, target: MutableList<String>) {
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
val length = s?.substring(index)?.length
|
||||
if (length == null) continue
|
||||
target.add(length.toString())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexedNotNull{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexedNotNull{}.mapTo(){}'"
|
||||
fun foo(list: List<String?>, target: MutableList<String>) {
|
||||
<caret>list
|
||||
.mapIndexedNotNull { index, s -> s?.substring(index)?.length }
|
||||
.mapTo(target) { it.toString() }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexedNotNull{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexedNotNull{}.mapTo(){}'"
|
||||
fun foo(list: List<String?>, target: MutableList<String>) {
|
||||
<caret>list
|
||||
.asSequence()
|
||||
.mapIndexedNotNull { index, s -> s?.substring(index)?.length }
|
||||
.mapTo(target) { it.toString() }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexedNotNullTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
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,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexedNotNullTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String?>, target: MutableList<Int>) {
|
||||
<caret>list.mapIndexedNotNullTo(target) { index, s -> s?.substring(index)?.length }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexedNotNullTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
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)
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexedNotNullTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String?>, target: MutableList<Int>) {
|
||||
<caret>list.mapIndexedNotNullTo(target) { index, s -> s?.substring(index)?.length }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexedNotNull{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexedNotNull{}.mapTo(){}'"
|
||||
fun foo(list: List<String?>, target: MutableList<String>) {
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
val length = s?.substring(index)?.length ?: continue
|
||||
target.add(length.toString())
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexedNotNull{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexedNotNull{}.mapTo(){}'"
|
||||
fun foo(list: List<String?>, target: MutableList<String>) {
|
||||
<caret>list
|
||||
.mapIndexedNotNull { index, s -> s?.substring(index)?.length }
|
||||
.mapTo(target) { it.toString() }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexedNotNull{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexedNotNull{}.mapTo(){}'"
|
||||
fun foo(list: List<String?>, target: MutableList<String>) {
|
||||
<caret>list
|
||||
.asSequence()
|
||||
.mapIndexedNotNull { index, s -> s?.substring(index)?.length }
|
||||
.mapTo(target) { it.toString() }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexedTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>, target: MutableList<Int>) {
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
target.add(s.hashCode() * index)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexedTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>, target: MutableList<Int>) {
|
||||
<caret>list.mapIndexedTo(target) { index, s -> s.hashCode() * index }
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterNot{}.mapIndexed{}.firstOrNull{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'"
|
||||
fun foo(list: List<String>): Int? {
|
||||
var index = 0
|
||||
<caret>for (s in list) {
|
||||
if (s.isBlank()) continue
|
||||
val x = s.length * index
|
||||
index++
|
||||
if (x > 0) return x
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterNot{}.mapIndexed{}.firstOrNull{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'"
|
||||
fun foo(list: List<String>): Int? {
|
||||
return list
|
||||
.filterNot { it.isBlank() }
|
||||
.mapIndexed { index, s -> s.length * index }
|
||||
.firstOrNull { it > 0 }
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterNot{}.mapIndexed{}.firstOrNull{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'"
|
||||
fun foo(list: List<String>): Int? {
|
||||
return list
|
||||
.asSequence()
|
||||
.filterNot { it.isBlank() }
|
||||
.mapIndexed { index, s -> s.length * index }
|
||||
.firstOrNull { it > 0 }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexed{}.mapIndexed{}.firstOrNull{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.mapIndexed{}.firstOrNull{}'"
|
||||
fun foo(list: List<String>): Int? {
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
val x = s.length * index
|
||||
val y = x + index
|
||||
if (y > 0) return y
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexed{}.mapIndexed{}.firstOrNull{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.mapIndexed{}.firstOrNull{}'"
|
||||
fun foo(list: List<String>): Int? {
|
||||
<caret>return list
|
||||
.mapIndexed { index, s -> s.length * index }
|
||||
.mapIndexed { index, x -> x + index }
|
||||
.firstOrNull { it > 0 }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexed{}.mapIndexed{}.firstOrNull{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.mapIndexed{}.firstOrNull{}'"
|
||||
fun foo(list: List<String>): Int? {
|
||||
<caret>return list
|
||||
.asSequence()
|
||||
.mapIndexed { index, s -> s.length * index }
|
||||
.mapIndexed { index, x -> x + index }
|
||||
.firstOrNull { it > 0 }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapNotNull{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().mapNotNull{}.mapTo(){}'"
|
||||
fun foo(list: List<String?>, target: MutableList<String>) {
|
||||
<caret>for (s in list) {
|
||||
val length = s?.length
|
||||
if (length == null) continue
|
||||
target.add(length.toString())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapNotNull{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().mapNotNull{}.mapTo(){}'"
|
||||
fun foo(list: List<String?>, target: MutableList<String>) {
|
||||
<caret>list
|
||||
.mapNotNull { it?.length }
|
||||
.mapTo(target) { it.toString() }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapNotNull{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().mapNotNull{}.mapTo(){}'"
|
||||
fun foo(list: List<String?>, target: MutableList<String>) {
|
||||
<caret>list
|
||||
.asSequence()
|
||||
.mapNotNull { it?.length }
|
||||
.mapTo(target) { it.toString() }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapNotNullTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String?>, target: MutableList<Int>) {
|
||||
<caret>for (s in list) {
|
||||
val length = s?.length
|
||||
if (length == null) continue
|
||||
target.add(length)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapNotNullTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String?>, target: MutableList<Int>) {
|
||||
<caret>list.mapNotNullTo(target) { it?.length }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapNotNullTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String?>, target: MutableList<Int>) {
|
||||
<caret>for (s in list) {
|
||||
val length = s?.length ?: continue
|
||||
target.add(length)
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapNotNullTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String?>, target: MutableList<Int>) {
|
||||
<caret>list.mapNotNullTo(target) { it?.length }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapNotNull{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().mapNotNull{}.mapTo(){}'"
|
||||
fun foo(list: List<String?>, target: MutableList<String>) {
|
||||
<caret>for (s in list) {
|
||||
val length = s?.length ?: continue
|
||||
target.add(length.toString())
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapNotNull{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().mapNotNull{}.mapTo(){}'"
|
||||
fun foo(list: List<String?>, target: MutableList<String>) {
|
||||
<caret>list
|
||||
.mapNotNull { it?.length }
|
||||
.mapTo(target) { it.toString() }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapNotNull{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().mapNotNull{}.mapTo(){}'"
|
||||
fun foo(list: List<String?>, target: MutableList<String>) {
|
||||
<caret>list
|
||||
.asSequence()
|
||||
.mapNotNull { it?.length }
|
||||
.mapTo(target) { it.toString() }
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'flatMap{}.mapNotNull{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.mapNotNull{}.mapTo(){}'"
|
||||
fun foo(list: List<String>, target: MutableList<String>) {
|
||||
<caret>for (s in list) {
|
||||
for (i in s.indices) {
|
||||
val v = bar(i) ?: continue
|
||||
target.add(v.substring(1))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(p: Int): String? = null
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'flatMap{}.mapNotNull{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.mapNotNull{}.mapTo(){}'"
|
||||
fun foo(list: List<String>, target: MutableList<String>) {
|
||||
<caret>list
|
||||
.flatMap { it.indices }
|
||||
.mapNotNull { bar(it) }
|
||||
.mapTo(target) { it.substring(1) }
|
||||
}
|
||||
|
||||
fun bar(p: Int): String? = null
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'flatMap{}.mapNotNull{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.mapNotNull{}.mapTo(){}'"
|
||||
fun foo(list: List<String>, target: MutableList<String>) {
|
||||
<caret>list
|
||||
.asSequence()
|
||||
.flatMap { it.indices.asSequence() }
|
||||
.mapNotNull { bar(it) }
|
||||
.mapTo(target) { it.substring(1) }
|
||||
}
|
||||
|
||||
fun bar(p: Int): String? = null
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>, target: MutableList<String>) {
|
||||
Loop@
|
||||
<caret>for (s in list) {
|
||||
for (i in s.indices) {
|
||||
val v = bar(i) ?: continue@Loop
|
||||
target.add(v.substring(1))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(p: Int): String? = null
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.mapTo(){}'"
|
||||
fun foo(list: List<String>, target: MutableList<Int>) {
|
||||
<caret>for (s in list) {
|
||||
if (s.length > 0)
|
||||
target.add(s.hashCode())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.mapTo(){}'"
|
||||
fun foo(list: List<String>, target: MutableList<Int>) {
|
||||
<caret>list
|
||||
.filter { it.length > 0 }
|
||||
.mapTo(target) { it.hashCode() }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.mapTo(){}'"
|
||||
fun foo(list: List<String>, target: MutableList<Int>) {
|
||||
<caret>list
|
||||
.asSequence()
|
||||
.filter { it.length > 0 }
|
||||
.mapTo(target) { it.hashCode() }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>, target: MutableList<Int>) {
|
||||
<caret>for (s in list) {
|
||||
val l = s.length
|
||||
target.add(l)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>, target: MutableList<Int>) {
|
||||
<caret>list.mapTo(target) { it.length }
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.mapTo(){}'"
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): List<Int> {
|
||||
val target = ArrayList<Int>(100)
|
||||
<caret>for (s in list) {
|
||||
if (s.length > 0)
|
||||
target.add(s.hashCode())
|
||||
}
|
||||
return target
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.mapTo(){}'"
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): List<Int> {
|
||||
val <caret>target = list
|
||||
.filter { it.length > 0 }
|
||||
.mapTo(ArrayList<Int>(100)) { it.hashCode() }
|
||||
return target
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.mapTo(){}'"
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): List<Int> {
|
||||
val <caret>target = list
|
||||
.asSequence()
|
||||
.filter { it.length > 0 }
|
||||
.mapTo(ArrayList<Int>(100)) { it.hashCode() }
|
||||
return target
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.mapTo(){}'"
|
||||
fun foo(list: List<String>): List<Int> {
|
||||
val target = createCollection()
|
||||
<caret>for (s in list) {
|
||||
if (s.length > 0)
|
||||
target.add(s.hashCode())
|
||||
}
|
||||
return target
|
||||
}
|
||||
|
||||
fun createCollection(): MutableList<Int> = java.util.ArrayList()
|
||||
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.mapTo(){}'"
|
||||
fun foo(list: List<String>): List<Int> {
|
||||
val target = createCollection()
|
||||
<caret>list
|
||||
.filter { it.length > 0 }
|
||||
.mapTo(target) { it.hashCode() }
|
||||
return target
|
||||
}
|
||||
|
||||
fun createCollection(): MutableList<Int> = java.util.ArrayList()
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.mapTo(){}'"
|
||||
fun foo(list: List<String>): List<Int> {
|
||||
val target = createCollection()
|
||||
<caret>list
|
||||
.asSequence()
|
||||
.filter { it.length > 0 }
|
||||
.mapTo(target) { it.hashCode() }
|
||||
return target
|
||||
}
|
||||
|
||||
fun createCollection(): MutableList<Int> = java.util.ArrayList()
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>, target: MutableList<Int>) {
|
||||
<caret>for (s in list) {
|
||||
if (s.length > 0)
|
||||
target.add(0)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Int? {
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
if (s.isBlank()) continue
|
||||
val x = s.length * index
|
||||
if (x > 1000) return x
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'map{}.firstOrNull{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.firstOrNull{}'"
|
||||
fun foo(list: List<String>): Int? {
|
||||
<caret>for (s in list) {
|
||||
var length = s.length
|
||||
if (length > 0) return length
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'map{}.firstOrNull{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.firstOrNull{}'"
|
||||
fun foo(list: List<String>): Int? {
|
||||
<caret>return list
|
||||
.map { it.length }
|
||||
.firstOrNull { it > 0 }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'map{}.firstOrNull{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.firstOrNull{}'"
|
||||
fun foo(list: List<String>): Int? {
|
||||
<caret>return list
|
||||
.asSequence()
|
||||
.map { it.length }
|
||||
.firstOrNull { it > 0 }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Int? {
|
||||
<caret>for (s in list) {
|
||||
var length = s.length
|
||||
if (length > 0) return ++length
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): String? {
|
||||
<caret>for (s in list) {
|
||||
val length = s.length
|
||||
if (length > 0) return s + length
|
||||
}
|
||||
return null
|
||||
}
|
||||
Reference in New Issue
Block a user