* contain the branch including the specified type.
*/
public RegionBasedTypeHierarchy(IRegion region, ICompilationUnit[] workingCopies, IType type, boolean computeSubtypes) {
super(type, workingCopies, (IJavaSearchScope)null, computeSubtypes);
Region newRegion = new Region() {
public void add(IJavaElement element) {
if (!contains(element)) {
//"new" element added to region
removeAllChildren(element);
fRootElements.add(element);
if (element.getElementType() == IJavaElement.JAVA_PROJECT) {
// add jar roots as well so that jars don't rely on their parent to know
// if they are contained in the region
// (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=146615)
try {
IPackageFragmentRoot[] roots = ((IJavaProject) element).getPackageFragmentRoots();
for (int i = 0, length = roots.length; i < length; i++) {
if (roots[i].isArchive() && !fRootElements.contains(roots[i]))
fRootElements.add(roots[i]);
}
} catch (JavaModelException e) {
// project doesn't exist
}
}
fRootElements.trimToSize();
}
}
};
IJavaElement[] elements = region.getElements();
for (int i = 0, length = elements.length; i < length; i++) {
newRegion.add(elements[i]);
}
this.region = newRegion;
if (elements.length > 0)
this.project = elements[0].getJavaProject();