### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java,v retrieving revision 1.45 diff -u -r1.45 JavaProjectElementInfo.java --- model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java 19 Apr 2007 08:27:09 -0000 1.45 +++ model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java 23 Apr 2007 08:43:41 -0000 @@ -33,12 +33,13 @@ /* package */ class JavaProjectElementInfo extends OpenableElementInfo { + + static final IPackageFragmentRoot[] NO_ROOTS = new IPackageFragmentRoot[0]; static class ProjectCache { - ProjectCache(IPackageFragmentRoot[] allPkgFragmentRootsCache, HashtableOfArrayToObject allPkgFragmentsCache, HashtableOfArrayToObject isPackageCache, Map rootToResolvedEntries) { + ProjectCache(IPackageFragmentRoot[] allPkgFragmentRootsCache, HashtableOfArrayToObject allPkgFragmentsCache, Map rootToResolvedEntries) { this.allPkgFragmentRootsCache = allPkgFragmentRootsCache; this.allPkgFragmentsCache = allPkgFragmentsCache; - this.isPackageCache = isPackageCache; this.rootToResolvedEntries = rootToResolvedEntries; } @@ -72,13 +73,12 @@ * Adds the given name and its super names to the given set * (e.g. for {"a", "b", "c"}, adds {"a", "b", "c"}, {"a", "b"}, and {"a"}) */ - public static void addNames(String[] name, HashtableOfArrayToObject set) { - set.put(name, name); - int length = name.length; + public static void addSuperPackageNames(String[] pkgName, HashtableOfArrayToObject packageFragments) { + int length = pkgName.length; for (int i = length-1; i > 0; i--) { - String[] superName = new String[i]; - System.arraycopy(name, 0, superName, 0, i); - set.put(superName, superName); + System.arraycopy(pkgName, 0, pkgName = new String[i], 0, i); + if (packageFragments.get(pkgName) == null) + packageFragments.put(pkgName, NO_ROOTS); } } @@ -209,7 +209,6 @@ HashMap otherRoots = JavaModelManager.getJavaModelManager().deltaState.otherRoots; HashtableOfArrayToObject fragmentsCache = new HashtableOfArrayToObject(); - HashtableOfArrayToObject isPackageCache = new HashtableOfArrayToObject(); for (int i = 0, length = roots.length; i < length; i++) { IPackageFragmentRoot root = roots[i]; IJavaElement[] frags = null; @@ -230,11 +229,11 @@ PackageFragment fragment= (PackageFragment) frags[j]; String[] pkgName = fragment.names; Object existing = fragmentsCache.get(pkgName); - if (existing == null) { + if (existing == null || existing == NO_ROOTS) { fragmentsCache.put(pkgName, root); - // cache whether each package and its including packages (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=119161) - // are actual packages - addNames(pkgName, isPackageCache); + // ensure super packages (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=119161) + // are also in the map + addSuperPackageNames(pkgName, fragmentsCache); } else { if (existing instanceof PackageFragmentRoot) { fragmentsCache.put(pkgName, new IPackageFragmentRoot[] {(PackageFragmentRoot) existing, root}); @@ -248,7 +247,7 @@ } } } - cache = new ProjectCache(roots, fragmentsCache, isPackageCache, reverseMap); + cache = new ProjectCache(roots, fragmentsCache, reverseMap); this.projectCache = cache; } return cache; @@ -290,7 +289,7 @@ */ NameLookup newNameLookup(JavaProject project, ICompilationUnit[] workingCopies) { ProjectCache cache = getProjectCache(project); - return new NameLookup(cache.allPkgFragmentRootsCache, cache.allPkgFragmentsCache, cache.isPackageCache, workingCopies, cache.rootToResolvedEntries); + return new NameLookup(cache.allPkgFragmentRootsCache, cache.allPkgFragmentsCache, workingCopies, cache.rootToResolvedEntries); } /* Index: model/org/eclipse/jdt/internal/core/NameLookup.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java,v retrieving revision 1.112 diff -u -r1.112 NameLookup.java --- model/org/eclipse/jdt/internal/core/NameLookup.java 6 Oct 2006 17:42:56 -0000 1.112 +++ model/org/eclipse/jdt/internal/core/NameLookup.java 23 Apr 2007 08:43:41 -0000 @@ -125,12 +125,6 @@ */ protected HashtableOfArrayToObject packageFragments; - /* - * A set of names (String[]) that are known to be package names. - * Value is not null for known package. - */ - protected HashtableOfArrayToObject isPackageCache; - /** * Reverse map from root path to corresponding resolved CP entry * (so as to be able to figure inclusion/exclusion rules) @@ -149,7 +143,6 @@ public NameLookup( IPackageFragmentRoot[] packageFragmentRoots, HashtableOfArrayToObject packageFragments, - HashtableOfArrayToObject isPackage, ICompilationUnit[] workingCopies, Map rootToResolvedEntries) { long start = -1; @@ -163,12 +156,10 @@ this.packageFragmentRoots = packageFragmentRoots; if (workingCopies == null) { this.packageFragments = packageFragments; - this.isPackageCache = isPackage; } else { // clone tables as we're adding packages from working copies try { this.packageFragments = (HashtableOfArrayToObject) packageFragments.clone(); - this.isPackageCache = (HashtableOfArrayToObject) isPackage.clone(); } catch (CloneNotSupportedException e1) { // ignore (implementation of HashtableOfArrayToObject supports cloning) } @@ -213,11 +204,11 @@ IPackageFragmentRoot root = (IPackageFragmentRoot) pkg.getParent(); String[] pkgName = pkg.names; Object existing = this.packageFragments.get(pkgName); - if (existing == null) { + if (existing == null || existing == JavaProjectElementInfo.NO_ROOTS) { this.packageFragments.put(pkgName, root); - // cache whether each package and its including packages (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=119161) - // are actual packages - JavaProjectElementInfo.addNames(pkgName, this.isPackageCache); + // ensure super packages (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=119161) + // are also in the map + JavaProjectElementInfo.addSuperPackageNames(pkgName, this.packageFragments); } else { if (existing instanceof PackageFragmentRoot) { if (!existing.equals(root)) @@ -778,7 +769,7 @@ } public boolean isPackage(String[] pkgName) { - return this.isPackageCache.get(pkgName) != null; + return this.packageFragments.get(pkgName) != null; } /**