use of net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd in project pmd-eclipse-plugin by pmd.
the class PMDCheckAction method reviewSingleResource.
/**
* Run the reviewCode command on a single resource
*
* @param resource
* @throws CommandException
*/
private void reviewSingleResource(IResource resource) throws CommandException {
ReviewCodeCmd cmd = new ReviewCodeCmd();
cmd.addResource(resource);
setupAndExecute(cmd, 1);
}
use of net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd in project pmd-eclipse-plugin by pmd.
the class ReviewResourceAction method run.
/**
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
try {
ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
dialog.run(false, false, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
setMonitor(monitor);
monitor.beginTask(getString(StringKeys.MONITOR_REVIEW), 5);
ReviewCodeCmd cmd = new ReviewCodeCmd();
cmd.addResource(resource);
cmd.setStepCount(1);
cmd.setTaskMarker(true);
cmd.setUserInitiated(true);
try {
cmd.performExecute();
} catch (CommandException e) {
logErrorByKey(StringKeys.ERROR_CORE_EXCEPTION, e);
}
monitor.done();
}
});
} catch (InvocationTargetException e) {
logErrorByKey(StringKeys.ERROR_INVOCATIONTARGET_EXCEPTION, e);
} catch (InterruptedException e) {
logErrorByKey(StringKeys.ERROR_INTERRUPTED_EXCEPTION, e);
}
}
use of net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd in project pmd-eclipse-plugin by pmd.
the class FileChangeReviewer method resourceChanged.
/**
* @param event
*/
public void resourceChanged(IResourceChangeEvent event) {
IWorkspaceDescription workspaceSettings = ResourcesPlugin.getWorkspace().getDescription();
if (workspaceSettings.isAutoBuilding()) {
PMDPlugin.getDefault().logInformation("Not running PMD via FileChangeReviewer, as autoBuilding is enabled for this workspace");
return;
}
Set<ResourceChange> itemsChanged = new HashSet<ResourceChange>();
switch(event.getType()) {
case IResourceChangeEvent.POST_CHANGE:
changed(itemsChanged, event.getDelta(), new NullProgressMonitor());
break;
default:
}
if (itemsChanged.isEmpty()) {
return;
}
// separate one for each thread
ReviewCodeCmd cmd = new ReviewCodeCmd();
cmd.reset();
for (ResourceChange chg : itemsChanged) {
cmd.addResource(chg.file);
}
try {
cmd.performExecute();
} catch (CommandException e) {
PMDPlugin.getDefault().log(IStatus.ERROR, "Error processing code review upon file changes", e);
}
}
use of net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd in project pmd-eclipse-plugin by pmd.
the class PMDBuilder method processProjectFiles.
/**
* Process all files in the project
*
* @param project
* the project
* @param monitor
* a progress monitor
* @throws CommandException
*/
private void processProjectFiles(IProject project, IProgressMonitor monitor) throws CommandException {
ReviewCodeCmd cmd = new ReviewCodeCmd();
cmd.addResource(project);
cmd.setTaskMarker(false);
cmd.setMonitor(monitor);
// a builder is always asynchronous; execute a command synchronously whatever its processor
cmd.performExecute();
}
use of net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd in project pmd-eclipse-plugin by pmd.
the class PMDBuilder method buildIncremental.
/**
* Incremental build
*
* @param monitor
* a progress monitor.
* @throws CommandException
*/
private void buildIncremental(IProgressMonitor monitor) throws CommandException {
/*
* Check the user preference to see if the user wants to run PMD on a save
* */
if (!PMDPlugin.getDefault().loadPreferences().isCheckAfterSaveEnabled()) {
return;
}
IProject currentProject = getProject();
if (currentProject != null) {
IResourceDelta resourceDelta = this.getDelta(currentProject);
if (resourceDelta != null && resourceDelta.getAffectedChildren().length != 0) {
ReviewCodeCmd cmd = new ReviewCodeCmd();
cmd.setResourceDelta(resourceDelta);
cmd.setTaskMarker(false);
cmd.setMonitor(monitor);
// a builder is always asynchronous;
// execute a command synchronously
// whatever its processor
cmd.performExecute();
} else {
LOG.info("No change reported. Performing no build");
}
}
}
Aggregations