Create SyntheticMemberDescriptor interface

Implement this interface by sam adapters/constructors and use it in navigation

 #KT-11708 Fixed
This commit is contained in:
Pavel V. Talanov
2016-06-20 18:16:51 +03:00
parent 4087e650aa
commit bafe8e55ce
15 changed files with 106 additions and 48 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -305,7 +305,7 @@ class LookupElementFactory(
return callableWeight(descriptor.getMethod)
}
if (descriptor is SamAdapterExtensionFunctionDescriptor) {
return callableWeight(descriptor.sourceFunction)
return callableWeight(descriptor.baseDescriptorForSynthetic)
}
if (descriptor.overriddenDescriptors.isNotEmpty()) {
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -288,7 +288,7 @@ class KotlinIndicesHelper(
// SAM-adapter
container.staticScope.getContributedFunctions(descriptor.name, NoLookupLocation.FROM_IDE)
.filterIsInstance<SamAdapterDescriptor<*>>()
.firstOrNull { it.originForSam.original == descriptor.original }
.firstOrNull { it.baseDescriptorForSynthetic.original == descriptor.original }
?.let { processor(it) }
}
}
@@ -0,0 +1,13 @@
package test
class MyClass: Test() {
}
fun test(m: MyClass) {
m.ac<caret>t {
}
}
// REF: (in test.Test).act(Action)
@@ -0,0 +1,10 @@
package test;
public class Test {
public interface Action {
String doSmth(String other);
}
void act(Action action) {
}
}
@@ -77,6 +77,12 @@ public class ReferenceResolveWithLibTestGenerated extends AbstractReferenceResol
doTest(fileName);
}
@TestMetadata("overridingFunctionWithSamAdapter.kt")
public void testOverridingFunctionWithSamAdapter() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/resolve/referenceWithLib/overridingFunctionWithSamAdapter.kt");
doTest(fileName);
}
@TestMetadata("packageOfLibDeclaration.kt")
public void testPackageOfLibDeclaration() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/resolve/referenceWithLib/packageOfLibDeclaration.kt");