diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiTypeElementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiTypeElementImpl.java index fc44c7b0cfc9..d90fdbb6b321 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiTypeElementImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiTypeElementImpl.java @@ -163,6 +163,11 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl if (iteratedValue != null) { return JavaGenericsUtil.getCollectionItemType(iteratedValue); } + return null; + } + + if (declarationScope instanceof PsiLambdaExpression) { + return ((PsiParameter)parent).getType(); } } else { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting11/GotoDeclarationOnLambdaVarParameter.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting11/GotoDeclarationOnLambdaVarParameter.java new file mode 100644 index 000000000000..c67ba83cdccb --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting11/GotoDeclarationOnLambdaVarParameter.java @@ -0,0 +1,7 @@ +import java.util.function.Function; + +class Main { + public static void main(String[] args) { + Function f = (final var a) -> a; + } +} diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/LightAdvHighlightingJdk11Test.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/LightAdvHighlightingJdk11Test.java new file mode 100644 index 000000000000..8752d5f2f725 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/LightAdvHighlightingJdk11Test.java @@ -0,0 +1,39 @@ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package com.intellij.java.codeInsight.daemon; + +import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; +import com.intellij.codeInsight.navigation.actions.GotoDeclarationAction; +import com.intellij.openapi.projectRoots.JavaSdkVersion; +import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.pom.java.LanguageLevel; +import com.intellij.psi.CommonClassNames; +import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiElement; +import com.intellij.testFramework.IdeaTestUtil; + +public class LightAdvHighlightingJdk11Test extends LightDaemonAnalyzerTestCase { + private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/advHighlighting11"; + + @Override + protected void setUp() throws Exception { + super.setUp(); + setLanguageLevel(LanguageLevel.JDK_X); + IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_10, getModule(), getTestRootDisposable());//todo + } + + public void testGotoDeclarationOnLambdaVarParameter() { + configureByFile(BASE_PATH + "/" + getTestName(false) + ".java"); + final int offset = getEditor().getCaretModel().getOffset(); + final PsiElement[] elements = + GotoDeclarationAction.findAllTargetElements(getProject(), getEditor(), offset); + assertSize(1, elements); + PsiElement element = elements[0]; + assertInstanceOf(element, PsiClass.class); + assertEquals(CommonClassNames.JAVA_LANG_STRING, ((PsiClass)element).getQualifiedName()); + } + + @Override + protected Sdk getProjectJDK() { + return IdeaTestUtil.getMockJdk9(); + } +} \ No newline at end of file