Initial implementation of smart completion after "by"

#KT-11787 Fixed
This commit is contained in:
Valentin Kipyatkov
2016-02-01 19:02:06 -07:00
parent c2065c1856
commit cda539d769
10 changed files with 421 additions and 60 deletions
@@ -0,0 +1,35 @@
import kotlin.reflect.KProperty
class X1 {
operator fun getValue(thisRef: C, property: KProperty<*>): CharSequence = ""
}
class X2 {
operator fun getValue(thisRef: C, property: KProperty<*>): String = ""
}
class X3 {
operator fun getValue(thisRef: C, property: KProperty<*>): Any = ""
}
class Y1
class Y2
operator fun Y1.getValue(thisRef: C, property: KProperty<*>): String = ""
operator fun Y2.getValue(thisRef: C, property: KProperty<*>): Int = 1
fun createX1() = X1()
fun createX2() = X2()
fun createX3() = X3()
fun createY1() = Y1()
fun createY2() = Y2()
class C {
val property: CharSequence by <caret>
}
// EXIST: lazy
// EXIST: createX1
// EXIST: createX2
// ABSENT: createX3
// EXIST: createY1
// ABSENT: createY2
/*TODO: add constructors*/
@@ -0,0 +1,29 @@
import kotlin.reflect.KProperty
class X1 {
operator fun getValue(thisRef: C, property: KProperty<*>): String = ""
operator fun setValue(thisRef: C, property: KProperty<*>, value: String) {}
}
class X2 {
operator fun getValue(thisRef: C, property: KProperty<*>): String = ""
operator fun setValue(thisRef: C, property: KProperty<*>, value: CharSequence) {}
}
class X3 {
operator fun getValue(thisRef: C, property: KProperty<*>): CharSequence = ""
operator fun setValue(thisRef: C, property: KProperty<*>, value: String) {}
}
fun createX1() = X1()
fun createX2() = X2()
fun createX3() = X3()
class C {
var property: CharSequence by <caret>
}
// ABSENT: lazy
// ABSENT: createX1
// EXIST: createX2
// ABSENT: createX3
@@ -0,0 +1,39 @@
import kotlin.reflect.KProperty
class X1 {
operator fun getValue(thisRef: C, property: KProperty<*>): String = ""
}
class X2 {
operator fun getValue(thisRef: String, property: KProperty<*>): String = ""
}
class X3 {
operator fun getValue(thisRef: Any, property: KProperty<*>): String = ""
}
class Y1
class Y2
class Y3
operator fun Y1.getValue(thisRef: C, property: KProperty<*>): String = ""
operator fun Y2.getValue(thisRef: String, property: KProperty<*>): String = ""
operator fun Y3.getValue(thisRef: Any, property: KProperty<*>): String = ""
fun createX1() = X1()
fun createX2() = X2()
fun createX3() = X3()
fun createY1() = Y1()
fun createY2() = Y2()
fun createY3() = Y3()
class C
val C.property by <caret>
// EXIST: lazy
// EXIST: createX1
// ABSENT: createX2
// EXIST: createX3
// EXIST: createY1
// ABSENT: createY2
// EXIST: createY3
/*TODO: add constructors*/
@@ -0,0 +1,42 @@
import kotlin.reflect.KProperty
class X1 {
operator fun getValue(thisRef: C, property: KProperty<*>): String = ""
operator fun setValue(thisRef: C, property: KProperty<*>, value: String) {}
}
class X2 {
operator fun getValue(thisRef: C, property: KProperty<*>): String = ""
}
class X3 {
operator fun getValue(thisRef: C, property: KProperty<*>): String = ""
operator fun setValue(thisRef: String, property: KProperty<*>, value: String) {}
}
class X4 {
operator fun getValue(thisRef: C, property: KProperty<*>): String = ""
operator fun setValue(thisRef: C, property: KProperty<*>, value: CharSequence) {}
}
class X5 {
operator fun getValue(thisRef: C, property: KProperty<*>): CharSequence = ""
operator fun setValue(thisRef: C, property: KProperty<*>, value: String) {}
}
fun createX1() = X1()
fun createX2() = X2()
fun createX3() = X3()
fun createX4() = X4()
fun createX5() = X5()
class C
var C.property by <caret>
// ABSENT: lazy
// EXIST: createX1
// ABSENT: createX2
// ABSENT: createX3
// EXIST: createX4
// ABSENT: createX5
@@ -0,0 +1,39 @@
import kotlin.reflect.KProperty
class X1 {
operator fun getValue(thisRef: C, property: KProperty<*>): String = ""
}
class X2 {
operator fun getValue(thisRef: String, property: KProperty<*>): String = ""
}
class X3 {
operator fun getValue(thisRef: Any, property: KProperty<*>): String = ""
}
class Y1
class Y2
class Y3
operator fun Y1.getValue(thisRef: C, property: KProperty<*>): String = ""
operator fun Y2.getValue(thisRef: String, property: KProperty<*>): String = ""
operator fun Y3.getValue(thisRef: Any, property: KProperty<*>): String = ""
fun createX1() = X1()
fun createX2() = X2()
fun createX3() = X3()
fun createY1() = Y1()
fun createY2() = Y2()
fun createY3() = Y3()
class C {
val property by <caret>
}
// EXIST: lazy
// EXIST: createX1
// ABSENT: createX2
// EXIST: createX3
// EXIST: createY1
// ABSENT: createY2
// EXIST: createY3
/*TODO: add constructors*/
@@ -0,0 +1,42 @@
import kotlin.reflect.KProperty
class X1 {
operator fun getValue(thisRef: C, property: KProperty<*>): String = ""
operator fun setValue(thisRef: C, property: KProperty<*>, value: String) {}
}
class X2 {
operator fun getValue(thisRef: C, property: KProperty<*>): String = ""
}
class X3 {
operator fun getValue(thisRef: C, property: KProperty<*>): String = ""
operator fun setValue(thisRef: String, property: KProperty<*>, value: String) {}
}
class X4 {
operator fun getValue(thisRef: C, property: KProperty<*>): String = ""
operator fun setValue(thisRef: C, property: KProperty<*>, value: CharSequence) {}
}
class X5 {
operator fun getValue(thisRef: C, property: KProperty<*>): CharSequence = ""
operator fun setValue(thisRef: C, property: KProperty<*>, value: String) {}
}
fun createX1() = X1()
fun createX2() = X2()
fun createX3() = X3()
fun createX4() = X4()
fun createX5() = X5()
class C {
var property by <caret>
}
// ABSENT: lazy
// EXIST: createX1
// ABSENT: createX2
// ABSENT: createX3
// EXIST: createX4
// ABSENT: createX5