Add braces to 'if' statement: save/restore comments correctly

So #KT-16332 Fixed
This commit is contained in:
Toshiaki Kameyama
2018-02-15 14:50:10 +03:00
committed by Mikhail Glukhikh
parent b436ee6e19
commit 4726b44371
17 changed files with 178 additions and 5 deletions
@@ -0,0 +1,6 @@
fun foo() {}
fun test() {
<caret>do /* aaa */ foo() // comment
while(true)
}
@@ -0,0 +1,7 @@
fun foo() {}
fun test() {
do {
/* aaa */ foo() // comment
} while(true)
}
+6
View File
@@ -0,0 +1,6 @@
fun foo() {}
fun test(b: Boolean) {
if (b) foo() <caret>else
/* aaa */ foo() // bbb
}
@@ -0,0 +1,7 @@
fun foo() {}
fun test(b: Boolean) {
if (b) foo() else {
/* aaa */ foo() // bbb
}
}
+5
View File
@@ -0,0 +1,5 @@
fun foo() {}
fun test() {
<caret>for (i in 1..4) /* aaa */ foo() // bbb
}
@@ -0,0 +1,7 @@
fun foo() {}
fun test() {
for (i in 1..4) {
/* aaa */ foo() // bbb
}
}
@@ -0,0 +1,5 @@
fun foo() {}
fun test(b: Boolean) {
<caret>if (b) foo() /* if comment */ else foo() // else comment
}
@@ -0,0 +1,7 @@
fun foo() {}
fun test(b: Boolean) {
if (b) {
foo() /* if comment */
} else foo() // else comment
}
+5
View File
@@ -0,0 +1,5 @@
fun foo() {}
fun test(b: Boolean) {
<caret>if (b) /* aaa */ /* bbb */ foo() // ccc
}
@@ -0,0 +1,7 @@
fun foo() {}
fun test(b: Boolean) {
if (b) {
/* aaa */ /* bbb */ foo() // ccc
}
}
+7
View File
@@ -0,0 +1,7 @@
fun foo() {}
fun test(a: Int) {
when (a) {
<caret>1 -> /* aaa */ foo() // bbb
}
}
@@ -0,0 +1,9 @@
fun foo() {}
fun test(a: Int) {
when (a) {
1 -> {
/* aaa */ foo() // bbb
}
}
}
@@ -0,0 +1,5 @@
fun foo() {}
fun test(b: Boolean) {
<caret>while (b) /* aaa */ foo() // bbb
}
@@ -0,0 +1,7 @@
fun foo() {}
fun test(b: Boolean) {
while (b) {
/* aaa */ foo() // bbb
}
}