Skip to content

Commit 2a11411

Browse files
committed
#1350 Check code after saving runs PMD unnecessarily
1 parent e46c67e commit 2a11411

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

ReleaseNotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Eclipse Update Site: <https://sourceforge.net/projects/pmd/files/pmd-eclipse/upd
66

77
## ????: 4.0.7.v????
88

9+
* Fixed Check code after saving runs PMD unnecessarily ([bug #1350](https://sourceforge.net/p/pmd/bugs/1350/))
910

1011
## 01-April-2015: 4.0.6.v20150401-1945
1112

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/plugin/FileChangeReviewer.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import org.eclipse.core.resources.IResourceChangeEvent;
1414
import org.eclipse.core.resources.IResourceChangeListener;
1515
import org.eclipse.core.resources.IResourceDelta;
16+
import org.eclipse.core.resources.IWorkspaceDescription;
17+
import org.eclipse.core.resources.ResourcesPlugin;
1618
import org.eclipse.core.runtime.CoreException;
1719
import org.eclipse.core.runtime.IProgressMonitor;
1820
import org.eclipse.core.runtime.IStatus;
@@ -65,6 +67,11 @@ public boolean equals(Object other) {
6567
* @param event
6668
*/
6769
public void resourceChanged(IResourceChangeEvent event) {
70+
IWorkspaceDescription workspaceSettings = ResourcesPlugin.getWorkspace().getDescription();
71+
if (workspaceSettings.isAutoBuilding()) {
72+
PMDPlugin.getDefault().logInformation("Not running PMD, as autoBuilding is enabled for this workspace");
73+
return;
74+
}
6875

6976
Set<ResourceChange> itemsChanged = new HashSet<ResourceChange>();
7077

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/ReviewCodeCmd.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ public class ReviewCodeCmd extends AbstractDefaultCommand {
102102
private int fileCount;
103103
private long pmdDuration;
104104
private String onErrorIssue = null;
105+
/** Whether to run the review command, even if PMD is disabled in the project settings. */
106+
private boolean runAlways = false;
105107

106108
private IProjectProperties propertyCache = null;
107109

@@ -291,6 +293,10 @@ public void setTaskMarker(boolean taskMarker) {
291293
this.taskMarker = taskMarker;
292294
}
293295

296+
public void setRunAlways(boolean runAlways) {
297+
this.runAlways = runAlways;
298+
}
299+
294300
/**
295301
* @param openPmdPerspective
296302
* Tell whether the PMD perspective should be opened after
@@ -310,6 +316,7 @@ public void reset() {
310316
setTerminated(false);
311317
openPmdPerspective = false;
312318
onErrorIssue = null;
319+
runAlways = false;
313320
}
314321

315322
/**
@@ -382,7 +389,7 @@ private void processResource(IResource resource) throws CommandException {
382389

383390
final IProject project = resource.getProject();
384391
final IProjectProperties properties = getProjectProperties(project);
385-
if (!properties.isPmdEnabled()) {
392+
if (!runAlways && !properties.isPmdEnabled()) {
386393
return;
387394
}
388395

0 commit comments

Comments
 (0)