diff --git a/java/java-impl/src/com/intellij/codeInsight/TargetElementUtil.java b/java/java-impl/src/com/intellij/codeInsight/TargetElementUtil.java index a82877e124d7..826a68e52253 100644 --- a/java/java-impl/src/com/intellij/codeInsight/TargetElementUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/TargetElementUtil.java @@ -99,6 +99,15 @@ public class TargetElementUtil extends TargetElementUtilBase { if (ref instanceof PsiJavaReference) { refElement = ((PsiJavaReference)ref).advancedResolve(true).getElement(); } + else if (ref == null) { + final PsiElement element = file.findElementAt(offset); + if (element != null) { + final PsiElement parent = element.getParent(); + if (parent instanceof PsiFunctionalExpression) { + refElement = PsiUtil.resolveClassInType(((PsiFunctionalExpression)parent).getFunctionalInterfaceType()); + } + } + } } if (refElement != null) { diff --git a/java/java-tests/testSrc/com/intellij/navigation/ShowImplementationHandlerTest.java b/java/java-tests/testSrc/com/intellij/navigation/ShowImplementationHandlerTest.java new file mode 100644 index 000000000000..a657a7fafb86 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/navigation/ShowImplementationHandlerTest.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2014 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.intellij.navigation; + +import com.intellij.codeInsight.TargetElementUtilBase; +import com.intellij.psi.CommonClassNames; +import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase; + +public class ShowImplementationHandlerTest extends JavaCodeInsightFixtureTestCase { + + public void testMultipleImplsFromAbstractCall() throws Throwable { + PsiFile file = myFixture.addFileToProject("Foo.java", "public abstract class Hello {" + + " {" + + " Runnable r = () -> {};\n" + + " }\n" + + "}\n" + + "\n"); + myFixture.configureFromExistingVirtualFile(file.getVirtualFile()); + + final PsiElement element = + TargetElementUtilBase.findTargetElement(myFixture.getEditor(), TargetElementUtilBase.getInstance().getAllAccepted()); + assertTrue(element instanceof PsiClass); + final String qualifiedName = ((PsiClass)element).getQualifiedName(); + assertEquals(CommonClassNames.JAVA_LANG_RUNNABLE, qualifiedName); + } + +} \ No newline at end of file