Bug 63245 - findPackageFragment won't return default package
Summary: findPackageFragment won't return default package
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 RC1   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-20 12:31 EDT by Richard Kulp CLA
Modified: 2004-05-28 15:38 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Kulp CLA 2004-05-20 12:31:24 EDT
If I just IJavaProject.findPackageFragment(path) where the path is a package
fragment root (but it is not the java project, it is an actual root source
folder in the project), it returns null instead of an IPackageFragment for the
default package.
Comment 1 Richard Kulp CLA 2004-05-20 12:39:12 EDT
Some debugging info for you:

In NameLookup.findPackageFragment(path) at:

IJavaElement fromFactory = JavaCore.create(possibleFragment);
if (fromFactory == null) {
	return null;
}
if (fromFactory instanceof IPackageFragment) {
	return (IPackageFragment) fromFactory;
} else
	if (fromFactory instanceof IJavaProject) {
		// default package in a default root
		JavaProject project = (JavaProject) fromFactory;

The fromFactory that is returned from JavaCore.create is an
IPackageFragmentRoot, so it drops through the following if's and returns null.
Comment 2 Jerome Lanneluc CLA 2004-05-24 13:47:36 EDT
Thanks for debugging it. Fixed NameLookup.findPackageFragment(IPath) to handle 
this case. Added regression test 
NameLookupTests2.testFindDefaultPackageFragmentInNonDefaultRoot()
Comment 3 Olivier Thomann CLA 2004-05-28 15:38:54 EDT
Verified in 200405281200 that the change is in the code