Mark required call with 'caret' in abstract resolved calls test
This commit is contained in:
@@ -34,6 +34,11 @@ import org.jetbrains.jet.lang.psi.JetDeclarationWithBody
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
||||
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.calls.ArgumentTypeResolver
|
||||
import org.jetbrains.jet.lang.psi.JetArrayAccessExpression
|
||||
import org.jetbrains.jet.lang.psi.JetUnaryExpression
|
||||
import org.jetbrains.jet.lang.psi.JetBinaryExpression
|
||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
|
||||
/**
|
||||
* For expressions like <code>a(), a[i], a.b.c(), +a, a + b, (a()), a(): Int, @label a()</code>
|
||||
@@ -57,6 +62,14 @@ fun JetExpression.getCorrespondingCall(bindingContext: BindingContext): Call? {
|
||||
return bindingContext[CALL, reference]
|
||||
}
|
||||
|
||||
fun JetExpression.getEnclosingCall(bindingContext: BindingContext): Call? {
|
||||
val parent = PsiTreeUtil.getNonStrictParentOfType<JetExpression>(
|
||||
this,
|
||||
javaClass<JetSimpleNameExpression>(), javaClass<JetCallExpression>(), javaClass<JetBinaryExpression>(),
|
||||
javaClass<JetUnaryExpression>(), javaClass<JetArrayAccessExpression>())
|
||||
return parent?.getCorrespondingCall(bindingContext)
|
||||
}
|
||||
|
||||
fun Call.hasUnresolvedArguments(bindingContext: BindingContext): Boolean {
|
||||
val arguments = getValueArguments().map { it?.getArgumentExpression() }
|
||||
return arguments.any {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun <T, S, R> foo(t: T, f: (T) -> S, g: (S) -> R) {}
|
||||
|
||||
|
||||
fun test() {
|
||||
foo(1, { x -> "$x"}, { y -> y.length })
|
||||
<caret>foo(1, { x -> "$x"}, { y -> y.length })
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun <T, S, R> foo(t: T, f: (T) -> S, g: (S) -> R) {}
|
||||
|
||||
|
||||
fun test() {
|
||||
foo(1, { x -> "$x"}, { y -> y.length })
|
||||
<caret>foo(1, { x -> "$x"}, { y -> y.length })
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-3
@@ -1,7 +1,5 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun <T> foo(f: () -> T) {}
|
||||
|
||||
fun test() {
|
||||
foo { b }
|
||||
<caret>foo { b }
|
||||
}
|
||||
+1
-3
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun <T> foo(f: () -> T) {}
|
||||
|
||||
fun test() {
|
||||
foo { b }
|
||||
<caret>foo { b }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun <T> foo(f: (T) -> String) {}
|
||||
|
||||
fun test() {
|
||||
foo { x -> "$x"}
|
||||
<caret>foo { x -> "$x"}
|
||||
}
|
||||
+1
-3
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun <T> foo(f: (T) -> String) {}
|
||||
|
||||
fun test() {
|
||||
foo { x -> "$x"}
|
||||
<caret>foo { x -> "$x"}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun <T> foo(f: (T) -> String) {}
|
||||
|
||||
fun test() {
|
||||
foo { (x: Int) -> "$x"}
|
||||
<caret>foo { (x: Int) -> "$x"}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun <T> foo(f: (T) -> String) {}
|
||||
|
||||
fun test() {
|
||||
foo { (x: Int) -> "$x"}
|
||||
<caret>foo { (x: Int) -> "$x"}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun foo(f: (Int) -> String) {}
|
||||
|
||||
fun test() {
|
||||
foo { x -> "$x"}
|
||||
<caret>foo { x -> "$x"}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun foo(f: (Int) -> String) {}
|
||||
|
||||
fun test() {
|
||||
foo { x -> "$x"}
|
||||
<caret>foo { x -> "$x"}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun foo() {}
|
||||
|
||||
fun test() {
|
||||
foo { x -> "$x"}
|
||||
<caret>foo { x -> "$x"}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun foo() {}
|
||||
|
||||
fun test() {
|
||||
foo { x -> "$x"}
|
||||
<caret>foo { x -> "$x"}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun <T> foo(t: T, l: List<T>) {}
|
||||
|
||||
fun use(vararg a: Any?) = a
|
||||
|
||||
fun test(a: Any, ls: List<String>) {
|
||||
use(foo(11, ls))
|
||||
use(<caret>foo(11, ls))
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun <T> foo(t: T, l: List<T>) {}
|
||||
|
||||
fun use(vararg a: Any?) = a
|
||||
|
||||
fun test(a: Any, ls: List<String>) {
|
||||
use(foo(11, ls))
|
||||
use(<caret>foo(11, ls))
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
|
||||
fun <T> foo(t: T) {}
|
||||
|
||||
fun bar() {
|
||||
foo(A())
|
||||
<caret>foo(A())
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
|
||||
fun <T> foo(t: T) {}
|
||||
|
||||
fun bar() {
|
||||
foo(A())
|
||||
<caret>foo(A())
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun <T> foo(t: T, l: MutableList<T>) {}
|
||||
|
||||
fun use(vararg a: Any?) = a
|
||||
|
||||
fun test(ls: MutableList<String>) {
|
||||
use(foo(11, ls))
|
||||
use(<caret>foo(11, ls))
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun <T> foo(t: T, l: MutableList<T>) {}
|
||||
|
||||
fun use(vararg a: Any?) = a
|
||||
|
||||
fun test(ls: MutableList<String>) {
|
||||
use(foo(11, ls))
|
||||
use(<caret>foo(11, ls))
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-3
@@ -1,7 +1,5 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun <T> foo(l: List<T>) {}
|
||||
|
||||
fun test() {
|
||||
foo(11)
|
||||
<caret>foo(11)
|
||||
}
|
||||
+1
-3
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun <T> foo(l: List<T>) {}
|
||||
|
||||
fun test() {
|
||||
foo(11)
|
||||
<caret>foo(11)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
class B {}
|
||||
|
||||
fun foo(a: A, b: B) {}
|
||||
|
||||
fun bar() {
|
||||
foo(b = B(), A())
|
||||
<caret>foo(b = B(), A())
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
class B {}
|
||||
|
||||
fun foo(a: A, b: B) {}
|
||||
|
||||
fun bar() {
|
||||
foo(b = B(), A())
|
||||
<caret>foo(b = B(), A())
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
class B {}
|
||||
|
||||
fun foo(a: A, b: B) {}
|
||||
|
||||
fun bar() {
|
||||
foo(b = B(), a = A())
|
||||
<caret>foo(b = B(), a = A())
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
class B {}
|
||||
|
||||
fun foo(a: A, b: B) {}
|
||||
|
||||
fun bar() {
|
||||
foo(b = B(), a = A())
|
||||
<caret>foo(b = B(), a = A())
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
|
||||
fun foo(a: A) {}
|
||||
|
||||
fun bar() {
|
||||
foo(b)
|
||||
<caret>foo(b)
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
|
||||
fun foo(a: A) {}
|
||||
|
||||
fun bar() {
|
||||
foo(b)
|
||||
<caret>foo(b)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
|
||||
fun foo(a: A) {}
|
||||
|
||||
fun bar() {
|
||||
foo(A())
|
||||
<caret>foo(A())
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
|
||||
fun foo(a: A) {}
|
||||
|
||||
fun bar() {
|
||||
foo(A())
|
||||
<caret>foo(A())
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
|
||||
fun foo(a: A) {}
|
||||
|
||||
fun bar() {
|
||||
foo("")
|
||||
<caret>foo("")
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
|
||||
fun foo(a: A) {}
|
||||
|
||||
fun bar() {
|
||||
foo("")
|
||||
<caret>foo("")
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun foo() {}
|
||||
|
||||
fun bar() {
|
||||
foo("")
|
||||
<caret>foo("")
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun foo() {}
|
||||
|
||||
fun bar() {
|
||||
foo("")
|
||||
<caret>foo("")
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
|
||||
fun <T> foo(t: T) {}
|
||||
@@ -7,5 +5,5 @@ fun <T> foo(t: T) {}
|
||||
fun <T> emptyList(): List<T> = throw Exception()
|
||||
|
||||
fun bar() {
|
||||
foo(emptyList())
|
||||
<caret>foo(emptyList())
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
|
||||
fun <T> foo(t: T) {}
|
||||
@@ -7,7 +5,7 @@ fun <T> foo(t: T) {}
|
||||
fun <T> emptyList(): List<T> = throw Exception()
|
||||
|
||||
fun bar() {
|
||||
foo(emptyList())
|
||||
<caret>foo(emptyList())
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
|
||||
fun <T> foo(t: T) {}
|
||||
@@ -7,5 +5,5 @@ fun <T> foo(t: T) {}
|
||||
fun <T> emptyList(): MutableList<T> = throw Exception()
|
||||
|
||||
fun bar() {
|
||||
foo(emptyList())
|
||||
<caret>foo(emptyList())
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
|
||||
fun <T> foo(t: T) {}
|
||||
@@ -7,7 +5,7 @@ fun <T> foo(t: T) {}
|
||||
fun <T> emptyList(): MutableList<T> = throw Exception()
|
||||
|
||||
fun bar() {
|
||||
foo(emptyList())
|
||||
<caret>foo(emptyList())
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
|
||||
fun foo(a: A) {}
|
||||
@@ -7,5 +5,5 @@ fun foo(a: A, s: String) {}
|
||||
fun foo(a: A, any: Any) {}
|
||||
|
||||
fun bar() {
|
||||
foo(A(), "")
|
||||
<caret>foo(A(), "")
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
|
||||
fun foo(a: A) {}
|
||||
@@ -7,7 +5,7 @@ fun foo(a: A, s: String) {}
|
||||
fun foo(a: A, any: Any) {}
|
||||
|
||||
fun bar() {
|
||||
foo(A(), "")
|
||||
<caret>foo(A(), "")
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
|
||||
fun A.foo() {}
|
||||
|
||||
fun bar(a: A) {
|
||||
a.foo()
|
||||
a.<caret>foo()
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
|
||||
fun A.foo() {}
|
||||
|
||||
fun bar(a: A) {
|
||||
a.foo()
|
||||
a.<caret>foo()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
fun bar(a: A) {
|
||||
a.foo()
|
||||
a.<caret>foo()
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
fun bar(a: A) {
|
||||
a.foo()
|
||||
a.<caret>foo()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// !CALL: invoke
|
||||
|
||||
fun bar(f: Int.()->Unit) {
|
||||
1.f()
|
||||
1.f<caret>()
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// !CALL: invoke
|
||||
|
||||
fun bar(f: Int.()->Unit) {
|
||||
1.f()
|
||||
1.f<caret>()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// !CALL: invoke
|
||||
|
||||
fun bar(f: ()->Unit) {
|
||||
f()
|
||||
f<caret>()
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// !CALL: invoke
|
||||
|
||||
fun bar(f: ()->Unit) {
|
||||
f()
|
||||
f<caret>()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
trait A {
|
||||
val foo: Int.()->Unit
|
||||
|
||||
fun test() {
|
||||
1.foo()
|
||||
1.<caret>foo()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
// !CALL: foo
|
||||
|
||||
trait A {
|
||||
val foo: Int.()->Unit
|
||||
|
||||
fun test() {
|
||||
1.foo()
|
||||
1.<caret>foo()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: invoke
|
||||
|
||||
trait A {
|
||||
val foo: Int.()->Unit
|
||||
|
||||
fun test() {
|
||||
1.foo()
|
||||
1.foo<caret>()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
// !CALL: invoke
|
||||
|
||||
trait A {
|
||||
val foo: Int.()->Unit
|
||||
|
||||
fun test() {
|
||||
1.foo()
|
||||
1.foo<caret>()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
trait A {
|
||||
val foo: (Int)->Int
|
||||
}
|
||||
|
||||
fun test(a: A) {
|
||||
a.foo(1)
|
||||
a.<caret>foo(1)
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
// !CALL: foo
|
||||
|
||||
trait A {
|
||||
val foo: (Int)->Int
|
||||
}
|
||||
|
||||
fun test(a: A) {
|
||||
a.foo(1)
|
||||
a.<caret>foo(1)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: invoke
|
||||
|
||||
trait A {
|
||||
val foo: (Int)->Int
|
||||
}
|
||||
|
||||
fun test(a: A) {
|
||||
a.foo(1)
|
||||
a.foo<caret>(1)
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
// !CALL: invoke
|
||||
|
||||
trait A {
|
||||
val foo: (Int)->Int
|
||||
}
|
||||
|
||||
fun test(a: A) {
|
||||
a.foo(1)
|
||||
a.foo<caret>(1)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {
|
||||
fun B.foo() {}
|
||||
}
|
||||
@@ -8,7 +6,7 @@ trait B
|
||||
|
||||
fun bar(a: A, b: B) {
|
||||
with (a) {
|
||||
b.foo()
|
||||
b.<caret>foo()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {
|
||||
fun B.foo() {}
|
||||
}
|
||||
@@ -8,7 +6,7 @@ trait B
|
||||
|
||||
fun bar(a: A, b: B) {
|
||||
with (a) {
|
||||
b.foo()
|
||||
b.<caret>foo()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-3
@@ -1,5 +1,3 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {
|
||||
fun B.foo() {}
|
||||
}
|
||||
@@ -9,7 +7,7 @@ trait B
|
||||
fun bar(a: A, b: B) {
|
||||
with (a) {
|
||||
with (b) {
|
||||
foo()
|
||||
<caret>foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -1,5 +1,3 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {
|
||||
fun B.foo() {}
|
||||
}
|
||||
@@ -9,7 +7,7 @@ trait B
|
||||
fun bar(a: A, b: B) {
|
||||
with (a) {
|
||||
with (b) {
|
||||
foo()
|
||||
<caret>foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
|
||||
fun A.foo() {}
|
||||
|
||||
fun A.bar() {
|
||||
foo()
|
||||
<caret>foo()
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {}
|
||||
|
||||
fun A.foo() {}
|
||||
|
||||
fun A.bar() {
|
||||
foo()
|
||||
<caret>foo()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
fun A.bar() {
|
||||
foo()
|
||||
<caret>foo()
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
fun A.bar() {
|
||||
foo()
|
||||
<caret>foo()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {
|
||||
fun foo() {}
|
||||
fun bar() {
|
||||
foo()
|
||||
<caret>foo()
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
class A {
|
||||
fun foo() {}
|
||||
fun bar() {
|
||||
foo()
|
||||
<caret>foo()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: invoke
|
||||
|
||||
class Foo() {
|
||||
fun Int.invoke() {}
|
||||
}
|
||||
|
||||
fun bar(f: Foo) {
|
||||
1.f()
|
||||
1.f<caret>()
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
// !CALL: invoke
|
||||
|
||||
class Foo() {
|
||||
fun Int.invoke() {}
|
||||
}
|
||||
|
||||
fun bar(f: Foo) {
|
||||
1.f()
|
||||
1.f<caret>()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
// !CALL: invoke
|
||||
|
||||
class Foo() {
|
||||
fun Int.invoke() {}
|
||||
}
|
||||
|
||||
fun bar(f: Foo, i: Int) {
|
||||
with (i) {
|
||||
f()
|
||||
f<caret>()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
// !CALL: invoke
|
||||
|
||||
class Foo() {
|
||||
fun Int.invoke() {}
|
||||
}
|
||||
|
||||
fun bar(f: Foo, i: Int) {
|
||||
with (i) {
|
||||
f()
|
||||
f<caret>()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// !CALL: invoke
|
||||
|
||||
class Foo
|
||||
fun Foo.invoke() {}
|
||||
|
||||
fun bar(f: Foo) {
|
||||
f()
|
||||
f<caret>()
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
// !CALL: invoke
|
||||
|
||||
class Foo
|
||||
fun Foo.invoke() {}
|
||||
|
||||
fun bar(f: Foo) {
|
||||
f()
|
||||
f<caret>()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: invoke
|
||||
|
||||
class Foo {
|
||||
fun invoke() {}
|
||||
}
|
||||
|
||||
fun bar(f: Foo) {
|
||||
f()
|
||||
f<caret>()
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
// !CALL: invoke
|
||||
|
||||
class Foo {
|
||||
fun invoke() {}
|
||||
}
|
||||
|
||||
fun bar(f: Foo) {
|
||||
f()
|
||||
f<caret>()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// !CALL: +
|
||||
|
||||
trait Element {
|
||||
fun render(builder: StringBuilder, indent: String)
|
||||
}
|
||||
@@ -34,7 +32,7 @@ fun html(init: HTML.() -> Unit): HTML = fail
|
||||
fun result() =
|
||||
html {
|
||||
head {
|
||||
title {+"Foo"}
|
||||
title { <caret>+"Foo" }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// !CALL: +
|
||||
|
||||
trait Element {
|
||||
fun render(builder: StringBuilder, indent: String)
|
||||
}
|
||||
@@ -34,7 +32,7 @@ fun html(init: HTML.() -> Unit): HTML = fail
|
||||
fun result() =
|
||||
html {
|
||||
head {
|
||||
title {+"Foo"}
|
||||
title { <caret>+"Foo" }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun foo() {}
|
||||
|
||||
fun bar() {
|
||||
foo()
|
||||
<caret>foo()
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// !CALL: foo
|
||||
|
||||
fun foo() {}
|
||||
|
||||
fun bar() {
|
||||
foo()
|
||||
<caret>foo()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.jetbrains.jet.ConfigurationKind
|
||||
import org.jetbrains.jet.JetLiteFixture
|
||||
import org.jetbrains.jet.JetTestUtils
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment
|
||||
import org.jetbrains.jet.lang.psi.JetElement
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.AbstractReceiverValue
|
||||
@@ -28,8 +27,6 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue
|
||||
|
||||
import java.io.File
|
||||
import kotlin.test.assertTrue
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.lazy.JvmResolveUtil
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentMapping
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentMatch
|
||||
@@ -37,43 +34,36 @@ import org.jetbrains.jet.lang.resolve.calls.util.getAllValueArguments
|
||||
import org.jetbrains.jet.renderer.DescriptorRenderer
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.jet.lang.psi.ValueArgument
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getEnclosingCall
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall
|
||||
|
||||
public abstract class AbstractResolvedCallsTest() : JetLiteFixture() {
|
||||
override fun createEnvironment(): JetCoreEnvironment = createEnvironmentWithMockJdk(ConfigurationKind.JDK_ONLY)
|
||||
|
||||
public fun doTest(filePath: String) {
|
||||
val file = File(filePath)
|
||||
val text = JetTestUtils.doLoadFile(file)
|
||||
val directives = JetTestUtils.parseDirectives(text)
|
||||
val text = JetTestUtils.doLoadFile(File(filePath))!!
|
||||
|
||||
val callName = directives["CALL"]
|
||||
val jetFile = JetPsiFactory.createFile(getProject(), text.replace("<caret>", ""))
|
||||
val bindingContext = JvmResolveUtil.analyzeOneFileWithJavaIntegration(jetFile).getBindingContext()
|
||||
|
||||
fun analyzeFileAndGetResolvedCallEntries(): Map<JetElement, ResolvedCall<*>> {
|
||||
val psiFile = JetTestUtils.loadJetFile(getProject(), file)!!
|
||||
val analyzeExhaust = JvmResolveUtil.analyzeOneFileWithJavaIntegration(psiFile)
|
||||
val bindingContext = analyzeExhaust.getBindingContext()
|
||||
return bindingContext.getSliceContents(BindingContext.RESOLVED_CALL)
|
||||
val element = jetFile.findElementAt(text.indexOf("<caret>"))
|
||||
val expression = PsiTreeUtil.getParentOfType(element, javaClass<JetExpression>())
|
||||
val call = expression?.getEnclosingCall(bindingContext)
|
||||
|
||||
val cachedCall = bindingContext[BindingContext.RESOLVED_CALL, call?.getCalleeExpression()]
|
||||
if (cachedCall == null) {
|
||||
throw AssertionError("No resolved call for:\nelement: ${element.toString()}\nexpression: ${expression.toString()}\ncall: $call")
|
||||
}
|
||||
|
||||
var callFound = false
|
||||
fun tryCall(resolvedCall: ResolvedCall<*>, actualName: String?) {
|
||||
if (callName == null || callName != actualName) return
|
||||
callFound = true
|
||||
val resolvedCall = if (cachedCall !is VariableAsFunctionResolvedCall) cachedCall
|
||||
else if ("(" == element?.getText()) cachedCall.functionCall
|
||||
else cachedCall.variableCall
|
||||
|
||||
val resolvedCallInfoFileName = FileUtil.getNameWithoutExtension(filePath) + ".txt"
|
||||
JetTestUtils.assertEqualsToFile(File(resolvedCallInfoFileName), "$text\n\n\n${resolvedCall.renderToText()}")
|
||||
}
|
||||
|
||||
for ((element, resolvedCall) in analyzeFileAndGetResolvedCallEntries()) {
|
||||
if (resolvedCall is VariableAsFunctionResolvedCall) {
|
||||
tryCall(resolvedCall.functionCall, "invoke")
|
||||
tryCall(resolvedCall.variableCall, element.getText())
|
||||
}
|
||||
else {
|
||||
tryCall(resolvedCall, element.getText())
|
||||
}
|
||||
}
|
||||
assertTrue(callFound, "Resolved call for $callName was not found")
|
||||
val resolvedCallInfoFileName = FileUtil.getNameWithoutExtension(filePath) + ".txt"
|
||||
JetTestUtils.assertEqualsToFile(File(resolvedCallInfoFileName), "$text\n\n\n${resolvedCall.renderToText()}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user