View | Details | Raw Unified | Return to bug 266771
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/NameLookupTests2.java (+20 lines)
Lines 14-19 Link Here
14
14
15
import org.eclipse.core.resources.IWorkspaceRunnable;
15
import org.eclipse.core.resources.IWorkspaceRunnable;
16
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.IPath;
17
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.Path;
19
import org.eclipse.core.runtime.Path;
19
import org.eclipse.jdt.core.*;
20
import org.eclipse.jdt.core.*;
Lines 250-255 Link Here
250
	}
251
	}
251
}
252
}
252
/*
253
/*
254
 * Ensure that finding a package fragment with a path with a length equals to an external jar path length + 1
255
 * (regression test for bug 266771 NameLookup.findPackageFragment returns very incorrect package fragments)
256
 */
257
public void testFindPackageFragment2() throws CoreException {
258
	try {
259
		JavaProject project = (JavaProject)createJavaProject("P", new String[0], new String[] {"JCL_LIB"}, "bin");
260
		NameLookup nameLookup =getNameLookup(project);
261
		IPath pathToSearch = new Path(getExternalJCLPathString() + 'a');
262
		IPackageFragment pkg = nameLookup.findPackageFragment(pathToSearch);
263
		assertElementEquals(
264
			"Unexpected package",
265
			"<null>",
266
			pkg);
267
	} finally {
268
		deleteProject("P");
269
	}
270
}
271
272
/*
253
 * Ensure that a member type with a name ending with a dollar and a number is found
273
 * Ensure that a member type with a name ending with a dollar and a number is found
254
 * (regression test for bug 103466 Stack Overflow: Requesting Java AST from selection)
274
 * (regression test for bug 103466 Stack Overflow: Requesting Java AST from selection)
255
 */
275
 */
(-)model/org/eclipse/jdt/internal/core/NameLookup.java (-2 / +1 lines)
Lines 414-421 Link Here
414
					continue;
414
					continue;
415
				}
415
				}
416
				IPath rootPath = root.getPath();
416
				IPath rootPath = root.getPath();
417
				int matchingCount = rootPath.matchingFirstSegments(path);
417
				if (rootPath.isPrefixOf(path)) {
418
				if (matchingCount != 0) {
419
					String name = path.toOSString();
418
					String name = path.toOSString();
420
					// + 1 is for the File.separatorChar
419
					// + 1 is for the File.separatorChar
421
					name = name.substring(rootPath.toOSString().length() + 1, name.length());
420
					name = name.substring(rootPath.toOSString().length() + 1, name.length());

Return to bug 266771