Supported indexOfFirst/indexOfLast
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'indexOfFirst{}'"
|
||||
fun foo(list: List<String>) {
|
||||
var result = -1
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
if (s.length > 0) {
|
||||
result = index
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'indexOfFirst{}'"
|
||||
fun foo(list: List<String>) {
|
||||
val <caret>result = list.indexOfFirst { it.length > 0 }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'indexOfFirst{}'"
|
||||
fun foo(list: List<String>): Int {
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
if (s.length > 0) {
|
||||
return index
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'indexOfFirst{}'"
|
||||
fun foo(list: List<String>): Int {
|
||||
<caret>return list.indexOfFirst { it.length > 0 }
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun foo(list: List<String>) {
|
||||
var result = -1
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
if (s.length > index) {
|
||||
result = index
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'indexOfLast{}'"
|
||||
fun foo(list: List<String>) {
|
||||
var result = -1
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
if (s.length > 0) {
|
||||
result = index
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'indexOfLast{}'"
|
||||
fun foo(list: List<String>) {
|
||||
val <caret>result = list.indexOfLast { it.length > 0 }
|
||||
}
|
||||
Reference in New Issue
Block a user