Extract Function: Add support of initializer expressions

This commit is contained in:
Alexey Sedunov
2014-06-26 18:50:22 +04:00
parent 026bc05a86
commit 0c49d48a48
30 changed files with 302 additions and 12 deletions
@@ -0,0 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
fun bar(n: Int) {
fun foo(a: Int, b: Int) = <selection>a + b - n</selection> - 1
}
@@ -0,0 +1,9 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
fun bar(n: Int) {
fun i(a: Int, b: Int): Int {
return a + b - n
}
fun foo(a: Int, b: Int) = i(a, b) - 1
}
@@ -0,0 +1,4 @@
// PARAM_TYPES: kotlin.Int
fun bar(n: Int) {
fun foo(a: Int, b: Int = <selection>a + n</selection>) = a + b - n - 1
}
@@ -0,0 +1 @@
Cannot extract method since following types are not denotable in the target scope: [ERROR : ]
@@ -0,0 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
class A(val n: Int) {
fun foo(a: Int, b: Int) = <selection>a + b - n</selection> - 1
}
@@ -0,0 +1,9 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
class A(val n: Int) {
fun foo(a: Int, b: Int) = i(a, b) - 1
fun i(a: Int, b: Int): Int {
return a + b - n
}
}
@@ -0,0 +1,4 @@
// PARAM_TYPES: kotlin.Int
class A(val n: Int) {
fun foo(a: Int, b: Int = <selection>a + n</selection>) = a + b - n - 1
}
@@ -0,0 +1,8 @@
// PARAM_TYPES: kotlin.Int
class A(val n: Int) {
fun foo(a: Int, b: Int = i(a)) = a + b - n - 1
fun i(a: Int): Int {
return a + n
}
}
@@ -0,0 +1,3 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
fun foo(a: Int, b: Int) = <selection>a + b</selection> - 1
@@ -0,0 +1,7 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
fun foo(a: Int, b: Int) = i(a, b) - 1
fun i(a: Int, b: Int): Int {
return a + b
}
@@ -0,0 +1,3 @@
// PARAM_TYPES: kotlin.Int
val n = 1
fun foo(a: Int, b: Int = <selection>a + n</selection>) = a + b - 1
@@ -0,0 +1,7 @@
// PARAM_TYPES: kotlin.Int
val n = 1
fun foo(a: Int, b: Int = i(a)) = a + b - 1
fun i(a: Int): Int {
return a + n
}