Revision: 6902
http://pmd.svn.sourceforge.net/pmd/?rev=6902&view=rev
Author: xlv
Date: 2009-03-28 20:31:36 +0000 (Sat, 28 Mar 2009)
Log Message:
-----------
merge of the violationsAsErrors config option from the 4.2.x branch
Modified Paths:
--------------
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/messages.properties
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/properties/IProjectProperties.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/properties/impl/ProjectPropertiesImpl.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/properties/impl/ProjectPropertiesManagerImpl.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/properties/impl/ProjectPropertiesTO.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/properties/impl/mapping.xml
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/nls/StringKeys.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/properties/PMDPropertyPage.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/properties/PMDPropertyPageBean.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/properties/PMDPropertyPageController.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/properties/UpdateProjectPropertiesCmd.java
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/messages.properties
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/messages.properties 2009-03-28 20:13:21 UTC (rev 6901)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/messages.properties 2009-03-28 20:31:36 UTC (rev 6902)
@@ -10,6 +10,7 @@
property.button.store_ruleset_project = Use the ruleset configured in a project file
property.button.ruleset_browse = Browse...
property.button.include_derived_files = Include derived files
+property.button.violations_as_errors = Handle high priority violations as Eclipse errors
# General preferences page
preference.pmd.header = PMD-Plugin options
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java 2009-03-28 20:13:21 UTC (rev 6901)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java 2009-03-28 20:31:36 UTC (rev 6902)
@@ -317,7 +317,7 @@
* a map that contains impacted file and marker informations
*/
private void updateMarkers(final IFile file, final RuleContext context, final boolean fTask, final Map<IFile, Set<MarkerInfo>> accumulator)
- throws CoreException {
+ throws CoreException, PropertiesException {
final Set<MarkerInfo> markerSet = new HashSet<MarkerInfo>();
final List<Review> reviewsList = findReviewedViolations(file);
final Review review = new Review();
@@ -441,7 +441,7 @@
* a marker type
* @return markerInfo a markerInfo object
*/
- private MarkerInfo getMarkerInfo(final RuleViolation violation, final String type) {
+ private MarkerInfo getMarkerInfo(final RuleViolation violation, final String type) throws PropertiesException {
final MarkerInfo markerInfo = new MarkerInfo();
markerInfo.setType(type);
@@ -468,9 +468,18 @@
case 1:
attributeNames.add(IMarker.PRIORITY);
values.add(Integer.valueOf(IMarker.PRIORITY_HIGH));
+ attributeNames.add(IMarker.SEVERITY);
+ values.add(new Integer(projectProperties.violationsAsErrors()?IMarker.SEVERITY_ERROR:IMarker.SEVERITY_WARNING));
+ break;
case 2:
attributeNames.add(IMarker.SEVERITY);
- values.add(Integer.valueOf(IMarker.SEVERITY_ERROR));
+ if (projectProperties.violationsAsErrors()) {
+ values.add(new Integer(IMarker.SEVERITY_ERROR));
+ } else {
+ values.add(new Integer(IMarker.SEVERITY_WARNING));
+ attributeNames.add(IMarker.PRIORITY);
+ values.add(new Integer(IMarker.PRIORITY_HIGH));
+ }
break;
case 5:
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/properties/IProjectProperties.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/properties/IProjectProperties.java 2009-03-28 20:13:21 UTC (rev 6901)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/properties/IProjectProperties.java 2009-03-28 20:31:36 UTC (rev 6902)
@@ -138,13 +138,23 @@
* @return whether derived files should be checked
*/
boolean isIncludeDerivedFiles() throws PropertiesException;
-
+
/**
* @param excludeDerivedFiles whether derived files should be checked
*/
void setIncludeDerivedFiles(boolean excludeDerivedFiles) throws PropertiesException;
/**
+ * @return whether high priority violations should be handled as Eclipse errors
+ */
+ boolean violationsAsErrors() throws PropertiesException;
+
+ /**
+ * @param violationsAsErrors whether high priority violations should be handled as Eclipse errors
+ */
+ void setViolationsAsErrors(boolean violationsAsErrors) throws PropertiesException;
+
+ /**
* Synchronize the properties with the persistant store
*
*/
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/properties/impl/ProjectPropertiesImpl.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/properties/impl/ProjectPropertiesImpl.java 2009-03-28 20:13:21 UTC (rev 6901)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/properties/impl/ProjectPropertiesImpl.java 2009-03-28 20:31:36 UTC (rev 6902)
@@ -76,7 +76,8 @@
private RuleSet projectRuleSet;
private IWorkingSet projectWorkingSet;
private boolean includeDerivedFiles;
-
+ private boolean violationsAsErrors = true;
+
/**
* The default constructor takes a project as an argument
*/
@@ -304,4 +305,17 @@
return clonedRuleSet;
}
+ /**
+ * @see net.sourceforge.pmd.eclipse.runtime.properties.IProjectProperties#violationsAsErrors()
+ */
+ public boolean violationsAsErrors() throws PropertiesException {
+ return this.violationsAsErrors;
+ }
+
+ public void setViolationsAsErrors(boolean violationsAsErrors) throws PropertiesException {
+ log.debug("Set to handle violations as errors: " + violationsAsErrors);
+ this.needRebuild |= this.violationsAsErrors != violationsAsErrors;
+ this.violationsAsErrors = violationsAsErrors;
+ }
+
}
\ No newline at end of file
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/properties/impl/ProjectPropertiesManagerImpl.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/properties/impl/ProjectPropertiesManagerImpl.java 2009-03-28 20:13:21 UTC (rev 6901)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/properties/impl/ProjectPropertiesManagerImpl.java 2009-03-28 20:31:36 UTC (rev 6902)
@@ -213,6 +213,7 @@
projectProperties.setRuleSetStoredInProject(to.isRuleSetStoredInProject());
projectProperties.setPmdEnabled(projectProperties.getProject().hasNature(PMDNature.PMD_NATURE));
projectProperties.setIncludeDerivedFiles(to.isIncludeDerivedFiles());
+ projectProperties.setViolationsAsErrors(to.isViolationsAsErrors());
if (to.isRuleSetStoredInProject()) {
loadRuleSetFromProject(projectProperties);
@@ -301,6 +302,7 @@
bean.setRuleSetFile(projectProperties.getRuleSetFile());
bean.setWorkingSetName(projectProperties.getProjectWorkingSet() == null ? null : projectProperties.getProjectWorkingSet().getName());
bean.setIncludeDerivedFiles(projectProperties.isIncludeDerivedFiles());
+ bean.setViolationsAsErrors(projectProperties.violationsAsErrors());
if (!projectProperties.isRuleSetStoredInProject()) {
final RuleSet ruleSet = projectProperties.getProjectRuleSet();
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/properties/impl/ProjectPropertiesTO.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/properties/impl/ProjectPropertiesTO.java 2009-03-28 20:13:21 UTC (rev 6901)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/properties/impl/ProjectPropertiesTO.java 2009-03-28 20:31:36 UTC (rev 6902)
@@ -51,8 +51,9 @@
private boolean ruleSetStoredInProject;
private String ruleSetFile;
private boolean includeDerivedFiles;
-
- /**
+ private boolean violationsAsErrors = true;
+
+ /**
* @return rules an array of RuleSpecTO objects that keep information of rules
* selected for the current project
*/
@@ -163,4 +164,12 @@
this.includeDerivedFiles = includeDerivedFiles;
}
+ public boolean isViolationsAsErrors() {
+ return violationsAsErrors;
+ }
+
+ public void setViolationsAsErrors(boolean violationsAsErrors) {
+ this.violationsAsErrors = violationsAsErrors;
+ }
+
}
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/properties/impl/mapping.xml
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/properties/impl/mapping.xml 2009-03-28 20:13:21 UTC (rev 6901)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/properties/impl/mapping.xml 2009-03-28 20:31:36 UTC (rev 6902)
@@ -57,6 +57,13 @@
set-method="setIncludeDerivedFiles">
<bind-xml name="includeDerivedFiles" node="element"/>
</field>
+
+ <field name="ViolationsAsErrors"
+ type="boolean"
+ get-method="isViolationsAsErrors"
+ set-method="setViolationsAsErrors">
+ <bind-xml name="violationsAsErrors" node="element"/>
+ </field>
</class>
<class name="net.sourceforge.pmd.eclipse.runtime.properties.impl.RuleSpecTO">
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/nls/StringKeys.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/nls/StringKeys.java 2009-03-28 20:13:21 UTC (rev 6901)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/nls/StringKeys.java 2009-03-28 20:31:36 UTC (rev 6902)
@@ -51,6 +51,7 @@
public static final String MSGKEY_PROPERTY_BUTTON_STORE_RULESET_PROJECT = "property.button.store_ruleset_project";
public static final String MSGKEY_PROPERTY_BUTTON_RULESET_BROWSE = "property.button.ruleset_browse";
public static final String MSGKEY_PROPERTY_BUTTON_INCLUDE_DERIVED_FILES = "property.button.include_derived_files";
+ public static final String MSGKEY_PROPERTY_BUTTON_VIOLATIONS_AS_ERRORS = "property.button.violations_as_errors";
public static final String MSGKEY_PREF_GENERAL_HEADER = "preference.pmd.header";
public static final String MSGKEY_PREF_GENERAL_TITLE = "preference.pmd.title";
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/properties/PMDPropertyPage.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/properties/PMDPropertyPage.java 2009-03-28 20:13:21 UTC (rev 6901)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/properties/PMDPropertyPage.java 2009-03-28 20:31:36 UTC (rev 6902)
@@ -84,6 +84,7 @@
private Label selectedWorkingSetLabel;
private Button deselectWorkingSetButton;
private Button includeDerivedFilesButton;
+ private Button violationsAsErrorsButton;
protected Button ruleSetStoredInProjectButton;
protected Text ruleSetFileText;
protected Button ruleSetBrowseButton;
@@ -125,7 +126,15 @@
data.horizontalAlignment = GridData.FILL;
data.grabExcessHorizontalSpace = true;
separator.setLayoutData(data);
+
+ this.violationsAsErrorsButton = buildViolationsAsErrorsButton(composite);
+ separator = new Label(composite, SWT.SEPARATOR | SWT.SHADOW_IN | SWT.HORIZONTAL);
+ data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ separator.setLayoutData(data);
+
this.selectedWorkingSetLabel = buildSelectedWorkingSetLabel(composite);
data = new GridData();
data.horizontalAlignment = GridData.FILL;
@@ -209,6 +218,18 @@
}
/**
+ * Create the violations as errors checkbox
+ * @param parent the parent composite
+ */
+ private Button buildViolationsAsErrorsButton(final Composite parent) {
+ final Button button = new Button(parent, SWT.CHECK);
+ button.setText(getMessage(StringKeys.MSGKEY_PROPERTY_BUTTON_VIOLATIONS_AS_ERRORS));
+ button.setSelection(model.violationsAsErrors());
+
+ return button;
+ }
+
+ /**
* Create the checkbox for storing configuration in a project file
* @param parent the parent composite
*/
@@ -409,6 +430,8 @@
this.model.setRuleSetFile(this.ruleSetFileText.getText());
this.model.setIncludeDerivedFiles(this.includeDerivedFilesButton.getSelection());
+ this.model.setViolationsAsErrors(this.violationsAsErrorsButton.getSelection());
+
return controller.performOk();
}
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/properties/PMDPropertyPageBean.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/properties/PMDPropertyPageBean.java 2009-03-28 20:13:21 UTC (rev 6901)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/properties/PMDPropertyPageBean.java 2009-03-28 20:31:36 UTC (rev 6902)
@@ -53,6 +53,7 @@
private boolean ruleSetStoredInProject;
private String ruleSetFile;
private boolean includeDerivedFiles;
+ private boolean violationsAsErrors = true;
/**
* @return Returns the pmdEnabled.
@@ -130,11 +131,25 @@
public boolean isIncludeDerivedFiles() {
return includeDerivedFiles;
}
-
+
/**
* @param includeDerivedFiles The includeDerivedFiles to set.
*/
public void setIncludeDerivedFiles(boolean includeDerivedFiles) {
this.includeDerivedFiles = includeDerivedFiles;
}
+
+ /**
+ * @return Returns the violationsAsErrors.
+ */
+ public boolean violationsAsErrors() {
+ return violationsAsErrors;
+ }
+
+ /**
+ * @param setViolationsAsErrors The setViolationsAsErrors to set.
+ */
+ public void setViolationsAsErrors(boolean violationsAsErrors) {
+ this.violationsAsErrors = violationsAsErrors;
+ }
}
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/properties/PMDPropertyPageController.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/properties/PMDPropertyPageController.java 2009-03-28 20:13:21 UTC (rev 6901)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/properties/PMDPropertyPageController.java 2009-03-28 20:31:36 UTC (rev 6902)
@@ -115,6 +115,7 @@
this.propertyPageBean.setRuleSetStoredInProject(properties.isRuleSetStoredInProject());
this.propertyPageBean.setRuleSetFile(properties.getRuleSetFile());
this.propertyPageBean.setIncludeDerivedFiles(properties.isIncludeDerivedFiles());
+ this.propertyPageBean.setViolationsAsErrors(properties.violationsAsErrors());
this.pmdAlreadyActivated = properties.isPmdEnabled();
} catch (PropertiesException e) {
@@ -152,6 +153,7 @@
cmd.setRuleSetStoredInProject(this.propertyPageBean.isRuleSetStoredInProject());
cmd.setRuleSetFile(this.propertyPageBean.getRuleSetFile());
cmd.setIncludeDerivedFiles(this.propertyPageBean.isIncludeDerivedFiles());
+ cmd.setViolationsAsErrors(this.propertyPageBean.violationsAsErrors());
cmd.setUserInitiated(true);
cmd.performExecute();
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/properties/UpdateProjectPropertiesCmd.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/properties/UpdateProjectPropertiesCmd.java 2009-03-28 20:13:21 UTC (rev 6901)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/properties/UpdateProjectPropertiesCmd.java 2009-03-28 20:31:36 UTC (rev 6902)
@@ -64,6 +64,7 @@
private boolean needRebuild;
private boolean ruleSetFileExists;
private boolean includeDerivedFiles;
+ private boolean violationsAsErrors = true;
/**
* Default constructor. Initializes command attributes
@@ -90,6 +91,7 @@
properties.setRuleSetStoredInProject(this.ruleSetStoredInProject);
properties.setRuleSetFile(this.ruleSetFile);
properties.setIncludeDerivedFiles(this.includeDerivedFiles);
+ properties.setViolationsAsErrors(this.violationsAsErrors);
properties.sync();
this.needRebuild = properties.isNeedRebuild();
this.ruleSetFileExists = !properties.isRuleSetFileExist();
@@ -143,7 +145,7 @@
this.ruleSetFile = ruleSetFile;
}
- /**
+ /**
* @param includeDerivedFiles The includeDerivedFiles to set.
*/
public void setIncludeDerivedFiles(boolean includeDerivedFiles) {
@@ -151,6 +153,13 @@
}
/**
+ * @param violationsAsErrors The violationsAsErrors to set.
+ */
+ public void setViolationsAsErrors(boolean violationsAsErrors) {
+ this.violationsAsErrors = violationsAsErrors;
+ }
+
+ /**
* @return Returns the needRebuild.
*/
public boolean isNeedRebuild() {
@@ -174,6 +183,7 @@
this.setRuleSetStoredInProject(false);
this.setRuleSetFile(null);
this.setIncludeDerivedFiles(false);
+ this.setViolationsAsErrors(false);
this.setTerminated(false);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|