KT-8898 If invocation context contains functional value compatible with function in completion list, show non-literal item

#KT-8898 Fixed
This commit is contained in:
Valentin Kipyatkov
2015-08-27 17:25:31 +03:00
parent fbb37f0154
commit a4c5907a1f
20 changed files with 408 additions and 78 deletions
@@ -0,0 +1,30 @@
interface I : () -> Unit
fun xfoo(p: () -> Unit){}
val global: () -> Unit = { }
fun X.test(p1: () -> Unit, p2: () -> String, p3: I) {
val local: () -> Unit = { }
xfoo<caret>
}
interface X {
public val publicVal: () -> Unit
protected val protectedVal: () -> Unit
}
val X.extension: () -> Unit
get() = {}
val String.wrongExtension: () -> Unit
get() = {}
// EXIST: { itemText: "xfoo", tailText: " {...} (p: () -> Unit) (<root>)", typeText:"Unit" }
// EXIST: { itemText: "xfoo", tailText: "(p1) (<root>)", typeText: "Unit" }
// EXIST: { itemText: "xfoo", tailText: "(p3) (<root>)", typeText: "Unit" }
// EXIST: { itemText: "xfoo", tailText: "(local) (<root>)", typeText: "Unit" }
// EXIST: { itemText: "xfoo", tailText: "(global) (<root>)", typeText: "Unit" }
// EXIST: { itemText: "xfoo", tailText: "(publicVal) (<root>)", typeText: "Unit" }
// EXIST: { itemText: "xfoo", tailText: "(extension) (<root>)", typeText: "Unit" }
// NOTHING_ELSE
@@ -0,0 +1,30 @@
interface I : () -> Unit
fun String.xfoo(p: () -> Unit){}
val global: () -> Unit = { }
fun X.test(p1: () -> Unit, p2: () -> String, p3: I) {
val local: () -> Unit = { }
"a".xfoo<caret>
}
interface X {
public val publicVal: () -> Unit
protected val protectedVal: () -> Unit
}
val X.extension: () -> Unit
get() = {}
val String.wrongExtension: () -> Unit
get() = {}
// EXIST: { itemText: "xfoo", tailText: " {...} (p: () -> Unit) for String in <root>", typeText:"Unit" }
// EXIST: { itemText: "xfoo", tailText: "(p1) for String in <root>", typeText: "Unit" }
// EXIST: { itemText: "xfoo", tailText: "(p3) for String in <root>", typeText: "Unit" }
// EXIST: { itemText: "xfoo", tailText: "(local) for String in <root>", typeText: "Unit" }
// EXIST: { itemText: "xfoo", tailText: "(global) for String in <root>", typeText: "Unit" }
// EXIST: { itemText: "xfoo", tailText: "(publicVal) for String in <root>", typeText: "Unit" }
// EXIST: { itemText: "xfoo", tailText: "(extension) for String in <root>", typeText: "Unit" }
// NOTHING_ELSE
@@ -0,0 +1,7 @@
fun test(p1: (String) -> Boolean, p2: (Int) -> Boolean) {
listOf("a", "b").filt<caret>
}
// EXIST: { itemText: "filter", tailText: " {...} (predicate: (String) -> Boolean) for Iterable<T> in kotlin", typeText:"List<String>" }
// EXIST: { itemText: "filter", tailText: "(p1) for Iterable<T> in kotlin", typeText: "List<String>" }
// ABSENT: { itemText: "filter", tailText: "(p2) for Iterable<T> in kotlin", typeText: "List<String>" }
@@ -0,0 +1,8 @@
fun test(p1: (String) -> Int, p2: (Int) -> Int, p3: (String) -> Char) {
listOf("a", "b").map<caret>
}
// EXIST: { itemText: "map", tailText: " {...} (transform: (String) -> R) for Iterable<T> in kotlin", typeText:"List<R>" }
// EXIST: { itemText: "map", tailText: "(p1) for Iterable<T> in kotlin", typeText: "List<Int>" }
// ABSENT: { itemText: "map", tailText: "(p2) for Iterable<T> in kotlin", typeText: "List<Int>" }
// EXIST: { itemText: "map", tailText: "(p3) for Iterable<T> in kotlin", typeText: "List<Char>" }
@@ -0,0 +1,24 @@
interface I1 {
val v: () -> Unit
val v1: () -> Unit
}
interface I2 {
val v: String
}
fun String.xfoo(p: () -> Unit){}
fun X.test(i1: I1, i2: I2) {
with(i1) {
with(i2) {
"a".xfoo<caret>
}
}
}
interface X
// EXIST: { itemText: "xfoo", tailText: " {...} (p: () -> Unit) for String in <root>", typeText:"Unit" }
// EXIST: { itemText: "xfoo", tailText: "(v1) for String in <root>", typeText: "Unit" }
// NOTHING_ELSE
@@ -0,0 +1,8 @@
fun foo(p: (String, Char) -> Unit){}
fun test() {
foo<caret>
}
// EXIST: { lookupString:"foo", itemText: "foo", tailText: "(p: (String, Char) -> Unit) (<root>)", typeText:"Unit" }
// EXIST: { lookupString:"foo", itemText: "foo", tailText: " { String, Char -> ... } (p: (String, Char) -> Unit) (<root>)", typeText:"Unit" }
@@ -0,0 +1,8 @@
fun String.foo(p: (String, Char) -> Unit){}
fun test() {
"".fo<caret>
}
// EXIST: { lookupString:"foo", itemText: "foo", tailText: "(p: (String, Char) -> Unit) for String in <root>", typeText:"Unit" }
// EXIST: { lookupString:"foo", itemText: "foo", tailText: " { String, Char -> ... } (p: (String, Char) -> Unit) for String in <root>", typeText:"Unit" }