List of usage examples for org.eclipse.jdt.internal.core.util HashSetOfArray HashSetOfArray
public HashSetOfArray()
From source file:com.codenvy.ide.ext.java.server.internal.core.JavaProjectElementInfo.java
License:Open Source License
ProjectCache getProjectCache(JavaProject project) {
ProjectCache cache = this.projectCache;
if (cache == null) {
IPackageFragmentRoot[] roots;/* w w w.j a v a2 s.c om*/
Map reverseMap = new HashMap(3);
try {
roots = project.getAllPackageFragmentRoots(reverseMap);
} catch (JavaModelException e) {
// project does not exist: cannot happen since this is the info of the project
roots = new IPackageFragmentRoot[0];
reverseMap.clear();
}
// HashMap rootInfos = JavaModelManager.getJavaModelManager().deltaState.roots;
HashMap pkgFragmentsCaches = new HashMap();
int length = roots.length;
JavaModelManager manager = project.manager; //JavaModelManager.getJavaModelManager();
for (int i = 0; i < length; i++) {
IPackageFragmentRoot root = roots[i];
DeltaProcessor.RootInfo rootInfo = null;// (DeltaProcessor.RootInfo) rootInfos.get(root.getPath());
if (rootInfo == null || rootInfo.project.equals(project)) {
// ensure that an identical root is used (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=217059 )
roots[i] = root = (IPackageFragmentRoot) manager.getExistingElement(root);
// compute fragment cache
HashSetOfArray fragmentsCache = new HashSetOfArray();
initializePackageNames(root, fragmentsCache);
pkgFragmentsCaches.put(root, fragmentsCache);
}
}
cache = new ProjectCache(roots, reverseMap, pkgFragmentsCaches);
this.projectCache = cache;
}
return cache;
}
From source file:com.codenvy.ide.ext.java.server.internal.core.JavaProjectElementInfo.java
License:Open Source License
NameLookup newNameLookup(JavaProject project, ICompilationUnit[] workingCopies) {
ProjectCache cache = getProjectCache(project);
HashtableOfArrayToObject allPkgFragmentsCache = cache.allPkgFragmentsCache;
if (allPkgFragmentsCache == null) {
// HashMap rootInfos = project.manager.deltaState.roots;
IPackageFragmentRoot[] allRoots = cache.allPkgFragmentRootsCache;
int length = allRoots.length;
allPkgFragmentsCache = new HashtableOfArrayToObject();
for (int i = 0; i < length; i++) {
IPackageFragmentRoot root = allRoots[i];
DeltaProcessor.RootInfo rootInfo = null;//(DeltaProcessor.RootInfo) rootInfos.get(root.getPath());
JavaProject rootProject = project;//rootInfo == null ? project : rootInfo.project;
HashSetOfArray fragmentsCache;
if (rootProject.equals(project)) {
// retrieve package fragments cache from this project
fragmentsCache = (HashSetOfArray) cache.pkgFragmentsCaches.get(root);
} else {
// retrieve package fragments cache from the root's project
ProjectCache rootProjectCache;
try {
rootProjectCache = rootProject.getProjectCache();
} catch (JavaModelException e) {
// project doesn't exit
continue;
}/*from w w w. j av a2 s. c o m*/
fragmentsCache = (HashSetOfArray) rootProjectCache.pkgFragmentsCaches.get(root);
}
if (fragmentsCache == null) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=183833
fragmentsCache = new HashSetOfArray();
initializePackageNames(root, fragmentsCache);
}
Object[][] set = fragmentsCache.set;
for (int j = 0, length2 = set.length; j < length2; j++) {
String[] pkgName = (String[]) set[j];
if (pkgName == null)
continue;
Object existing = allPkgFragmentsCache.get(pkgName);
if (existing == null || existing == NO_ROOTS) {
allPkgFragmentsCache.put(pkgName, root);
// ensure super packages (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=119161)
// are also in the map
addSuperPackageNames(pkgName, allPkgFragmentsCache);
} else {
if (existing instanceof PackageFragmentRoot) {
allPkgFragmentsCache.put(pkgName,
new IPackageFragmentRoot[] { (PackageFragmentRoot) existing, root });
} else {
IPackageFragmentRoot[] roots = (IPackageFragmentRoot[]) existing;
int rootLength = roots.length;
System.arraycopy(roots, 0, roots = new IPackageFragmentRoot[rootLength + 1], 0,
rootLength);
roots[rootLength] = root;
allPkgFragmentsCache.put(pkgName, roots);
}
}
}
}
cache.allPkgFragmentsCache = allPkgFragmentsCache;
}
return new NameLookup(cache.allPkgFragmentRootsCache, cache.allPkgFragmentsCache, workingCopies,
cache.rootToResolvedEntries, project.getJavaModelManager());
}