Quick Fixes: Implement "Create label" quick fix

#KT-8855 Fixed
This commit is contained in:
Alexey Sedunov
2016-12-23 16:30:49 +03:00
parent 534a773816
commit 23ec8f0813
18 changed files with 285 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
// "Create label foo@" "true"
fun test() {
while (true) {
break@<caret>foo
}
}
@@ -0,0 +1,7 @@
// "Create label foo@" "true"
fun test() {
foo@ while (true) {
<caret>break@foo
}
}
@@ -0,0 +1,9 @@
// "Create label foo@" "true"
fun test() {
while (true) {
while (true) {
break@<caret>foo
}
}
}
@@ -0,0 +1,9 @@
// "Create label foo@" "true"
fun test() {
foo@ while (true) {
while (true) {
<caret> break@foo
}
}
}
@@ -0,0 +1,11 @@
// "Create label foo@" "false"
// ERROR: The label '@foo' does not denote a loop
// ERROR: Unresolved reference: @foo
fun bar(f: () -> Unit) { }
fun test() {
while (true) {
bar { break@<caret>foo }
}
}
+8
View File
@@ -0,0 +1,8 @@
// "Create label foo@" "false"
// ACTION: Convert to expression body
// ERROR: The label '@foo' does not denote a loop
// ERROR: Unresolved reference: @foo
fun test() {
break@<caret>foo
}
+7
View File
@@ -0,0 +1,7 @@
// "Create label foo@" "true"
fun test() {
while (true) {
continue@<caret>foo
}
}
@@ -0,0 +1,7 @@
// "Create label foo@" "true"
fun test() {
foo@ while (true) {
<caret>continue@foo
}
}
+8
View File
@@ -0,0 +1,8 @@
// "Create label foo@" "false"
// ACTION: Convert to expression body
// ERROR: The label '@foo' does not denote a loop
// ERROR: Unresolved reference: @foo
fun test() {
continue@<caret>foo
}
+7
View File
@@ -0,0 +1,7 @@
// "Create label foo@" "true"
inline fun Int.bar(f: (Int) -> Unit) { }
fun test() {
1.bar { if (it == 2) return@<caret>foo }
}
@@ -0,0 +1,7 @@
// "Create label foo@" "true"
inline fun Int.bar(f: (Int) -> Unit) { }
fun test() {
1.bar foo@ { if (it == 2) return@<caret>foo }
}
@@ -0,0 +1,7 @@
// "Create label foo@" "true"
inline fun Int.bar(f: (Int) -> Unit) { }
fun test() {
1.bar { 2.bar { if (it == 2) return@<caret>foo } }
}
@@ -0,0 +1,7 @@
// "Create label foo@" "true"
inline fun Int.bar(f: (Int) -> Unit) { }
fun test() {
1.bar foo@ { 2.bar { if (it == 2) return@<caret>foo } }
}
+7
View File
@@ -0,0 +1,7 @@
// "Create label foo@" "false"
// ACTION: Convert to expression body
// ERROR: Unresolved reference: @foo
fun test(): Int {
return@<caret>foo 1
}