From f3c952be2e23d70cb8765aafeb1ad9a730320c07 Mon Sep 17 00:00:00 2001 From: Brian Remedios Date: Wed, 15 Oct 2008 06:12:08 +0000 Subject: [PATCH] Initial upgrade to new property mgmt scheme, much more to follow. git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@6616 51baf565-9d33-0410-a72c-fc3788e3496d --- .../pmd/eclipse/runtime/PMDRuntimeConstants.java | 5 +++-- .../sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java | 7 ++----- .../eclipse/ui/views/ViolationOverviewLabelProvider.java | 5 +++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/PMDRuntimeConstants.java b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/PMDRuntimeConstants.java index 2d4efd90cb..ec15d5afd2 100644 --- a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/PMDRuntimeConstants.java +++ b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/PMDRuntimeConstants.java @@ -1,6 +1,7 @@ package net.sourceforge.pmd.eclipse.runtime; import net.sourceforge.pmd.eclipse.plugin.PMDPlugin; +import net.sourceforge.pmd.lang.rule.properties.IntegerProperty; /** @@ -15,8 +16,8 @@ public class PMDRuntimeConstants { public static final String PMD_DFA_MARKER = PMDPlugin.PLUGIN_ID + ".pmdDFAMarker"; public static final String PMD_TASKMARKER = PMDPlugin.PLUGIN_ID + ".pmdTaskMarker"; - public static final String RULE_PROPERTY_MAXVIOLATIONS = "maxviolations"; - + public static final IntegerProperty MAX_VIOLATIONS_DESCRIPTOR = new IntegerProperty("maxviolations", "Max allowable violations", 1, Integer.MAX_VALUE-1, 1000, 0f); + public static final String ID_PERSPECTIVE = "net.sourceforge.pmd.eclipse.ui.views.pmdPerspective"; public static final String KEY_MARKERATT_RULENAME = "rulename"; diff --git a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java index 1765aae3fb..c93de54759 100644 --- a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java +++ b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java @@ -321,7 +321,7 @@ public class BaseVisitor { final Review review = new Review(); final Iterator iter = context.getReport().iterator(); final IPreferences preferences = PMDPlugin.getDefault().loadPreferences(); - final int maxViolationsPerFilePerRule = preferences.getMaxViolationsPerFilePerRule(); +// final int maxViolationsPerFilePerRule = preferences.getMaxViolationsPerFilePerRule(); final Map violationsCounter = new HashMap(); while (iter.hasNext()) { @@ -339,11 +339,8 @@ public class BaseVisitor { violationsCounter.put(violation.getRule(), counter); } + int maxViolations = violation.getRule().getProperty(PMDRuntimeConstants.MAX_VIOLATIONS_DESCRIPTOR); - int maxViolations = maxViolationsPerFilePerRule; - if (violation.getRule().hasProperty(PMDRuntimeConstants.RULE_PROPERTY_MAXVIOLATIONS)) { - maxViolations = violation.getRule().getIntProperty(PMDRuntimeConstants.RULE_PROPERTY_MAXVIOLATIONS); - } if (counter.intValue() < maxViolations) { // Ryan Gustafson 02/16/2008 - Always use PMD_MARKER, as people get confused as to why PMD problems don't always show up on Problems view like they do when you do build. // markerSet.add(getMarkerInfo(violation, fTask ? PMDRuntimeConstants.PMD_TASKMARKER : PMDRuntimeConstants.PMD_MARKER)); diff --git a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/views/ViolationOverviewLabelProvider.java b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/views/ViolationOverviewLabelProvider.java index 33a0ac95c5..ec94f92571 100644 --- a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/views/ViolationOverviewLabelProvider.java +++ b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/views/ViolationOverviewLabelProvider.java @@ -215,9 +215,10 @@ public class ViolationOverviewLabelProvider extends LabelProvider implements ITa private int getMaxViolations(String ruleName) { int maxViolations = PMDPlugin.getDefault().loadPreferences().getMaxViolationsPerFilePerRule(); final Rule rule = PMDPlugin.getDefault().getPreferencesManager().getRuleSet().getRuleByName(ruleName); - if (rule != null && rule.hasProperty(PMDRuntimeConstants.RULE_PROPERTY_MAXVIOLATIONS)) { - maxViolations = rule.getIntProperty(PMDRuntimeConstants.RULE_PROPERTY_MAXVIOLATIONS); + if (rule != null) { + return rule.getProperty(PMDRuntimeConstants.MAX_VIOLATIONS_DESCRIPTOR); } + return maxViolations; }