diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests18.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests18.java index 068ce664005..385d4bd1927 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests18.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests18.java @@ -3166,7 +3166,7 @@ public static void main(String[] args) { parser.setStatementsRecovery(true); CompilationUnit dom = (CompilationUnit)parser.createAST(null); Name variable = (Name)new NodeFinder(dom, start, length).getCoveredNode(); - IJavaElement javaElement = variable.resolveBinding().getJavaElement(); + IJavaElement javaElement = variable.resolveBinding().getJavaElement(); assertElementsEqual( "Unexpected elements", @@ -3174,4 +3174,37 @@ public static void main(String[] args) { new IJavaElement[] { javaElement } ); } +public void testGH2571() throws JavaModelException { + String contents = """ + package org.eclipse; + + import java.util.function.Predicate; + import java.util.function.Supplier; + + public class PopupKiller { + + public final Supplier> predicateSupplier = () -> new Predicate() { + + @SuppressWarnings("unused") + public static boolean THIS_VARIABLE_KILLS_JAVADOC_POPUPS_AND_F3 = true; + + @Override + public boolean test(final String record) { + System.out.println("<-- try to Mouseover System.out.: nothing!"); + return true; + } + }; + } + """; + this.wc = getWorkingCopy("/Resolve/src/org/eclipse/PopupKiller.java", contents); + String selectionIdentifier = "out"; + int start = contents.indexOf(selectionIdentifier); + + IJavaElement[] elements = this.wc.codeSelect(start, selectionIdentifier.length()); + assertElementsEqual( + "Unexpected elements", + "out [in System [in System.class [in java.lang [in /home/eclipse/jdt-master/jclFull1.8.jar]]]]", + elements + ); +} } diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java index 194c44f7722..312056cf4d1 100644 --- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java +++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java @@ -567,6 +567,8 @@ protected boolean triggerRecoveryUponLambdaClosure(Statement statement, boolean statementEnd = statement.sourceEnd; } for (int i = this.elementPtr; i >= 0; --i) { + if (this.elementKindStack[i] == K_TYPE_DELIMITER) + break; if (this.elementKindStack[i] != K_LAMBDA_EXPRESSION_DELIMITER) continue; LambdaExpression expression = (LambdaExpression) this.elementObjectInfoStack[i];