Extract Function: Generate function in property's enclosing declaration if original expression belongs to initializer of that property

#KT-6290 Fixed
This commit is contained in:
Alexey Sedunov
2014-12-26 11:53:44 +03:00
parent 22f4caa78d
commit 59d646bc16
10 changed files with 50 additions and 29 deletions
@@ -1,3 +1,7 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// PARAM_DESCRIPTOR: value-parameter val a: kotlin.Int defined in bar
// PARAM_DESCRIPTOR: value-parameter val b: kotlin.Int defined in bar
fun bar(a: Int, b: Int) {
val foo = <selection>a + b</selection> - 1
}
@@ -1,7 +1,11 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// PARAM_DESCRIPTOR: value-parameter val a: kotlin.Int defined in bar
// PARAM_DESCRIPTOR: value-parameter val b: kotlin.Int defined in bar
fun bar(a: Int, b: Int) {
fun i(): Int {
return a + b
}
val foo = i(a, b) - 1
}
val foo = i() - 1
private fun i(a: Int, b: Int): Int {
return a + b
}
@@ -1,3 +1,7 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// PARAM_DESCRIPTOR: value-parameter val a: kotlin.Int defined in bar
// PARAM_DESCRIPTOR: value-parameter val b: kotlin.Int defined in bar
fun bar(a: Int, b: Int) {
val foo = { <selection>a + b</selection> - 1 }.invoke()
}
@@ -1,7 +1,11 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// PARAM_DESCRIPTOR: value-parameter val a: kotlin.Int defined in bar
// PARAM_DESCRIPTOR: value-parameter val b: kotlin.Int defined in bar
fun bar(a: Int, b: Int) {
fun i(): Int {
return a + b
}
val foo = { i(a, b) - 1 }.invoke()
}
val foo = { i() - 1 }.invoke()
private fun i(a: Int, b: Int): Int {
return a + b
}