Extract Function: Implement validation

This commit is contained in:
Alexey Sedunov
2014-04-21 18:23:28 +04:00
parent e052a64767
commit 0e9676173b
17 changed files with 230 additions and 32 deletions
@@ -0,0 +1,8 @@
// NEXT_SIBLING:
fun foo(a: Int): Int {
class A {
fun bar(): Int = a + 10
}
return <selection>A().bar()</selection>
}
@@ -0,0 +1 @@
class foo.A will no longer be accessible after extraction
@@ -0,0 +1,8 @@
// NEXT_SIBLING:
fun foo(a: Int): Int {
class A {
val bar: Int = a + 10
}
return <selection>A().bar</selection>
}
@@ -0,0 +1 @@
class foo.A will no longer be accessible after extraction
@@ -0,0 +1,6 @@
// NEXT_SIBLING:
fun foo(a: Int): Int {
fun bar(): Int = a + 10
return <selection>bar()</selection>
}
@@ -0,0 +1 @@
function foo.bar will no longer be accessible after extraction
@@ -0,0 +1,8 @@
// NEXT_SIBLING:
fun bar(): Int = 100
fun foo(a: Int): Int {
fun bar(): Int = a + 10
return <selection>bar()</selection>
}
@@ -0,0 +1 @@
function foo.bar will no longer be accessible after extraction
@@ -0,0 +1,8 @@
// NEXT_SIBLING:
class A {
private val t: Int = 1
fun foo(): Int {
return <selection>t</selection>
}
}
@@ -0,0 +1 @@
property A.t will become invisible after extraction
@@ -0,0 +1,6 @@
// NEXT_SIBLING:
fun foo(a: Int): Int {
<selection>println(a)
if (a > 0) return a</selection>
return -a
}
@@ -0,0 +1,11 @@
// NEXT_SIBLING:
fun b(a: Int): Boolean {
println(a)
if (a > 0) return true
return false
}
fun foo(a: Int): Int {
if (b(a)) return a
return -a
}