Option to use 'asSequence()'
This commit is contained in:
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.intentions.loopToCallChain.LoopToLazyCallChainIntention
|
||||
@@ -1,7 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with '+='"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>, target: MutableList<String>) {
|
||||
<caret>for (s in list) {
|
||||
target.add(s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with '+='"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>, target: MutableList<String>) {
|
||||
<caret>target += list
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'toMutableList()'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(map: Map<Int, String>): List<String> {
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'toMutableList()'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(map: Map<Int, String>): List<String> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<MutableCollection<Int>>) {
|
||||
<caret>for (collection in list) {
|
||||
collection.add(collection.size)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.ArrayList
|
||||
|
||||
var globalCollection = ArrayList<Int>()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<MutableCollection<Int>>) {
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<MutableCollection<Int>>) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'any{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
var found = false
|
||||
<caret>for (s in list) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'any{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
val <caret>found = list.any { it.length > 0 }
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'any{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
var found = false
|
||||
println("Starting the search")
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'any{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
println("Starting the search")
|
||||
val <caret>found = list.any { it.length > 0 }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'any{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>, p: Int) {
|
||||
var found: Boolean
|
||||
if (p > 0) {
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'any{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>, p: Int) {
|
||||
var found: Boolean
|
||||
if (p > 0) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'any{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
var found = false
|
||||
<caret>for (s in list) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'any{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
val <caret>found = list.any { it.length > 0 }
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'any{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
var result = 0
|
||||
<caret>for (s in list) {
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'any{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
val <caret>result = if (list.any { it.length > 0 }) 1 else 0
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
var result = takeInt()
|
||||
<caret>for (s in list) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'any{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Boolean {
|
||||
<caret>for (s in list) {
|
||||
if (s.length > 0) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'any{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Boolean {
|
||||
<caret>return list.any { it.length > 0 }
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'any{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Int {
|
||||
<caret>for (s in list) {
|
||||
if (s.length > 0) {
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'any{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Int {
|
||||
<caret>return if (list.any { it.length > 0 }) -1 else takeInt()
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexed{}.any()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.any()'"
|
||||
fun foo(list: List<String>) {
|
||||
var found = false
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexed{}.any()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.any()'"
|
||||
fun foo(list: List<String>) {
|
||||
val <caret>found = list
|
||||
.filterIndexed { index, s -> s.length > index }
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexed{}.any()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.any()'"
|
||||
fun foo(list: List<String>) {
|
||||
val <caret>found = list
|
||||
.asSequence()
|
||||
.filterIndexed { index, s -> s.length > index }
|
||||
.any()
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'any()'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Boolean {
|
||||
<caret>for (s in list) {
|
||||
return true
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'any()'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Boolean {
|
||||
<caret>return list.any()
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(array: Array<String>): String? {
|
||||
<caret>for (s in array) {
|
||||
if (s.isNotBlank()) {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(array: Array<String>): String? {
|
||||
<caret>return array.firstOrNull { it.isNotBlank() }
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): List<String> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): List<String> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>, p: Int): List<String> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>, p: Int): List<String> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexed{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.*
|
||||
|
||||
fun foo(list: List<String>): List<String> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexed{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.*
|
||||
|
||||
fun foo(list: List<String>): List<String> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterNotNull()'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String?>): List<String> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterNotNull()'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String?>): List<String> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): ArrayList<String> {
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): ArrayList<String> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>, p: Int): ArrayList<String> {
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>, p: Int): ArrayList<String> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.*
|
||||
|
||||
fun foo(list: List<String>): ArrayList<String> {
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.*
|
||||
|
||||
fun foo(list: List<String>): ArrayList<String> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.toMutableList()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.toMutableList()'"
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): MutableList<String> {
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.toMutableList()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.toMutableList()'"
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): MutableList<String> {
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.toMutableList()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.toMutableList()'"
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): MutableList<String> {
|
||||
val <caret>result = list
|
||||
.asSequence()
|
||||
.filter { it.length > 0 }
|
||||
.toMutableList()
|
||||
return result
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(): List<String> {
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(): List<String> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// 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> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// 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> {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// 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> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// 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> {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'contains()'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Boolean {
|
||||
<caret>for (s in list) {
|
||||
if (s == "a") {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'contains()'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Boolean {
|
||||
<caret>return list.contains("a")
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'contains()'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
var v = true
|
||||
<caret>for (s in list) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'contains()'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
val <caret>v = !list.contains("a")
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'contains()'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
var v = false
|
||||
<caret>for (s in list) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'contains()'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
val <caret>v = list.contains("a")
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'contains()'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Int {
|
||||
<caret>for (s in list) {
|
||||
if (s == "a") {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'contains()'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Int {
|
||||
<caret>return if (list.contains("a")) 1 else 0
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'count{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Int {
|
||||
var count = 0
|
||||
<caret>for (s in list) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'count{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Int {
|
||||
val <caret>count = list.count { it.isNotBlank() }
|
||||
return count
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'count()'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: Iterable<String>): Int {
|
||||
var count = 0
|
||||
<caret>for (s in list) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'count()'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: Iterable<String>): Int {
|
||||
val <caret>count = list.count()
|
||||
return count
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Long {
|
||||
var count = 0L
|
||||
<caret>for (s in list) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'count{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Int {
|
||||
var count = bar()
|
||||
<caret>for (s in list) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'count{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Int {
|
||||
val <caret>count = bar() + list.count { it.isNotBlank() }
|
||||
return count
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'count{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Int {
|
||||
var count = 1
|
||||
<caret>for (s in list) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'count{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Int {
|
||||
val <caret>count = 1 + list.count { it.isNotBlank() }
|
||||
return count
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'count{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Int {
|
||||
var count = 0
|
||||
<caret>for (s in list) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'count{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Int {
|
||||
val <caret>count = list.count { it.isNotBlank() }
|
||||
return count
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Int {
|
||||
var count = 0
|
||||
<caret>for (s in list) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// IS_APPLICABLE: false
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
class X {
|
||||
operator fun iterator(): Iterator<String>{
|
||||
return emptyList<String>().iterator()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String?>, target: MutableList<String>) {
|
||||
<caret>for (s in list) {
|
||||
val length = s?.length ?: break
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>, target: MutableList<String>) {
|
||||
<caret>for (s in list) {
|
||||
val length = if (s.isNotEmpty()) s.length else break
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>, target: MutableList<String>) {
|
||||
<caret>for (s in list) {
|
||||
val length = if (s.isNotEmpty()) s.length else continue
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
|
||||
fun foo(list: List<String>): String? {
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
if (s.length > index) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
|
||||
fun foo(list: List<String>): String? {
|
||||
<caret>return list
|
||||
.filterIndexed { index, s -> s.length > index }
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
|
||||
fun foo(list: List<String>): String? {
|
||||
<caret>return list
|
||||
.asSequence()
|
||||
.filterIndexed { index, s -> s.length > index }
|
||||
.firstOrNull()
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
|
||||
fun foo(list: List<String>): String? {
|
||||
var i = 0
|
||||
<caret>for (s in list) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
|
||||
fun foo(list: List<String>): String? {
|
||||
<caret>return list
|
||||
.filterIndexed { i, s -> s.length > i }
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
|
||||
fun foo(list: List<String>): String? {
|
||||
<caret>return list
|
||||
.asSequence()
|
||||
.filterIndexed { i, s -> s.length > i }
|
||||
.firstOrNull()
|
||||
}
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with '...flatMap{}.filterNot{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence()...flatMap{}.filterNot{}.mapTo(){}'"
|
||||
fun foo(list: List<String>, target: MutableCollection<String>) {
|
||||
var i = 0
|
||||
<caret>for (s in list) {
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with '...flatMap{}.filterNot{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence()...flatMap{}.filterNot{}.mapTo(){}'"
|
||||
fun foo(list: List<String>, target: MutableCollection<String>) {
|
||||
<caret>list
|
||||
.filterIndexed { i, s -> i % 10 != 0 }
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with '...flatMap{}.filterNot{}.mapTo(){}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence()...flatMap{}.filterNot{}.mapTo(){}'"
|
||||
fun foo(list: List<String>, target: MutableCollection<String>) {
|
||||
<caret>list
|
||||
.asSequence()
|
||||
.filterIndexed { i, s -> i % 10 != 0 }
|
||||
.flatMap { it.indices.asSequence() }
|
||||
.filterNot { it == 10 }
|
||||
.mapTo(target) { it.toString() }
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexedTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>, target: MutableList<String>) {
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
if (s.length > index)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexedTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>, target: MutableList<String>) {
|
||||
<caret>list.filterIndexedTo(target) { index, s -> s.length > index }
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexedTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): List<String> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexedTo(){}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): List<String> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>, target: MutableCollection<String>): String? {
|
||||
var i = 0
|
||||
<caret>for (s in list) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): String? {
|
||||
var i = 1
|
||||
<caret>for (s in list) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>, target: MutableCollection<String>): String? {
|
||||
var i = 0
|
||||
<caret>for (s in list) {
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>, target: MutableCollection<String>): String? {
|
||||
var i = 0
|
||||
<caret>for (s in list) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
|
||||
fun foo(list: List<String>): String? {
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
if (s.length > index * 10) continue
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
|
||||
fun foo(list: List<String>): String? {
|
||||
<caret>return list
|
||||
.filterIndexed { index, s -> s.length <= index * 10 && s.length > index }
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
|
||||
fun foo(list: List<String>): String? {
|
||||
<caret>return list
|
||||
.asSequence()
|
||||
.filterIndexed { index, s -> s.length <= index * 10 && s.length > index }
|
||||
.firstOrNull()
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user