View | Details | Raw Unified | Return to bug 329727 | Differences between
and this patch

Collapse All | Expand All

(-)search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java (-6 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 269-279 Link Here
269
		if (matchBinary(pattern, method, info)) {
269
		if (matchBinary(pattern, method, info)) {
270
			char[] name;
270
			char[] name;
271
			if (method.isConstructor()) {
271
			if (method.isConstructor()) {
272
				name = info.getName();
272
				// https://bugs.eclipse.org/bugs/show_bug.cgi?id=329727
273
				int lastSlash = CharOperation.lastIndexOf('/', name);
273
				// We don't need the enclosing type name for the constructor name
274
				if (lastSlash != -1) {
274
				name = info.getSourceName();
275
					name = CharOperation.subarray(name, lastSlash+1, name.length);
276
				}
277
			} else {
275
			} else {
278
				name = method.getSelector();
276
				name = method.getSelector();
279
			}
277
			}
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (+55 lines)
Lines 12337-12340 Link Here
12337
		"src/b324109/X.java void b324109.X.run() [run] POTENTIAL_MATCH"
12337
		"src/b324109/X.java void b324109.X.run() [run] POTENTIAL_MATCH"
12338
	);
12338
	);
12339
}
12339
}
12340
/**
12341
 * @bug 329727 Invalid check in the isConstructor() method of the IMethod implementation.
12342
 * @test check that in a binary type, method's name doesn't contain the enclosing type name and
12343
 * that IMethod#isContructor returns correct value 
12344
 * 
12345
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=329727"
12346
 * @throws CoreException
12347
 * @throws IOException
12348
 */
12349
public void testBug329727() throws CoreException, IOException {
12350
	IJavaProject project = getJavaProject("JavaSearchBugs");
12351
	IClasspathEntry[] originalCP = project.getRawClasspath();
12352
		try {
12353
			int cpLength = originalCP.length;
12354
			IClasspathEntry[] newCP = new IClasspathEntry[cpLength + 1];
12355
			System.arraycopy(originalCP, 0, newCP, 0, cpLength);
12356
			createLibrary(project, "bug329727.jar", null, new String[] {
12357
					"p/OuterClass.java",
12358
					"package p;\n" + "public class OuterClass {\n"
12359
							+ "	public OuterClass(){}\n"
12360
							+ "	class InnerClass {\n"
12361
							+ "		public InnerClass(){}\n" + "	}\n" + "}\n" },
12362
					new String[0], JavaCore.VERSION_1_4);
12363
			newCP[cpLength] = JavaCore.newLibraryEntry(
12364
						new Path("/JavaSearchBugs/bug329727.jar"), null, null);
12365
			project.setRawClasspath(newCP, null);
12366
12367
			final String txtPattern = "InnerClas*";
12368
			SearchPattern pattern = SearchPattern.createPattern(txtPattern,
12369
					IJavaSearchConstants.CONSTRUCTOR,
12370
					IJavaSearchConstants.DECLARATIONS,
12371
					SearchPattern.R_CASE_SENSITIVE
12372
							| SearchPattern.R_PATTERN_MATCH);
12373
12374
			SearchParticipant[] participants = new SearchParticipant[1];
12375
			participants[0] = SearchEngine.getDefaultSearchParticipant();
12376
12377
			SearchRequestor requestor = new SearchRequestor() {
12378
				public void acceptSearchMatch(SearchMatch match)
12379
						throws CoreException {
12380
					assertTrue("Incorrect Element", match.getElement() instanceof IMethod);
12381
					assertTrue("Must be a constructor", ((IMethod) match.getElement()).isConstructor());
12382
					assertEquals("Incorrect Constructor name", "InnerClass", ((IMethod)match.getElement()).getElementName()); 
12383
				}
12384
			};
12385
12386
			SearchEngine engine = new SearchEngine();
12387
			IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
12388
			engine.search(pattern, participants, scope, requestor, null);
12389
    }
12390
    finally{
12391
		project.setRawClasspath(originalCP, null);
12392
    	deleteFile("/JavaSearchBugs/bug329727.jar");
12393
    }
12394
}
12340
}
12395
}

Return to bug 329727