Extract Function: Allow to combine throws with other exit points
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
// NEXT_SIBLING:
|
||||
fun foo(a: Int): Int {
|
||||
val b: Int = 1
|
||||
for (n in 1..b) {
|
||||
<selection>if (a > 0) throw Exception("")
|
||||
if (a + b > 0) break
|
||||
println(a - b)</selection>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// NEXT_SIBLING:
|
||||
fun b(a: Int, b: Int): Boolean {
|
||||
if (a > 0) throw Exception("")
|
||||
if (a + b > 0) return true
|
||||
println(a - b)
|
||||
return false
|
||||
}
|
||||
|
||||
fun foo(a: Int): Int {
|
||||
val b: Int = 1
|
||||
for (n in 1..b) {
|
||||
if (b(a, b)) break
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// NEXT_SIBLING:
|
||||
fun foo(a: Int): Int {
|
||||
val b: Int = 1
|
||||
for (n in 1..b) {
|
||||
<selection>if (a > 0) throw Exception("")
|
||||
if (a + b > 0) continue
|
||||
println(a - b)</selection>
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// NEXT_SIBLING:
|
||||
fun b(a: Int, b: Int): Boolean {
|
||||
if (a > 0) throw Exception("")
|
||||
if (a + b > 0) return true
|
||||
println(a - b)
|
||||
return false
|
||||
}
|
||||
|
||||
fun foo(a: Int): Int {
|
||||
val b: Int = 1
|
||||
for (n in 1..b) {
|
||||
if (b(a, b)) continue
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// NEXT_SIBLING:
|
||||
fun foo(a: Int): Int {
|
||||
val b: Int = 1
|
||||
|
||||
val t = <selection>if (a > 0) throw Exception("") else a + b</selection>
|
||||
return t
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// NEXT_SIBLING:
|
||||
fun i(a: Int, b: Int): Int {
|
||||
return if (a > 0) throw Exception("") else a + b
|
||||
}
|
||||
|
||||
fun foo(a: Int): Int {
|
||||
val b: Int = 1
|
||||
|
||||
val t = i(a, b)
|
||||
return t
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// NEXT_SIBLING:
|
||||
fun foo(a: Int) {
|
||||
val b: Int = 1
|
||||
|
||||
<selection>if (a > 0) throw Exception("")
|
||||
if (b + a > 0) return
|
||||
println(a - b)</selection>
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// NEXT_SIBLING:
|
||||
fun b(a: Int, b: Int): Boolean {
|
||||
if (a > 0) throw Exception("")
|
||||
if (b + a > 0) return true
|
||||
println(a - b)
|
||||
return false
|
||||
}
|
||||
|
||||
fun foo(a: Int) {
|
||||
val b: Int = 1
|
||||
|
||||
if (b(a, b)) return
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// NEXT_SIBLING:
|
||||
fun foo(a: Int): Int {
|
||||
val b: Int = 1
|
||||
|
||||
<selection>if (a > 0) throw Exception("") else return a + b
|
||||
return a - b</selection>
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// NEXT_SIBLING:
|
||||
fun i(a: Int, b: Int): Int {
|
||||
if (a > 0) throw Exception("") else return a + b
|
||||
return a - b
|
||||
}
|
||||
|
||||
fun foo(a: Int): Int {
|
||||
val b: Int = 1
|
||||
|
||||
return i(a, b)
|
||||
}
|
||||
Reference in New Issue
Block a user