### Eclipse Workspace Patch 1.0 #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.43 diff -u -r1.43 ClassFileMatchLocator.java --- search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java 18 Sep 2008 15:24:57 -0000 1.43 +++ search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java 18 Nov 2010 06:43:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 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 @@ -269,11 +269,9 @@ if (matchBinary(pattern, method, info)) { char[] name; if (method.isConstructor()) { - name = info.getName(); - int lastSlash = CharOperation.lastIndexOf('/', name); - if (lastSlash != -1) { - name = CharOperation.subarray(name, lastSlash+1, name.length); - } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=329727 + // We don't need the enclosing type name for the constructor name + name = info.getSourceName(); } else { name = method.getSelector(); } #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.207 diff -u -r1.207 JavaSearchBugsTests.java --- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 6 Oct 2010 17:32:30 -0000 1.207 +++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 18 Nov 2010 06:43:20 -0000 @@ -12337,4 +12337,59 @@ "src/b324109/X.java void b324109.X.run() [run] POTENTIAL_MATCH" ); } +/** + * @bug 329727 Invalid check in the isConstructor() method of the IMethod implementation. + * @test check that in a binary type, method's name doesn't contain the enclosing type name and + * that IMethod#isContructor returns correct value + * + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=329727" + * @throws CoreException + * @throws IOException + */ +public void testBug329727() throws CoreException, IOException { + IJavaProject project = getJavaProject("JavaSearchBugs"); + IClasspathEntry[] originalCP = project.getRawClasspath(); + try { + int cpLength = originalCP.length; + IClasspathEntry[] newCP = new IClasspathEntry[cpLength + 1]; + System.arraycopy(originalCP, 0, newCP, 0, cpLength); + createLibrary(project, "bug329727.jar", null, new String[] { + "p/OuterClass.java", + "package p;\n" + "public class OuterClass {\n" + + " public OuterClass(){}\n" + + " class InnerClass {\n" + + " public InnerClass(){}\n" + " }\n" + "}\n" }, + new String[0], JavaCore.VERSION_1_4); + newCP[cpLength] = JavaCore.newLibraryEntry( + new Path("/JavaSearchBugs/bug329727.jar"), null, null); + project.setRawClasspath(newCP, null); + + final String txtPattern = "InnerClas*"; + SearchPattern pattern = SearchPattern.createPattern(txtPattern, + IJavaSearchConstants.CONSTRUCTOR, + IJavaSearchConstants.DECLARATIONS, + SearchPattern.R_CASE_SENSITIVE + | SearchPattern.R_PATTERN_MATCH); + + SearchParticipant[] participants = new SearchParticipant[1]; + participants[0] = SearchEngine.getDefaultSearchParticipant(); + + SearchRequestor requestor = new SearchRequestor() { + public void acceptSearchMatch(SearchMatch match) + throws CoreException { + assertTrue("Incorrect Element", match.getElement() instanceof IMethod); + assertTrue("Must be a constructor", ((IMethod) match.getElement()).isConstructor()); + assertEquals("Incorrect Constructor name", "InnerClass", ((IMethod)match.getElement()).getElementName()); + } + }; + + SearchEngine engine = new SearchEngine(); + IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); + engine.search(pattern, participants, scope, requestor, null); + } + finally{ + project.setRawClasspath(originalCP, null); + deleteFile("/JavaSearchBugs/bug329727.jar"); + } +} } \ No newline at end of file