FIR IDE: add quickfix AddWhenElseBranchFix

This commit is contained in:
Tianyu Geng
2021-05-03 09:55:56 -07:00
committed by Ilya Kirillov
parent 8e10b5fdec
commit 302e0fa46b
56 changed files with 242 additions and 41 deletions
@@ -7,3 +7,4 @@ fun use(c: Color) {
}
fun red() {}
/* IGNORE_FIR */
@@ -8,3 +8,4 @@ fun use(c: Color) {
}
fun red() {}
/* IGNORE_FIR */
@@ -8,4 +8,5 @@ fun test(a: A) {
val r = <caret>when (a) {
}
}
}
/* IGNORE_FIR */
@@ -8,4 +8,5 @@ fun test(a: A) {
val r = when (a) {
is B -> TODO()
}
}
}
/* IGNORE_FIR */
@@ -10,4 +10,5 @@ fun test(a: A) {
// comment
}
}
}
/* IGNORE_FIR */
@@ -10,4 +10,5 @@ fun test(a: A) {
// comment
is B -> TODO()
}
}
}
/* IGNORE_FIR */
@@ -3,3 +3,4 @@
fun test(b: Boolean) = wh<caret>en(b) {
false -> 0
}
/* IGNORE_FIR */
@@ -4,3 +4,4 @@ fun test(b: Boolean) = when(b) {
false -> 0
true -> TODO()
}
/* IGNORE_FIR */
@@ -5,3 +5,4 @@ enum class Color { R, G, B }
fun test(c: Color) = wh<caret>en(c) {
Color.B -> 0xff
}
/* IGNORE_FIR */
@@ -7,3 +7,4 @@ fun test(c: Color) = when(c) {
Color.R -> TODO()
Color.G -> TODO()
}
/* IGNORE_FIR */
@@ -7,4 +7,5 @@ enum class FooEnum {
fun test(foo: FooEnum?) = <caret>when (foo) {
FooEnum.A -> "A"
}
}
/* IGNORE_FIR */
@@ -13,4 +13,5 @@ fun test(foo: FooEnum?) = <caret>when (foo) {
FooEnum.`false` -> TODO()
FooEnum.`null` -> TODO()
null -> TODO()
}
}
/* IGNORE_FIR */
@@ -10,3 +10,4 @@ class Test {
}
}
}
/* IGNORE_FIR */
@@ -15,3 +15,4 @@ class Test {
}
}
}
/* IGNORE_FIR */
@@ -13,3 +13,4 @@ class Test {
}
}
}
/* IGNORE_FIR */
@@ -14,3 +14,4 @@ class Test {
}
}
}
/* IGNORE_FIR */
@@ -23,3 +23,4 @@ class Test {
}
}
}
/* IGNORE_FIR */
@@ -26,3 +26,4 @@ class Test {
}
}
}
/* IGNORE_FIR */
@@ -23,3 +23,4 @@ class Test {
}
}
}
/* IGNORE_FIR */
@@ -28,3 +28,4 @@ class Test {
}
}
}
/* IGNORE_FIR */
@@ -9,3 +9,4 @@ fun use(c: Color) {
}
fun red() {}
/* IGNORE_FIR */
@@ -11,3 +11,4 @@ fun use(c: Color) {
}
fun red() {}
/* IGNORE_FIR */
@@ -6,3 +6,4 @@ enum class Color { R, G, B }
fun test(c: Color) = wh<caret>en(c) {
Color.B -> 0xff
}
/* IGNORE_FIR */
@@ -8,3 +8,4 @@ fun test(c: Color) = when(c) {
Color.R -> TODO()
Color.G -> TODO()
}
/* IGNORE_FIR */
@@ -12,3 +12,4 @@ sealed class Variant {
fun test(v: Variant?) = wh<caret>en(v) {
Variant.Singleton -> "s"
}
/* IGNORE_FIR */
@@ -15,3 +15,4 @@ fun test(v: Variant?) = when(v) {
is Variant.Something -> TODO()
null -> TODO()
}
/* IGNORE_FIR */
@@ -12,4 +12,5 @@ object `null`: FooSealed()
fun test(foo: FooSealed?) = <caret>when (foo) {
A -> "A"
}
}
/* IGNORE_FIR */
@@ -19,4 +19,5 @@ fun test(foo: FooSealed?) = <caret>when (foo) {
`null` -> TODO()
is `true` -> TODO()
null -> TODO()
}
}
/* IGNORE_FIR */
@@ -14,3 +14,4 @@ fun test(v: Variant?) {
Variant.Singleton -> "s"
}
}
/* IGNORE_FIR */
@@ -17,3 +17,4 @@ fun test(v: Variant?) {
null -> TODO()
}
}
/* IGNORE_FIR */
+1
View File
@@ -16,3 +16,4 @@ fun breakContinueInWhen(i: Int) {
}
}
}
/* IGNORE_FIR */
+1
View File
@@ -16,3 +16,4 @@ fun breakContinueInWhen(i: Int) {
}
}
}
/* IGNORE_FIR */
+2 -1
View File
@@ -12,4 +12,5 @@ fun foo(chars: CharArray) {
}
pos++
}
}
}
/* IGNORE_FIR */
+2 -1
View File
@@ -12,4 +12,5 @@ fun foo(chars: CharArray) {
}
pos++
}
}
}
/* IGNORE_FIR */
@@ -8,4 +8,5 @@ fun test(i: Int, j: Int) {
i < 0, j < 0, j > i -> { /* code 4 */ }
else -> { /* other code */ }
}
}
}
/* IGNORE_FIR */
@@ -8,4 +8,5 @@ fun test(i: Int, j: Int) {
i < 0 || j < 0 || j > i -> { /* code 4 */ }
else -> { /* other code */ }
}
}
}
/* IGNORE_FIR */
@@ -5,4 +5,5 @@ fun test(a: Boolean, b: Boolean, c: Boolean) {
c -> "b"
else -> "e"
}
}
}
/* IGNORE_FIR */
@@ -5,4 +5,5 @@ fun test(a: Boolean, b: Boolean, c: Boolean) {
c -> "b"
else -> "e"
}
}
}
/* IGNORE_FIR */
+1
View File
@@ -16,3 +16,4 @@ fun breakContinueInWhen(i: Int) {
}
}
}
/* IGNORE_FIR */
+1
View File
@@ -16,3 +16,4 @@ fun breakContinueInWhen(i: Int) {
}
}
}
/* IGNORE_FIR */
+2 -1
View File
@@ -12,4 +12,5 @@ fun foo(chars: CharArray) {
}
pos++
}
}
}
/* IGNORE_FIR */
@@ -12,4 +12,5 @@ fun foo(chars: CharArray) {
}
pos++
}
}
}
/* IGNORE_FIR */
@@ -18,3 +18,4 @@ fun breakContinueInWhen(i: Int) {
}
}
}
/* IGNORE_FIR */
@@ -18,3 +18,4 @@ fun breakContinueInWhen(i: Int) {
}
}
}
/* IGNORE_FIR */
+2 -1
View File
@@ -6,4 +6,5 @@ fun test() {
el<caret>se -> { /* other code */ }
2 -> { /* some more code */ }
}
}
}
/* IGNORE_FIR */
+2 -1
View File
@@ -6,4 +6,5 @@ fun test() {
2 -> { /* some more code */ }
el<caret>se -> { /* other code */ }
}
}
}
/* IGNORE_FIR */
+2 -1
View File
@@ -6,4 +6,5 @@ fun test(x: Int): String {
<caret>null -> "null"
else -> ""
}
}
}
/* IGNORE_FIR */
+2 -1
View File
@@ -5,4 +5,5 @@ fun test(x: Int): String {
2 -> "2"
else -> ""
}
}
}
/* IGNORE_FIR */
+2 -1
View File
@@ -6,4 +6,5 @@ fun foo(b: Boolean) {
false -> {}
<caret>else -> error()
}
}
}
/* IGNORE_FIR */
+2 -1
View File
@@ -5,4 +5,5 @@ fun foo(b: Boolean) {
true -> return
false -> {}
}
}
}
/* IGNORE_FIR */
+1
View File
@@ -14,3 +14,4 @@ fun foo() {
3 -> { /* some other code */ }
}
}
/* IGNORE_FIR */