Lines 33-44
Link Here
|
33 |
|
33 |
|
34 |
/* package */ |
34 |
/* package */ |
35 |
class JavaProjectElementInfo extends OpenableElementInfo { |
35 |
class JavaProjectElementInfo extends OpenableElementInfo { |
|
|
36 |
|
37 |
static final IPackageFragmentRoot[] NO_ROOTS = new IPackageFragmentRoot[0]; |
36 |
|
38 |
|
37 |
static class ProjectCache { |
39 |
static class ProjectCache { |
38 |
ProjectCache(IPackageFragmentRoot[] allPkgFragmentRootsCache, HashtableOfArrayToObject allPkgFragmentsCache, HashtableOfArrayToObject isPackageCache, Map rootToResolvedEntries) { |
40 |
ProjectCache(IPackageFragmentRoot[] allPkgFragmentRootsCache, HashtableOfArrayToObject allPkgFragmentsCache, Map rootToResolvedEntries) { |
39 |
this.allPkgFragmentRootsCache = allPkgFragmentRootsCache; |
41 |
this.allPkgFragmentRootsCache = allPkgFragmentRootsCache; |
40 |
this.allPkgFragmentsCache = allPkgFragmentsCache; |
42 |
this.allPkgFragmentsCache = allPkgFragmentsCache; |
41 |
this.isPackageCache = isPackageCache; |
|
|
42 |
this.rootToResolvedEntries = rootToResolvedEntries; |
43 |
this.rootToResolvedEntries = rootToResolvedEntries; |
43 |
} |
44 |
} |
44 |
|
45 |
|
Lines 72-84
Link Here
|
72 |
* Adds the given name and its super names to the given set |
73 |
* Adds the given name and its super names to the given set |
73 |
* (e.g. for {"a", "b", "c"}, adds {"a", "b", "c"}, {"a", "b"}, and {"a"}) |
74 |
* (e.g. for {"a", "b", "c"}, adds {"a", "b", "c"}, {"a", "b"}, and {"a"}) |
74 |
*/ |
75 |
*/ |
75 |
public static void addNames(String[] name, HashtableOfArrayToObject set) { |
76 |
public static void addSuperPackageNames(String[] pkgName, HashtableOfArrayToObject packageFragments) { |
76 |
set.put(name, name); |
77 |
int length = pkgName.length; |
77 |
int length = name.length; |
|
|
78 |
for (int i = length-1; i > 0; i--) { |
78 |
for (int i = length-1; i > 0; i--) { |
79 |
String[] superName = new String[i]; |
79 |
System.arraycopy(pkgName, 0, pkgName = new String[i], 0, i); |
80 |
System.arraycopy(name, 0, superName, 0, i); |
80 |
if (packageFragments.get(pkgName) == null) |
81 |
set.put(superName, superName); |
81 |
packageFragments.put(pkgName, NO_ROOTS); |
82 |
} |
82 |
} |
83 |
} |
83 |
} |
84 |
|
84 |
|
Lines 209-215
Link Here
|
209 |
|
209 |
|
210 |
HashMap otherRoots = JavaModelManager.getJavaModelManager().deltaState.otherRoots; |
210 |
HashMap otherRoots = JavaModelManager.getJavaModelManager().deltaState.otherRoots; |
211 |
HashtableOfArrayToObject fragmentsCache = new HashtableOfArrayToObject(); |
211 |
HashtableOfArrayToObject fragmentsCache = new HashtableOfArrayToObject(); |
212 |
HashtableOfArrayToObject isPackageCache = new HashtableOfArrayToObject(); |
|
|
213 |
for (int i = 0, length = roots.length; i < length; i++) { |
212 |
for (int i = 0, length = roots.length; i < length; i++) { |
214 |
IPackageFragmentRoot root = roots[i]; |
213 |
IPackageFragmentRoot root = roots[i]; |
215 |
IJavaElement[] frags = null; |
214 |
IJavaElement[] frags = null; |
Lines 230-240
Link Here
|
230 |
PackageFragment fragment= (PackageFragment) frags[j]; |
229 |
PackageFragment fragment= (PackageFragment) frags[j]; |
231 |
String[] pkgName = fragment.names; |
230 |
String[] pkgName = fragment.names; |
232 |
Object existing = fragmentsCache.get(pkgName); |
231 |
Object existing = fragmentsCache.get(pkgName); |
233 |
if (existing == null) { |
232 |
if (existing == null || existing == NO_ROOTS) { |
234 |
fragmentsCache.put(pkgName, root); |
233 |
fragmentsCache.put(pkgName, root); |
235 |
// cache whether each package and its including packages (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=119161) |
234 |
// ensure super packages (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=119161) |
236 |
// are actual packages |
235 |
// are also in the map |
237 |
addNames(pkgName, isPackageCache); |
236 |
addSuperPackageNames(pkgName, fragmentsCache); |
238 |
} else { |
237 |
} else { |
239 |
if (existing instanceof PackageFragmentRoot) { |
238 |
if (existing instanceof PackageFragmentRoot) { |
240 |
fragmentsCache.put(pkgName, new IPackageFragmentRoot[] {(PackageFragmentRoot) existing, root}); |
239 |
fragmentsCache.put(pkgName, new IPackageFragmentRoot[] {(PackageFragmentRoot) existing, root}); |
Lines 248-254
Link Here
|
248 |
} |
247 |
} |
249 |
} |
248 |
} |
250 |
} |
249 |
} |
251 |
cache = new ProjectCache(roots, fragmentsCache, isPackageCache, reverseMap); |
250 |
cache = new ProjectCache(roots, fragmentsCache, reverseMap); |
252 |
this.projectCache = cache; |
251 |
this.projectCache = cache; |
253 |
} |
252 |
} |
254 |
return cache; |
253 |
return cache; |
Lines 290-296
Link Here
|
290 |
*/ |
289 |
*/ |
291 |
NameLookup newNameLookup(JavaProject project, ICompilationUnit[] workingCopies) { |
290 |
NameLookup newNameLookup(JavaProject project, ICompilationUnit[] workingCopies) { |
292 |
ProjectCache cache = getProjectCache(project); |
291 |
ProjectCache cache = getProjectCache(project); |
293 |
return new NameLookup(cache.allPkgFragmentRootsCache, cache.allPkgFragmentsCache, cache.isPackageCache, workingCopies, cache.rootToResolvedEntries); |
292 |
return new NameLookup(cache.allPkgFragmentRootsCache, cache.allPkgFragmentsCache, workingCopies, cache.rootToResolvedEntries); |
294 |
} |
293 |
} |
295 |
|
294 |
|
296 |
/* |
295 |
/* |