private static void getClassURLs(IJavaProject javaProject, List urls) {
IProject project = javaProject.getProject();
IWorkspaceRoot workspaceRoot = project.getWorkspace().getRoot();
IClasspathEntry[] paths = null;
IPath defaultOutputLocation = null;
try {
paths = javaProject.getResolvedClasspath(true);
defaultOutputLocation = javaProject.getOutputLocation();
} catch (JavaModelException e) {
// don't show message to user neither log it
// BytecodeOutlinePlugin.log(e, IStatus.ERROR);
}
if (paths != null) {
IPath projectPath = javaProject.getProject().getLocation();
for (int i = 0; i < paths.length; ++i) {
IClasspathEntry cpEntry = paths[i];
IPath p = null;
if (cpEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
// filter out source container - there are unused for class
// search - add bytecode output location instead
p = cpEntry.getOutputLocation();
if (p == null) {
// default output used:
p = defaultOutputLocation;
}
} else if (cpEntry.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
String projName = cpEntry.getPath().toPortableString()
.substring(1);
IProject proj = workspaceRoot.getProject(projName);
IJavaProject projj = JavaCore.create(proj);
getClassURLs(projj, urls);
continue;
} else {
p = cpEntry.getPath();
}
if (p == null) {
continue;
}
if (!p.toFile().exists()) {
// removeFirstSegments: remove project from relative path
p = projectPath.append(p.removeFirstSegments(1));
if (!p.toFile().exists()) {
continue;
}
}
try {
urls.add(p.toFile().toURI().toURL());
} catch (MalformedURLException e) {
// don't show message to user
BytecodeOutlinePlugin.log(e, IStatus.ERROR);
}
}