From d2f23581a2f7bb8dd52f590e0f07abaa4452aaef Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 8 Jul 2016 16:15:31 +0300 Subject: [PATCH] IDEA-158241 Find Usages fails to find usages --- .../psi/impl/FindSuperElementsHelper.java | 4 ++-- .../SiblingInheritanceAndGenerics.after.java | 18 ++++++++++++++++++ .../SiblingInheritanceAndGenerics.java | 18 ++++++++++++++++++ .../daemon/impl/JavaGotoSuperTest.java | 10 ++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/gotosuper/SiblingInheritanceAndGenerics.after.java create mode 100644 java/java-tests/testData/codeInsight/gotosuper/SiblingInheritanceAndGenerics.java diff --git a/java/java-analysis-impl/src/com/intellij/psi/impl/FindSuperElementsHelper.java b/java/java-analysis-impl/src/com/intellij/psi/impl/FindSuperElementsHelper.java index aabcce64630c..871c816acda3 100644 --- a/java/java-analysis-impl/src/com/intellij/psi/impl/FindSuperElementsHelper.java +++ b/java/java-analysis-impl/src/com/intellij/psi/impl/FindSuperElementsHelper.java @@ -174,9 +174,9 @@ public class FindSuperElementsHelper { // calculate substitutor of containingClass --> inheritor PsiSubstitutor substitutor = TypeConversionUtil.getSuperClassSubstitutor(myContainingClass, inheritor, PsiSubstitutor.EMPTY); // calculate substitutor of inheritor --> superInterface - substitutor = TypeConversionUtil.getSuperClassSubstitutor(superInterface, inheritor, substitutor); + PsiSubstitutor superInterfaceSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(superInterface, inheritor, substitutor); - return MethodSignatureUtil.isSubsignature(superMethod.getSignature(substitutor), method.getSignature(PsiSubstitutor.EMPTY)); + return MethodSignatureUtil.isSubsignature(superMethod.getSignature(superInterfaceSubstitutor), method.getSignature(substitutor)); } Map getResult() { diff --git a/java/java-tests/testData/codeInsight/gotosuper/SiblingInheritanceAndGenerics.after.java b/java/java-tests/testData/codeInsight/gotosuper/SiblingInheritanceAndGenerics.after.java new file mode 100644 index 000000000000..5cb44b445d07 --- /dev/null +++ b/java/java-tests/testData/codeInsight/gotosuper/SiblingInheritanceAndGenerics.after.java @@ -0,0 +1,18 @@ +package x; + +class Data { +} + +abstract class Abstract { + public String foo(T data) { + return "foo"; + } +} + +interface Interface { + public String foo(T data); +} + +class Implementation extends Abstract implements Interface { + +} diff --git a/java/java-tests/testData/codeInsight/gotosuper/SiblingInheritanceAndGenerics.java b/java/java-tests/testData/codeInsight/gotosuper/SiblingInheritanceAndGenerics.java new file mode 100644 index 000000000000..adee5ecd2202 --- /dev/null +++ b/java/java-tests/testData/codeInsight/gotosuper/SiblingInheritanceAndGenerics.java @@ -0,0 +1,18 @@ +package x; + +class Data { +} + +abstract class Abstract { + public String foo(T data) { + return "foo"; + } +} + +interface Interface { + public String foo(T data); +} + +class Implementation extends Abstract implements Interface { + +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/JavaGotoSuperTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/JavaGotoSuperTest.java index 93cf74193d38..cd5212eb9179 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/JavaGotoSuperTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/JavaGotoSuperTest.java @@ -115,6 +115,16 @@ public class JavaGotoSuperTest extends LightDaemonAnalyzerTestCase { checkResultByFile(getBasePath() + "SiblingInheritance.java"); } + public void testSiblingInheritanceAndGenerics() throws Throwable { + configureByFile(getBasePath() + "SiblingInheritanceAndGenerics.java"); + AnAction action = ActionManager.getInstance().getAction(IdeActions.ACTION_GOTO_SUPER); + AnActionEvent event = AnActionEvent.createFromAnAction(action, null, "", DataManager.getInstance().getDataContextFromFocus().getResultSync()); + action.update(event); + assertTrue(event.getPresentation().isEnabledAndVisible()); + action.actionPerformed(event); + checkResultByFile(getBasePath() + "SiblingInheritanceAndGenerics.after.java"); + } + public void testDoNotShowSiblingInheritanceLineMarkerIfSubclassImplementsTheSameInterfaceAsTheCurrentClass() throws Throwable { configureByFile(getBasePath() + "DeceivingSiblingInheritance.java"); PsiJavaFile file = (PsiJavaFile)getFile();