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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/util/Util.java (+11 lines)
Lines 1788-1793 Link Here
1788
		return binaryTypeName.substring(nameStart, end);
1788
		return binaryTypeName.substring(nameStart, end);
1789
	}
1789
	}
1790
1790
1791
	public static char[] localTypeName(char[] binaryTypeName, int lastDollar, int end) {
1792
		// If local name starts with a dollar sign, don't touch the name
1793
		if(lastDollar > 0 && binaryTypeName[lastDollar-1] == '$') 
1794
			return binaryTypeName;
1795
		
1796
		int nameStart = lastDollar+1;
1797
		while (nameStart < end && Character.isDigit(binaryTypeName[nameStart]))
1798
			nameStart++;
1799
		return CharOperation.subarray(binaryTypeName, nameStart, end);
1800
	}
1801
	
1791
	/*
1802
	/*
1792
	 * Add a log entry
1803
	 * Add a log entry
1793
	 */
1804
	 */
(-)search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java (-1 / +6 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 21-26 Link Here
21
import org.eclipse.jdt.internal.compiler.lookup.*;
21
import org.eclipse.jdt.internal.compiler.lookup.*;
22
import org.eclipse.jdt.internal.core.*;
22
import org.eclipse.jdt.internal.core.*;
23
import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants;
23
import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants;
24
import org.eclipse.jdt.internal.core.util.Util;
24
25
25
public class ClassFileMatchLocator implements IIndexConstants {
26
public class ClassFileMatchLocator implements IIndexConstants {
26
27
Lines 274-279 Link Here
274
				if (lastSlash != -1) {
275
				if (lastSlash != -1) {
275
					name = CharOperation.subarray(name, lastSlash+1, name.length);
276
					name = CharOperation.subarray(name, lastSlash+1, name.length);
276
				}
277
				}
278
				// https://bugs.eclipse.org/bugs/show_bug.cgi?id=329727
279
				// Remove the enclosing type name from the constructor name if applicable
280
				int lastDollar = CharOperation.lastIndexOf('$', name);
281
				name = lastDollar > -1 ? Util.localTypeName(name, lastDollar, name.length) : name;
277
			} else {
282
			} else {
278
				name = method.getSelector();
283
				name = method.getSelector();
279
			}
284
			}
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java (+55 lines)
Lines 4464-4467 Link Here
4464
	// Should have same types with these 2 searches
4464
	// Should have same types with these 2 searches
4465
	assertEquals("Found types sounds not to be correct", requestor.toString(), collector.toString());
4465
	assertEquals("Found types sounds not to be correct", requestor.toString(), collector.toString());
4466
}
4466
}
4467
/**
4468
 * @bug 329727 Invalid check in the isConstructor() method of the IMethod implementation.
4469
 * @test check that in a binary type, method's name doesn't contain the enclosing type name and
4470
 * that IMethod#isContructor returns correct value 
4471
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=329727"
4472
 * @throws CoreException
4473
 * @throws IOException
4474
 */
4475
public void testBug329727() throws CoreException, IOException {
4476
	
4477
	IJavaProject project = getJavaProject("JavaSearch");
4478
	IClasspathEntry[] originalCP = project.getRawClasspath();
4479
		try {
4480
			int cpLength = originalCP.length;
4481
			IClasspathEntry[] newCP = new IClasspathEntry[cpLength + 1];
4482
			System.arraycopy(originalCP, 0, newCP, 0, cpLength);
4483
			createLibrary(project, "bug329727.jar", null, new String[] {
4484
					"p/OuterClass.java",
4485
					"package p;\n" + "public class OuterClass {\n"
4486
							+ "	public OuterClass(){}\n"
4487
							+ "	class InnerClass {\n"
4488
							+ "		public InnerClass(){}\n" + "	}\n" + "}\n" },
4489
					new String[0], JavaCore.VERSION_1_4);
4490
			newCP[cpLength] = JavaCore.newLibraryEntry(
4491
						new Path("/JavaSearch/bug329727.jar"), null, null);
4492
			project.setRawClasspath(newCP, null);
4493
4494
			final String txtPattern = "InnerClas*";
4495
			SearchPattern pattern = SearchPattern.createPattern(txtPattern,
4496
					IJavaSearchConstants.CONSTRUCTOR,
4497
					IJavaSearchConstants.DECLARATIONS,
4498
					SearchPattern.R_CASE_SENSITIVE
4499
							| SearchPattern.R_PATTERN_MATCH);
4500
4501
			SearchParticipant[] participants = new SearchParticipant[1];
4502
			participants[0] = SearchEngine.getDefaultSearchParticipant();
4503
4504
			SearchRequestor requestor = new SearchRequestor() {
4505
				public void acceptSearchMatch(SearchMatch match)
4506
						throws CoreException {
4507
					assertTrue("Incorrect Element", match.getElement() instanceof IMethod);
4508
					assertTrue("Must be a constructor", ((IMethod) match.getElement()).isConstructor());
4509
					assertEquals("Incorrect Constructor name", "InnerClass", ((IMethod)match.getElement()).getElementName()); 
4510
				}
4511
			};
4512
4513
			SearchEngine engine = new SearchEngine();
4514
			IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
4515
			engine.search(pattern, participants, scope, requestor, null);
4516
    }
4517
    finally{
4518
		project.setRawClasspath(originalCP, null);
4519
    }
4520
4521
}
4467
}
4522
}

Return to bug 329727