Navigation to implementation / overriding method: do not show method of inline class twice
#KT-28661 Fixed #KT-26924 Fixed
This commit is contained in:
committed by
Nikolay Krasko
parent
aa9ce7b2e9
commit
80e1fc2ace
+1
-1
@@ -174,7 +174,7 @@ fun PsiMethod.forEachOverridingMethod(
|
|||||||
val ktMember = this.unwrapped as? KtNamedDeclaration ?: return true
|
val ktMember = this.unwrapped as? KtNamedDeclaration ?: return true
|
||||||
val ktClass = runReadAction { ktMember.containingClassOrObject as? KtClass } ?: return true
|
val ktClass = runReadAction { ktMember.containingClassOrObject as? KtClass } ?: return true
|
||||||
return forEachKotlinOverride(ktClass, listOf(ktMember), scope) { _, overrider ->
|
return forEachKotlinOverride(ktClass, listOf(ktMember), scope) { _, overrider ->
|
||||||
val lightMethods = runReadAction { overrider.toPossiblyFakeLightMethods() }
|
val lightMethods = runReadAction { overrider.toPossiblyFakeLightMethods().distinctBy { it.unwrapped } }
|
||||||
lightMethods.all { processor(it) }
|
lightMethods.all { processor(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
interface I {
|
||||||
|
fun <caret>x()
|
||||||
|
}
|
||||||
|
|
||||||
|
inline class Foo(val value: Int) : I {
|
||||||
|
override fun x() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// REF: (in Foo).x()
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
interface I {
|
||||||
|
fun <caret>x() = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
inline class Foo(val value: Int) : I {
|
||||||
|
override fun x() = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
// REF: (in Foo).x()
|
||||||
Vendored
+1
@@ -8,6 +8,7 @@ class ExpectedChildChild : ExpectedChild()
|
|||||||
|
|
||||||
class SimpleChild : SimpleParent()
|
class SimpleChild : SimpleParent()
|
||||||
|
|
||||||
|
// DISTINCT_REF
|
||||||
// REF: [testModule_Common] (test).ExpectedChild
|
// REF: [testModule_Common] (test).ExpectedChild
|
||||||
// REF: [testModule_Common] (test).ExpectedChildChild
|
// REF: [testModule_Common] (test).ExpectedChildChild
|
||||||
// REF: [testModule_Common] (test).SimpleChild
|
// REF: [testModule_Common] (test).SimpleChild
|
||||||
|
|||||||
Vendored
+1
@@ -16,6 +16,7 @@ class SimpleChild : SimpleParent() {
|
|||||||
override val bar: Int get() = 1
|
override val bar: Int get() = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DISTINCT_REF
|
||||||
// REF: [testModule_Common] (in test.ExpectedChild).bar
|
// REF: [testModule_Common] (in test.ExpectedChild).bar
|
||||||
// REF: [testModule_Common] (in test.ExpectedChildChild).bar
|
// REF: [testModule_Common] (in test.ExpectedChildChild).bar
|
||||||
// REF: [testModule_Common] (in test.SimpleChild).bar
|
// REF: [testModule_Common] (in test.SimpleChild).bar
|
||||||
|
|||||||
Generated
+10
@@ -104,6 +104,11 @@ public class KotlinGotoImplementationTestGenerated extends AbstractKotlinGotoImp
|
|||||||
runTest("idea/testData/navigation/implementations/ImplementGenericWithPrimitives.kt");
|
runTest("idea/testData/navigation/implementations/ImplementGenericWithPrimitives.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ImplementsInInlineClass.kt")
|
||||||
|
public void testImplementsInInlineClass() throws Exception {
|
||||||
|
runTest("idea/testData/navigation/implementations/ImplementsInInlineClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("ObjectImported.kt")
|
@TestMetadata("ObjectImported.kt")
|
||||||
public void testObjectImported() throws Exception {
|
public void testObjectImported() throws Exception {
|
||||||
runTest("idea/testData/navigation/implementations/ObjectImported.kt");
|
runTest("idea/testData/navigation/implementations/ObjectImported.kt");
|
||||||
@@ -114,6 +119,11 @@ public class KotlinGotoImplementationTestGenerated extends AbstractKotlinGotoImp
|
|||||||
runTest("idea/testData/navigation/implementations/OverridesInEnumEntries.kt");
|
runTest("idea/testData/navigation/implementations/OverridesInEnumEntries.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("OverridesInInlineClass.kt")
|
||||||
|
public void testOverridesInInlineClass() throws Exception {
|
||||||
|
runTest("idea/testData/navigation/implementations/OverridesInInlineClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("PropertyOverriddenNavigation.kt")
|
@TestMetadata("PropertyOverriddenNavigation.kt")
|
||||||
public void testPropertyOverriddenNavigation() throws Exception {
|
public void testPropertyOverriddenNavigation() throws Exception {
|
||||||
runTest("idea/testData/navigation/implementations/PropertyOverriddenNavigation.kt");
|
runTest("idea/testData/navigation/implementations/PropertyOverriddenNavigation.kt");
|
||||||
|
|||||||
@@ -45,8 +45,9 @@ public final class NavigationTestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void assertGotoDataMatching(Editor editor, GotoTargetHandler.GotoData gotoData, boolean renderModule) {
|
public static void assertGotoDataMatching(Editor editor, GotoTargetHandler.GotoData gotoData, boolean renderModule) {
|
||||||
|
String documentText = editor.getDocument().getText();
|
||||||
// Get expected references from the tested document
|
// Get expected references from the tested document
|
||||||
List<String> expectedReferences = InTextDirectivesUtils.findListWithPrefixes(editor.getDocument().getText(), "// REF:");
|
List<String> expectedReferences = InTextDirectivesUtils.findListWithPrefixes(documentText, "// REF:");
|
||||||
for (int i = 0; i < expectedReferences.size(); i++) {
|
for (int i = 0; i < expectedReferences.size(); i++) {
|
||||||
String expectedText = expectedReferences.get(i);
|
String expectedText = expectedReferences.get(i);
|
||||||
expectedText = expectedText.replace("\\n", "\n");
|
expectedText = expectedText.replace("\\n", "\n");
|
||||||
@@ -59,9 +60,14 @@ public final class NavigationTestUtils {
|
|||||||
Collections.sort(expectedReferences);
|
Collections.sort(expectedReferences);
|
||||||
|
|
||||||
if (gotoData != null) {
|
if (gotoData != null) {
|
||||||
List<PsiElement> distinctTargets = ArraysKt.distinctBy(gotoData.targets, element -> LightClassUtilsKt.getUnwrapped(element));
|
List<PsiElement> targets;
|
||||||
|
if (InTextDirectivesUtils.isDirectiveDefined(documentText, "// DISTINCT_REF")) {
|
||||||
|
targets = ArraysKt.distinctBy(gotoData.targets, element -> LightClassUtilsKt.getUnwrapped(element));
|
||||||
|
} else {
|
||||||
|
targets = Arrays.asList(gotoData.targets);
|
||||||
|
}
|
||||||
// Transform given reference result to strings
|
// Transform given reference result to strings
|
||||||
List<String> psiElements = Lists.transform(distinctTargets, new Function<PsiElement, String>() {
|
List<String> psiElements = Lists.transform(targets, new Function<PsiElement, String>() {
|
||||||
@Override
|
@Override
|
||||||
public String apply(@Nullable PsiElement element) {
|
public String apply(@Nullable PsiElement element) {
|
||||||
Assert.assertNotNull(element);
|
Assert.assertNotNull(element);
|
||||||
|
|||||||
Reference in New Issue
Block a user