roots = (IPackageFragmentRoot[]) allOldRoots.get(this.project);
}
if (roots != null) {
removedRoots = new HashMap();
for (int i = 0; i < roots.length; i++) {
IPackageFragmentRoot root = roots[i];
removedRoots.put(root.getPath(), root);
}
}
int newLength = newResolvedClasspath.length;
int oldLength = this.oldResolvedClasspath.length;
for (int i = 0; i < oldLength; i++) {
int index = classpathContains(newResolvedClasspath, this.oldResolvedClasspath[i]);
if (index == -1) {
// remote project changes
if (this.oldResolvedClasspath[i].getEntryKind() == IClasspathEntry.CPE_PROJECT) {
result |= HAS_PROJECT_CHANGE;
continue;
}
IPackageFragmentRoot[] pkgFragmentRoots = null;
if (removedRoots != null) {
IPackageFragmentRoot oldRoot = (IPackageFragmentRoot) removedRoots.get(this.oldResolvedClasspath[i].getPath());
if (oldRoot != null) { // use old root if any (could be none if entry wasn't bound)
pkgFragmentRoots = new IPackageFragmentRoot[] { oldRoot };
}
}
if (pkgFragmentRoots == null) {
try {
ObjectVector accumulatedRoots = new ObjectVector();
HashSet rootIDs = new HashSet(5);
rootIDs.add(this.project.rootID());
this.project.computePackageFragmentRoots(
this.oldResolvedClasspath[i],
accumulatedRoots,
rootIDs,
null, // inside original project
false, // don't check existency
false, // don't retrieve exported roots
null); /*no reverse map*/
pkgFragmentRoots = new IPackageFragmentRoot[accumulatedRoots.size()];
accumulatedRoots.copyInto(pkgFragmentRoots);
} catch (JavaModelException e) {
pkgFragmentRoots = new IPackageFragmentRoot[] {};
}
}
addClasspathDeltas(delta, pkgFragmentRoots, IJavaElementDelta.F_REMOVED_FROM_CLASSPATH);
result |= HAS_DELTA;
} else {
// remote project changes
if (this.oldResolvedClasspath[i].getEntryKind() == IClasspathEntry.CPE_PROJECT) {
result |= HAS_PROJECT_CHANGE;
continue;
}
if (index != i) { //reordering of the classpath
addClasspathDeltas(delta, this.project.computePackageFragmentRoots(this.oldResolvedClasspath[i]), IJavaElementDelta.F_REORDER);
result |= HAS_DELTA;
}
// check source attachment
IPath newSourcePath = newResolvedClasspath[index].getSourceAttachmentPath();
int sourceAttachmentFlags = getSourceAttachmentDeltaFlag(this.oldResolvedClasspath[i].getSourceAttachmentPath(), newSourcePath);
IPath oldRootPath = this.oldResolvedClasspath[i].getSourceAttachmentRootPath();
IPath newRootPath = newResolvedClasspath[index].getSourceAttachmentRootPath();
int sourceAttachmentRootFlags = getSourceAttachmentDeltaFlag(oldRootPath, newRootPath);
int flags = sourceAttachmentFlags | sourceAttachmentRootFlags;
if (flags != 0) {
addClasspathDeltas(delta, this.project.computePackageFragmentRoots(this.oldResolvedClasspath[i]), flags);
result |= HAS_DELTA;
} else {
if (oldRootPath == null && newRootPath == null) {
// if source path is specified and no root path, it needs to be recomputed dynamically
// force detach source on jar package fragment roots (source will be lazily computed when needed)
IPackageFragmentRoot[] computedRoots = this.project.computePackageFragmentRoots(this.oldResolvedClasspath[i]);
for (int j = 0; j < computedRoots.length; j++) {
IPackageFragmentRoot root = computedRoots[j];
// force detach source on jar package fragment roots (source will be lazily computed when needed)
try {
root.close();
} catch (JavaModelException e) {
// ignore
}
}
}