diff options
author | Manoj Palat | 2017-08-30 01:52:32 +0000 |
---|---|---|
committer | Manoj Palat | 2017-08-30 01:52:32 +0000 |
commit | 0a908cd3dc3279066d94660987f6e5450b72486e (patch) | |
tree | 8b644d6327e795d42cf1082a409a413ca16ddfdc | |
parent | e1b14cfdbdad346fc8227bd09a1a2522ddd00ff8 (diff) | |
download | eclipse.jdt.core-0a908cd3dc3279066d94660987f6e5450b72486e.tar.gz eclipse.jdt.core-0a908cd3dc3279066d94660987f6e5450b72486e.tar.xz eclipse.jdt.core-0a908cd3dc3279066d94660987f6e5450b72486e.zip |
Fix for Bug 521240: Search ignores the qualifier of the parameter typeS4_8_0_M2I20170925-2000I20170924-2000I20170923-1500I20170922-2000I20170921-2000I20170920-2000I20170920-0100I20170919-2000I20170918-2000I20170917-2000I20170916-1500I20170915-2000I20170915-1030I20170913-2000I20170913-1120I20170913-0800I20170913-0420I20170913-0220I20170912-2255I20170912-2000I20170912-0800I20170911-2000I20170911-0800I20170911-0405I20170910-2000I20170910-1055I20170910-0800I20170909-1500I20170909-0920I20170909-0800I20170909-0510I20170908-2345I20170908-2000I20170908-0035I20170907-2000I20170906-2000I20170906-0815I20170906-0225I20170905-2000I20170905-0600I20170905-0310I20170904-2000I20170904-0230I20170903-2000I20170902-1500I20170901-2000I20170831-2000I20170830-2000I20170830-0605
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 { |