From 25d5c187d75910a361f8a1386beedcf0fcdd0bb9 Mon Sep 17 00:00:00 2001 From: "Anna.Kozlova" Date: Mon, 21 Nov 2016 16:26:17 +0100 Subject: [PATCH] goto implementation: when no implementations are possible (e.g. static method), include self into presentation --- .../navigation/GotoImplementationHandlerTest.java | 12 ++++++++++++ .../navigation/ImplementationSearcher.java | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/java/java-tests/testSrc/com/intellij/navigation/GotoImplementationHandlerTest.java b/java/java-tests/testSrc/com/intellij/navigation/GotoImplementationHandlerTest.java index a0851b20f261..ba1257d4d8e0 100644 --- a/java/java-tests/testSrc/com/intellij/navigation/GotoImplementationHandlerTest.java +++ b/java/java-tests/testSrc/com/intellij/navigation/GotoImplementationHandlerTest.java @@ -249,6 +249,18 @@ public class GotoImplementationHandlerTest extends JavaCodeInsightFixtureTestCas assertEquals("A", aClass.getName()); } + public void testStaticMethodReference() { + PsiFile file = myFixture.addFileToProject("Foo.java", + "class C {\n" + + " static void a(){}\n" + + " {a();}" + + "}"); + myFixture.configureFromExistingVirtualFile(file.getVirtualFile()); + + final PsiElement[] impls = getTargets(file); + assertEquals(1, impls.length); + } + private PsiElement[] getTargets(PsiFile file) { GotoTargetHandler.GotoData gotoData = CodeInsightTestUtil.gotoImplementation(myFixture.getEditor(), file); assertNotNull(gotoData); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/ImplementationSearcher.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/ImplementationSearcher.java index 3bafb52b20a2..201d42fd44e3 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/ImplementationSearcher.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/ImplementationSearcher.java @@ -149,7 +149,7 @@ public class ImplementationSearcher { return null; } PsiElement foundElement = result[0]; - return foundElement != null ? new PsiElement[] {foundElement} : null; + return foundElement != null ? new PsiElement[] {foundElement} : PsiElement.EMPTY_ARRAY; } protected boolean canShowPopupWithOneItem(PsiElement element) {