Introduce Property: Initial support (properties with getter)

This commit is contained in:
Alexey Sedunov
2015-03-04 18:01:06 +03:00
parent 48914e70ff
commit 03fada71d7
36 changed files with 396 additions and 158 deletions
@@ -0,0 +1,9 @@
// EXTRACTION_TARGET: property with initializer
class A {
val i = 1
fun foo(): Int {
return <selection>1 + 2</selection>
}
}
@@ -0,0 +1,11 @@
// EXTRACTION_TARGET: property with initializer
class A {
val i = 1
fun foo(): Int {
return i1
}
private val i1 = 1 + 2
}
@@ -0,0 +1,7 @@
// EXTRACTION_TARGET: property with initializer
val i = 1
fun foo(): Int {
return <selection>1 + 2</selection>
}
@@ -0,0 +1,9 @@
// EXTRACTION_TARGET: property with initializer
val i = 1
fun foo(): Int {
return i1
}
private val i1 = 1 + 2
@@ -0,0 +1,4 @@
// EXTRACTION_TARGET: property with getter
fun foo(n: Int): Int {
return {<selection>n + 1</selection>}()
}
@@ -0,0 +1 @@
Can't generate property: n + 1
@@ -0,0 +1,4 @@
// EXTRACTION_TARGET: property with getter
fun foo() {
<selection>1 + 1</selection>
}
@@ -0,0 +1 @@
Can't generate property: 1 + 1
@@ -0,0 +1,9 @@
// EXTRACTION_TARGET: property with getter
class A {
fun foo(): Int {
<selection>val a = 1 + 2
val b = a*2</selection>
val c = b - 1
}
}
@@ -0,0 +1,15 @@
// EXTRACTION_TARGET: property with getter
class A {
fun foo(): Int {
val b = i
val c = b - 1
}
private val i: Int
get() {
val a = 1 + 2
val b = a * 2
return b
}
}
@@ -0,0 +1,9 @@
// EXTRACTION_TARGET: property with getter
class A(val n: Int = 1) {
val m: Int = 2
fun foo(): Int {
return <selection>m + n + 1</selection>
}
}
@@ -0,0 +1,14 @@
// EXTRACTION_TARGET: property with getter
class A(val n: Int = 1) {
val m: Int = 2
fun foo(): Int {
return i
}
private val i: Int
get() {
return m + n + 1
}
}
@@ -0,0 +1,6 @@
// EXTRACTION_TARGET: property with getter
val n: Int = 1
fun foo(): Int {
return <selection>n + 1</selection>
}
@@ -0,0 +1,11 @@
// EXTRACTION_TARGET: property with getter
val n: Int = 1
fun foo(): Int {
return i
}
private val i: Int
get() {
return n + 1
}
@@ -0,0 +1,7 @@
// EXTRACTION_TARGET: property with getter
val n: Int = 1
fun foo(): Int {
val m = 1
return <selection>n + m + 1</selection>
}
@@ -0,0 +1 @@
Can't generate property: n + m + 1