Find usages and reference to delegation origin
This commit is contained in:
@@ -42,6 +42,7 @@ import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.psi.JetClassOrObject;
|
||||
import org.jetbrains.kotlin.psi.JetNamedFunction;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.resolve.annotations.AnnotationsPackage;
|
||||
import org.jetbrains.kotlin.resolve.calls.CallResolverUtil;
|
||||
@@ -76,7 +77,9 @@ import static org.jetbrains.kotlin.resolve.DescriptorToSourceUtils.callableDescr
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isFunctionLiteral;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isTrait;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.diagnostics.DiagnosticsPackage.*;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.diagnostics.DiagnosticsPackage.Delegation;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.diagnostics.DiagnosticsPackage.OtherOrigin;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.diagnostics.DiagnosticsPackage.Synthetic;
|
||||
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
||||
|
||||
public class FunctionCodegen {
|
||||
@@ -836,7 +839,7 @@ public class FunctionCodegen {
|
||||
final StackValue field
|
||||
) {
|
||||
generateMethod(
|
||||
Delegation(null, delegateFunction), delegateFunction,
|
||||
Delegation(DescriptorToSourceUtils.descriptorToDeclaration(delegatedTo), delegateFunction), delegateFunction,
|
||||
new FunctionGenerationStrategy() {
|
||||
@Override
|
||||
public void generateBody(
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetNamedFunction
|
||||
// OPTIONS: usages, skipImports
|
||||
package server
|
||||
|
||||
trait TraitWithImpl {
|
||||
fun <caret>foo() = 1
|
||||
}
|
||||
|
||||
public class TraitWithDelegatedWithImpl(f: TraitWithImpl): TraitWithImpl by f
|
||||
|
||||
fun test(twdwi: TraitWithDelegatedWithImpl) = twdwi.foo()
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package client;
|
||||
|
||||
import server.TraitWithDelegatedWithImpl;
|
||||
|
||||
public class Test {
|
||||
public static void bar(TraitWithDelegatedWithImpl some) {
|
||||
some.foo();
|
||||
}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
Function call (11: 53) fun test(twdwi: TraitWithDelegatedWithImpl) = twdwi.foo()
|
||||
Unclassified usage (7: 14) some.foo();
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetNamedFunction
|
||||
// OPTIONS: usages, skipImports
|
||||
package server
|
||||
|
||||
trait TraitNoImpl {
|
||||
fun <caret>foo()
|
||||
}
|
||||
|
||||
public class TraitWithDelegatedNoImpl(f: TraitNoImpl): TraitNoImpl by f
|
||||
|
||||
fun test(twdni: TraitWithDelegatedNoImpl) = twdni.foo()
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package client;
|
||||
|
||||
import server.TraitWithDelegatedNoImpl;
|
||||
|
||||
public class JClient {
|
||||
public static void bar(TraitWithDelegatedNoImpl some) {
|
||||
some.foo();
|
||||
}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
Function call (11: 51) fun test(twdni: TraitWithDelegatedNoImpl) = twdni.foo()
|
||||
Unclassified usage (7: 14) some.foo();
|
||||
@@ -0,0 +1,9 @@
|
||||
import k.*;
|
||||
|
||||
public class Test {
|
||||
public static void bar(TraitWithDelegatedNoImpl some) {
|
||||
some.<caret>foo();
|
||||
}
|
||||
}
|
||||
|
||||
// REF: (in k.TraitNoImpl).foo()
|
||||
@@ -0,0 +1,9 @@
|
||||
import k.*;
|
||||
|
||||
public class Test {
|
||||
public static void bar(TraitWithDelegatedWithImpl some) {
|
||||
some.<caret>foo();
|
||||
}
|
||||
}
|
||||
|
||||
// REF: (in k.TraitWithImpl).foo()
|
||||
@@ -39,4 +39,12 @@ object PlatformStaticFun {
|
||||
|
||||
trait TraitNoImpl {
|
||||
fun foo()
|
||||
}
|
||||
}
|
||||
|
||||
public class TraitWithDelegatedNoImpl(f: TraitNoImpl): TraitNoImpl by f
|
||||
|
||||
trait TraitWithImpl {
|
||||
fun foo() = 1
|
||||
}
|
||||
|
||||
public class TraitWithDelegatedWithImpl(f: TraitWithImpl): TraitWithImpl by f
|
||||
|
||||
@@ -556,6 +556,18 @@ public class JetFindUsagesTestGenerated extends AbstractJetFindUsagesTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinTraitImplThroughDelegate.0.kt")
|
||||
public void testKotlinTraitImplThroughDelegate() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/findUsages/kotlin/findFunctionUsages/kotlinTraitImplThroughDelegate.0.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinTraitNoImplThroughDelegate.0.kt")
|
||||
public void testKotlinTraitNoImplThroughDelegate() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/findUsages/kotlin/findFunctionUsages/kotlinTraitNoImplThroughDelegate.0.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("synthesizedFunction.0.kt")
|
||||
public void testSynthesizedFunction() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/findUsages/kotlin/findFunctionUsages/synthesizedFunction.0.kt");
|
||||
|
||||
@@ -60,6 +60,18 @@ public class ReferenceResolveInJavaTestGenerated extends AbstractReferenceResolv
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DelegatedMethodFromTraitNoImpl.java")
|
||||
public void testDelegatedMethodFromTraitNoImpl() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/referenceInJava/DelegatedMethodFromTraitNoImpl.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DelegatedMethodFromTraitWithImpl.java")
|
||||
public void testDelegatedMethodFromTraitWithImpl() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/referenceInJava/DelegatedMethodFromTraitWithImpl.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DeprecatedClassObjectField.java")
|
||||
public void testDeprecatedClassObjectField() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/referenceInJava/DeprecatedClassObjectField.java");
|
||||
|
||||
Reference in New Issue
Block a user