reduce nesting, misc
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@7271 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -27,7 +27,7 @@ public class PMDBuilder extends IncrementalProjectBuilder {
|
||||
public static final Logger log = Logger.getLogger(PMDBuilder.class);
|
||||
public static final String PMD_BUILDER = "net.sourceforge.pmd.eclipse.plugin.pmdBuilder";
|
||||
|
||||
IProject[] EMPTY_PROJECT_ARRAY = new IProject[0];
|
||||
public static final IProject[] EMPTY_PROJECT_ARRAY = new IProject[0];
|
||||
/**
|
||||
* @see org.eclipse.core.resources.IncrementalProjectBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
|
@ -35,53 +35,54 @@ public class JavaProjectClassLoader extends URLClassLoader {
|
||||
}
|
||||
|
||||
private void addURLs(IJavaProject javaProject, boolean exportsOnly) {
|
||||
if (!javaProjects.contains(javaProject)) {
|
||||
javaProjects.add(javaProject);
|
||||
|
||||
if (javaProjects.contains(javaProject)) return;
|
||||
|
||||
javaProjects.add(javaProject);
|
||||
|
||||
try {
|
||||
// Add default output location
|
||||
addURL(javaProject.getOutputLocation());
|
||||
try {
|
||||
// Add default output location
|
||||
addURL(javaProject.getOutputLocation());
|
||||
|
||||
// Add each classpath entry
|
||||
IClasspathEntry[] classpathEntries = javaProject.getResolvedClasspath(true);
|
||||
for (IClasspathEntry classpathEntry : classpathEntries) {
|
||||
if (classpathEntry.isExported() || !exportsOnly) {
|
||||
switch (classpathEntry.getEntryKind()) {
|
||||
// Add each classpath entry
|
||||
IClasspathEntry[] classpathEntries = javaProject.getResolvedClasspath(true);
|
||||
for (IClasspathEntry classpathEntry : classpathEntries) {
|
||||
if (classpathEntry.isExported() || !exportsOnly) {
|
||||
switch (classpathEntry.getEntryKind()) {
|
||||
|
||||
// Recurse on projects
|
||||
case IClasspathEntry.CPE_PROJECT:
|
||||
IProject project = javaProject.getProject().getWorkspace().getRoot().getProject(
|
||||
classpathEntry.getPath().toString());
|
||||
IJavaProject javaProj = JavaCore.create(project);
|
||||
if (javaProj != null) {
|
||||
addURLs(javaProj, true);
|
||||
// Recurse on projects
|
||||
case IClasspathEntry.CPE_PROJECT:
|
||||
IProject project = javaProject.getProject().getWorkspace().getRoot().getProject(
|
||||
classpathEntry.getPath().toString());
|
||||
IJavaProject javaProj = JavaCore.create(project);
|
||||
if (javaProj != null) {
|
||||
addURLs(javaProj, true);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
// Library
|
||||
case IClasspathEntry.CPE_LIBRARY:
|
||||
addURL(classpathEntry);
|
||||
break;
|
||||
case IClasspathEntry.CPE_LIBRARY:
|
||||
addURL(classpathEntry);
|
||||
break;
|
||||
|
||||
// Only Source entries with custom output location need to be added
|
||||
case IClasspathEntry.CPE_SOURCE:
|
||||
IPath outputLocation = classpathEntry.getOutputLocation();
|
||||
if (outputLocation != null) {
|
||||
addURL(outputLocation);
|
||||
// Only Source entries with custom output location need to be added
|
||||
case IClasspathEntry.CPE_SOURCE:
|
||||
IPath outputLocation = classpathEntry.getOutputLocation();
|
||||
if (outputLocation != null) {
|
||||
addURL(outputLocation);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
// Variable and Container entries should not be happening, because we've asked for resolved entries.
|
||||
case IClasspathEntry.CPE_VARIABLE:
|
||||
case IClasspathEntry.CPE_CONTAINER:
|
||||
break;
|
||||
}
|
||||
// Variable and Container entries should not be happening, because we've asked for resolved entries.
|
||||
case IClasspathEntry.CPE_VARIABLE:
|
||||
case IClasspathEntry.CPE_CONTAINER:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (JavaModelException e) {
|
||||
log.debug("MalformedURLException occurred: " + e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
} catch (JavaModelException e) {
|
||||
log.debug("MalformedURLException occurred: " + e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void addURL(IClasspathEntry classpathEntry) {
|
||||
|
Reference in New Issue
Block a user