### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java,v retrieving revision 1.95 diff -u -r1.95 JavaSearchBugsTests.java --- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 17 Nov 2006 12:17:35 -0000 1.95 +++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 6 Dec 2006 17:59:36 -0000 @@ -160,6 +160,7 @@ addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b123679.jar", false); addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b140156.jar", false); addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b164791.jar", false); + addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b166348.jar", false); } public void tearDownSuite() throws Exception { deleteProject("JavaSearchBugs"); @@ -7762,4 +7763,23 @@ collector ); } + +/** + * @bug 166348: [search] Stack trace console resolves wrong source + * @test Ensure that only type with same qualification is found in class files + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=166348" + */ +public void testBug166348() throws CoreException { + search("Test166348", TYPE, DECLARATIONS); + assertSearchResults( + "lib/b166348.jar pack.Test166348 [No source] EXACT_MATCH\n" + + "lib/b166348.jar test.Test166348 [No source] EXACT_MATCH" + ); +} +public void testBug166348_Qualified() throws CoreException { + search("test.Test166348", TYPE, DECLARATIONS); + assertSearchResults( + "lib/b166348.jar test.Test166348 [No source] EXACT_MATCH" + ); +} } \ No newline at end of file #P org.eclipse.jdt.core Index: search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java,v retrieving revision 1.29 diff -u -r1.29 ClassFileMatchLocator.java --- search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java 7 Sep 2006 12:59:26 -0000 1.29 +++ search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java 6 Dec 2006 17:59:38 -0000 @@ -241,11 +241,13 @@ IBinaryType type = (IBinaryType) binaryInfo; char[] fullyQualifiedTypeName = convertClassFileFormat(type.getName()); - if (pattern.enclosingTypeNames == null || pattern instanceof QualifiedTypeDeclarationPattern) { + boolean qualifiedPattern = pattern instanceof QualifiedTypeDeclarationPattern; + if (pattern.enclosingTypeNames == null || qualifiedPattern) { char[] simpleName = (pattern.getMatchMode() == SearchPattern.R_PREFIX_MATCH) ? CharOperation.concat(pattern.simpleName, IIndexConstants.ONE_STAR) : pattern.simpleName; - if (!checkTypeName(simpleName, pattern.pkg, fullyQualifiedTypeName, pattern.isCaseSensitive(), pattern.isCamelCase())) return false; + char[] pkg = qualifiedPattern ? ((QualifiedTypeDeclarationPattern)pattern).qualification : pattern.pkg; + if (!checkTypeName(simpleName, pkg, fullyQualifiedTypeName, pattern.isCaseSensitive(), pattern.isCamelCase())) return false; } else { char[] enclosingTypeName = CharOperation.concatWith(pattern.enclosingTypeNames, '.'); char[] patternString = pattern.pkg == null