Lines 18-26
Link Here
|
18 |
import org.eclipse.core.runtime.CoreException; |
18 |
import org.eclipse.core.runtime.CoreException; |
19 |
import org.eclipse.core.runtime.IPath; |
19 |
import org.eclipse.core.runtime.IPath; |
20 |
import org.eclipse.jdt.core.*; |
20 |
import org.eclipse.jdt.core.*; |
21 |
import org.eclipse.jdt.core.IClasspathEntry; |
|
|
22 |
import org.eclipse.jdt.core.IPackageFragmentRoot; |
23 |
import org.eclipse.jdt.core.JavaModelException; |
24 |
import org.eclipse.jdt.internal.core.util.Util; |
21 |
import org.eclipse.jdt.internal.core.util.Util; |
25 |
import org.eclipse.jdt.internal.core.util.HashtableOfArrayToObject; |
22 |
import org.eclipse.jdt.internal.core.util.HashtableOfArrayToObject; |
26 |
|
23 |
|
Lines 38-46
Link Here
|
38 |
class JavaProjectElementInfo extends OpenableElementInfo { |
35 |
class JavaProjectElementInfo extends OpenableElementInfo { |
39 |
|
36 |
|
40 |
static class ProjectCache { |
37 |
static class ProjectCache { |
41 |
ProjectCache(IPackageFragmentRoot[] allPkgFragmentRootsCache, HashtableOfArrayToObject allPkgFragmentsCache, Map rootToResolvedEntries) { |
38 |
ProjectCache(IPackageFragmentRoot[] allPkgFragmentRootsCache, HashtableOfArrayToObject allPkgFragmentsCache, HashtableOfArrayToObject isPackageCache, Map rootToResolvedEntries) { |
42 |
this.allPkgFragmentRootsCache = allPkgFragmentRootsCache; |
39 |
this.allPkgFragmentRootsCache = allPkgFragmentRootsCache; |
43 |
this.allPkgFragmentsCache = allPkgFragmentsCache; |
40 |
this.allPkgFragmentsCache = allPkgFragmentsCache; |
|
|
41 |
this.isPackageCache = isPackageCache; |
44 |
this.rootToResolvedEntries = rootToResolvedEntries; |
42 |
this.rootToResolvedEntries = rootToResolvedEntries; |
45 |
} |
43 |
} |
46 |
|
44 |
|
Lines 54-59
Link Here
|
54 |
* (a map from String[] (the package name) to IPackageFragmentRoot[] (the package fragment roots that contain a package fragment with this name) |
52 |
* (a map from String[] (the package name) to IPackageFragmentRoot[] (the package fragment roots that contain a package fragment with this name) |
55 |
*/ |
53 |
*/ |
56 |
public HashtableOfArrayToObject allPkgFragmentsCache; |
54 |
public HashtableOfArrayToObject allPkgFragmentsCache; |
|
|
55 |
|
56 |
/* |
57 |
* A set of package names (String[]) that are known to be packages. |
58 |
*/ |
59 |
public HashtableOfArrayToObject isPackageCache; |
57 |
|
60 |
|
58 |
public Map rootToResolvedEntries; |
61 |
public Map rootToResolvedEntries; |
59 |
} |
62 |
} |
Lines 65-70
Link Here
|
65 |
|
68 |
|
66 |
ProjectCache projectCache; |
69 |
ProjectCache projectCache; |
67 |
|
70 |
|
|
|
71 |
/* |
72 |
* 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 |
*/ |
75 |
public static void addNames(String[] name, HashtableOfArrayToObject set) { |
76 |
set.put(name, name); |
77 |
int length = name.length; |
78 |
for (int i = length-1; i > 0; i--) { |
79 |
String[] superName = new String[i]; |
80 |
System.arraycopy(name, 0, superName, 0, i); |
81 |
set.put(superName, superName); |
82 |
} |
83 |
} |
84 |
|
68 |
/** |
85 |
/** |
69 |
* Create and initialize a new instance of the receiver |
86 |
* Create and initialize a new instance of the receiver |
70 |
*/ |
87 |
*/ |
Lines 188-193
Link Here
|
188 |
reverseMap.clear(); |
205 |
reverseMap.clear(); |
189 |
} |
206 |
} |
190 |
HashtableOfArrayToObject fragmentsCache = new HashtableOfArrayToObject(); |
207 |
HashtableOfArrayToObject fragmentsCache = new HashtableOfArrayToObject(); |
|
|
208 |
HashtableOfArrayToObject isPackageCache = new HashtableOfArrayToObject(); |
191 |
for (int i = 0, length = roots.length; i < length; i++) { |
209 |
for (int i = 0, length = roots.length; i < length; i++) { |
192 |
IPackageFragmentRoot root = roots[i]; |
210 |
IPackageFragmentRoot root = roots[i]; |
193 |
IJavaElement[] frags = null; |
211 |
IJavaElement[] frags = null; |
Lines 203-208
Link Here
|
203 |
Object existing = fragmentsCache.get(pkgName); |
221 |
Object existing = fragmentsCache.get(pkgName); |
204 |
if (existing == null) { |
222 |
if (existing == null) { |
205 |
fragmentsCache.put(pkgName, root); |
223 |
fragmentsCache.put(pkgName, root); |
|
|
224 |
// cache whether each package and its including packages (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=119161) |
225 |
// are actual packages |
226 |
addNames(pkgName, isPackageCache); |
206 |
} else { |
227 |
} else { |
207 |
if (existing instanceof PackageFragmentRoot) { |
228 |
if (existing instanceof PackageFragmentRoot) { |
208 |
fragmentsCache.put(pkgName, new IPackageFragmentRoot[] {(PackageFragmentRoot) existing, root}); |
229 |
fragmentsCache.put(pkgName, new IPackageFragmentRoot[] {(PackageFragmentRoot) existing, root}); |
Lines 216-222
Link Here
|
216 |
} |
237 |
} |
217 |
} |
238 |
} |
218 |
} |
239 |
} |
219 |
cache = new ProjectCache(roots, fragmentsCache, reverseMap); |
240 |
cache = new ProjectCache(roots, fragmentsCache, isPackageCache, reverseMap); |
220 |
this.projectCache = cache; |
241 |
this.projectCache = cache; |
221 |
} |
242 |
} |
222 |
return cache; |
243 |
return cache; |
Lines 258-264
Link Here
|
258 |
*/ |
279 |
*/ |
259 |
NameLookup newNameLookup(JavaProject project, ICompilationUnit[] workingCopies) { |
280 |
NameLookup newNameLookup(JavaProject project, ICompilationUnit[] workingCopies) { |
260 |
ProjectCache cache = getProjectCache(project); |
281 |
ProjectCache cache = getProjectCache(project); |
261 |
return new NameLookup(cache.allPkgFragmentRootsCache, cache.allPkgFragmentsCache, workingCopies, cache.rootToResolvedEntries); |
282 |
return new NameLookup(cache.allPkgFragmentRootsCache, cache.allPkgFragmentsCache, cache.isPackageCache, workingCopies, cache.rootToResolvedEntries); |
262 |
} |
283 |
} |
263 |
|
284 |
|
264 |
/* |
285 |
/* |