Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorssankaran2014-03-06 13:55:17 +0000
committerssankaran2014-03-06 13:55:17 +0000
commitc2d0f99b1b05ac2833cefa5e25e72d4b3b457443 (patch)
treebccbdd8136afd17f46b8481f7816ff298848a2a8
parentbd6ca77171fabf4da2f366e7f152e0ef38feca91 (diff)
downloadeclipse.jdt.core-c2d0f99b1b05ac2833cefa5e25e72d4b3b457443.tar.gz
eclipse.jdt.core-c2d0f99b1b05ac2833cefa5e25e72d4b3b457443.tar.xz
eclipse.jdt.core-c2d0f99b1b05ac2833cefa5e25e72d4b3b457443.zip
Fixed Bug 429738 - [1.8][search] Find Declarations (Ctrl + G) shows no
result for type-less lambda parameter
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs8Tests.java53
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java5
2 files changed, 58 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs8Tests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs8Tests.java
index bf7ae4d07a..7ff061bee2 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs8Tests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs8Tests.java
@@ -26,6 +26,7 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.ILocalVariable;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
@@ -3504,6 +3505,58 @@ public void testBug400905_0030() throws CoreException {
search(this.workingCopies[0].getType("Y").getType("Z").getMethod("goo", new String[] { "I" }), IMPLICIT_THIS_REFERENCE);
assertSearchResults("");
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=429738, [1.8][search] Find Declarations (Ctrl + G) shows no result for type-less lambda parameter
+public void test429738() throws CoreException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b400905/X.java",
+ "@FunctionalInterface\n" +
+ "interface Foo {\n" +
+ " int foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " // Select 'x' in lambda body and press Ctrl+G.\n" +
+ " Foo f1= x -> /* here*/ x; //[1]\n" +
+ " Foo f2= (int x) -> x; //[2]\n" +
+ "}\n"
+ );
+
+ String str = this.workingCopies[0].getSource();
+ String selection = "/* here*/ x";
+ int start = str.indexOf(selection);
+ int length = selection.length();
+
+ IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length);
+ ILocalVariable local = (ILocalVariable) elements[0];
+ search(local, DECLARATIONS, EXACT_RULE);
+ assertSearchResults(
+ "src/b400905/X.java int b400905.X.f1:Lambda(Foo).foo(int).x [x] EXACT_MATCH");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=429738, [1.8][search] Find Declarations (Ctrl + G) shows no result for type-less lambda parameter
+public void test429738a() throws CoreException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b400905/X.java",
+ "@FunctionalInterface\n" +
+ "interface Foo {\n" +
+ " int foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " // Select 'x' in lambda body and press Ctrl+G.\n" +
+ " Foo f1= x -> x; //[1]\n" +
+ " Foo f2= (int x) -> /* here*/ x; //[2]\n" +
+ "}\n"
+ );
+
+ String str = this.workingCopies[0].getSource();
+ String selection = "/* here*/ x";
+ int start = str.indexOf(selection);
+ int length = selection.length();
+
+ IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length);
+ ILocalVariable local = (ILocalVariable) elements[0];
+ search(local, DECLARATIONS, EXACT_RULE);
+ assertSearchResults(
+ "src/b400905/X.java int b400905.X.f1:Lambda(Foo).foo(int).x [x] EXACT_MATCH");
+}
// Add new tests in JavaSearchBugs8Tests
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java
index 0cacc7b40a..722f7d7950 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java
@@ -665,6 +665,11 @@ protected void consumeTypeArguments() {
}
}
+protected void consumeTypeElidedLambdaParameter(boolean parenthesized) {
+ super.consumeTypeElidedLambdaParameter(parenthesized);
+ this.patternLocator.match((LocalDeclaration) this.astStack[this.astPtr], this.nodeSet);
+}
+
protected void consumeTypeParameter1WithExtends() {
super.consumeTypeParameter1WithExtends();
if ((this.patternFineGrain & IJavaSearchConstants.TYPE_VARIABLE_BOUND_TYPE_REFERENCE) != 0) {

Back to the top