Added tests on resolved call for 'this'
This commit is contained in:
@@ -39,6 +39,7 @@ import org.jetbrains.jet.lang.psi.JetUnaryExpression
|
|||||||
import org.jetbrains.jet.lang.psi.JetBinaryExpression
|
import org.jetbrains.jet.lang.psi.JetBinaryExpression
|
||||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
||||||
import com.intellij.psi.util.PsiTreeUtil
|
import com.intellij.psi.util.PsiTreeUtil
|
||||||
|
import org.jetbrains.jet.lang.psi.JetThisExpression
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For expressions like <code>a(), a[i], a.b.c(), +a, a + b, (a()), a(): Int, @label a()</code>
|
* For expressions like <code>a(), a[i], a.b.c(), +a, a + b, (a()), a(): Int, @label a()</code>
|
||||||
@@ -54,9 +55,11 @@ fun JetExpression.getCorrespondingCall(bindingContext: BindingContext): Call? {
|
|||||||
if (expr is JetQualifiedExpression) {
|
if (expr is JetQualifiedExpression) {
|
||||||
return expr.getSelectorExpression()?.getCorrespondingCall(bindingContext)
|
return expr.getSelectorExpression()?.getCorrespondingCall(bindingContext)
|
||||||
}
|
}
|
||||||
val reference = when (expr) {
|
val parent = expr.getParent()
|
||||||
is JetCallExpression -> expr.getCalleeExpression()
|
val reference = when {
|
||||||
is JetOperationExpression -> expr.getOperationReference()
|
parent is JetThisExpression -> parent : JetThisExpression
|
||||||
|
expr is JetCallExpression -> expr.getCalleeExpression()
|
||||||
|
expr is JetOperationExpression -> expr.getOperationReference()
|
||||||
else -> expr
|
else -> expr
|
||||||
}
|
}
|
||||||
return bindingContext[CALL, reference]
|
return bindingContext[CALL, reference]
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class A {
|
||||||
|
fun foo() {
|
||||||
|
<caret>this@A.foo()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
class A {
|
||||||
|
fun foo() {
|
||||||
|
<caret>this@A.foo()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Resolved call:
|
||||||
|
|
||||||
|
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||||
|
This object = NO_RECEIVER
|
||||||
|
Receiver argument = NO_RECEIVER
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class A {
|
||||||
|
fun foo() {
|
||||||
|
<caret>this.foo()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
class A {
|
||||||
|
fun foo() {
|
||||||
|
<caret>this.foo()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Resolved call:
|
||||||
|
|
||||||
|
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||||
|
This object = NO_RECEIVER
|
||||||
|
Receiver argument = NO_RECEIVER
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class A {
|
||||||
|
fun foo() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun A.bar() = <caret>this.foo()
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
class A {
|
||||||
|
fun foo() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun A.bar() = <caret>this.foo()
|
||||||
|
|
||||||
|
|
||||||
|
Resolved call:
|
||||||
|
|
||||||
|
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||||
|
This object = NO_RECEIVER
|
||||||
|
Receiver argument = NO_RECEIVER
|
||||||
@@ -31,7 +31,7 @@ import org.jetbrains.jet.resolve.calls.AbstractResolvedCallsTest;
|
|||||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
@TestMetadata("compiler/testData/resolvedCalls")
|
@TestMetadata("compiler/testData/resolvedCalls")
|
||||||
@InnerTestClasses({ResolvedCallsTestGenerated.Arguments.class, ResolvedCallsTestGenerated.FunctionTypes.class, ResolvedCallsTestGenerated.Invoke.class, ResolvedCallsTestGenerated.RealExamples.class})
|
@InnerTestClasses({ResolvedCallsTestGenerated.Arguments.class, ResolvedCallsTestGenerated.FunctionTypes.class, ResolvedCallsTestGenerated.Invoke.class, ResolvedCallsTestGenerated.RealExamples.class, ResolvedCallsTestGenerated.This.class})
|
||||||
public class ResolvedCallsTestGenerated extends AbstractResolvedCallsTest {
|
public class ResolvedCallsTestGenerated extends AbstractResolvedCallsTest {
|
||||||
public void testAllFilesPresentInResolvedCalls() throws Exception {
|
public void testAllFilesPresentInResolvedCalls() throws Exception {
|
||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/resolvedCalls"), Pattern.compile("^(.+)\\.kt$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/resolvedCalls"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
@@ -319,6 +319,29 @@ public class ResolvedCallsTestGenerated extends AbstractResolvedCallsTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/resolvedCalls/this")
|
||||||
|
public static class This extends AbstractResolvedCallsTest {
|
||||||
|
public void testAllFilesPresentInThis() throws Exception {
|
||||||
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/resolvedCalls/this"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("labeledThis.kt")
|
||||||
|
public void testLabeledThis() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/this/labeledThis.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simpleThis.kt")
|
||||||
|
public void testSimpleThis() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/this/simpleThis.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("thisInExtensionFunction.kt")
|
||||||
|
public void testThisInExtensionFunction() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/this/thisInExtensionFunction.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite = new TestSuite("ResolvedCallsTestGenerated");
|
TestSuite suite = new TestSuite("ResolvedCallsTestGenerated");
|
||||||
suite.addTestSuite(ResolvedCallsTestGenerated.class);
|
suite.addTestSuite(ResolvedCallsTestGenerated.class);
|
||||||
@@ -326,6 +349,7 @@ public class ResolvedCallsTestGenerated extends AbstractResolvedCallsTest {
|
|||||||
suite.addTestSuite(FunctionTypes.class);
|
suite.addTestSuite(FunctionTypes.class);
|
||||||
suite.addTestSuite(Invoke.class);
|
suite.addTestSuite(Invoke.class);
|
||||||
suite.addTestSuite(RealExamples.class);
|
suite.addTestSuite(RealExamples.class);
|
||||||
|
suite.addTestSuite(This.class);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user