Revision: 6742
http://pmd.svn.sourceforge.net/pmd/?rev=6742&view=rev
Author: rgustav
Date: 2008-12-05 07:55:16 +0000 (Fri, 05 Dec 2008)
Log Message:
-----------
Open things up to support files other than .java files. This includes:
1) Allow the PMD context menu on any File type, not just *.java.
2) Modify some places which check for a .java extension to _not_ do so.
3) Modify some places to check with the PMDEngine whether a File "applies" (e.g. is it for a Language which is understood by PMD and are there any Rules in the RuleSet for that Language).
Expand the Rule table to have a Language column in the 1st column. The table setup in this plugin/SWT still *sucks* as bad I remember it being the last time I added columns.
With these changes I can get both JS and XML Rules to work. Violations show up, and for JS, I can be brought to the proper line number in the code!
Also fixed and issue with this plugin looking for a "maxViolations" property on the Rules, which given PMD 5.0 changes to require a propery to exist to ask for a value... needed some tweaking to first check for the value on the Rule. More verbose, but a safer API than the Wild West style of pre-5.0.
The Rule Editor needs some work to account for the new structure of Rules in PMD 5.0. Currently any Rule it creates causes things to blow up due to missing Language. Easy enough to fix, but it's just the 1st of several things needing to be corrected.
Modified Paths:
--------------
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/messages.properties
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/nl/fr/messages.properties
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/plugin.xml
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/plugin/PMDPlugin.java
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/PMDEngine.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/ReviewResourceForRuleCommand.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/model/PackageRecord.java
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/preferences/PMDPreferencePage.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/RuleCellModifier.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/RuleLabelProvider.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/RuleSetSelectionDialog.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/RuleTableViewerSorter.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/views/ViolationOverviewLabelProvider.java
Removed Paths:
-------------
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/core/PluginConstants.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 2008-12-05 07:43:25 UTC (rev 6741)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/messages.properties 2008-12-05 07:55:16 UTC (rev 6742)
@@ -44,6 +44,7 @@
preference.ruleset.label.rulepropstable = Rule properties
preference.ruleset.label.exclude_patterns_table = Exclude patterns
preference.ruleset.label.include_patterns_table = Include patterns
+preference.ruleset.column.language = Language
preference.ruleset.column.ruleset_name = Rule set name
preference.ruleset.column.rule_name = Rule name
preference.ruleset.column.since = Since
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/nl/fr/messages.properties
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/nl/fr/messages.properties 2008-12-05 07:43:25 UTC (rev 6741)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/nl/fr/messages.properties 2008-12-05 07:55:16 UTC (rev 6742)
@@ -44,6 +44,7 @@
preference.ruleset.label.rulepropstable = Propri\xE9t\xE9s de la r\xE8gle
preference.ruleset.label.exclude_patterns_table = Sch\xE9ma d'exclusion
preference.ruleset.label.include_patterns_table = Sch\xE9ma d'inclusion
+preference.ruleset.column.language = Langage
preference.ruleset.column.ruleset_name = Ensemble de r\xE8gles nom
preference.ruleset.column.rule_name = R\xE8gle nom
preference.ruleset.column.since = Depuis
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/plugin.xml
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/plugin.xml 2008-12-05 07:43:25 UTC (rev 6741)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/plugin.xml 2008-12-05 07:55:16 UTC (rev 6742)
@@ -226,7 +226,7 @@
<objectContribution
objectClass="org.eclipse.core.resources.IFile"
adaptable="true"
- nameFilter="*.java"
+ nameFilter="*"
id="net.sourceforge.pmd.eclipse.ui.pmdFileContribution">
<menu
label="%menu.pmd"
Deleted: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/core/PluginConstants.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/core/PluginConstants.java 2008-12-05 07:43:25 UTC (rev 6741)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/core/PluginConstants.java 2008-12-05 07:55:16 UTC (rev 6742)
@@ -1,79 +0,0 @@
-/*
- * Created on 7 juin 2005
- *
- * Copyright (c) 2005, PMD for Eclipse Development Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * The end-user documentation included with the redistribution, if
- * any, must include the following acknowledgement:
- * "This product includes software developed in part by support from
- * the Defense Advanced Research Project Agency (DARPA)"
- * * Neither the name of "PMD for Eclipse Development Team" nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package net.sourceforge.pmd.eclipse.core;
-
-/**
- * This interface is a container for all the constants of the plugin
- *
- * @author Philippe Herlin
- */
-public class PluginConstants {
-
- private static final String PMD_JAVA_RULESET_PATH = "rulesets/java/";
-
- public static final String[] PMD_JAVA_RULESETS = {
- PMD_JAVA_RULESET_PATH + "basic.xml",
- PMD_JAVA_RULESET_PATH + "braces.xml",
- PMD_JAVA_RULESET_PATH + "clone.xml",
- PMD_JAVA_RULESET_PATH + "codesize.xml",
- PMD_JAVA_RULESET_PATH + "controversial.xml",
- PMD_JAVA_RULESET_PATH + "rulesets/coupling.xml",
- PMD_JAVA_RULESET_PATH + "design.xml",
- PMD_JAVA_RULESET_PATH + "finalizers.xml",
- PMD_JAVA_RULESET_PATH + "imports.xml",
- PMD_JAVA_RULESET_PATH + "j2ee.xml",
- PMD_JAVA_RULESET_PATH + "javabeans.xml",
- PMD_JAVA_RULESET_PATH + "junit.xml",
- PMD_JAVA_RULESET_PATH + "logging-jakarta-commons.xml",
- PMD_JAVA_RULESET_PATH + "logging-java.xml",
- PMD_JAVA_RULESET_PATH + "migrating.xml",
- PMD_JAVA_RULESET_PATH + "naming.xml",
- PMD_JAVA_RULESET_PATH + "optimizations.xml",
- PMD_JAVA_RULESET_PATH + "strictexception.xml",
- PMD_JAVA_RULESET_PATH + "strings.xml",
- PMD_JAVA_RULESET_PATH + "sunsecure.xml",
- PMD_JAVA_RULESET_PATH + "typeresolution.xml",
- PMD_JAVA_RULESET_PATH + "unusedcode.xml"
- };
-
- /**
- * This class is not meant to be instantiated
- *
- */
- private PluginConstants() {
- super();
- }
-}
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/plugin/PMDPlugin.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/plugin/PMDPlugin.java 2008-12-05 07:43:25 UTC (rev 6741)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/plugin/PMDPlugin.java 2008-12-05 07:55:16 UTC (rev 6742)
@@ -1,12 +1,12 @@
package net.sourceforge.pmd.eclipse.plugin;
import java.io.IOException;
+import java.util.Iterator;
import net.sourceforge.pmd.RuleSet;
import net.sourceforge.pmd.RuleSetFactory;
import net.sourceforge.pmd.RuleSetNotFoundException;
import net.sourceforge.pmd.eclipse.core.IRuleSetManager;
-import net.sourceforge.pmd.eclipse.core.PluginConstants;
import net.sourceforge.pmd.eclipse.core.ext.RuleSetsExtensionProcessor;
import net.sourceforge.pmd.eclipse.core.impl.RuleSetManagerImpl;
import net.sourceforge.pmd.eclipse.runtime.preferences.IPreferences;
@@ -335,14 +335,15 @@
*/
private void registerStandardRuleSets() {
final RuleSetFactory factory = new RuleSetFactory();
- for (int i = 0; i < PluginConstants.PMD_JAVA_RULESETS.length; i++) {
- try {
- final RuleSet ruleSet = factory.createRuleSets(PluginConstants.PMD_JAVA_RULESETS[i]).getAllRuleSets()[0];
+ try {
+ Iterator<RuleSet> iterator = factory.getRegisteredRuleSets();
+ while (iterator.hasNext()) {
+ final RuleSet ruleSet = iterator.next();
getRuleSetManager().registerRuleSet(ruleSet);
getRuleSetManager().registerDefaultRuleSet(ruleSet);
- } catch (RuleSetNotFoundException e) {
- this.log(IStatus.WARNING, "The RuleSet \"" + PluginConstants.PMD_JAVA_RULESETS[i] + "\" cannot be found", e);
}
+ } catch (RuleSetNotFoundException e) {
+ this.log(IStatus.WARNING, "Problem getting all registered PMD RuleSets", e);
}
}
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 2008-12-05 07:43:25 UTC (rev 6741)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java 2008-12-05 07:55:16 UTC (rev 6742)
@@ -23,6 +23,7 @@
package net.sourceforge.pmd.eclipse.runtime.cmd;
import java.io.BufferedReader;
+import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
@@ -230,7 +231,7 @@
*/
protected final void reviewResource(final IResource resource) {
final IFile file = (IFile) resource.getAdapter(IFile.class);
- if (file != null && file.getFileExtension() != null && file.getFileExtension().equals("java")) {
+ if (file != null && file.getFileExtension() != null) {
try {
boolean included = this.projectProperties.isIncludeDerivedFiles() || !this.projectProperties.isIncludeDerivedFiles() && !file.isDerived();
@@ -238,13 +239,14 @@
log.debug("file " + file.getName() + " is derived: " + file.isDerived());
log.debug("file checked: " + included);
- if (isFileInWorkingSet(file) && (this.projectProperties.isIncludeDerivedFiles() || !this.projectProperties.isIncludeDerivedFiles() && !file.isDerived())) {
+ final File sourceCodeFile = file.getRawLocation().toFile();
+ if (getPmdEngine().applies(sourceCodeFile, getRuleSet()) && isFileInWorkingSet(file) && (this.projectProperties.isIncludeDerivedFiles() || !this.projectProperties.isIncludeDerivedFiles() && !file.isDerived())) {
subTask("PMD Checking file " + file.getName());
Timer timer = new Timer();
final RuleContext context = new RuleContext();
- context.setSourceCodeFile(file.getRawLocation().toFile());
+ context.setSourceCodeFile(sourceCodeFile);
context.setSourceCodeFilename(file.getName());
context.setReport(new Report());
@@ -339,7 +341,10 @@
violationsCounter.put(violation.getRule(), counter);
}
- int maxViolations = violation.getRule().getProperty(PMDRuntimeConstants.MAX_VIOLATIONS_DESCRIPTOR);
+ int maxViolations = PMDRuntimeConstants.MAX_VIOLATIONS_DESCRIPTOR.defaultValue();
+ if (violation.getRule().hasDescriptor(PMDRuntimeConstants.MAX_VIOLATIONS_DESCRIPTOR)) {
+ maxViolations = violation.getRule().getProperty(PMDRuntimeConstants.MAX_VIOLATIONS_DESCRIPTOR);
+ }
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.
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/PMDEngine.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/PMDEngine.java 2008-12-05 07:43:25 UTC (rev 6741)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/PMDEngine.java 2008-12-05 07:55:16 UTC (rev 6742)
@@ -1,5 +1,6 @@
package net.sourceforge.pmd.eclipse.runtime.cmd;
+import java.io.File;
import java.io.Reader;
import net.sourceforge.pmd.Configuration;
@@ -33,6 +34,10 @@
return configuration.getClassLoader();
}
+ public boolean applies(File file, RuleSet ruleSet) {
+ return ruleSet.applies(file);
+ }
+
public void processFile(Reader input, RuleSet ruleSet, RuleContext context) throws PMDException {
RuleSets set = new RuleSets();
set.addRuleSet(ruleSet);
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/ReviewResourceForRuleCommand.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/ReviewResourceForRuleCommand.java 2008-12-05 07:43:25 UTC (rev 6741)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/ReviewResourceForRuleCommand.java 2008-12-05 07:55:16 UTC (rev 6742)
@@ -36,6 +36,7 @@
package net.sourceforge.pmd.eclipse.runtime.cmd;
+import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
@@ -123,36 +124,38 @@
final IFile file = (IFile) resource.getAdapter(IFile.class);
beginTask("PMD Checking for specific rule...", 1);
- if (file != null && "java".equals(file.getFileExtension())) {
+ if (file != null) {
final RuleSet ruleSet = new RuleSet();
ruleSet.addRule(rule);
final PMDEngine pmdEngine = getPmdEngineForProject(project);
-
- try {
- this.context = new RuleContext();
- this.context.setSourceCodeFile(file.getFullPath().toFile());
- this.context.setSourceCodeFilename(file.getName());
- this.context.setReport(new Report());
-
- final Reader input = new InputStreamReader(file.getContents(), file.getCharset());
- pmdEngine.processFile(input, ruleSet, this.context);
- input.close();
- } catch (CoreException e) {
- throw new CommandException(e);
- } catch (PMDException e) {
- throw new CommandException(e);
- } catch (IOException e) {
- throw new CommandException(e);
+ final File sourceCodeFile = file.getFullPath().toFile();
+ if (pmdEngine.applies(sourceCodeFile, ruleSet)) {
+ try {
+ this.context = new RuleContext();
+ this.context.setSourceCodeFile(sourceCodeFile);
+ this.context.setSourceCodeFilename(file.getName());
+ this.context.setReport(new Report());
+
+ final Reader input = new InputStreamReader(file.getContents(), file.getCharset());
+ pmdEngine.processFile(input, ruleSet, this.context);
+ input.close();
+ } catch (CoreException e) {
+ throw new CommandException(e);
+ } catch (PMDException e) {
+ throw new CommandException(e);
+ } catch (IOException e) {
+ throw new CommandException(e);
+ }
+
+ // trigger event propertyChanged for all listeners
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ for (IPropertyListener listener: listenerList) {
+ listener.propertyChanged(context.getReport().iterator(), PMDRuntimeConstants.PROPERTY_REVIEW);
+ }
+ }
+ });
}
-
- // trigger event propertyChanged for all listeners
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- for (IPropertyListener listener: listenerList) {
- listener.propertyChanged(context.getReport().iterator(), PMDRuntimeConstants.PROPERTY_REVIEW);
- }
- }
- });
}
}
}
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/model/PackageRecord.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/model/PackageRecord.java 2008-12-05 07:43:25 UTC (rev 6741)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/model/PackageRecord.java 2008-12-05 07:55:16 UTC (rev 6742)
@@ -151,11 +151,12 @@
*/
@Override
public AbstractPMDRecord addResource(IResource resource) {
- final ICompilationUnit unit = this.packageFragment.getCompilationUnit(resource.getName());
+ //final ICompilationUnit unit = this.packageFragment.getCompilationUnit(resource.getName());
FileRecord file = null;
+ // TODO This should be more question of whether PMD is interested in the File!
// we want the File to be a java-File
- if (unit != null) {
+// if (unit != null) {
// we create a new FileRecord and add it to the List
file = new FileRecord(resource, this);
final List<AbstractPMDRecord> files = getChildrenAsList();
@@ -163,7 +164,7 @@
this.children = new AbstractPMDRecord[files.size()];
files.toArray(this.children);
- }
+// }
return file;
}
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 2008-12-05 07:43:25 UTC (rev 6741)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/nls/StringKeys.java 2008-12-05 07:55:16 UTC (rev 6742)
@@ -82,6 +82,7 @@
public static final String MSGKEY_PREF_RULESET_LABEL_RULEPROPSTABLE = "preference.ruleset.label.rulepropstable";
public static final String MSGKEY_PREF_RULESET_LABEL_EXCLUDE_PATTERNS_TABLE = "preference.ruleset.label.exclude_patterns_table";
public static final String MSGKEY_PREF_RULESET_LABEL_INCLUDE_PATTERNS_TABLE = "preference.ruleset.label.include_patterns_table";
+ public static final String MSGKEY_PREF_RULESET_COLUMN_LANGUAGE = "preference.ruleset.column.language";
public static final String MSGKEY_PREF_RULESET_COLUMN_RULESET_NAME = "preference.ruleset.column.ruleset_name";
public static final String MSGKEY_PREF_RULESET_COLUMN_RULE_NAME = "preference.ruleset.column.rule_name";
public static final String MSGKEY_PREF_RULESET_COLUMN_SINCE = "preference.ruleset.column.since";
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/PMDPreferencePage.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/PMDPreferencePage.java 2008-12-05 07:43:25 UTC (rev 6741)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/PMDPreferencePage.java 2008-12-05 07:55:16 UTC (rev 6742)
@@ -60,6 +60,7 @@
*/
public class PMDPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+ public static final String PROPERTY_LANGUAGE = "language";
public static final String PROPERTY_RULESET_NAME = "ruleSetname";
public static final String PROPERTY_RULE_NAME = "ruleName";
public static final String PROPERTY_SINCE = "since";
@@ -332,6 +333,8 @@
ruleTableViewer = new TableViewer(parent, tableStyle);
Table ruleTable = ruleTableViewer.getTable();
+ addColumnTo(ruleTable, SWT.LEFT, true, getMessage(StringKeys.MSGKEY_PREF_RULESET_COLUMN_LANGUAGE), 70,
+ RuleTableViewerSorter.RULE_LANGUAGE_COMPARATOR);
addColumnTo(ruleTable, SWT.LEFT, true, getMessage(StringKeys.MSGKEY_PREF_RULESET_COLUMN_RULESET_NAME), 110,
RuleTableViewerSorter.RULE_RULESET_NAME_COMPARATOR);
addColumnTo(ruleTable, SWT.LEFT, true, getMessage(StringKeys.MSGKEY_PREF_RULESET_COLUMN_RULE_NAME), 170,
@@ -363,10 +366,10 @@
}
});
- ruleTableViewer.setColumnProperties(new String[] { PROPERTY_RULESET_NAME, PROPERTY_RULE_NAME, PROPERTY_SINCE,
+ ruleTableViewer.setColumnProperties(new String[] { PROPERTY_LANGUAGE, PROPERTY_RULESET_NAME, PROPERTY_RULE_NAME, PROPERTY_SINCE,
PROPERTY_PRIORITY, PROPERTY_DESCRIPTION });
ruleTableViewer.setCellModifier(new RuleCellModifier(ruleTableViewer));
- ruleTableViewer.setCellEditors(new CellEditor[] { null, null, null,
+ ruleTableViewer.setCellEditors(new CellEditor[] { null, null, null, null,
new ComboBoxCellEditor(ruleTable, PMDPlugin.getDefault().getPriorityLabels()),
new TextCellEditor(ruleTable) });
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/RuleCellModifier.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/RuleCellModifier.java 2008-12-05 07:43:25 UTC (rev 6741)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/RuleCellModifier.java 2008-12-05 07:55:16 UTC (rev 6742)
@@ -41,7 +41,9 @@
if (element instanceof Rule) {
Rule rule = (Rule) element;
- if (property.equalsIgnoreCase(PMDPreferencePage.PROPERTY_RULESET_NAME)) {
+ if (property.equalsIgnoreCase(PMDPreferencePage.PROPERTY_LANGUAGE)) {
+ result = rule.getLanguage().getShortName();
+ } else if (property.equalsIgnoreCase(PMDPreferencePage.PROPERTY_RULESET_NAME)) {
result = rule.getRuleSetName();
} else if (property.equalsIgnoreCase(PMDPreferencePage.PROPERTY_RULE_NAME)) {
result = rule.getName();
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/RuleLabelProvider.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/RuleLabelProvider.java 2008-12-05 07:43:25 UTC (rev 6741)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/RuleLabelProvider.java 2008-12-05 07:55:16 UTC (rev 6742)
@@ -22,6 +22,8 @@
if (element instanceof Rule) {
Rule rule = (Rule) element;
if (columnIndex == 0) {
+ result = rule.getLanguage().getShortName();
+ } else if (columnIndex == 1) {
result = rule.getRuleSetName();
/*
if (rule instanceof RuleReference) {
@@ -32,18 +34,18 @@
}
}
*/
- } else if (columnIndex == 1) {
+ } else if (columnIndex == 2) {
result = rule.getName();
- } else if (columnIndex == 2) {
+ } else if (columnIndex == 3) {
result = rule.getSince();
result = (result == null) ? "n/a" : result;
- } else if (columnIndex == 3) {
+ } else if (columnIndex == 4) {
if ((rule.getPriority().getPriority() <= PRIORITY_LABEL.length) && (rule.getPriority().getPriority() > 0)) {
result = PRIORITY_LABEL[rule.getPriority().getPriority() - 1];
} else {
result = PRIORITY_ILLEGAL;
}
- } else if (columnIndex == 4) {
+ } else if (columnIndex == 5) {
result = rule.getDescription();
result = (result == null) ? "" : result.trim();
}
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/RuleSetSelectionDialog.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/RuleSetSelectionDialog.java 2008-12-05 07:43:25 UTC (rev 6741)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/RuleSetSelectionDialog.java 2008-12-05 07:55:16 UTC (rev 6742)
@@ -69,6 +69,9 @@
while (i.hasNext()) {
ruleSets[index] = i.next();
ruleSetNames[index] = ruleSets[index].getName();
+ if (!ruleSets[index].getRules().isEmpty()) {
+ ruleSetNames[index] = ruleSets[index].getRules().iterator().next().getLanguage().getShortName() + " - " + ruleSetNames[index];
+ }
index++;
}
}
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/RuleTableViewerSorter.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/RuleTableViewerSorter.java 2008-12-05 07:43:25 UTC (rev 6741)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/RuleTableViewerSorter.java 2008-12-05 07:55:16 UTC (rev 6742)
@@ -64,8 +64,17 @@
};
/**
- * Rule Name comparator for tabular display of Rules.
+ * Rule Language comparator for tabular display of Rules.
*/
+ public static final Comparator<Rule> RULE_LANGUAGE_COMPARATOR = new Comparator<Rule>() {
+ public int compare(Rule r1, Rule r2) {
+ return r1.getLanguage().compareTo(r2.getLanguage());
+ }
+ };
+
+ /**
+ * RuleSet Name comparator for tabular display of Rules.
+ */
public static final Comparator<Rule> RULE_RULESET_NAME_COMPARATOR = new Comparator<Rule>() {
public int compare(Rule r1, Rule r2) {
return compareStrings(r1.getRuleSetName(), r2.getRuleSetName());
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 2008-12-05 07:43:25 UTC (rev 6741)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/properties/PMDPropertyPage.java 2008-12-05 07:55:16 UTC (rev 6742)
@@ -296,9 +296,10 @@
final Table ruleTable = availableRulesTableViewer.getTable();
+ addColumnTo(ruleTable, SWT.LEFT, true, getMessage(StringKeys.MSGKEY_PREF_RULESET_COLUMN_LANGUAGE), 70 + 20, RuleTableViewerSorter.RULE_LANGUAGE_COMPARATOR);
addColumnTo(ruleTable, SWT.LEFT, true, getMessage(StringKeys.MSGKEY_PREF_RULESET_COLUMN_RULESET_NAME), 110, RuleTableViewerSorter.RULE_RULESET_NAME_COMPARATOR);
addColumnTo(ruleTable, SWT.LEFT, true, getMessage(StringKeys.MSGKEY_PREF_RULESET_COLUMN_RULE_NAME), 170, RuleTableViewerSorter.RULE_NAME_COMPARATOR);
- addColumnTo(ruleTable, SWT.LEFT, false, getMessage(StringKeys.MSGKEY_PREF_RULESET_COLUMN_SINCE), 40, RuleTableViewerSorter.RULE_SINCE_COMPARATOR);
+ addColumnTo(ruleTable, SWT.LEFT, false, getMessage(StringKeys.MSGKEY_PREF_RULESET_COLUMN_SINCE), 40, RuleTableViewerSorter.RULE_SINCE_COMPARATOR);
addColumnTo(ruleTable, SWT.LEFT, false, getMessage(StringKeys.MSGKEY_PREF_RULESET_COLUMN_PRIORITY), 80, RuleTableViewerSorter.RULE_PRIORITY_COMPARATOR);
addColumnTo(ruleTable, SWT.LEFT, true, getMessage(StringKeys.MSGKEY_PREF_RULESET_COLUMN_DESCRIPTION), 300, RuleTableViewerSorter.RULE_DESCRIPTION_COMPARATOR);
@@ -310,6 +311,7 @@
this.availableRulesTableViewer.setSorter(this.availableRuleTableViewerSorter);
this.availableRulesTableViewer.setColumnProperties(
new String[] {
+ PMDPreferencePage.PROPERTY_LANGUAGE,
PMDPreferencePage.PROPERTY_RULESET_NAME,
PMDPreferencePage.PROPERTY_RULE_NAME,
PMDPreferencePage.PROPERTY_SINCE,
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/views/ViolationOverviewLabelProvider.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/views/ViolationOverviewLabelProvider.java 2008-12-05 07:43:25 UTC (rev 6741)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/views/ViolationOverviewLabelProvider.java 2008-12-05 07:55:16 UTC (rev 6742)
@@ -216,7 +216,11 @@
int maxViolations = PMDPlugin.getDefault().loadPreferences().getMaxViolationsPerFilePerRule();
final Rule rule = PMDPlugin.getDefault().getPreferencesManager().getRuleSet().getRuleByName(ruleName);
if (rule != null) {
+ if (rule.hasDescriptor(PMDRuntimeConstants.MAX_VIOLATIONS_DESCRIPTOR)) {
return rule.getProperty(PMDRuntimeConstants.MAX_VIOLATIONS_DESCRIPTOR);
+ } else {
+ return PMDRuntimeConstants.MAX_VIOLATIONS_DESCRIPTOR.defaultValue();
+ }
}
return maxViolations;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|