Extract Function: Allow to extract local variables which are used outside of extracted fragment

This commit is contained in:
Alexey Sedunov
2014-07-03 18:55:11 +04:00
parent 540e8b8b46
commit d95f6383b7
35 changed files with 439 additions and 93 deletions
@@ -0,0 +1,18 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// PARAM_DESCRIPTOR: value-parameter val a: kotlin.Int defined in foo
// PARAM_DESCRIPTOR: val b: kotlin.Int defined in foo
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..a) {
<selection>if (a + b > 0) break
val c: Int
println(a - b)
if (a - b > 0) break
println(a + b)</selection>
c = 1
println(c)
}
return 1
}
@@ -0,0 +1,24 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// PARAM_DESCRIPTOR: value-parameter val a: kotlin.Int defined in foo
// PARAM_DESCRIPTOR: val b: kotlin.Int defined in foo
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..a) {
val c: Int
if (b(a, b)) break
c = 1
println(c)
}
return 1
}
fun b(a: Int, b: Int): Boolean {
if (a + b > 0) return true
val c: Int
println(a - b)
if (a - b > 0) return true
println(a + b)
return false
}