tests: apply official code style

#KT-38632 Fixed
This commit is contained in:
Dmitry Gridin
2020-04-28 15:51:57 +07:00
parent d8f9643650
commit 11a3482970
406 changed files with 1785 additions and 1525 deletions
@@ -1,3 +1,4 @@
fun foo(p: Dependency): Double {
return p.getInt().toDouble() // explicit conversion to Double must be added on conversion (if type Dependency) is correctly resolved
return p.getInt()
.toDouble() // explicit conversion to Double must be added on conversion (if type Dependency) is correctly resolved
}
@@ -5,16 +5,17 @@ class A {
var element = element
element = JetPsiUtil.ascendIfPropertyAccessor(element)
if (element is JetNamedFunction || element is JetProperty) {
val bindingContext = AnalyzerFacadeWithCache.analyzeFileWithCache(element.getContainingJetFile()).getBindingContext()
val bindingContext =
AnalyzerFacadeWithCache.analyzeFileWithCache(element.getContainingJetFile()).getBindingContext()
val declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element)
if (declarationDescriptor is CallableMemberDescriptor) {
val containingDescriptor = declarationDescriptor.getContainingDeclaration()
if (containingDescriptor is ClassDescriptor) {
return JetBundle.message(
"override.declaration.x.in.y",
DescriptorRenderer.COMPACT.render(declarationDescriptor),
IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.render(containingDescriptor)
"override.declaration.x.in.y",
DescriptorRenderer.COMPACT.render(declarationDescriptor),
IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.render(containingDescriptor)
)
}
}
@@ -20,8 +20,10 @@ class Target {
}
var ambiguousKotlin: IAmbiguousKotlin = AmbiguousKotlin() // Should not add import in case of 2 declarations in Kotlin
var ambiguous: IAmbiguous = Ambiguous() // Should not add import in case of ambiguous declarations in Kotlin and in Java
var ambiguousKotlin: IAmbiguousKotlin =
AmbiguousKotlin() // Should not add import in case of 2 declarations in Kotlin
var ambiguous: IAmbiguous =
Ambiguous() // Should not add import in case of ambiguous declarations in Kotlin and in Java
var ambiguousJava: IAmbiguousJava = AmbiguousJava() // Should not add import in case of 2 declarations in Java
fun workWithStatics() {
@@ -1,7 +1,7 @@
fun test() {
var a = 1
a =
<caret>
<caret>
}
// SET_TRUE: ALIGN_MULTILINE_BINARY_OPERATION
@@ -1,7 +1,7 @@
fun test() {
var a = 1
a =
<caret>
<caret>
}
// SET_TRUE: ALIGN_MULTILINE_BINARY_OPERATION
@@ -1,4 +1,4 @@
fun testParam(
<caret>
<caret>
) {
}
@@ -1,2 +1,2 @@
fun test() =
<caret>
<caret>
@@ -5,4 +5,4 @@ interface A1
open class B1
class Simpleclass() : B1(),
<caret>A1
<caret>A1
@@ -1,3 +1,3 @@
val a: (String) -> String = {
<caret>some ->
<caret>some ->
}
@@ -1,4 +1,4 @@
fun test() {
val (a, b) =
<caret>
<caret>
}
@@ -1,2 +1,2 @@
val a =
<caret>
<caret>
@@ -1,6 +1,6 @@
fun foo(arg: Any): Int {
// 1
return arg as? Int
// 2
?: 10
// 2
?: 10
}
@@ -6,5 +6,5 @@ val xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
fun main() {
val c = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
?: "abcdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdf"
?: "abcdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdf"
}
@@ -2,37 +2,37 @@
fun test(list: List<Int>): List<Pair<IndexedValue<List<Int>>, IndexedValue<List<Int>>>> {
return list
.asSequence()
.chunked(1)
.distinct()
.distinctBy { it }
.drop(1)
.dropWhile { true }
.filter { true }
.filterIndexed { index, list -> true }
.filterIsInstance<Int>()
.filterNot { true }
.filterNotNull()
.map { it }
.mapIndexed { index, i -> i }
.mapIndexedNotNull { index, i -> i }
.mapNotNull { it }
.minus(1)
.minusElement(1)
.onEach {}
.plus(1)
.plusElement(1)
.requireNoNulls()
.sorted()
.sortedBy { it }
.sortedByDescending { it }
.sortedDescending()
.sortedWith(Comparator { o1, o2 -> 0 })
.take(1)
.takeWhile { true }
.windowed(1, 1, true)
.withIndex()
.zipWithNext()
.zipWithNext { a, b -> a }
.toList()
.asSequence()
.chunked(1)
.distinct()
.distinctBy { it }
.drop(1)
.dropWhile { true }
.filter { true }
.filterIndexed { index, list -> true }
.filterIsInstance<Int>()
.filterNot { true }
.filterNotNull()
.map { it }
.mapIndexed { index, i -> i }
.mapIndexedNotNull { index, i -> i }
.mapNotNull { it }
.minus(1)
.minusElement(1)
.onEach {}
.plus(1)
.plusElement(1)
.requireNoNulls()
.sorted()
.sortedBy { it }
.sortedByDescending { it }
.sortedDescending()
.sortedWith(Comparator { o1, o2 -> 0 })
.take(1)
.takeWhile { true }
.windowed(1, 1, true)
.withIndex()
.zipWithNext()
.zipWithNext { a, b -> a }
.toList()
}
@@ -2,7 +2,7 @@
fun test(list: List<Int>): Int {
return list // comment1
.<caret>filter { it > 1 } // comment2
.map { it * 2 } // comment3
.sum() // comment4
.<caret>filter { it > 1 } // comment2
.map { it * 2 } // comment3
.sum() // comment4
}
@@ -2,8 +2,8 @@
fun test(list: List<Int>): Int {
return list // comment1
.asSequence()
.filter { it > 1 } // comment2
.map { it * 2 } // comment3
.sum() // comment4
.asSequence()
.filter { it > 1 } // comment2
.map { it * 2 } // comment3
.sum() // comment4
}
@@ -2,6 +2,6 @@
fun test(list: List<Int>): List<Int> {
return list // comment1
.<caret>filter { it > 1 } // comment2
.map { it * 2 } // comment3
.<caret>filter { it > 1 } // comment2
.map { it * 2 } // comment3
}
@@ -2,8 +2,8 @@
fun test(list: List<Int>): List<Int> {
return list // comment1
.asSequence()
.filter { it > 1 } // comment2
.map { it * 2 }
.toList() // comment3
.asSequence()
.filter { it > 1 } // comment2
.map { it * 2 }
.toList() // comment3
}
@@ -2,7 +2,7 @@
fun test(list: List<List<Int>>): List<Int> {
return list
.<caret>filter { it.count() > 2 }
.map { it + it }
.flatMap { it + it }
.<caret>filter { it.count() > 2 }
.map { it + it }
.flatMap { it + it }
}
@@ -2,9 +2,9 @@
fun test(list: List<List<Int>>): List<Int> {
return list
.asSequence()
.filter { it.count() > 2 }
.map { it + it }
.toList()
.flatMap { it + it }
.asSequence()
.filter { it.count() > 2 }
.map { it + it }
.toList()
.flatMap { it + it }
}
@@ -2,9 +2,9 @@
fun test(): Int {
return listOf(1, 2, 3)
.<caret>filter { it > 1 }
.map { it * 2 }
.let {
it.binarySearch(1)
}
.<caret>filter { it > 1 }
.map { it * 2 }
.let {
it.binarySearch(1)
}
}
@@ -2,11 +2,11 @@
fun test(): Int {
return listOf(1, 2, 3)
.asSequence()
.filter { it > 1 }
.map { it * 2 }
.toList()
.let {
it.binarySearch(1)
}
.asSequence()
.filter { it > 1 }
.map { it * 2 }
.toList()
.let {
it.binarySearch(1)
}
}
@@ -2,8 +2,8 @@
fun test(list: List<Int>?): List<Int>? {
return list
?.asSequence()
?.filter { it > 1 }
?.map { it * 2 }
?.toList()
?.asSequence()
?.filter { it > 1 }
?.map { it * 2 }
?.toList()
}
@@ -2,11 +2,11 @@
fun test(list: List<Int>): List<Int> {
return list
.asSequence()
.filter { it > 1 }
.mapNotNull {
if (it == 2) return@mapNotNull null
it * 2
}
.toList()
.asSequence()
.filter { it > 1 }
.mapNotNull {
if (it == 2) return@mapNotNull null
it * 2
}
.toList()
}
@@ -3,5 +3,6 @@
// WITH_RUNTIME
fun test(): List<Int> {
return listOf(1, 2, 3).asSequence().filter { it > 1 }.map { it * 2 }.map { it * 3 }.map { it * 4 }.map { it * 5 }.toList()
return listOf(1, 2, 3).asSequence().filter { it > 1 }.map { it * 2 }.map { it * 3 }.map { it * 4 }.map { it * 5 }
.toList()
}
@@ -3,8 +3,8 @@
fun test(list: List<Int>): List<Int> {
return list
.filter<caret> { it > 1 }
.map { it * 2 }
.map { it * 3 }
.map { it * 4 }
.filter<caret> { it > 1 }
.map { it * 2 }
.map { it * 3 }
.map { it * 4 }
}
@@ -3,10 +3,10 @@
fun test(list: List<Int>): List<Int> {
return list
.asSequence()
.filter { it > 1 }
.map { it * 2 }
.map { it * 3 }
.map { it * 4 }
.toList()
.asSequence()
.filter { it > 1 }
.map { it * 2 }
.map { it * 3 }
.map { it * 4 }
.toList()
}
@@ -2,9 +2,9 @@
fun test(list: List<Int>): List<Int> {
return list
.reversed()
.<caret>map { it + 1 }
.map { it + 1 }
.dropLast(1)
.takeLast(2)
.reversed()
.<caret>map { it + 1 }
.map { it + 1 }
.dropLast(1)
.takeLast(2)
}
@@ -2,11 +2,11 @@
fun test(list: List<Int>): List<Int> {
return list
.reversed()
.asSequence()
.map { it + 1 }
.map { it + 1 }
.toList()
.dropLast(1)
.takeLast(2)
}
.reversed()
.asSequence()
.map { it + 1 }
.map { it + 1 }
.toList()
.dropLast(1)
.takeLast(2)
}
@@ -2,10 +2,10 @@
fun test(foo: Foo): List<Int> {
return foo.getList()
.asSequence()
.filter { it > 1 }
.map { it * 2 }
.toList()
.asSequence()
.filter { it > 1 }
.map { it * 2 }
.toList()
}
class Foo {
@@ -1,5 +1,6 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val filterIndexedTo: MutableList<Int> = list.asSequence().filter { it > 1 }.filterIndexedTo(mutableListOf()) { index, it -> true }
val filterIndexedTo: MutableList<Int> = list.asSequence().filter { it > 1 }
.filterIndexedTo(mutableListOf()) { index, it -> true }
}
@@ -1,5 +1,6 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val mapIndexedNotNullTo: MutableList<Int> = list.asSequence().filter { it > 1 }.mapIndexedNotNullTo(mutableListOf()) { index, i -> i }
val mapIndexedNotNullTo: MutableList<Int> = list.asSequence().filter { it > 1 }
.mapIndexedNotNullTo(mutableListOf()) { index, i -> i }
}
@@ -1,12 +1,12 @@
// WITH_RUNTIME
val x = listOf(1, 2, 3).joinToString(
// comment2
prefix = "= ",
// comment3
separator = " + "
// comment4
,
// comment1
transform = Int::toString
// comment2
prefix = "= ",
// comment3
separator = " + "
// comment4
,
// comment1
transform = Int::toString
)
@@ -2,11 +2,11 @@
val sb = StringBuilder()
val x = listOf(1, 2, 3).joinTo(
// comment1
buffer = sb,
// comment2
prefix = "= ",
// comment3
separator = " + "
// comment4
// comment1
buffer = sb,
// comment2
prefix = "= ",
// comment3
separator = " + "
// comment4
) { "$it*$it" }
@@ -2,7 +2,7 @@
fun test() {
<caret>listOfNotNull(
true, // comment1
null // comment2
true, // comment1
null // comment2
).first()
}
@@ -1,3 +1,3 @@
// WITH_RUNTIME
val v1 = // Some Comment
listOf(1, 2, 3, 11, 33, 25, 100).any { it % 2 == 0 } // Some Additional Comment
listOf(1, 2, 3, 11, 33, 25, 100).any { it % 2 == 0 } // Some Additional Comment
@@ -1,3 +1,3 @@
// WITH_RUNTIME
val v1 = // Some Comment
listOf(1, 2, 3, 11, 33, 25, 100).any { it % 2 == 0 }
listOf(1, 2, 3, 11, 33, 25, 100).any { it % 2 == 0 }
@@ -1,6 +1,6 @@
fun foo(p: List<String?>): Int {
val v = p[0]
?: // return -1 if null
<caret>return -1
?: // return -1 if null
<caret>return -1
return v.length
}
@@ -1,8 +1,8 @@
fun foo(p: List<String?>): Int {
val v = p[0]
?: // v is null
// we should do something with it
return -1 // let's return -1
?: // v is null
// we should do something with it
return -1 // let's return -1
// end of if
return v.length
}
@@ -1,6 +1,6 @@
fun foo(): Any {
val yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy = 7
val xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = 24
?: return yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
?: return yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
return 42
}
@@ -1,6 +1,6 @@
@Suppress(
"HEADER_CLASS_CONSTRUCTOR_DELEGATION_CALL",
<caret>"HEADER_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER",
"HEADER_ENUM_CONSTRUCTOR"
"HEADER_CLASS_CONSTRUCTOR_DELEGATION_CALL",
<caret>"HEADER_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER",
"HEADER_ENUM_CONSTRUCTOR"
)
class Dummy
@@ -1,6 +1,6 @@
@Suppress(
"HEADER_CLASS_CONSTRUCTOR_DELEGATION_CALL",
"EXPECTED_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER",
"HEADER_ENUM_CONSTRUCTOR"
"HEADER_CLASS_CONSTRUCTOR_DELEGATION_CALL",
"EXPECTED_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER",
"HEADER_ENUM_CONSTRUCTOR"
)
class Dummy
@@ -2,6 +2,6 @@
// FIX: Add trailing comma
fun a(
i: Int,
b: Boolean,
i: Int,
b: Boolean,
) = Unit
@@ -2,6 +2,6 @@
// FIX: Add trailing comma
fun a(
i: Int,
b: Boolean,
i: Int,
b: Boolean,
) = Unit
@@ -2,6 +2,6 @@
// FIX: Add trailing comma
fun a(
i: Int,
b: Boolean,
i: Int,
b: Boolean,
) = Unit
@@ -2,9 +2,9 @@
// FIX: Add trailing comma
val x = {
x: String,
y
: String,
x: String,
y
: String,
->
val a = 2
}
@@ -2,7 +2,7 @@
// FIX: Fix comma position
fun a(
i: Int, /*
i: Int, /*
*/
b: Boolean,
b: Boolean,
) = Unit
@@ -2,7 +2,7 @@
// FIX: Fix comma position
fun a(
i: Int, /*
i: Int, /*
*/
b: Boolean,
b: Boolean,
) = Unit
@@ -2,8 +2,8 @@
// FIX: Fix comma position
val x = {
x: Comparable<Comparable<Number>>,
y: String,
x: Comparable<Comparable<Number>>,
y: String,
->
val a = 42
}
@@ -2,6 +2,6 @@
// FIX: Add line break
fun a(
i: Int,
b: Boolean,
i: Int,
b: Boolean,
) = Unit
@@ -2,6 +2,6 @@
// FIX: Add line break
fun a(
i: Int,
b: Boolean,
i: Int,
b: Boolean,
) = Unit
@@ -2,6 +2,6 @@
// FIX: Add line break
fun a(
i: Int,
b: Boolean,
i: Int,
b: Boolean,
) = Unit
@@ -1,2 +1,2 @@
fun getText(): String =// let's return xxx
"xxx" //TODO
"xxx" //TODO
@@ -1,2 +1,2 @@
fun getText(): String =// let's return xxx
"xxx"
"xxx"
@@ -1,2 +1,2 @@
fun getText(): String =/* let's return xxx */
"xxx" /* TODO */
"xxx" /* TODO */
@@ -1,9 +1,9 @@
// HIGHLIGHT: INFORMATION
fun abs(x: Int): Int =// No highlighting here
if (x > 0) {
x
}
else {
-x
}
if (x > 0) {
x
}
else {
-x
}
@@ -1,4 +1,4 @@
fun foo(s1: String, s2: String) = s1 + s2
fun bar(): String =
foo("gjahkrgkjuyrtetyuairytoiuyareoihuyitouy897304hkdjgnba", "uiyiuye987130423toiuywtuiyrwityriwyhw")
foo("gjahkrgkjuyrtetyuairytoiuyareoihuyitouy897304hkdjgnba", "uiyiuye987130423toiuywtuiyrwityriwyhw")
@@ -1,9 +1,12 @@
// WITH_RUNTIME
fun main(args: Array<String>) {
val doSomething = doSomething("one" + 1,
"two",
3 * 4)
val t = if (doSomething != null) doSomething else throw NullPointerException("Expression 'doSomething(\"one\" + 1, ...' must not be null")
val doSomething = doSomething(
"one" + 1,
"two",
3 * 4
)
val t = if (doSomething != null
) doSomething else throw NullPointerException("Expression 'doSomething(\"one\" + 1, ...' must not be null")
}
fun doSomething(vararg a: Any): Any? = null
@@ -2,7 +2,7 @@ fun foo(arg: Int): Int {
// 1
when (arg) {
0 -> return 0
// 2
// 2
else -> return -1
}
}
@@ -4,17 +4,17 @@ fun foo(arg: Any?): Int {
is Int -> {
return arg // 2
}
// 3
// 3
is String -> {
return 42 // 4
}
// 5
// 5
null -> {
// 6
return 0
}
// 7
// 8
// 7
// 8
else -> return -1
}
}
@@ -1,5 +1,5 @@
fun foo(b: Boolean) {
if (// comment 1
b) 1 // comment 2
b) 1 // comment 2
else 2
}
@@ -1,7 +1,8 @@
fun foo(a: Int) {
if (a
// some comment
== 0) bar(a)
// some comment
== 0
) bar(a)
// another comment
else if (a == 1) bar(a)
@@ -1,8 +1,8 @@
fun f() {
foo(
1,
"a",
2
1,
"a",
2
)
}
@@ -3,9 +3,9 @@
fun f() {
foo(
1,
"a",
2,
1,
"a",
2,
)
}
@@ -1,6 +1,6 @@
fun foo(
p: Int,
c: Char,
b: <caret>Boolean
p: Int,
c: Char,
b: <caret>Boolean
) {
}
@@ -1,8 +1,8 @@
// SET_TRUE: ALLOW_TRAILING_COMMA
fun foo(
p: Int,
c: Char,
b: <caret>Boolean,
p: Int,
c: Char,
b: <caret>Boolean,
) {
}
@@ -1,6 +1,6 @@
fun foo(
p: Int,
c: Char,
b: <caret>Boolean
p: Int,
c: Char,
b: <caret>Boolean
) {
}
@@ -1,6 +1,6 @@
fun foo(
p: Int,
c: Char,
b: <caret>Boolean
p: Int,
c: Char,
b: <caret>Boolean
) {
}
@@ -1,5 +1,5 @@
fun foo(
p: Int,
<caret> c: Char
p: Int,
<caret> c: Char
) {
}
@@ -2,9 +2,10 @@ class WithComments/* Some parameter */
/**
* A constructor
*/(
/**
* A very important property
*/
val veryImportant: Any) {
/**
* A very important property
*/
val veryImportant: Any
) {
}
@@ -2,7 +2,9 @@ annotation class AnnParam
annotation class AnnProperty
abstract class WithComposedModifiers(@AnnParam vararg @AnnProperty
open val x: String) {
abstract class WithComposedModifiers(
@AnnParam vararg @AnnProperty
open val x: String
) {
}
+2 -2
View File
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().sum()'"
fun f(list: List<Int?>): Int{
val r = list
.filterNotNull()
.sum()
.filterNotNull()
.sum()
return r
}
+3 -3
View File
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().sum()'"
fun f(list: List<Int?>): Int{
val r = list
.asSequence()
.filterNotNull()
.sum()
.asSequence()
.filterNotNull()
.sum()
return r
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.any()'"
fun foo(list: List<String>) {
val <caret>found = list
.filterIndexed { index, s -> s.length > index }
.any()
.filterIndexed { index, s -> s.length > index }
.any()
}
@@ -3,7 +3,7 @@
// 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()
.asSequence()
.filterIndexed { index, s -> s.length > index }
.any()
}
@@ -4,9 +4,9 @@
fun getMaxLineWidth(lineCount: Int): Float {
var max_width = 0.0f
<caret>(0..lineCount - 1)
.asSequence()
.filter { getLineWidth(it) > max_width }
.forEach { max_width = getLineWidth(it) }
.asSequence()
.filter { getLineWidth(it) > max_width }
.forEach { max_width = getLineWidth(it) }
return max_width
}
@@ -4,7 +4,7 @@
fun foo(list: List<String>): Long {
var count = 0L
list
.filter { it.length > 10 }
.forEach { count++ }
.filter { it.length > 10 }
.forEach { count++ }
return count
}
@@ -4,8 +4,8 @@
fun foo(list: List<String>): Long {
var count = 0L
list
.asSequence()
.filter { it.length > 10 }
.forEach { count++ }
.asSequence()
.filter { it.length > 10 }
.forEach { count++ }
return count
}
@@ -4,8 +4,8 @@
fun foo(list: List<String>): Int {
var count = 0
list
.asSequence()
.filter { it.length > count }
.forEach { count++ }
.asSequence()
.filter { it.length > count }
.forEach { count++ }
return count
}
@@ -5,7 +5,7 @@ import java.util.ArrayList
fun foo(list: List<String>): MutableList<String> {
val <caret>result = list
.filter { it.length > 0 }
.toMutableList()
.filter { it.length > 0 }
.toMutableList()
return result
}
@@ -5,8 +5,8 @@ import java.util.ArrayList
fun foo(list: List<String>): MutableList<String> {
val <caret>result = list
.asSequence()
.filter { it.length > 0 }
.toMutableList()
.asSequence()
.filter { it.length > 0 }
.toMutableList()
return result
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
fun foo(list: List<String?>){
list
.filter { it != null && it.startsWith("IMG:") }
.forEach { println(it) }
.filter { it != null && it.startsWith("IMG:") }
.forEach { println(it) }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
fun foo(list: List<String?>){
list
.asSequence()
.filter { it != null && it.startsWith("IMG:") }
.forEach { println(it) }
.asSequence()
.filter { it != null && it.startsWith("IMG:") }
.forEach { println(it) }
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? {
<caret>return list
.filterIndexed { index, s -> s.length > index }
.firstOrNull()
.filterIndexed { index, s -> s.length > index }
.firstOrNull()
}
@@ -3,7 +3,7 @@
// 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()
.asSequence()
.filterIndexed { index, s -> s.length > index }
.firstOrNull()
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? {
<caret>return list
.filterIndexed { i, s -> s.length > i }
.firstOrNull()
.filterIndexed { i, s -> s.length > i }
.firstOrNull()
}
@@ -3,7 +3,7 @@
// 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()
.asSequence()
.filterIndexed { i, s -> s.length > i }
.firstOrNull()
}
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence()...flatMap{}.filter{}.mapTo(){}'"
fun foo(list: List<String>, target: MutableCollection<String>) {
<caret>list
.filterIndexed { i, s -> i % 10 != 0 }
.flatMap { it.indices }
.filter { it != 10 }
.mapTo(target) { it.toString() }
.filterIndexed { i, s -> i % 10 != 0 }
.flatMap { it.indices }
.filter { it != 10 }
.mapTo(target) { it.toString() }
}
@@ -3,9 +3,9 @@
// INTENTION_TEXT_2: "Replace with 'asSequence()...flatMap{}.filter{}.mapTo(){}'"
fun foo(list: List<String>, target: MutableCollection<String>) {
<caret>list
.asSequence()
.filterIndexed { i, s -> i % 10 != 0 }
.flatMap { it.indices.asSequence() }
.filter { it != 10 }
.mapTo(target) { it.toString() }
.asSequence()
.filterIndexed { i, s -> i % 10 != 0 }
.flatMap { it.indices.asSequence() }
.filter { it != 10 }
.mapTo(target) { it.toString() }
}
@@ -3,6 +3,6 @@
// 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 }
.firstOrNull()
.filterIndexed { index, s -> s.length <= index * 10 && s.length > index }
.firstOrNull()
}
@@ -3,7 +3,7 @@
// 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()
.asSequence()
.filterIndexed { index, s -> s.length <= index * 10 && s.length > index }
.firstOrNull()
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? {
<caret>return list
.filterIndexed { index, s -> !s.isBlank() && s.length > index }
.firstOrNull()
.filterIndexed { index, s -> !s.isBlank() && s.length > index }
.firstOrNull()
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? {
<caret>return list
.asSequence()
.filterIndexed { index, s -> !s.isBlank() && s.length > index }
.firstOrNull()
.asSequence()
.filterIndexed { index, s -> !s.isBlank() && s.length > index }
.firstOrNull()
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? {
<caret>return list
.filterIndexed { index, s -> s.length <= index && s.isNotBlank() }
.firstOrNull()
.filterIndexed { index, s -> s.length <= index && s.isNotBlank() }
.firstOrNull()
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? {
<caret>return list
.asSequence()
.filterIndexed { index, s -> s.length <= index && s.isNotBlank() }
.firstOrNull()
.asSequence()
.filterIndexed { index, s -> s.length <= index && s.isNotBlank() }
.firstOrNull()
}
@@ -4,6 +4,6 @@
fun foo(list: List<String>): String? {
var index2 = 0
return list
.filterIndexed { index1, s -> s.length <= index1 && s.length >= index2++ }
.firstOrNull()
.filterIndexed { index1, s -> s.length <= index1 && s.length >= index2++ }
.firstOrNull()
}
@@ -4,7 +4,7 @@
fun foo(list: List<String>): String? {
var index2 = 0
return list
.asSequence()
.filterIndexed { index1, s -> s.length <= index1 && s.length >= index2++ }
.firstOrNull()
.asSequence()
.filterIndexed { index1, s -> s.length <= index1 && s.length >= index2++ }
.firstOrNull()
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.filterIndexedTo(){}'"
fun foo(list: List<String>, target: MutableCollection<String>) {
<caret>list
.filterIndexed { i, s -> s.length <= i }
.filterIndexedTo(target) { j, s -> s.length % j == 0 }
.filterIndexed { i, s -> s.length <= i }
.filterIndexedTo(target) { j, s -> s.length % j == 0 }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.filterIndexedTo(){}'"
fun foo(list: List<String>, target: MutableCollection<String>) {
<caret>list
.asSequence()
.filterIndexed { i, s -> s.length <= i }
.filterIndexedTo(target) { j, s -> s.length % j == 0 }
.asSequence()
.filterIndexed { i, s -> s.length <= i }
.filterIndexedTo(target) { j, s -> s.length % j == 0 }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIsInstance<>().map{}.firstOrNull()'"
fun foo(list: List<Any>): Int? {
return list
.filterIsInstance<String>()
.map { it.length }
.firstOrNull()
.filterIsInstance<String>()
.map { it.length }
.firstOrNull()
}

Some files were not shown because too many files have changed in this diff Show More