ArrayList collector = new ArrayList();
for (int i = 0, max = elements.length; i < max; i++) {
// collect all the java project
IJavaElement element = elements[i];
IJavaProject javaProject = element.getJavaProject();
IProject project = javaProject.getProject();
State state = null;
State currentState = (State) projectsStates.get(project);
if (currentState != null) {
state = currentState;
} else {
state = (State) JavaModelManager.getJavaModelManager().getLastBuiltState(project, null);
if (state != null) {
projectsStates.put(project, state);
}
}
if (state == null) continue;
if (element.getElementType() == IJavaElement.JAVA_PROJECT) {
IPackageFragmentRoot[] roots = null;
try {
roots = javaProject.getPackageFragmentRoots();
} catch (JavaModelException e) {
// ignore
}
if (roots == null) continue;
IRegion region2 = JavaCore.newRegion();
for (int j = 0; j < roots.length; j++) {
region2.add(roots[j]);
}
IResource[] res = getGeneratedResources(region2, includesNonJavaResources);
for (int j = 0, max2 = res.length; j < max2; j++) {
collector.add(res[j]);
}
continue;
}
IPath outputLocation = null;
try {
outputLocation = javaProject.getOutputLocation();
} catch (JavaModelException e) {
// ignore
}
IJavaElement root = element;
while (root != null && root.getElementType() != IJavaElement.PACKAGE_FRAGMENT_ROOT) {
root = root.getParent();
}
if (root == null) continue;
IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) root;
int rootPathSegmentCounts = packageFragmentRoot.getPath().segmentCount();
try {
IClasspathEntry entry = packageFragmentRoot.getRawClasspathEntry();
IPath entryOutputLocation = entry.getOutputLocation();
if (entryOutputLocation != null) {
outputLocation = entryOutputLocation;
}
} catch (JavaModelException e) {
e.printStackTrace();
}
if (outputLocation == null) continue;
IContainer container = (IContainer) project.getWorkspace().getRoot().findMember(outputLocation);
switch(element.getElementType()) {
case IJavaElement.COMPILATION_UNIT :
// get the .class files generated when this element was built
ICompilationUnit unit = (ICompilationUnit) element;
getGeneratedResource(unit, container, state, rootPathSegmentCounts, collector);