Fix tests after implementing trailing comma in formatter

#KT-34744
This commit is contained in:
Dmitry Gridin
2020-01-14 20:56:48 +07:00
parent d98794479d
commit d06787886a
112 changed files with 598 additions and 371 deletions
@@ -14,7 +14,7 @@ class A {
return JetBundle.message(
"x.in.y",
DescriptorRenderer.COMPACT.render(declarationDescriptor),
IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.render(containingDescriptor)
IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.render(containingDescriptor),
)
}
}
@@ -4,9 +4,8 @@ val x = listOf(1, 2, 3).joinToString(
// comment2
prefix = "= ",
// comment3
separator = " + "
separator = " + ",
// comment4
,
// comment1
transform = Int::toString
transform = Int::toString,
)
@@ -7,6 +7,6 @@ val x = listOf(1, 2, 3).joinTo(
// comment2
prefix = "= ",
// comment3
separator = " + "
separator = " + ",
// comment4
) { "$it*$it" }
@@ -3,6 +3,6 @@
fun test() {
<caret>listOfNotNull(
true, // comment1
null // comment2
null, // comment2
).first()
}
@@ -2,6 +2,8 @@
// HIGHLIGHT: INFORMATION
fun test(list: List<Int>) {
println(list.filter { it > 1 }
.filter { it > 2 })
println(
list.filter { it > 1 }
.filter { it > 2 }
)
}
@@ -2,7 +2,9 @@
// HIGHLIGHT: INFORMATION
fun test() {
println(runCatching {
println(
runCatching {
/* lots of code*/
})
}
)
}
@@ -3,9 +3,11 @@
fun foo(x: Int) {}
fun bar() {
foo(run {
foo(1)
foo(2)
1
})
foo(
run {
foo(1)
foo(2)
1
}
)
}
@@ -3,9 +3,12 @@ fun test() {
operator fun get(a: Int, b: Int, fn: (i: Int) -> Int) : Int = 0
}
val test = Test()
test<caret>[1, 2, { i ->
i
}]
test<caret>[
1, 2,
{ i ->
i
}
]
}
fun withSuppression() {
@@ -3,7 +3,9 @@ fun test() {
operator fun get(fn: (i: Int) -> Int) : Int = 0
}
val test = Test()
test<caret>[{ i ->
i
}]
test<caret>[
{ i ->
i
}
]
}
@@ -1,5 +1,7 @@
fun test() {
Foo.Bar().bar({
true
})
Foo.Bar().bar(
{
true
}
)
}
@@ -1,8 +1,10 @@
// WITH_RUNTIME
fun main(args: Array<String>) {
val doSomething = doSomething("one" + 1,
val doSomething = doSomething(
"one" + 1,
"two",
3 * 4)
3 * 4
)
val t = if (doSomething != null) doSomething else throw NullPointerException("Expression 'doSomething(\"one\" + 1, ...' must not be null")
}
@@ -5,6 +5,7 @@ class WithComments/* Some parameter */
/**
* A very important property
*/
val veryImportant: Any) {
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
) {
}
@@ -1,7 +1,9 @@
fun foo(f: (Int) -> String) {}
fun test() {
foo(fun(it: Int): String {
return ""
})
foo(
fun(it: Int): String {
return ""
}
)
}
@@ -1,7 +1,9 @@
fun bar(f: (Int, Int) -> String) {}
fun test() {
bar(fun(i: Int, j: Int): String {
return "$i$j"
})
bar(
fun(i: Int, j: Int): String {
return "$i$j"
}
)
}
@@ -2,7 +2,9 @@ class Foo
fun bar(f: Foo.() -> Unit) {}
fun main(args: Array<String>) {
bar(fun Foo.() {
bar(
fun Foo.() {
})
}
)
}
@@ -2,7 +2,9 @@ class Foo
fun baz(f: Foo.(i: Int, j: Int) -> Int) {}
fun main(args: Array<String>) {
baz(fun Foo.(i: Int, j: Int): Int {
return i + j
})
baz(
fun Foo.(i: Int, j: Int): Int {
return i + j
}
)
}
@@ -6,7 +6,9 @@ import java.util.*
fun foo(f: () -> ArrayDeque<*>) {}
fun test() {
foo(fun(): ArrayDeque<Int> {
return ArrayDeque<Int>()
})
foo(
fun(): ArrayDeque<Int> {
return ArrayDeque<Int>()
}
)
}
@@ -6,7 +6,9 @@ import java.util.*
fun foo(f: () -> ArrayDeque<*>) {}
fun test() {
foo(fun(): ArrayDeque<*> {
return ArrayDeque<Int>()
})
foo(
fun(): ArrayDeque<*> {
return ArrayDeque<Int>()
}
)
}
@@ -1,9 +1,11 @@
fun foo(f: (Int) -> String) {}
fun test() {
foo(fun(it: Int): String {
// comment1
return ""
// comment2
})
foo(
fun(it: Int): String {
// comment1
return ""
// comment2
}
)
}
@@ -1,7 +1,9 @@
fun foo(f: (Int) -> String) {}
fun test() {
foo(fun(it: Int): String {
return "$it"
})
foo(
fun(it: Int): String {
return "$it"
}
)
}
@@ -1,10 +1,12 @@
fun foo(f: (Int) -> String) {}
fun test() {
foo(fun(it: Int): String {
if (it == 1) {
return "1"
}
return "$it"
})
foo(
fun(it: Int): String {
if (it == 1) {
return "1"
}
return "$it"
}
)
}
@@ -1,13 +1,15 @@
fun foo(f: (Int) -> String) {}
fun test() {
foo(fun(it: Int): String {
if (it == 1) {
return "1"
} else if (it == 2) {
return "2"
} else {
return "$it"
}
})
foo(
fun(it: Int): String {
if (it == 1) {
return "1"
} else if (it == 2) {
return "2"
} else {
return "$it"
}
}
)
}
@@ -2,10 +2,12 @@
fun foo(f: (Int) -> String) {}
fun test() {
foo(fun(it: Int): String {
listOf(1).map {
return@map 2
}
return "$it"
})
foo(
fun(it: Int): String {
listOf(1).map {
return@map 2
}
return "$it"
}
)
}
@@ -1,8 +1,10 @@
fun foo(f: (Int) -> String) {}
fun test() {
foo(fun(it: Int): String {
val b = it == 1
return if (b) "1" else "2"
})
foo(
fun(it: Int): String {
val b = it == 1
return if (b) "1" else "2"
}
)
}
@@ -1,7 +1,9 @@
fun foo(f: (Int) -> String) {}
fun test() {
foo(fun(it: Int): String {
return "$it"
})
foo(
fun(it: Int): String {
return "$it"
}
)
}
@@ -1,5 +1,7 @@
fun main() {
Test().foo(fun(it: Int) {
Test().foo(
fun(it: Int) {
})
}
)
}
@@ -3,5 +3,6 @@ fun baz(name: String, f: (Int) -> String) {}
fun test() {
baz(name = "", f = fun(it: Int): String {
return "$it"
})
}
)
}
@@ -1,7 +1,9 @@
fun foo(f: () -> String) {}
fun test() {
foo(fun(): String {
return ""
})
foo(
fun(): String {
return ""
}
)
}
@@ -3,8 +3,10 @@ fun unit(f: (Int) -> Unit) {}
fun foo(i: Int) {}
fun test() {
unit(fun(it: Int) {
foo(it)
foo(it)
})
unit(
fun(it: Int) {
foo(it)
foo(it)
}
)
}
@@ -7,7 +7,9 @@ data class My(val x: Int)
fun foo(f: () -> My) {}
fun test() {
foo(fun(): My {
return My(42)
})
foo(
fun(): My {
return My(42)
}
)
}
@@ -1,8 +1,10 @@
// IS_APPLICABLE: true
fun foo() {
bar(2, {
it * 3
})
bar(2,
{
it * 3
}
)
}
fun bar(a: Int, b: (Int) -> Int) {
@@ -1,8 +1,10 @@
// IS_APPLICABLE: true
fun foo() {
bar(b = {
it * 3
})
bar(
b = {
it * 3
}
)
}
fun bar(a : Int = 2, b: (Int) -> Int) {
@@ -1,8 +1,10 @@
// IS_APPLICABLE: true
fun foo() {
bar(1, b = {
it * 3
})
bar(1,
b = {
it * 3
}
)
}
fun bar(c: Int, a: Int = 2, b: (Int) -> Int) {
@@ -1,9 +1,11 @@
// IS_APPLICABLE: true
fun foo() {
bar(2, {
val x = 3
it * x
})
bar(2,
{
val x = 3
it * x
}
)
}
fun bar(a: Int, b: (Int) -> Int) {
@@ -1,9 +1,11 @@
// IS_APPLICABLE: true
fun foo() {
bar(a = 2, b = {
val x = 3
it * x
})
bar(a = 2,
b = {
val x = 3
it * x
}
)
}
fun bar(a: Int, b: (Int) -> Int) {
@@ -3,11 +3,13 @@
fun foo(runnable: Runnable) {}
fun bar(list: List<String>) {
foo(Runnable {
list.filter(fun (element: String): Boolean {
if (element == "a") return false
if (element == "b") return@Runnable
return true
})
})
foo(
Runnable {
list.filter(fun (element: String): Boolean {
if (element == "a") return false
if (element == "b") return@Runnable
return true
})
}
)
}
@@ -3,9 +3,11 @@
fun foo(runnable: Runnable) {}
fun bar(p: Int) {
foo(Runnable {
if (p < 0) return@Runnable
println("a")
println("b")
})
foo(
Runnable {
if (p < 0) return@Runnable
println("a")
println("b")
}
)
}
@@ -5,8 +5,10 @@ import java.io.FilenameFilter
fun foo(filter: FilenameFilter) {}
fun bar() {
foo(FilenameFilter { file, name ->
if (file.isDirectory) return@FilenameFilter true
name == "x"
})
foo(
FilenameFilter { file, name ->
if (file.isDirectory) return@FilenameFilter true
name == "x"
}
)
}
@@ -5,18 +5,20 @@ import java.io.FileFilter
fun foo(filter: FileFilter) {}
fun bar() {
foo(FileFilter { file ->
val name = file.name
if (name.startsWith("a")) {
false
}
else {
if (name.endsWith("b"))
true
else {
val l = name.length
l > 10
foo(
FileFilter { file ->
val name = file.name
if (name.startsWith("a")) {
false
}
else {
if (name.endsWith("b"))
true
else {
val l = name.length
l > 10
}
}
}
}
})
)
}
@@ -5,17 +5,19 @@ import java.io.FileFilter
fun foo(filter: FileFilter) {}
fun bar() {
foo(FileFilter { file ->
val name = file.name
when (name) {
"foo" -> true
foo(
FileFilter { file ->
val name = file.name
when (name) {
"foo" -> true
"bar" -> false
"bar" -> false
else -> {
if (name.startsWith("a")) return@FileFilter true
false
else -> {
if (name.startsWith("a")) return@FileFilter true
false
}
}
}
}
})
)
}
@@ -3,8 +3,10 @@
import javax.swing.SwingUtilities
fun bar(p: Int) {
SwingUtilities.invokeLater(Runnable {
if (p < 0) return@Runnable
throw UnsupportedOperationException()
})
SwingUtilities.invokeLater(
Runnable {
if (p < 0) return@Runnable
throw UnsupportedOperationException()
}
)
}
@@ -5,8 +5,10 @@ import java.io.FileFilter
fun foo(filter: FileFilter) {}
fun bar() {
foo(FileFilter { file ->
val name = file.name
name.startsWith("a")
})
foo(
FileFilter { file ->
val name = file.name
name.startsWith("a")
}
)
}
@@ -4,7 +4,9 @@ interface C {
class D(val c: C) {
fun foo() {
this.c/* and this is c */.set("a", // it's "a"
"b" /* and this is "b" */, /* we use 10 */10)
this.c/* and this is c */.set(
"a", // it's "a"
"b" /* and this is "b" */, /* we use 10 */10
)
}
}
@@ -1,7 +1,9 @@
fun main() {
J().foo(object : J.Sam {
override fun bar() {
J().foo(
object : J.Sam {
override fun bar() {
}
})
}
}
)
}
@@ -7,7 +7,9 @@ fun newFun(p1: Int, a: Int, p2: Int, p3: Int, b: Int){}
fun foo() {
newFun(0, // 0
newFun(
0, // 0
-1, 1, // 1
2, // 2
-2)
-2
)
@@ -7,7 +7,12 @@ fun newFun(p4: Int, p3: Int, p2: Int, p1: Int, p0: Int){}
fun foo() {
newFun(/* 4 */ 4, 3, 2, // 2
/* 1 */ 1,
/* 0 */ 0)
newFun(
/* 4 */
4, 3, 2, // 2
/* 1 */
1,
/* 0 */
0
)
}
@@ -8,7 +8,8 @@ interface X {
fun newFun(x: X, a: Int, b: Int){}
fun foo(x: X) {
newFun(x/*receiver*/, 1, // pass 1
newFun(
x/*receiver*/, 1, // pass 1
2 // pass 2
)
}
@@ -11,5 +11,6 @@ fun foo(x: X) {
x.newFun(
1,
2,
0)
0
)
}
@@ -8,7 +8,9 @@ interface X {
}
fun foo(x: X) {
x.<caret>newFun(1,
x.<caret>newFun(
1,
2,
3)
3
)
}
@@ -18,7 +18,9 @@ fun useSimple(s: Int): Int {
fun println(s: String) {}
fun useIt() {
val t = useSimple(simple {
println("abc")
})
val t = useSimple(
simple {
println("abc")
}
)
}
@@ -36,5 +36,6 @@ fun createHi(any: Any) = "Hi $any"
val unDeprecateMe = mutableListOf("Hello").apply {
addA(d(::createHi, 1 ) { // Run the quick fix from the IDE and watch it produce broken code.
println("Yo")
}, Unit)
}, Unit
)
}
@@ -3,15 +3,19 @@ fun <caret>foo(a: Int, b: Int, d: Int, c: Int, e: Int) {
}
fun test() {
foo(1,
foo(
1,
2,
4,
3,
5)
foo(1, 2,
5
)
foo(
1, 2,
4,
3,
5)
5
)
foo(
1,
2,
@@ -3,7 +3,11 @@ fun foo(x: Int, cl: () -> Int, y: Int): Int {
}
fun bar() {
foo(1, {
3
}, 2)
foo(
1,
{
3
},
2
)
}
@@ -1,18 +1,24 @@
interface T {
fun foo(a: Int = 1,
b: String = "2")
fun foo(
a: Int = 1,
b: String = "2"
)
}
open class A: T {
override fun foo(a: Int,
b: String) {
override fun foo(
a: Int,
b: String
) {
throw UnsupportedOperationException()
}
}
class B: A() {
override fun foo(a: Int,
b: String) {
override fun foo(
a: Int,
b: String
) {
throw UnsupportedOperationException()
}
}
@@ -3,8 +3,10 @@ fun <caret>foo(b: Int, c: Int) {
}
fun test() {
foo(2,
3)
foo(
2,
3
)
foo(2, 3)
foo(
2,
@@ -3,8 +3,10 @@ fun <caret>foo(a: Int, c: Int) {
}
fun test() {
foo(1,
3)
foo(
1,
3
)
foo(1, 3)
foo(
1,
@@ -3,8 +3,10 @@ fun <caret>foo(a: Int, b: Int) {
}
fun test() {
foo(1,
2)
foo(
1,
2
)
foo(1, 2)
foo(
1,
@@ -3,11 +3,15 @@ fun <caret>foo(c: Int, b: Int, a: Int) {
}
fun test() {
foo(3,
foo(
3,
2,
1)
foo(3, 2,
1)
1
)
foo(
3, 2,
1
)
foo(
3,
2,
@@ -3,5 +3,6 @@ fun callInDefault(simple: List<String> = provideSimple(), complex: List<String>
val result = mutableListOf("statement 1")
result.add("statement 2")
result
}) {
}
) {
}
@@ -1,6 +1,8 @@
fun g() {
println(listOf("a", "b").any {
if (it.isEmpty()) return@any false
it.length < 10
})
}
println(
listOf("a", "b").any {
if (it.isEmpty()) return@any false
it.length < 10
}
)
}
@@ -1,8 +1,10 @@
fun foo(i: Int) { }
fun test(i: () -> Int = {
(1
+ 2)
}) {
fun test(
i: () -> Int = {
(1
+ 2)
}
) {
foo(i())
}
@@ -1,8 +1,10 @@
fun foo(i: Int) { }
fun test(i: () -> Int = {
(1 // abc
/*def*/ + 2)
}) {
fun test(
i: () -> Int = {
(1 // abc
/*def*/ + 2)
}
) {
foo(i())
}
@@ -1,8 +1,10 @@
fun foo(i: Int) { }
fun test(i: () -> Int = {
(1
+ 2 - 3)
}) {
fun test(
i: () -> Int = {
(1
+ 2 - 3)
}
) {
foo(i())
}
@@ -1,8 +1,10 @@
fun foo(i: Int) { }
fun test(i: () -> Int = {
(1 + 2
- 3)
}) {
fun test(
i: () -> Int = {
(1 + 2
- 3)
}
) {
foo(i())
}
@@ -1,7 +1,10 @@
fun foo(a: Int, s: (Int) -> String = { a ->
"""c$a
fun foo(
a: Int,
s: (Int) -> String = { a ->
"""c$a
:${a + 1}d"""
}): String {
}
): String {
val x = """_${s(a)}_"""
val y = "_$a:${a + 1}d_"
val z = """_c$a:${a + 1}d_"""
@@ -1,6 +1,8 @@
fun foo(i: Int) { }
fun test(i: Int = (1
+ 2)) {
fun test(
i: Int = (1
+ 2)
) {
foo(i)
}
@@ -1,6 +1,8 @@
fun foo(i: Int) { }
fun test(i: Int = (1 // abc
/*def*/ + 2)) {
fun test(
i: Int = (1 // abc
/*def*/ + 2)
) {
foo(i)
}
@@ -1,6 +1,8 @@
fun foo(i: Int) { }
fun test(i: Int = (1
+ 2 - 3)) {
fun test(
i: Int = (1
+ 2 - 3)
) {
foo(i)
}
@@ -1,6 +1,8 @@
fun foo(i: Int) { }
fun test(i: Int = (1 + 2
- 3)) {
fun test(
i: Int = (1 + 2
- 3)
) {
foo(i)
}
@@ -1,5 +1,8 @@
fun foo(a: Int, s: String = """c$a
:${a + 1}d"""): String {
fun foo(
a: Int,
s: String = """c$a
:${a + 1}d"""
): String {
val x = """_${s}_"""
val y = "_$a:${a + 1}d_"
val z = """_c$a:${a + 1}d_"""
@@ -10,8 +10,10 @@ fun boo(s: Second, body: () -> Unit) { }
fun foo(s: Second) {
boo(s) {
s.testInvoke[{
s.testInvoke[
{
"Hello"
}]
}
]
}
}
@@ -10,8 +10,10 @@ fun boo(s: Second?, body: () -> Unit) { }
fun foo(s: Second?) {
boo(s) {
s?.testInvoke[{
s?.testInvoke[
{
"Hello"
}]
}
]
}
}