use of org.eclipse.jdt.internal.ui.browsing.LogicalPackage in project xtext-eclipse by eclipse.
the class MultiOrganizeImportsHandler method collectRelevantFiles.
private void collectRelevantFiles(Object element, Multimap<IProject, IFile> result) {
try {
if (element instanceof IJavaElement) {
IJavaElement elem = (IJavaElement) element;
if (elem.exists()) {
switch(elem.getElementType()) {
case IJavaElement.PACKAGE_FRAGMENT:
collectRelevantFiles((IPackageFragment) elem, result);
break;
case IJavaElement.PACKAGE_FRAGMENT_ROOT:
collectRelevantFiles((IPackageFragmentRoot) elem, result);
break;
case IJavaElement.JAVA_PROJECT:
IPackageFragmentRoot[] roots;
roots = ((IJavaProject) elem).getPackageFragmentRoots();
for (int k = 0; k < roots.length; k++) {
collectRelevantFiles(roots[k], result);
}
break;
}
}
} else if (element instanceof LogicalPackage) {
IPackageFragment[] packageFragments = ((LogicalPackage) element).getFragments();
for (int k = 0; k < packageFragments.length; k++) {
IPackageFragment pack = packageFragments[k];
if (pack.exists()) {
collectRelevantFiles(pack, result);
}
}
} else if (element instanceof IWorkingSet) {
IWorkingSet workingSet = (IWorkingSet) element;
IAdaptable[] elements = workingSet.getElements();
for (int j = 0; j < elements.length; j++) {
collectRelevantFiles(elements[j], result);
}
} else if (element instanceof IFile) {
collectIFiles(result, new Object[] { element });
}
} catch (JavaModelException e) {
e.printStackTrace();
}
}
Aggregations