Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2017-08-30 01:52:32 +0000
committerManoj Palat2017-08-30 01:52:32 +0000
commit0a908cd3dc3279066d94660987f6e5450b72486e (patch)
tree8b644d6327e795d42cf1082a409a413ca16ddfdc
parente1b14cfdbdad346fc8227bd09a1a2522ddd00ff8 (diff)
downloadeclipse.jdt.core-0a908cd3dc3279066d94660987f6e5450b72486e.tar.gz
eclipse.jdt.core-0a908cd3dc3279066d94660987f6e5450b72486e.tar.xz
eclipse.jdt.core-0a908cd3dc3279066d94660987f6e5450b72486e.zip
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java36
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java12
2 files changed, 45 insertions, 3 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java
index 98a256ddb4..fe79f9f504 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15102,4 +15102,38 @@ public void testBug483650_010() throws Exception {
assertTrue("Unexpected Method Name", expectedName.equals(name));
assertTrue("IJavaElement Does not exist", method.exists());
}
+public void testBug521240_001() throws CoreException {
+ this.workingCopies = new ICompilationUnit[3];
+ WorkingCopyOwner owner = new WorkingCopyOwner() {};
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/pack1/X.java",
+ "package pack1;\n" +
+ "public class X {\n" +
+ " void foo(Y s) {}\n" +
+ " void foo(pack2.Y s) {}\n" +
+ "}\n",
+ owner
+ );
+ this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/pack1/Y.java",
+ "package pack1;\n" +
+ "public class Y{}\n",
+ owner
+ );
+ this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/pack2/Y.java",
+ "package pack2;\n" +
+ "public class Y{}\n",
+ owner
+ );
+ SearchPattern pattern = SearchPattern.createPattern("pack1.X.foo(pack1.Y)",METHOD, DECLARATIONS,
+ SearchPattern.R_ERASURE_MATCH | SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE);
+
+ new SearchEngine(this.workingCopies).search(pattern,
+ new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
+ getJavaSearchWorkingCopiesScope(),
+ this.resultCollector,
+ null);
+ assertSearchResults(
+ "src/pack1/X.java void pack1.X.foo(Y) [foo] EXACT_MATCH"
+ );
+}
+
} \ No newline at end of file
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java
index 99e193f568..3d4d143738 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -1105,6 +1105,13 @@ private MethodBinding getMethodBinding0(MethodPattern methodPattern) {
this.bindings.put(methodPattern, result != null ? result : new ProblemMethodBinding(methodPattern.selector, null, ProblemReasons.NotFound));
return result;
}
+private boolean matchParams(MethodPattern methodPattern, int index, TypeBinding binding) {
+ char[] qualifier = CharOperation.concat(methodPattern.parameterQualifications[index], methodPattern.parameterSimpleNames[index], '.');
+ int offset = (qualifier.length > 0 && qualifier[0] == '*') ? 1 : 0;
+ String s1 = new String(qualifier, offset, qualifier.length - offset);
+ char[] s2 = CharOperation.concat(binding.qualifiedPackageName(), binding.qualifiedSourceName(), '.');
+ return new String(s2).endsWith(s1);
+}
private MethodBinding getMethodBinding(MethodPattern methodPattern, TypeBinding declaringTypeBinding) {
MethodBinding result;
@@ -1125,7 +1132,8 @@ private MethodBinding getMethodBinding(MethodPattern methodPattern, TypeBinding
boolean found = false;
if (methodParameters != null && paramLength == paramTypeslength) {
for (int p=0; p<paramLength; p++) {
- if (CharOperation.equals(methodParameters[p].sourceName(), parameterTypes[p])) {
+ TypeBinding parameter = methodParameters[p];
+ if (matchParams(methodPattern, p, parameter)) {
// param erasure match
found = true;
} else {

Back to the top