code cleanup: generics warnings since code is now compiled with java 1.5
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@6606 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
1 parent
35088adb03
commit
4cd2019c00
54 files changed
+1223
-1095
No files matched your search
+1
-1
@@ -133,7 +133,7 @@ public abstract class AbstractProcessableCommand implements Command {
|
||||
try {
|
||||
final ResourceBundle bundle = ResourceBundle.getBundle(CommandProcessorStrategy.COMMAND_PROCESSOR_STRATEGY_BUNDLE);
|
||||
final String strategyClassName = bundle.getString(CommandProcessorStrategy.STRATEGY_CLASS_KEY);
|
||||
final Class strategyClass = Class.forName(strategyClassName);
|
||||
final Class<?> strategyClass = Class.forName(strategyClassName);
|
||||
|
||||
strategy = (CommandProcessorStrategy) strategyClass.newInstance();
|
||||
|
||||
|
||||
+10
-10
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Patterns Library - Implementation of various design patterns
|
||||
* Copyright (C) 2004 Philippe Herlin
|
||||
* Copyright (C) 2004 Philippe Herlin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Lesser General Public License as published by the Free
|
||||
@@ -13,10 +13,10 @@
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this library; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Contact: philippe_herlin@yahoo.fr
|
||||
*
|
||||
* Contact: philippe_herlin@yahoo.fr
|
||||
*
|
||||
*/
|
||||
package name.herlin.command;
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.util.ResourceBundle;
|
||||
*/
|
||||
public class DefaultCommandProcessorStrategy implements CommandProcessorStrategy {
|
||||
private static final CommandProcessor DEFAULT_COMMAND_PROCESSOR = new DefaultCommandProcessor();
|
||||
private final Map registeredCommandProcessors = new Hashtable();
|
||||
private final Map<String, String> registeredCommandProcessors = new Hashtable<String, String>();
|
||||
|
||||
/**
|
||||
* Default constructor. Load registered command from bundle.
|
||||
@@ -48,7 +48,7 @@ public class DefaultCommandProcessorStrategy implements CommandProcessorStrategy
|
||||
* @return a processor for the specified command according to the strategy.
|
||||
*/
|
||||
public CommandProcessor getCommandProcessor(final AbstractProcessableCommand aCommand) {
|
||||
CommandProcessor aProcessor = getRegisteredCommandProcessor(aCommand);
|
||||
CommandProcessor aProcessor = getRegisteredCommandProcessor(aCommand);
|
||||
|
||||
if (aProcessor == null) {
|
||||
aProcessor = aCommand.getPreferredCommandProcessor();
|
||||
@@ -70,9 +70,9 @@ public class DefaultCommandProcessorStrategy implements CommandProcessorStrategy
|
||||
CommandProcessor aProcessor = null;
|
||||
|
||||
try {
|
||||
final String processorClassName = (String) this.registeredCommandProcessors.get(aCommand.getName());
|
||||
final String processorClassName = this.registeredCommandProcessors.get(aCommand.getName());
|
||||
if (processorClassName != null) {
|
||||
final Class clazz = Class.forName(processorClassName);
|
||||
final Class<?> clazz = Class.forName(processorClassName);
|
||||
aProcessor = (CommandProcessor) clazz.newInstance();
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
@@ -97,9 +97,9 @@ public class DefaultCommandProcessorStrategy implements CommandProcessorStrategy
|
||||
private void loadBundle() {
|
||||
try {
|
||||
final ResourceBundle bundle = ResourceBundle.getBundle(COMMAND_PROCESSOR_STRATEGY_BUNDLE);
|
||||
final Enumeration e = bundle.getKeys();
|
||||
final Enumeration<String> e = bundle.getKeys();
|
||||
while (e.hasMoreElements()) {
|
||||
final String key = (String) e.nextElement();
|
||||
final String key = e.nextElement();
|
||||
final String value = bundle.getString(key);
|
||||
this.registeredCommandProcessors.put(key, value);
|
||||
}
|
||||
|
||||
+9
-9
@@ -7,7 +7,7 @@
|
||||
* 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
|
||||
@@ -20,7 +20,7 @@
|
||||
* * 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
|
||||
@@ -41,7 +41,7 @@ import net.sourceforge.pmd.RuleSet;
|
||||
|
||||
/**
|
||||
* Interface for a rule set manager. A RuleSetManager handle a set of rule sets.
|
||||
*
|
||||
*
|
||||
* @author Philippe Herlin
|
||||
*
|
||||
*/
|
||||
@@ -51,24 +51,24 @@ public interface IRuleSetManager {
|
||||
* @param ruleSet the ruleset to register
|
||||
*/
|
||||
void registerRuleSet(RuleSet ruleSet);
|
||||
|
||||
|
||||
/**
|
||||
* Unregister a rule set
|
||||
* @param ruleSet the ruleset to unregister
|
||||
*/
|
||||
void unregisterRuleSet(RuleSet ruleSet);
|
||||
|
||||
|
||||
/**
|
||||
* @return a set of registered ruleset; this can be empty but never null
|
||||
*/
|
||||
Set getRegisteredRuleSets();
|
||||
|
||||
Set<RuleSet> getRegisteredRuleSets();
|
||||
|
||||
/**
|
||||
* Register a rule set for the default set
|
||||
* @param ruleSet the ruleset to register
|
||||
*/
|
||||
void registerDefaultRuleSet(RuleSet ruleSet);
|
||||
|
||||
|
||||
/**
|
||||
* Unregister a rule set from the default set
|
||||
* @param ruleSet the ruleset to unregister
|
||||
@@ -78,5 +78,5 @@ public interface IRuleSetManager {
|
||||
/**
|
||||
* @return the plugin default ruleset set
|
||||
*/
|
||||
Set getDefaultRuleSets();
|
||||
Set<RuleSet> getDefaultRuleSets();
|
||||
}
|
||||
+11
-9
@@ -7,7 +7,7 @@
|
||||
* 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
|
||||
@@ -20,7 +20,7 @@
|
||||
* * 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
|
||||
@@ -38,25 +38,27 @@ package net.sourceforge.pmd.eclipse.core;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.sourceforge.pmd.RuleSet;
|
||||
|
||||
/**
|
||||
* This is the interface for implementors of the RuleSets extension point.
|
||||
*
|
||||
*
|
||||
* @author Herlin
|
||||
*
|
||||
*/
|
||||
|
||||
public interface IRuleSetsExtension {
|
||||
|
||||
|
||||
/**
|
||||
* Allows an extension to add more rules to to completly replace the sets of rulesets.
|
||||
* Allows an extension to add more rules to to completely replace the sets of rulesets.
|
||||
* @param registeredRuleSet the already registered rulesets (modifiable set)
|
||||
*/
|
||||
void registerRuleSets(Set registeredRuleSets);
|
||||
|
||||
void registerRuleSets(Set<RuleSet> registeredRuleSets);
|
||||
|
||||
/**
|
||||
* Allows an extension to specify rulesets that has to be loaded when no rulesets has been defined
|
||||
* for the plugin (for instance, after creating a new worspace)
|
||||
* for the plugin (for instance, after creating a new workspace)
|
||||
* @param defaultRuleSets the set of default rulesets (modifiable set)
|
||||
*/
|
||||
void registerDefaultRuleSets(Set defaultRuleSets);
|
||||
void registerDefaultRuleSets(Set<RuleSet> defaultRuleSets);
|
||||
}
|
||||
+16
-16
@@ -7,7 +7,7 @@
|
||||
* 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
|
||||
@@ -20,7 +20,7 @@
|
||||
* * 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
|
||||
@@ -42,22 +42,22 @@ import net.sourceforge.pmd.RuleSet;
|
||||
import net.sourceforge.pmd.eclipse.core.IRuleSetManager;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author Philippe Herlin
|
||||
*
|
||||
*/
|
||||
public class RuleSetManagerImpl implements IRuleSetManager {
|
||||
private final Set ruleSets = new HashSet();
|
||||
private final Set defaultRuleSets = new HashSet();
|
||||
private final Set<RuleSet> ruleSets = new HashSet<RuleSet>();
|
||||
private final Set<RuleSet> defaultRuleSets = new HashSet<RuleSet>();
|
||||
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.core.IRuleSetManager#getRegisteredRuleSets()
|
||||
*/
|
||||
public Set getRegisteredRuleSets() {
|
||||
public Set<RuleSet> getRegisteredRuleSets() {
|
||||
return this.ruleSets;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.core.IRuleSetManager#registerRuleSet(net.sourceforge.pmd.RuleSet)
|
||||
*/
|
||||
@@ -65,10 +65,10 @@ public class RuleSetManagerImpl implements IRuleSetManager {
|
||||
if (ruleSet == null) {
|
||||
throw new IllegalArgumentException("ruleSet cannot be null"); // TODO NLS // NOPMD by Herlin on 20/06/06 22:56
|
||||
}
|
||||
|
||||
|
||||
this.ruleSets.add(ruleSet);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.core.IRuleSetManager#unregisterRuleSet(net.sourceforge.pmd.RuleSet)
|
||||
*/
|
||||
@@ -76,17 +76,17 @@ public class RuleSetManagerImpl implements IRuleSetManager {
|
||||
if (ruleSet == null) {
|
||||
throw new IllegalArgumentException("ruleSet cannot be null"); // TODO NLS
|
||||
}
|
||||
|
||||
|
||||
this.ruleSets.remove(ruleSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.core.IRuleSetManager#getDefaultRuleSets()
|
||||
*/
|
||||
public Set getDefaultRuleSets() {
|
||||
public Set<RuleSet> getDefaultRuleSets() {
|
||||
return this.defaultRuleSets;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.core.IRuleSetManager#registerDefaultRuleSet(net.sourceforge.pmd.RuleSet)
|
||||
*/
|
||||
@@ -94,10 +94,10 @@ public class RuleSetManagerImpl implements IRuleSetManager {
|
||||
if (ruleSet == null) {
|
||||
throw new IllegalArgumentException("ruleSet cannot be null"); // TODO NLS
|
||||
}
|
||||
|
||||
|
||||
this.defaultRuleSets.add(ruleSet);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.core.IRuleSetManager#unregisterDefaultRuleSet(net.sourceforge.pmd.RuleSet)
|
||||
*/
|
||||
@@ -105,7 +105,7 @@ public class RuleSetManagerImpl implements IRuleSetManager {
|
||||
if (ruleSet == null) {
|
||||
throw new IllegalArgumentException("ruleSet cannot be null"); // TODO NLS
|
||||
}
|
||||
|
||||
|
||||
this.defaultRuleSets.remove(ruleSet);
|
||||
}
|
||||
}
|
||||
+9
-10
@@ -7,7 +7,7 @@
|
||||
* 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
|
||||
@@ -20,7 +20,7 @@
|
||||
* * 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
|
||||
@@ -64,7 +64,7 @@ import org.exolab.castor.xml.ValidationException;
|
||||
/**
|
||||
* Implementation of an IRuleSetsManager.
|
||||
* The serialization is based on the usage of Castor.
|
||||
*
|
||||
*
|
||||
* @author Herlin
|
||||
*
|
||||
*/
|
||||
@@ -82,7 +82,7 @@ public class RuleSetsManagerImpl implements IRuleSetsManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuleSetNotFoundException
|
||||
* @throws RuleSetNotFoundException
|
||||
* @see net.sourceforge.pmd.eclipse.core.rulesets.IRuleSetsManager#valueOf(java.lang.String[])
|
||||
*/
|
||||
public RuleSet valueOf(String[] ruleSetUrls) throws PMDCoreException {
|
||||
@@ -96,19 +96,18 @@ public class RuleSetsManagerImpl implements IRuleSetsManager {
|
||||
|
||||
try {
|
||||
final RuleSet ruleSet = new RuleSet();
|
||||
|
||||
|
||||
for (int i = 0; i < ruleSetUrls.length; i++) {
|
||||
final RuleSetFactory factory = new RuleSetFactory(); // NOPMD by Herlin on 21/06/06 23:25
|
||||
final Collection rules = factory.createSingleRuleSet(ruleSetUrls[i]).getRules();
|
||||
for (final Iterator j = rules.iterator(); j.hasNext();) {
|
||||
final net.sourceforge.pmd.Rule pmdRule = (net.sourceforge.pmd.Rule) j.next();
|
||||
final Collection<net.sourceforge.pmd.Rule> rules = factory.createSingleRuleSet(ruleSetUrls[i]).getRules();
|
||||
for (final net.sourceforge.pmd.Rule pmdRule: rules) {
|
||||
final Rule rule = new Rule(); // NOPMD by Herlin on 21/06/06 23:29
|
||||
rule.setRef(ruleSetUrls[i] + '/' + pmdRule.getName());
|
||||
rule.setPmdRule(pmdRule);
|
||||
ruleSet.addRule(rule);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ruleSet;
|
||||
|
||||
} catch (RuleSetNotFoundException e) {
|
||||
@@ -135,7 +134,7 @@ public class RuleSetsManagerImpl implements IRuleSetsManager {
|
||||
marshaller.marshal(ruleSets);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
|
||||
|
||||
output.write(writer.getBuffer().toString().getBytes());
|
||||
output.flush();
|
||||
|
||||
|
||||
+13
-10
@@ -7,7 +7,7 @@
|
||||
* 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
|
||||
@@ -20,7 +20,7 @@
|
||||
* * 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
|
||||
@@ -41,11 +41,11 @@ import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* This class is a value objet that composes the structure of a rulesets object.
|
||||
* This class is a value object that composes the structure of a rulesets object.
|
||||
* It holds a collection of Property objects.
|
||||
*
|
||||
*
|
||||
* @author Herlin
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public class Properties {
|
||||
@@ -53,7 +53,7 @@ public class Properties {
|
||||
|
||||
/**
|
||||
* Getter for the propertiesSet.
|
||||
*
|
||||
*
|
||||
* @return Returns the propertiesSet.
|
||||
*/
|
||||
public Set getProperties() {
|
||||
@@ -62,7 +62,7 @@ public class Properties {
|
||||
|
||||
/**
|
||||
* Setter for the propertiesSet
|
||||
*
|
||||
*
|
||||
* @param propertiesSet The propertiesSet to set.
|
||||
*/
|
||||
public void setProperties(Set properties) {
|
||||
@@ -76,20 +76,22 @@ public class Properties {
|
||||
/**
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object arg0) {
|
||||
boolean equal = false;
|
||||
|
||||
|
||||
if (arg0 instanceof Properties) {
|
||||
final Properties p = (Properties) arg0;
|
||||
equal = this.propertiesSet.equals(p.propertiesSet);
|
||||
}
|
||||
|
||||
|
||||
return equal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.propertiesSet.hashCode();
|
||||
}
|
||||
@@ -97,6 +99,7 @@ public class Properties {
|
||||
/**
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuffer buffer = new StringBuffer("Properties");
|
||||
for (final Iterator i = this.propertiesSet.iterator(); i.hasNext();) {
|
||||
@@ -104,7 +107,7 @@ public class Properties {
|
||||
buffer.append(' ');
|
||||
buffer.append(p);
|
||||
}
|
||||
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
|
||||
+20
-18
@@ -7,7 +7,7 @@
|
||||
* 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
|
||||
@@ -20,7 +20,7 @@
|
||||
* * 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
|
||||
@@ -38,15 +38,14 @@ package net.sourceforge.pmd.eclipse.core.rulesets.vo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* This class is a value objet which composes the structure of a rulesets object.
|
||||
* It holds the definition of a rule set which is actually a named collection of
|
||||
* rules.
|
||||
*
|
||||
*
|
||||
* @author Herlin
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public class RuleSet {
|
||||
@@ -64,11 +63,11 @@ public class RuleSet {
|
||||
private String description = "";
|
||||
private String language = LANGUAGE_JAVA;
|
||||
final private net.sourceforge.pmd.RuleSet pmdRuleSet = new net.sourceforge.pmd.RuleSet();
|
||||
final private Collection rules = new ArrayList();
|
||||
final private Collection<Rule> rules = new ArrayList<Rule>();
|
||||
|
||||
/**
|
||||
* Getter for the description attribute. May be empty but never null.
|
||||
*
|
||||
*
|
||||
* @return Returns the description.
|
||||
*/
|
||||
public String getDescription() {
|
||||
@@ -77,7 +76,7 @@ public class RuleSet {
|
||||
|
||||
/**
|
||||
* Setter of the description attribute. Cannot be null but can be empty.
|
||||
*
|
||||
*
|
||||
* @param description The description to set.
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
@@ -91,7 +90,7 @@ public class RuleSet {
|
||||
/**
|
||||
* Getter for the name attribute. Cannot be null. May be empty if the object
|
||||
* has not been initialized.
|
||||
*
|
||||
*
|
||||
* @return Returns the name.
|
||||
*/
|
||||
public String getName() {
|
||||
@@ -100,7 +99,7 @@ public class RuleSet {
|
||||
|
||||
/**
|
||||
* Setter for the name attribute. Cannot be null nor empty
|
||||
*
|
||||
*
|
||||
* @param name The name to set.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
@@ -117,16 +116,16 @@ public class RuleSet {
|
||||
/**
|
||||
* Getter for the rules collection attribute. Cannot be null, but may be
|
||||
* empty.
|
||||
*
|
||||
*
|
||||
* @return Returns the rules.
|
||||
*/
|
||||
public Collection getRules() {
|
||||
public Collection<Rule> getRules() {
|
||||
return this.rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a rule to the rule set.
|
||||
*
|
||||
*
|
||||
* @param rule The rule to add. Cannot be null
|
||||
*/
|
||||
public void addRule(Rule rule) {
|
||||
@@ -140,7 +139,7 @@ public class RuleSet {
|
||||
|
||||
/**
|
||||
* Getter of the language attribute. Is one of the LANGUAGE_xxx constants.
|
||||
*
|
||||
*
|
||||
* @return Returns the language.
|
||||
*/
|
||||
public String getLanguage() {
|
||||
@@ -150,7 +149,7 @@ public class RuleSet {
|
||||
/**
|
||||
* Setter of the language constant. Must be one of the LANGUAGE_xxx
|
||||
* constant.
|
||||
*
|
||||
*
|
||||
* @param language The language to set.
|
||||
*/
|
||||
public void setLanguage(String language) {
|
||||
@@ -164,6 +163,7 @@ public class RuleSet {
|
||||
/**
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object arg0) {
|
||||
boolean equal = false;
|
||||
|
||||
@@ -178,6 +178,7 @@ public class RuleSet {
|
||||
/**
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.name.hashCode() + this.rules.hashCode() * 21 * 21 + this.language.hashCode() * 13 * 13;
|
||||
}
|
||||
@@ -185,11 +186,12 @@ public class RuleSet {
|
||||
/**
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuffer buffer = new StringBuffer("RuleSet name=" + this.name + " description=" + " language=" + this.language
|
||||
+ " rules=");
|
||||
for (final Iterator i = this.rules.iterator(); i.hasNext();) {
|
||||
buffer.append(' ').append(i.next());
|
||||
for (Rule rule : this.rules) {
|
||||
buffer.append(' ').append(rule);
|
||||
}
|
||||
|
||||
return buffer.toString();
|
||||
@@ -199,7 +201,7 @@ public class RuleSet {
|
||||
* Getter for a PMD RuleSet object.
|
||||
* This object is a native PMD Rule Set composed of all rules of this
|
||||
* rule set.
|
||||
*
|
||||
*
|
||||
* @return Returns the pmdRuleSet.
|
||||
*/
|
||||
public net.sourceforge.pmd.RuleSet getPmdRuleSet() {
|
||||
|
||||
+22
-22
@@ -7,7 +7,7 @@
|
||||
* 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
|
||||
@@ -20,7 +20,7 @@
|
||||
* * 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
|
||||
@@ -37,27 +37,26 @@
|
||||
package net.sourceforge.pmd.eclipse.core.rulesets.vo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is a value objet that is the root of the structure of a rulesets
|
||||
* object. It holds the different configurations the user may define and use in
|
||||
* each project.
|
||||
*
|
||||
*
|
||||
* @author Herlin
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public class RuleSets {
|
||||
private RuleSet defaultRuleSet;
|
||||
private List ruleSetsList = new ArrayList();
|
||||
private List<RuleSet> ruleSetsList = new ArrayList<RuleSet>();
|
||||
|
||||
/**
|
||||
* Getter for the defaultRuleSet attribute. The default rule set is the one
|
||||
* loaded by the "getRuleSet(void)" operation from the preferences manager.
|
||||
* Also, the default rule set is the one selected on each new Java project.
|
||||
*
|
||||
*
|
||||
* @return Returns the defaultRuleSet.
|
||||
*/
|
||||
public RuleSet getDefaultRuleSet() {
|
||||
@@ -67,7 +66,7 @@ public class RuleSets {
|
||||
/**
|
||||
* Setter for the defaultRuleSet attribute. The rule set must belong to the
|
||||
* rule sets list.
|
||||
*
|
||||
*
|
||||
* @param defaultRuleSet The defaultRuleSet to set.
|
||||
*/
|
||||
public void setDefaultRuleSet(RuleSet defaultRuleSet) {
|
||||
@@ -84,19 +83,19 @@ public class RuleSets {
|
||||
|
||||
/**
|
||||
* Getter of the rule sets list attribute.
|
||||
*
|
||||
*
|
||||
* @return Returns the ruleSet list.
|
||||
*/
|
||||
public List getRuleSets() {
|
||||
public List<RuleSet> getRuleSets() {
|
||||
return this.ruleSetsList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter of the rule sets list attribute.
|
||||
*
|
||||
*
|
||||
* @param ruleSetsSet The ruleSetsSet to set.
|
||||
*/
|
||||
public void setRuleSets(List ruleSets) {
|
||||
public void setRuleSets(List<RuleSet> ruleSets) {
|
||||
if (ruleSets == null) {
|
||||
throw new IllegalArgumentException("ruleSets cannot be null");
|
||||
}
|
||||
@@ -106,7 +105,7 @@ public class RuleSets {
|
||||
}
|
||||
this.ruleSetsList = ruleSets;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the name of the default ruleset
|
||||
* @return the name of the default ruleset
|
||||
@@ -114,9 +113,9 @@ public class RuleSets {
|
||||
public String getDefaultRuleSetName() {
|
||||
return this.defaultRuleSet.getName();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the default ruleset by its name. If the ruleset does not exist,
|
||||
* Sets the default ruleset by its name. If the ruleset does not exist,
|
||||
* the default ruleset is not set.
|
||||
* @param ruleSetName a name of an already defined ruleset.
|
||||
*/
|
||||
@@ -124,9 +123,9 @@ public class RuleSets {
|
||||
if (ruleSetName == null) {
|
||||
throw new IllegalArgumentException("The default ruleset name must not ne null");
|
||||
}
|
||||
|
||||
for (final Iterator i = this.ruleSetsList.iterator(); i.hasNext();) {
|
||||
final RuleSet ruleSet = (RuleSet) i.next();
|
||||
|
||||
for (RuleSet ruleSet2 : this.ruleSetsList) {
|
||||
final RuleSet ruleSet = ruleSet2;
|
||||
if (ruleSet.getName().equals(ruleSetName)) {
|
||||
setDefaultRuleSet(ruleSet);
|
||||
break;
|
||||
@@ -137,15 +136,16 @@ public class RuleSets {
|
||||
/**
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuffer buffer = new StringBuffer("RuleSets defaultRuleSet=");
|
||||
buffer.append(this.defaultRuleSet.getName());
|
||||
buffer.append(" ruleSetsList=");
|
||||
|
||||
for (final Iterator i = this.ruleSetsList.iterator(); i.hasNext();) {
|
||||
buffer.append(i.next());
|
||||
|
||||
for (RuleSet ruleSet : this.ruleSetsList) {
|
||||
buffer.append(ruleSet);
|
||||
}
|
||||
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
+70
-67
File diff suppressed because it is too large.
Load diff
+18
-18
@@ -16,17 +16,17 @@ import org.eclipse.ui.ResourceWorkingSetFilter;
|
||||
|
||||
/**
|
||||
* A visitor to process IFile resource against CPD
|
||||
*
|
||||
*
|
||||
* @author David Craine
|
||||
* @author Philippe Herlin
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class CPDVisitor implements IResourceVisitor {
|
||||
private static final Logger log = Logger.getLogger(CPDVisitor.class);
|
||||
private boolean includeDerivedFiles;
|
||||
private ResourceWorkingSetFilter workingSetFilter;
|
||||
private Language language;
|
||||
private List files;
|
||||
private List<File> files;
|
||||
|
||||
/**
|
||||
* @param includeDerivedFiles The includeDerivedFiles to set.
|
||||
@@ -34,7 +34,7 @@ public class CPDVisitor implements IResourceVisitor {
|
||||
public void setIncludeDerivedFiles(boolean includeDerivedFiles) {
|
||||
this.includeDerivedFiles = includeDerivedFiles;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param workingSet WorkingSet of the visited project.
|
||||
*/
|
||||
@@ -42,28 +42,28 @@ public class CPDVisitor implements IResourceVisitor {
|
||||
this.workingSetFilter = new ResourceWorkingSetFilter();
|
||||
this.workingSetFilter.setWorkingSet(workingSet);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param language Only add files with that language
|
||||
*/
|
||||
public void setLanguage(Language language) {
|
||||
this.language = language;
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the list of files
|
||||
*/
|
||||
public List getFiles() {
|
||||
public List<File> getFiles() {
|
||||
return this.files;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param files the list of files to set
|
||||
*/
|
||||
public void setFiles(List files) {
|
||||
public void setFiles(List<File> files) {
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.core.resources.IResourceVisitor#visit(IResource) Add java files into the CPD object
|
||||
*/
|
||||
@@ -75,11 +75,11 @@ public class CPDVisitor implements IResourceVisitor {
|
||||
final IFile file = (IFile) resource;
|
||||
final File ioFile = ((IFile) resource).getLocation().toFile();
|
||||
try {
|
||||
if ((((IFile) resource).getFileExtension() != null)
|
||||
&& (this.language.getFileFilter().accept(ioFile, file.getName()))
|
||||
&& (isFileInWorkingSet(file)
|
||||
&& (this.includeDerivedFiles
|
||||
|| (!this.includeDerivedFiles && !file.isDerived())))) {
|
||||
if (((IFile) resource).getFileExtension() != null
|
||||
&& this.language.getFileFilter().accept(ioFile, file.getName())
|
||||
&& isFileInWorkingSet(file)
|
||||
&& (this.includeDerivedFiles
|
||||
|| !this.includeDerivedFiles && !file.isDerived())) {
|
||||
log.debug("Add file " + resource.getName());
|
||||
this.files.add(ioFile);
|
||||
result = false;
|
||||
@@ -95,13 +95,13 @@ public class CPDVisitor implements IResourceVisitor {
|
||||
|
||||
/**
|
||||
* Test if a file is in the PMD working set
|
||||
*
|
||||
*
|
||||
* @param file
|
||||
* @return true if the file should be checked
|
||||
*/
|
||||
private boolean isFileInWorkingSet(final IFile file) throws PropertiesException {
|
||||
boolean fileInWorkingSet = true;
|
||||
|
||||
|
||||
if (this.workingSetFilter != null) {
|
||||
fileInWorkingSet = this.workingSetFilter.select(null, null, file);
|
||||
}
|
||||
|
||||
+17
-13
@@ -47,6 +47,7 @@ import name.herlin.command.CommandException;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.cpd.Language;
|
||||
import net.sourceforge.pmd.cpd.LanguageFactory;
|
||||
import net.sourceforge.pmd.cpd.Match;
|
||||
import net.sourceforge.pmd.cpd.Renderer;
|
||||
import net.sourceforge.pmd.eclipse.runtime.PMDRuntimeConstants;
|
||||
import net.sourceforge.pmd.eclipse.plugin.PMDPlugin;
|
||||
@@ -79,7 +80,7 @@ public class DetectCutAndPasteCmd extends AbstractDefaultCommand {
|
||||
private Renderer renderer;
|
||||
private String reportName;
|
||||
private boolean createReport;
|
||||
private List listenerList;
|
||||
private List<IPropertyListener> listenerList;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
@@ -91,16 +92,17 @@ public class DetectCutAndPasteCmd extends AbstractDefaultCommand {
|
||||
this.setOutputProperties(true);
|
||||
this.setReadOnly(false);
|
||||
this.setTerminated(false);
|
||||
this.listenerList = new ArrayList();
|
||||
this.listenerList = new ArrayList<IPropertyListener>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see name.herlin.command.AbstractProcessableCommand#execute()
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws CommandException {
|
||||
try {
|
||||
// find the files
|
||||
final List files = findFiles();
|
||||
final List<File> files = findFiles();
|
||||
|
||||
if (files.size() == 0) {
|
||||
PMDPlugin.getDefault().logInformation("No files found to specified language.");
|
||||
@@ -124,9 +126,9 @@ public class DetectCutAndPasteCmd extends AbstractDefaultCommand {
|
||||
// trigger event propertyChanged for all listeners
|
||||
Display.getDefault().asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
final Iterator listenerIterator = listenerList.iterator();
|
||||
final Iterator<IPropertyListener> listenerIterator = listenerList.iterator();
|
||||
while (listenerIterator.hasNext()) {
|
||||
final IPropertyListener listener = (IPropertyListener) listenerIterator.next();
|
||||
final IPropertyListener listener = listenerIterator.next();
|
||||
listener.propertyChanged(cpd.getMatches(), PMDRuntimeConstants.PROPERTY_CPD);
|
||||
}
|
||||
}
|
||||
@@ -147,6 +149,7 @@ public class DetectCutAndPasteCmd extends AbstractDefaultCommand {
|
||||
/**
|
||||
* @see name.herlin.command.Command#reset()
|
||||
*/
|
||||
@Override
|
||||
public void reset() {
|
||||
this.setProject(null);
|
||||
this.setTerminated(false);
|
||||
@@ -156,7 +159,7 @@ public class DetectCutAndPasteCmd extends AbstractDefaultCommand {
|
||||
this.setMinTileSize(PMDPlugin.getDefault().loadPreferences().getMinTileSize());
|
||||
this.setCreateReport(false);
|
||||
this.addPropertyListener(null);
|
||||
this.listenerList = new ArrayList();
|
||||
this.listenerList = new ArrayList<IPropertyListener>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,10 +215,11 @@ public class DetectCutAndPasteCmd extends AbstractDefaultCommand {
|
||||
/**
|
||||
* @see name.herlin.command.Command#isReadyToExecute()
|
||||
*/
|
||||
@Override
|
||||
public boolean isReadyToExecute() {
|
||||
return this.project != null
|
||||
&& this.language != null
|
||||
&& (!this.createReport // need a renderer and reportname if a report should be created
|
||||
&& (!this.createReport // need a renderer and reportName if a report should be created
|
||||
|| this.renderer != null && this.reportName != null);
|
||||
}
|
||||
|
||||
@@ -226,13 +230,13 @@ public class DetectCutAndPasteCmd extends AbstractDefaultCommand {
|
||||
* @throws PropertiesException
|
||||
* @throws CoreException
|
||||
*/
|
||||
private List findFiles() throws PropertiesException, CoreException {
|
||||
private List<File> findFiles() throws PropertiesException, CoreException {
|
||||
final IProjectProperties properties = PMDPlugin.getDefault().loadProjectProperties(project);
|
||||
final CPDVisitor visitor = new CPDVisitor();
|
||||
visitor.setWorkingSet(properties.getProjectWorkingSet());
|
||||
visitor.setIncludeDerivedFiles(properties.isIncludeDerivedFiles());
|
||||
visitor.setLanguage(language);
|
||||
visitor.setFiles(new ArrayList());
|
||||
visitor.setFiles(new ArrayList<File>());
|
||||
this.project.accept(visitor);
|
||||
return visitor.getFiles();
|
||||
}
|
||||
@@ -244,14 +248,14 @@ public class DetectCutAndPasteCmd extends AbstractDefaultCommand {
|
||||
* @return the CPD itself for retrieving the matches.
|
||||
* @throws CoreException
|
||||
*/
|
||||
private CPD detectCutAndPaste(final List files) {
|
||||
private CPD detectCutAndPaste(final List<File> files) {
|
||||
log.debug("Searching for project files");
|
||||
final CPD cpd = new CPD(minTileSize, language);
|
||||
|
||||
subTask("Adding files for the CPD");
|
||||
final Iterator fileIterator = files.iterator();
|
||||
final Iterator<File> fileIterator = files.iterator();
|
||||
while (fileIterator.hasNext() && !isCanceled()) {
|
||||
final File file = (File) fileIterator.next();
|
||||
final File file = fileIterator.next();
|
||||
try {
|
||||
cpd.add(file);
|
||||
worked(1);
|
||||
@@ -276,7 +280,7 @@ public class DetectCutAndPasteCmd extends AbstractDefaultCommand {
|
||||
* @param matches matches of the CPD
|
||||
* @throws CommandException
|
||||
*/
|
||||
private void renderReport(Iterator matches) throws CommandException {
|
||||
private void renderReport(Iterator<Match> matches) throws CommandException {
|
||||
try {
|
||||
log.debug("Rendering CPD report");
|
||||
subTask("Rendering CPD report");
|
||||
|
||||
+3
-4
@@ -21,14 +21,14 @@ import org.eclipse.jdt.core.JavaModelException;
|
||||
public class JavaProjectClassLoader extends URLClassLoader {
|
||||
private static final Logger log = Logger.getLogger(JavaProjectClassLoader.class);
|
||||
|
||||
private Set javaProjects = new HashSet();
|
||||
private Set<IJavaProject> javaProjects = new HashSet<IJavaProject>();
|
||||
private IWorkspaceRoot workspaceRoot;
|
||||
|
||||
public JavaProjectClassLoader(ClassLoader parent, IJavaProject javaProject) {
|
||||
super(new URL[0], parent);
|
||||
workspaceRoot = javaProject.getProject().getWorkspace().getRoot();
|
||||
addURLs(javaProject, false);
|
||||
|
||||
|
||||
// No longer need these things, drop references
|
||||
javaProjects = null;
|
||||
workspaceRoot = null;
|
||||
@@ -44,8 +44,7 @@ public class JavaProjectClassLoader extends URLClassLoader {
|
||||
|
||||
// Add each classpath entry
|
||||
IClasspathEntry[] classpathEntries = javaProject.getResolvedClasspath(true);
|
||||
for (int i = 0; i < classpathEntries.length; i++) {
|
||||
IClasspathEntry classpathEntry = classpathEntries[i];
|
||||
for (IClasspathEntry classpathEntry : classpathEntries) {
|
||||
if (classpathEntry.isExported() || !exportsOnly) {
|
||||
switch (classpathEntry.getEntryKind()) {
|
||||
|
||||
|
||||
+16
-15
@@ -7,7 +7,7 @@
|
||||
* 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
|
||||
@@ -20,7 +20,7 @@
|
||||
* * 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
|
||||
@@ -56,13 +56,13 @@ import org.eclipse.core.runtime.jobs.Job;
|
||||
/**
|
||||
* This is a particular processor for Eclipse in order to handle long running
|
||||
* commands.
|
||||
*
|
||||
*
|
||||
* @author Philippe Herlin
|
||||
*
|
||||
*/
|
||||
public class JobCommandProcessor implements CommandProcessor {
|
||||
private static final Logger log = Logger.getLogger(JobCommandProcessor.class);
|
||||
private final Map jobs = Collections.synchronizedMap(new HashMap());
|
||||
private final Map<AbstractProcessableCommand, Job> jobs = Collections.synchronizedMap(new HashMap<AbstractProcessableCommand, Job>());
|
||||
|
||||
/**
|
||||
* @see name.herlin.command.CommandProcessor#processCommand(name.herlin.command.AbstractProcessableCommand)
|
||||
@@ -73,8 +73,9 @@ public class JobCommandProcessor implements CommandProcessor {
|
||||
if (!aCommand.isReadyToExecute()) {
|
||||
throw new UnsetInputPropertiesException();
|
||||
}
|
||||
|
||||
|
||||
final Job job = new Job(aCommand.getName()) {
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
if (aCommand instanceof AbstractDefaultCommand) {
|
||||
@@ -87,11 +88,11 @@ public class JobCommandProcessor implements CommandProcessor {
|
||||
} catch (CommandException e) {
|
||||
PMDPlugin.getDefault().logError("Error executing command " + aCommand.getName(), e);
|
||||
}
|
||||
|
||||
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if (aCommand instanceof AbstractDefaultCommand) {
|
||||
job.setUser(((AbstractDefaultCommand) aCommand).isUserInitiated());
|
||||
}
|
||||
@@ -105,7 +106,7 @@ public class JobCommandProcessor implements CommandProcessor {
|
||||
* @see name.herlin.command.CommandProcessor#waitCommandToFinish(name.herlin.command.AbstractProcessableCommand)
|
||||
*/
|
||||
public void waitCommandToFinish(final AbstractProcessableCommand aCommand) throws CommandException {
|
||||
final Job job = (Job) this.jobs.get(aCommand);
|
||||
final Job job = this.jobs.get(aCommand);
|
||||
if (job != null) {
|
||||
try {
|
||||
job.join();
|
||||
@@ -115,21 +116,21 @@ public class JobCommandProcessor implements CommandProcessor {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a job to the map. Also, clear all finished jobs
|
||||
* @param command for which to keep the job
|
||||
* @param command for which to keep the job
|
||||
* @param job a job to keep until it is finished
|
||||
*/
|
||||
private void addJob(final AbstractProcessableCommand command, final Job job) {
|
||||
this.jobs.put(command, job);
|
||||
|
||||
|
||||
// clear terminated command
|
||||
final Iterator i = this.jobs.keySet().iterator();
|
||||
final Iterator<AbstractProcessableCommand> i = this.jobs.keySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
final AbstractProcessableCommand aCommand = (AbstractProcessableCommand) i.next();
|
||||
final Job aJob = (Job) this.jobs.get(aCommand);
|
||||
if ((aJob == null) || (aJob.getResult() != null)) {
|
||||
final AbstractProcessableCommand aCommand = i.next();
|
||||
final Job aJob = this.jobs.get(aCommand);
|
||||
if (aJob == null || aJob.getResult() != null) {
|
||||
this.jobs.remove(aCommand);
|
||||
}
|
||||
}
|
||||
|
||||
+11
-13
@@ -40,7 +40,6 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import name.herlin.command.CommandException;
|
||||
@@ -78,7 +77,7 @@ public class RenderReportCmd extends AbstractDefaultCommand {
|
||||
/**
|
||||
* Table containing the renderers indexed by the file name.
|
||||
*/
|
||||
private HashMap renderers = new HashMap();
|
||||
private HashMap<String, Renderer> renderers = new HashMap<String, Renderer>();
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
@@ -105,6 +104,7 @@ public class RenderReportCmd extends AbstractDefaultCommand {
|
||||
/**
|
||||
* @see name.herlin.command.AbstractProcessableCommand#execute()
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws CommandException {
|
||||
try {
|
||||
log.debug("Starting RenderReport command");
|
||||
@@ -117,12 +117,9 @@ public class RenderReportCmd extends AbstractDefaultCommand {
|
||||
folder.create(true, true, this.getMonitor());
|
||||
}
|
||||
|
||||
Iterator i = renderers.entrySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry) i.next();
|
||||
|
||||
final String reportName = (String) entry.getKey();
|
||||
final Renderer renderer = (Renderer) entry.getValue();
|
||||
for (Map.Entry<String, Renderer> entry: renderers.entrySet()) {
|
||||
final String reportName = entry.getKey();
|
||||
final Renderer renderer = entry.getValue();
|
||||
|
||||
log.debug(" Render the report");
|
||||
final StringWriter w = new StringWriter();
|
||||
@@ -159,9 +156,10 @@ public class RenderReportCmd extends AbstractDefaultCommand {
|
||||
/**
|
||||
* @see name.herlin.command.Command#reset()
|
||||
*/
|
||||
@Override
|
||||
public void reset() {
|
||||
this.setProject(null);
|
||||
this.renderers = new HashMap();
|
||||
this.renderers = new HashMap<String, Renderer>();
|
||||
this.setTerminated(false);
|
||||
}
|
||||
|
||||
@@ -175,6 +173,7 @@ public class RenderReportCmd extends AbstractDefaultCommand {
|
||||
/**
|
||||
* @see name.herlin.command.Command#isReadyToExecute()
|
||||
*/
|
||||
@Override
|
||||
public boolean isReadyToExecute() {
|
||||
return this.project != null && !this.renderers.isEmpty();
|
||||
}
|
||||
@@ -188,8 +187,7 @@ public class RenderReportCmd extends AbstractDefaultCommand {
|
||||
final Report report = new Report();
|
||||
|
||||
final IMarker[] markers = project.findMarkers(PMDRuntimeConstants.PMD_MARKER, true, IResource.DEPTH_INFINITE);
|
||||
for (int i = 0; i < markers.length; i++) {
|
||||
IMarker marker = markers[i];
|
||||
for (IMarker marker : markers) {
|
||||
final String ruleName = marker.getAttribute(PMDRuntimeConstants.KEY_MARKERATT_RULENAME, "");
|
||||
final Rule rule = PMDPlugin.getDefault().getPreferencesManager().getRuleSet().getRuleByName(ruleName);
|
||||
|
||||
@@ -203,8 +201,8 @@ public class RenderReportCmd extends AbstractDefaultCommand {
|
||||
ruleViolation.setFilename(marker.getResource().getProjectRelativePath().toString());
|
||||
ruleViolation.setDescription(marker.getAttribute(IMarker.MESSAGE, rule.getMessage()));
|
||||
|
||||
if (markers[i].getResource() instanceof IFile) {
|
||||
final ICompilationUnit unit = JavaCore.createCompilationUnitFrom((IFile) markers[i].getResource());
|
||||
if (marker.getResource() instanceof IFile) {
|
||||
final ICompilationUnit unit = JavaCore.createCompilationUnitFrom((IFile) marker.getResource());
|
||||
final IPackageDeclaration packages[] = unit.getPackageDeclarations();
|
||||
if (packages.length > 0) {
|
||||
ruleViolation.setPackageName(packages[0].getElementName());
|
||||
|
||||
+13
-13
@@ -88,9 +88,9 @@ public class ReviewCodeCmd extends AbstractDefaultCommand {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Logger log = Logger.getLogger(ReviewCodeCmd.class);
|
||||
final private List resources = new ArrayList();
|
||||
final private List<ISchedulingRule> resources = new ArrayList<ISchedulingRule>();
|
||||
private IResourceDelta resourceDelta;
|
||||
private Map markers = new HashMap();
|
||||
private Map<IFile, Set<MarkerInfo>> markers = new HashMap<IFile, Set<MarkerInfo>>();
|
||||
private boolean taskMarker = false;
|
||||
private boolean openPmdPerspective = false;
|
||||
private int rulesCount;
|
||||
@@ -177,14 +177,14 @@ public class ReviewCodeCmd extends AbstractDefaultCommand {
|
||||
/**
|
||||
* @return Returns the file markers
|
||||
*/
|
||||
public Map getMarkers() {
|
||||
public Map<IFile, Set<MarkerInfo>> getMarkers() {
|
||||
return this.markers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource The resource to set.
|
||||
*/
|
||||
public void setResources(final List resources) {
|
||||
public void setResources(final List<ISchedulingRule> resources) {
|
||||
this.resources.clear();
|
||||
this.resources.addAll(resources);
|
||||
}
|
||||
@@ -229,7 +229,7 @@ public class ReviewCodeCmd extends AbstractDefaultCommand {
|
||||
*/
|
||||
public void reset() {
|
||||
this.resources.clear();
|
||||
this.markers = new HashMap();
|
||||
this.markers = new HashMap<IFile, Set<MarkerInfo>>();
|
||||
this.setTerminated(false);
|
||||
this.openPmdPerspective = false;
|
||||
}
|
||||
@@ -256,7 +256,7 @@ public class ReviewCodeCmd extends AbstractDefaultCommand {
|
||||
for (int i = 0; i < rules.length; i++) {
|
||||
rules[i] = ruleFactory.markerRule((IResource) this.resources.get(i));
|
||||
}
|
||||
rule = new MultiRule((ISchedulingRule[]) this.resources.toArray(rules));
|
||||
rule = new MultiRule(this.resources.toArray(rules));
|
||||
}
|
||||
|
||||
return rule;
|
||||
@@ -268,7 +268,7 @@ public class ReviewCodeCmd extends AbstractDefaultCommand {
|
||||
* @throws CommandException
|
||||
*/
|
||||
private void processResources() throws CommandException {
|
||||
final Iterator i = this.resources.iterator();
|
||||
final Iterator<ISchedulingRule> i = this.resources.iterator();
|
||||
while (i.hasNext()) {
|
||||
final IResource resource = (IResource) i.next();
|
||||
|
||||
@@ -397,21 +397,21 @@ public class ReviewCodeCmd extends AbstractDefaultCommand {
|
||||
|
||||
String currentFile = ""; // for logging
|
||||
try {
|
||||
final Set filesSet = this.markers.keySet();
|
||||
final Iterator i = filesSet.iterator();
|
||||
final Set<IFile> filesSet = this.markers.keySet();
|
||||
final Iterator<IFile> i = filesSet.iterator();
|
||||
|
||||
beginTask("PMD Applying markers", filesSet.size());
|
||||
|
||||
while (i.hasNext() && !isCanceled()) {
|
||||
final IFile file = (IFile) i.next();
|
||||
final IFile file = i.next();
|
||||
currentFile = file.getName();
|
||||
|
||||
final Set markerInfoSet = (Set) this.markers.get(file);
|
||||
final Set<MarkerInfo> markerInfoSet = this.markers.get(file);
|
||||
file.deleteMarkers(PMDRuntimeConstants.PMD_MARKER, true, IResource.DEPTH_INFINITE);
|
||||
file.deleteMarkers(PMDRuntimeConstants.PMD_DFA_MARKER, true, IResource.DEPTH_INFINITE);
|
||||
final Iterator j = markerInfoSet.iterator();
|
||||
final Iterator<MarkerInfo> j = markerInfoSet.iterator();
|
||||
while (j.hasNext()) {
|
||||
final MarkerInfo markerInfo = (MarkerInfo) j.next();
|
||||
final MarkerInfo markerInfo = j.next();
|
||||
final IMarker marker = file.createMarker(markerInfo.getType());
|
||||
marker.setAttributes(markerInfo.getAttributeNames(), markerInfo.getAttributeValues());
|
||||
violationsCount++;
|
||||
|
||||
+7
-6
@@ -73,7 +73,7 @@ public class ReviewResourceForRuleCommand extends AbstractDefaultCommand {
|
||||
private IResource resource;
|
||||
private RuleContext context;
|
||||
private Rule rule;
|
||||
private List listenerList;
|
||||
private List<IPropertyListener> listenerList;
|
||||
|
||||
public ReviewResourceForRuleCommand() {
|
||||
super();
|
||||
@@ -82,7 +82,7 @@ public class ReviewResourceForRuleCommand extends AbstractDefaultCommand {
|
||||
this.setOutputProperties(true);
|
||||
this.setReadOnly(true);
|
||||
this.setTerminated(false);
|
||||
this.listenerList = new ArrayList();
|
||||
this.listenerList = new ArrayList<IPropertyListener>();
|
||||
}
|
||||
|
||||
public void setResource(IResource resource) {
|
||||
@@ -101,6 +101,7 @@ public class ReviewResourceForRuleCommand extends AbstractDefaultCommand {
|
||||
this.listenerList.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadyToExecute() {
|
||||
return resource != null && rule != null;
|
||||
}
|
||||
@@ -108,15 +109,17 @@ public class ReviewResourceForRuleCommand extends AbstractDefaultCommand {
|
||||
/* (non-Javadoc)
|
||||
* @see net.sourceforge.pmd.eclipse.runtime.cmd.AbstractDefaultCommand#reset()
|
||||
*/
|
||||
@Override
|
||||
public void reset() {
|
||||
setResource(null);
|
||||
setRule(null);
|
||||
this.listenerList = new ArrayList();
|
||||
this.listenerList = new ArrayList<IPropertyListener>();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.sourceforge.pmd.eclipse.runtime.cmd.AbstractDefaultCommand#execute()
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws CommandException {
|
||||
final IProject project = resource.getProject();
|
||||
final IFile file = (IFile) resource.getAdapter(IFile.class);
|
||||
@@ -149,9 +152,7 @@ public class ReviewResourceForRuleCommand extends AbstractDefaultCommand {
|
||||
// trigger event propertyChanged for all listeners
|
||||
Display.getDefault().asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
final Iterator listenerIterator = listenerList.iterator();
|
||||
while (listenerIterator.hasNext()) {
|
||||
final IPropertyListener listener = (IPropertyListener) listenerIterator.next();
|
||||
for (IPropertyListener listener: listenerList) {
|
||||
listener.propertyChanged(context.getReport().iterator(), PMDRuntimeConstants.PROPERTY_REVIEW);
|
||||
}
|
||||
}
|
||||
|
||||
+12
-24
@@ -43,9 +43,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
@@ -147,9 +145,7 @@ class PreferencesManagerImpl implements IPreferencesManager {
|
||||
props.load(in);
|
||||
in.close();
|
||||
loadPreferencesStore = new PreferenceStore();
|
||||
Iterator i = props.entrySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry)i.next();
|
||||
for (Map.Entry<Object, Object> entry: props.entrySet()) {
|
||||
String key = (String)entry.getKey();
|
||||
if (key.startsWith(OLD_PREFERENCE_PREFIX)) {
|
||||
key = key.replaceFirst(OLD_PREFERENCE_PREFIX, PMDPlugin.PLUGIN_ID);
|
||||
@@ -367,9 +363,7 @@ class PreferencesManagerImpl implements IPreferencesManager {
|
||||
preferedRuleSet.setDescription("PMD Plugin preferences rule set");
|
||||
|
||||
IRuleSetManager ruleSetManager = PMDPlugin.getDefault().getRuleSetManager();
|
||||
Iterator i = ruleSetManager.getDefaultRuleSets().iterator();
|
||||
while (i.hasNext()) {
|
||||
RuleSet ruleSet = (RuleSet) i.next();
|
||||
for (RuleSet ruleSet: ruleSetManager.getDefaultRuleSets()) {
|
||||
preferedRuleSet.addRuleSetByReference(ruleSet, false);
|
||||
}
|
||||
}
|
||||
@@ -381,12 +375,9 @@ class PreferencesManagerImpl implements IPreferencesManager {
|
||||
/**
|
||||
* Find if rules has been added
|
||||
*/
|
||||
private Set getNewRules(RuleSet newRuleSet) {
|
||||
Set addedRules = new HashSet();
|
||||
Collection newRules = newRuleSet.getRules();
|
||||
Iterator i = newRules.iterator();
|
||||
while (i.hasNext()) {
|
||||
Rule rule = (Rule) i.next();
|
||||
private Set<Rule> getNewRules(RuleSet newRuleSet) {
|
||||
Set<Rule> addedRules = new HashSet<Rule>();
|
||||
for (Rule rule: newRuleSet.getRules()) {
|
||||
if (this.ruleSet.getRuleByName(rule.getName()) == null) {
|
||||
addedRules.add(rule);
|
||||
}
|
||||
@@ -401,30 +392,27 @@ class PreferencesManagerImpl implements IPreferencesManager {
|
||||
private void updateConfiguredProjects(RuleSet updatedRuleSet) {
|
||||
log.debug("Updating configured projects");
|
||||
RuleSet addedRuleSet = new RuleSet();
|
||||
Set newRules = getNewRules(updatedRuleSet);
|
||||
Iterator ruleIterator = newRules.iterator();
|
||||
while (ruleIterator.hasNext()) {
|
||||
Rule rule = (Rule) ruleIterator.next();
|
||||
for (Rule rule: getNewRules(updatedRuleSet)) {
|
||||
addedRuleSet.addRule(rule);
|
||||
}
|
||||
|
||||
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
|
||||
|
||||
for (int i = 0; i < projects.length; i++) {
|
||||
for (IProject project : projects) {
|
||||
|
||||
if (projects[i].isAccessible()) {
|
||||
if (project.isAccessible()) {
|
||||
try {
|
||||
IProjectProperties properties = PMDPlugin.getDefault().loadProjectProperties(projects[i]);
|
||||
IProjectProperties properties = PMDPlugin.getDefault().loadProjectProperties(project);
|
||||
RuleSet projectRuleSet = properties.getProjectRuleSet();
|
||||
if (projectRuleSet != null) {
|
||||
projectRuleSet.addRuleSet(addedRuleSet);
|
||||
projectRuleSet.setExcludePatterns(new ArrayList(updatedRuleSet.getExcludePatterns()));
|
||||
projectRuleSet.setIncludePatterns(new ArrayList(updatedRuleSet.getIncludePatterns()));
|
||||
projectRuleSet.setExcludePatterns(new ArrayList<String>(updatedRuleSet.getExcludePatterns()));
|
||||
projectRuleSet.setIncludePatterns(new ArrayList<String>(updatedRuleSet.getIncludePatterns()));
|
||||
properties.setProjectRuleSet(projectRuleSet);
|
||||
properties.sync();
|
||||
}
|
||||
} catch (PropertiesException e) {
|
||||
PMDPlugin.getDefault().logError("Unable to add new rules for project: " + projects[i], e);
|
||||
PMDPlugin.getDefault().logError("Unable to add new rules for project: " + project, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+16
-18
@@ -7,7 +7,7 @@
|
||||
* 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
|
||||
@@ -20,7 +20,7 @@
|
||||
* * 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
|
||||
@@ -39,7 +39,6 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.RuleSet;
|
||||
@@ -58,9 +57,9 @@ import org.eclipse.ui.IWorkingSet;
|
||||
|
||||
/**
|
||||
* Implementation of a project properties information structure
|
||||
*
|
||||
*
|
||||
* @author Philippe Herlin
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ProjectPropertiesImpl implements IProjectProperties {
|
||||
private static final Logger log = Logger.getLogger(ProjectPropertiesImpl.class);
|
||||
@@ -146,7 +145,7 @@ public class ProjectPropertiesImpl implements IProjectProperties {
|
||||
log.debug("Set rule set stored in project for project " + this.project.getName() + ": " + ruleSetStoredInProject);
|
||||
this.needRebuild |= this.ruleSetStoredInProject != ruleSetStoredInProject;
|
||||
this.ruleSetStoredInProject = ruleSetStoredInProject;
|
||||
if ((this.ruleSetStoredInProject) && (!isRuleSetFileExist())) {
|
||||
if (this.ruleSetStoredInProject && !isRuleSetFileExist()) {
|
||||
throw new PropertiesException("The project ruleset file cannot be found for project " + this.project.getName()); // TODO NLS
|
||||
}
|
||||
}
|
||||
@@ -169,7 +168,7 @@ public class ProjectPropertiesImpl implements IProjectProperties {
|
||||
log.debug("Set rule set file for project " + this.project.getName() + ": " + ruleSetFile);
|
||||
this.needRebuild |= this.ruleSetFile == null || !ruleSetFile.equals(ruleSetFile);
|
||||
this.ruleSetFile = ruleSetFile;
|
||||
if ((this.ruleSetStoredInProject) && (!isRuleSetFileExist())) {
|
||||
if (this.ruleSetStoredInProject && !isRuleSetFileExist()) {
|
||||
throw new PropertiesException("The project ruleset file cannot be found for project " + this.project.getName()); // TODO NLS
|
||||
}
|
||||
}
|
||||
@@ -188,7 +187,7 @@ public class ProjectPropertiesImpl implements IProjectProperties {
|
||||
log.debug("Set working set for project " + this.project.getName() + ": "
|
||||
+ (projectWorkingSet == null ? "none" : projectWorkingSet.getName()));
|
||||
|
||||
this.needRebuild |= (this.projectWorkingSet == null)?(projectWorkingSet != null):!this.projectWorkingSet.equals(projectWorkingSet);
|
||||
this.needRebuild |= this.projectWorkingSet == null?projectWorkingSet != null:!this.projectWorkingSet.equals(projectWorkingSet);
|
||||
this.projectWorkingSet = projectWorkingSet;
|
||||
}
|
||||
|
||||
@@ -236,7 +235,7 @@ public class ProjectPropertiesImpl implements IProjectProperties {
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a project ruleset file from the current configured rules
|
||||
*
|
||||
@@ -248,12 +247,12 @@ public class ProjectPropertiesImpl implements IProjectProperties {
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
writer.write(baos, this.projectRuleSet);
|
||||
baos.close();
|
||||
|
||||
|
||||
final IFile file = this.project.getFile(PROJECT_RULESET_FILE);
|
||||
if (file.exists() && file.isAccessible()) {
|
||||
throw new PropertiesException("Project ruleset file already exists");
|
||||
} else {
|
||||
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
file.create(bais, true, null);
|
||||
bais.close();
|
||||
}
|
||||
@@ -264,7 +263,7 @@ public class ProjectPropertiesImpl implements IProjectProperties {
|
||||
} catch (CoreException e) {
|
||||
throw new PropertiesException(e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -280,7 +279,7 @@ public class ProjectPropertiesImpl implements IProjectProperties {
|
||||
public void setIncludeDerivedFiles(boolean includeDerivedFiles) {
|
||||
log.debug("Set if derived files should be included: " + includeDerivedFiles);
|
||||
this.needRebuild |= this.includeDerivedFiles != includeDerivedFiles;
|
||||
this.includeDerivedFiles = includeDerivedFiles;
|
||||
this.includeDerivedFiles = includeDerivedFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,21 +289,20 @@ public class ProjectPropertiesImpl implements IProjectProperties {
|
||||
log.info("Commit properties for project " + this.project.getName());
|
||||
this.projectPropertiesManager.storeProjectProperties(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clone the PMD ruleset.
|
||||
* @return a pmd ruleSetClone.
|
||||
*/
|
||||
private RuleSet cloneRuleSet() {
|
||||
final RuleSet clonedRuleSet = new RuleSet();
|
||||
|
||||
for (final Iterator i = this.projectRuleSet.getRules().iterator(); i.hasNext();) {
|
||||
final Rule rule = (Rule) i.next();
|
||||
|
||||
for (Rule rule: this.projectRuleSet.getRules()) {
|
||||
clonedRuleSet.addRule(rule);
|
||||
}
|
||||
clonedRuleSet.addExcludePatterns(this.projectRuleSet.getExcludePatterns());
|
||||
clonedRuleSet.addIncludePatterns(this.projectRuleSet.getIncludePatterns());
|
||||
|
||||
|
||||
return clonedRuleSet;
|
||||
}
|
||||
|
||||
|
||||
+11
-15
@@ -73,7 +73,7 @@ import org.exolab.castor.xml.Unmarshaller;
|
||||
import org.exolab.castor.xml.ValidationException;
|
||||
|
||||
/**
|
||||
* This class manages the persistances of the ProjectProperies information structure
|
||||
* This class manages the persistence of the ProjectProperies information structure
|
||||
*
|
||||
* @author Philippe Herlin
|
||||
*
|
||||
@@ -84,7 +84,7 @@ public class ProjectPropertiesManagerImpl implements IProjectPropertiesManager {
|
||||
private static final String PROPERTIES_FILE = ".pmd";
|
||||
private static final String PROPERTIES_MAPPING = "/net/sourceforge/pmd/eclipse/runtime/properties/impl/mapping.xml";
|
||||
|
||||
private final Map projectsProperties = new HashMap();
|
||||
private final Map<IProject, IProjectProperties> projectsProperties = new HashMap<IProject, IProjectProperties>();
|
||||
|
||||
/**
|
||||
* Load a project properties
|
||||
@@ -94,7 +94,7 @@ public class ProjectPropertiesManagerImpl implements IProjectPropertiesManager {
|
||||
public IProjectProperties loadProjectProperties(final IProject project) throws PropertiesException {
|
||||
log.debug("Loading project properties for project " + project.getName());
|
||||
try {
|
||||
IProjectProperties projectProperties = (IProjectProperties) this.projectsProperties.get(project);
|
||||
IProjectProperties projectProperties = this.projectsProperties.get(project);
|
||||
if (projectProperties == null) {
|
||||
projectProperties = new PropertiesFactoryImpl().newProjectProperties(project, this);
|
||||
final ProjectPropertiesTO to = readProjectProperties(project);
|
||||
@@ -304,15 +304,13 @@ public class ProjectPropertiesManagerImpl implements IProjectPropertiesManager {
|
||||
|
||||
if (!projectProperties.isRuleSetStoredInProject()) {
|
||||
final RuleSet ruleSet = projectProperties.getProjectRuleSet();
|
||||
final List rules = new ArrayList();
|
||||
final Iterator i = ruleSet.getRules().iterator();
|
||||
while (i.hasNext()) {
|
||||
final Rule rule = (Rule) i.next();
|
||||
final List<RuleSpecTO> rules = new ArrayList<RuleSpecTO>();
|
||||
for (Rule rule: ruleSet.getRules()) {
|
||||
rules.add(new RuleSpecTO(rule.getName(), rule.getRuleSetName())); // NOPMD:AvoidInstantiatingObjectInLoop
|
||||
}
|
||||
bean.setRules((RuleSpecTO[]) rules.toArray(new RuleSpecTO[rules.size()]));
|
||||
bean.setExcludePatterns((String[])ruleSet.getExcludePatterns().toArray(new String[ruleSet.getExcludePatterns().size()]));
|
||||
bean.setIncludePatterns((String[])ruleSet.getIncludePatterns().toArray(new String[ruleSet.getIncludePatterns().size()]));
|
||||
bean.setRules(rules.toArray(new RuleSpecTO[rules.size()]));
|
||||
bean.setExcludePatterns(ruleSet.getExcludePatterns().toArray(new String[ruleSet.getExcludePatterns().size()]));
|
||||
bean.setIncludePatterns(ruleSet.getIncludePatterns().toArray(new String[ruleSet.getIncludePatterns().size()]));
|
||||
}
|
||||
|
||||
return bean;
|
||||
@@ -336,9 +334,9 @@ public class ProjectPropertiesManagerImpl implements IProjectPropertiesManager {
|
||||
|
||||
// 1-If rules have been deleted from preferences
|
||||
// delete them also from the project ruleset
|
||||
final Iterator i = projectRuleSet.getRules().iterator();
|
||||
final Iterator<Rule> i = projectRuleSet.getRules().iterator();
|
||||
while (i.hasNext()) {
|
||||
final Rule projectRule = (Rule) i.next();
|
||||
final Rule projectRule = i.next();
|
||||
final Rule pluginRule = pluginRuleSet.getRuleByName(projectRule.getName());
|
||||
if (pluginRule == null) {
|
||||
log.debug("The rule " + projectRule.getName() + " is no more defined in the plugin ruleset. Remove it.");
|
||||
@@ -347,12 +345,10 @@ public class ProjectPropertiesManagerImpl implements IProjectPropertiesManager {
|
||||
}
|
||||
|
||||
// 2-For all other rules, replace the current one by the plugin one
|
||||
final Iterator k = projectRuleSet.getRules().iterator();
|
||||
final RuleSet ruleSet = new RuleSet();
|
||||
ruleSet.setDescription(projectRuleSet.getDescription());
|
||||
ruleSet.setName(projectRuleSet.getName());
|
||||
while (k.hasNext()) {
|
||||
final Rule projectRule = (Rule) k.next();
|
||||
for (Rule projectRule: projectRuleSet.getRules()) {
|
||||
final Rule pluginRule = pluginRuleSet.getRuleByName(projectRule.getName());
|
||||
if (pluginRule != null) {
|
||||
// log.debug("Keeping rule " + projectRule.getName());
|
||||
|
||||
+28
-28
@@ -1,23 +1,23 @@
|
||||
/*
|
||||
* <copyright>
|
||||
/*
|
||||
* <copyright>
|
||||
* Copyright 1997-2003 PMD for Eclipse Development team
|
||||
* under sponsorship of the Defense Advanced Research Projects
|
||||
* Agency (DARPA).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the Cougaar Open Source License as published by
|
||||
* DARPA on the Cougaar Open Source Website (www.cougaar.org).
|
||||
*
|
||||
* THE COUGAAR SOFTWARE AND ANY DERIVATIVE SUPPLIED BY LICENSOR IS
|
||||
* PROVIDED "AS IS" WITHOUT WARRANTIES OF ANY KIND, WHETHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING (BUT NOT LIMITED TO) ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND WITHOUT
|
||||
* ANY WARRANTIES AS TO NON-INFRINGEMENT. IN NO EVENT SHALL COPYRIGHT
|
||||
* HOLDER BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT OR CONSEQUENTIAL
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE OF DATA OR PROFITS,
|
||||
* TORTIOUS CONDUCT, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THE COUGAAR SOFTWARE.
|
||||
*
|
||||
* under sponsorship of the Defense Advanced Research Projects
|
||||
* Agency (DARPA).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the Cougaar Open Source License as published by
|
||||
* DARPA on the Cougaar Open Source Website (www.cougaar.org).
|
||||
*
|
||||
* THE COUGAAR SOFTWARE AND ANY DERIVATIVE SUPPLIED BY LICENSOR IS
|
||||
* PROVIDED "AS IS" WITHOUT WARRANTIES OF ANY KIND, WHETHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING (BUT NOT LIMITED TO) ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND WITHOUT
|
||||
* ANY WARRANTIES AS TO NON-INFRINGEMENT. IN NO EVENT SHALL COPYRIGHT
|
||||
* HOLDER BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT OR CONSEQUENTIAL
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE OF DATA OR PROFITS,
|
||||
* TORTIOUS CONDUCT, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THE COUGAAR SOFTWARE.
|
||||
*
|
||||
* </copyright>
|
||||
*/
|
||||
package net.sourceforge.pmd.eclipse.runtime.writer.impl;
|
||||
@@ -50,7 +50,7 @@ import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Implements a default AST Writer
|
||||
*
|
||||
*
|
||||
* @author Philippe Herlin
|
||||
*
|
||||
*/
|
||||
@@ -99,7 +99,7 @@ class AstWriterImpl implements IAstWriter {
|
||||
|
||||
for (int i = 0; i < simpleNode.jjtGetNumChildren(); i++) {
|
||||
Node child = simpleNode.jjtGetChild(i);
|
||||
Element element = getElement(doc, (Node) child);
|
||||
Element element = getElement(doc, child);
|
||||
simpleNodeElement.appendChild(element);
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ class AstWriterImpl implements IAstWriter {
|
||||
|
||||
/**
|
||||
* Add attributes to element by introspecting the node. This way, the abstract
|
||||
* tree can evolve indepently from the way it is persisted
|
||||
* tree can evolve independently from the way it is persisted
|
||||
* @param element a xml element
|
||||
* @param simpleNode a ast node
|
||||
*/
|
||||
@@ -116,17 +116,17 @@ class AstWriterImpl implements IAstWriter {
|
||||
try {
|
||||
BeanInfo beanInfo = Introspector.getBeanInfo(simpleNode.getClass());
|
||||
PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
|
||||
for (int i = 0; i < descriptors.length; i++) {
|
||||
String attributeName = descriptors[i].getName();
|
||||
for (PropertyDescriptor descriptor : descriptors) {
|
||||
String attributeName = descriptor.getName();
|
||||
if (!attributeName.equals("class") && !attributeName.equals("scope")) {
|
||||
log.debug(" processing attribute " + descriptors[i].getName());
|
||||
Method getter = descriptors[i].getReadMethod();
|
||||
log.debug(" processing attribute " + descriptor.getName());
|
||||
Method getter = descriptor.getReadMethod();
|
||||
if (getter != null) {
|
||||
try {
|
||||
Object result = getter.invoke(simpleNode, null);
|
||||
Object result = getter.invoke(simpleNode, (Object)null);
|
||||
if (result != null) {
|
||||
log.debug(" added");
|
||||
element.setAttribute(descriptors[i].getName(), result.toString());
|
||||
element.setAttribute(descriptor.getName(), result.toString());
|
||||
} else {
|
||||
log.debug(" not added attribute is null");
|
||||
}
|
||||
|
||||
+18
-18
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
@@ -18,7 +18,7 @@
|
||||
* * 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
|
||||
@@ -72,9 +72,9 @@ import org.eclipse.ui.IWorkbenchPart;
|
||||
|
||||
/**
|
||||
* Implements the clear reviews action
|
||||
*
|
||||
*
|
||||
* @author Philippe Herlin
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ClearReviewsAction implements IObjectActionDelegate, IResourceVisitor, IViewActionDelegate {
|
||||
private static final Logger log = Logger.getLogger(ClearReviewsAction.class);
|
||||
@@ -124,7 +124,7 @@ public class ClearReviewsAction implements IObjectActionDelegate, IResourceVisit
|
||||
|
||||
/**
|
||||
* Get the monitor
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected IProgressMonitor getMonitor() {
|
||||
@@ -133,7 +133,7 @@ public class ClearReviewsAction implements IObjectActionDelegate, IResourceVisit
|
||||
|
||||
/**
|
||||
* Set the monitor
|
||||
*
|
||||
*
|
||||
* @param monitor
|
||||
*/
|
||||
protected void setMonitor(IProgressMonitor monitor) {
|
||||
@@ -151,7 +151,7 @@ public class ClearReviewsAction implements IObjectActionDelegate, IResourceVisit
|
||||
|
||||
/**
|
||||
* Set a substask
|
||||
*
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
protected void monitorSubTask(String message) {
|
||||
@@ -170,15 +170,15 @@ public class ClearReviewsAction implements IObjectActionDelegate, IResourceVisit
|
||||
if (this.targetPart instanceof IViewPart) {
|
||||
ISelection selection = targetPart.getSite().getSelectionProvider().getSelection();
|
||||
|
||||
if ((selection != null) && (selection instanceof IStructuredSelection)) {
|
||||
if (selection != null && selection instanceof IStructuredSelection) {
|
||||
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
|
||||
if (getMonitor() != null) {
|
||||
getMonitor().beginTask(getString(StringKeys.MSGKEY_MONITOR_REMOVE_REVIEWS),
|
||||
IProgressMonitor.UNKNOWN);
|
||||
|
||||
Iterator i = structuredSelection.iterator();
|
||||
Iterator<Object> i = structuredSelection.iterator();
|
||||
while (i.hasNext()) {
|
||||
Object object = (Object) i.next();
|
||||
Object object = i.next();
|
||||
IResource resource = null;
|
||||
|
||||
if (object instanceof IMarker) {
|
||||
@@ -225,7 +225,7 @@ public class ClearReviewsAction implements IObjectActionDelegate, IResourceVisit
|
||||
|
||||
/**
|
||||
* Clear reviews for a file
|
||||
*
|
||||
*
|
||||
* @param file
|
||||
*/
|
||||
private void clearReviews(IFile file) {
|
||||
@@ -241,7 +241,7 @@ public class ClearReviewsAction implements IObjectActionDelegate, IResourceVisit
|
||||
|
||||
/**
|
||||
* remove reviews from file content
|
||||
*
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
@@ -262,18 +262,18 @@ public class ClearReviewsAction implements IObjectActionDelegate, IResourceVisit
|
||||
String line = origLine.trim();
|
||||
int index = origLine.indexOf(PMDRuntimeConstants.PMD_STYLE_REVIEW_COMMENT);
|
||||
int quoteIndex = origLine.indexOf('"');
|
||||
|
||||
|
||||
if (line.startsWith("/*")) {
|
||||
if (line.indexOf("*/") == -1) {
|
||||
comment = true;
|
||||
}
|
||||
out.println(origLine);
|
||||
} else if (comment && (line.indexOf("*/") != -1)) {
|
||||
} else if (comment && line.indexOf("*/") != -1) {
|
||||
comment = false;
|
||||
out.println(origLine);
|
||||
} else if (!comment && line.startsWith(PMDRuntimeConstants.PLUGIN_STYLE_REVIEW_COMMENT)) {
|
||||
noChange = false;
|
||||
} else if (!comment && (index != -1) && !(quoteIndex != -1 && quoteIndex < index && index < origLine.lastIndexOf('"'))) {
|
||||
} else if (!comment && index != -1 && !(quoteIndex != -1 && quoteIndex < index && index < origLine.lastIndexOf('"'))) {
|
||||
noChange = false;
|
||||
out.println(origLine.substring(0, index));
|
||||
} else {
|
||||
@@ -294,7 +294,7 @@ public class ClearReviewsAction implements IObjectActionDelegate, IResourceVisit
|
||||
|
||||
/**
|
||||
* Save the file
|
||||
*
|
||||
*
|
||||
* @param file
|
||||
* @param newContent
|
||||
*/
|
||||
@@ -314,9 +314,9 @@ public class ClearReviewsAction implements IObjectActionDelegate, IResourceVisit
|
||||
clearReviews((IFile) resource);
|
||||
}
|
||||
|
||||
return (resource instanceof IProject) || (resource instanceof IFolder);
|
||||
return resource instanceof IProject || resource instanceof IFolder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method to return an NLS string from its key
|
||||
*/
|
||||
|
||||
+57
-57
File diff suppressed because it is too large.
Load diff
+23
-23
@@ -7,7 +7,7 @@
|
||||
* 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
|
||||
@@ -20,7 +20,7 @@
|
||||
* * 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
|
||||
@@ -54,9 +54,9 @@ import org.eclipse.jdt.core.IMethod;
|
||||
* This class holds information for use with the dataflow view. It contains a
|
||||
* Java-Method and the corresponding PMD-Method (SimpleNode) and can return
|
||||
* Dataflow Anomalies for it.
|
||||
*
|
||||
*
|
||||
* @author SebastianRaffel ( 07.06.2005 ), Philippe Herlin, Sven Jacob
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DataflowMethodRecord {
|
||||
private final IMethod method;
|
||||
@@ -64,7 +64,7 @@ public class DataflowMethodRecord {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*
|
||||
* @param javaMethod, the Method of the JavaModel
|
||||
* @param pmdMethod, the corresponding PMD-SimpleNode / ASTMethodDeclaration
|
||||
*/
|
||||
@@ -104,11 +104,11 @@ public class DataflowMethodRecord {
|
||||
|
||||
/**
|
||||
* Finds Dataflow-Anomalies for a Method
|
||||
*
|
||||
*
|
||||
* @return a List of Anomalies
|
||||
*/
|
||||
public IMarker[] getMarkers() {
|
||||
final List markers = new ArrayList();
|
||||
final List<IMarker> markers = new ArrayList<IMarker>();
|
||||
try {
|
||||
if (this.method.getResource().isAccessible()) {
|
||||
|
||||
@@ -123,7 +123,7 @@ public class DataflowMethodRecord {
|
||||
// the Marker should have valid Information in it
|
||||
// ... and we don't want it twice, so we check,
|
||||
// if the Marker already exists
|
||||
if (markerIsValid(allMarkers[i]) && (!markerIsInList(allMarkers[i], markers))) {
|
||||
if (markerIsValid(allMarkers[i]) && !markerIsInList(allMarkers[i], markers)) {
|
||||
markers.add(allMarkers[i]);
|
||||
}
|
||||
}
|
||||
@@ -142,7 +142,7 @@ public class DataflowMethodRecord {
|
||||
* Returns a list of Attributes for a Dataflow Marker, (1.) the Error
|
||||
* Message, (2.) the beginning Line of the Error, (3.) the ending Line and
|
||||
* (4.) the Variable (Marker Attribute)
|
||||
*
|
||||
*
|
||||
* @param marker
|
||||
* @return an Array of Attributes
|
||||
*/
|
||||
@@ -176,32 +176,32 @@ public class DataflowMethodRecord {
|
||||
/**
|
||||
* Checks, if a Marker is valid, meaning that it (1.) is set for this Method
|
||||
* (between Begin and End-Line) and (2.) has a Variable and Message set
|
||||
*
|
||||
*
|
||||
* @param marker
|
||||
* @return true if the Marker is valid, false otherwise
|
||||
*/
|
||||
private boolean markerIsValid(IMarker marker) {
|
||||
boolean isValid = false;
|
||||
|
||||
// get the Markers atrributes
|
||||
// get the Markers attributes
|
||||
final Object[] values = getMarkerAttributes(marker);
|
||||
final int line1 = ((Integer) values[1]).intValue();
|
||||
final int line2 = ((Integer) values[2]).intValue();
|
||||
|
||||
// the Marker has to be in this Method
|
||||
if ((line1 >= this.node.getBeginLine()) && (line2 <= this.node.getEndLine())) {
|
||||
if (line1 >= this.node.getBeginLine() && line2 <= this.node.getEndLine()) {
|
||||
isValid = true;
|
||||
for (int k = 0; (k < values.length) && isValid; k++) {
|
||||
for (int k = 0; k < values.length && isValid; k++) {
|
||||
|
||||
// if it is a String, it has to be the Variable
|
||||
// or Message, which shouldn't be empty
|
||||
if ((values[k] instanceof String) && (((String) values[k]).equals(""))) {
|
||||
if (values[k] instanceof String && ((String) values[k]).equals("")) {
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// else it is one of the Lines (Line, Line2)
|
||||
// and they also should not be 0
|
||||
else if ((values[k] instanceof Integer) && (((Integer) values[k]).intValue() == 0)) {
|
||||
else if (values[k] instanceof Integer && ((Integer) values[k]).intValue() == 0) {
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
@@ -213,33 +213,33 @@ public class DataflowMethodRecord {
|
||||
|
||||
/**
|
||||
* Checks if a Marker is already in a List
|
||||
*
|
||||
*
|
||||
* @param marker
|
||||
* @param list
|
||||
* @return true, is the marker exists in thelist, false otherwise
|
||||
* @return true, is the marker exists in the list, false otherwise
|
||||
*/
|
||||
private boolean markerIsInList(IMarker marker, List list) {
|
||||
private boolean markerIsInList(IMarker marker, List<IMarker> list) {
|
||||
boolean inList = false;
|
||||
|
||||
if ((list != null) && (!list.isEmpty())) {
|
||||
if (list != null && !list.isEmpty()) {
|
||||
|
||||
// here we can't simply compare Objects, because the Dataflow
|
||||
// Anomaly Calculation sets different Markers for the same Error
|
||||
|
||||
// get the Markers Attributes and compare with all other Markers
|
||||
final Object[] markerAttr = getMarkerAttributes(marker);
|
||||
for (int i = 0; (i < list.size()) && !inList; i++) {
|
||||
for (int i = 0; i < list.size() && !inList; i++) {
|
||||
// get the Marker from the List and its Attributes
|
||||
final Object[] listAttr = getMarkerAttributes((IMarker) list.get(i));
|
||||
final Object[] listAttr = getMarkerAttributes(list.get(i));
|
||||
|
||||
boolean markersAreEqual = true;
|
||||
for (int j = 0; j < listAttr.length; j++) {
|
||||
// compare the String- and Integer-Values
|
||||
if ((markerAttr[j] instanceof String) && (!((String) markerAttr[j]).equalsIgnoreCase((String) listAttr[j]))) {
|
||||
if (markerAttr[j] instanceof String && !((String) markerAttr[j]).equalsIgnoreCase((String) listAttr[j])) {
|
||||
markersAreEqual = false;
|
||||
}
|
||||
|
||||
else if ((markerAttr[j] instanceof Integer) && (!((Integer) markerAttr[j]).equals((Integer) listAttr[j]))) {
|
||||
else if (markerAttr[j] instanceof Integer && !((Integer) markerAttr[j]).equals(listAttr[j])) {
|
||||
markersAreEqual = false;
|
||||
}
|
||||
}
|
||||
|
||||
+65
-51
File diff suppressed because it is too large.
Load diff
+40
-27
@@ -7,7 +7,7 @@
|
||||
* 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
|
||||
@@ -20,7 +20,7 @@
|
||||
* * 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
|
||||
@@ -44,7 +44,7 @@ import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Sven
|
||||
*
|
||||
*/
|
||||
@@ -54,11 +54,11 @@ public class MarkerRecord extends AbstractPMDRecord {
|
||||
private final FileRecord parent;
|
||||
private final String ruleName;
|
||||
private final int priority;
|
||||
private final List markers;
|
||||
|
||||
private final List<IMarker> markers;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
*
|
||||
* @param javaResource the given File
|
||||
*/
|
||||
public MarkerRecord(FileRecord parent, String ruleName, int priority) {
|
||||
@@ -66,21 +66,22 @@ public class MarkerRecord extends AbstractPMDRecord {
|
||||
this.parent = parent;
|
||||
this.ruleName = ruleName;
|
||||
this.priority = priority;
|
||||
this.markers = new ArrayList();
|
||||
this.markers = new ArrayList<IMarker>();
|
||||
this.children = AbstractPMDRecord.EMPTY_RECORDS;
|
||||
}
|
||||
|
||||
|
||||
public void addViolation(IMarker marker) {
|
||||
this.markers.add(marker);
|
||||
}
|
||||
|
||||
|
||||
public int getViolationsCounted() {
|
||||
return markers.size();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#addResource(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
@Override
|
||||
public AbstractPMDRecord addResource(IResource resource) {
|
||||
return null;
|
||||
}
|
||||
@@ -88,27 +89,29 @@ public class MarkerRecord extends AbstractPMDRecord {
|
||||
public void updateChildren() {
|
||||
this.children = createChildren();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#createChildren()
|
||||
*/
|
||||
@Override
|
||||
public final AbstractPMDRecord[] createChildren() {
|
||||
final List children = new ArrayList();
|
||||
|
||||
final List markers = parent.getParent().findResourcesByName(this.ruleName, TYPE_MARKER);
|
||||
final Iterator markerIterator = markers.iterator();
|
||||
|
||||
final List<AbstractPMDRecord> children = new ArrayList<AbstractPMDRecord>();
|
||||
|
||||
final List<AbstractPMDRecord> markers = parent.getParent().findResourcesByName(this.ruleName, TYPE_MARKER);
|
||||
final Iterator<AbstractPMDRecord> markerIterator = markers.iterator();
|
||||
|
||||
while (markerIterator.hasNext()) {
|
||||
final MarkerRecord marker = (MarkerRecord) markerIterator.next();
|
||||
children.add(new FileToMarkerRecord(marker)); // NOPMD by Sven on 13.11.06 12:05
|
||||
}
|
||||
|
||||
return (AbstractPMDRecord[]) children.toArray(new AbstractPMDRecord[children.size()]);
|
||||
|
||||
return children.toArray(new AbstractPMDRecord[children.size()]);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getChildren()
|
||||
*/
|
||||
@Override
|
||||
public AbstractPMDRecord[] getChildren() {
|
||||
return children; // NOPMD by Sven on 13.11.06 12:05
|
||||
}
|
||||
@@ -116,10 +119,11 @@ public class MarkerRecord extends AbstractPMDRecord {
|
||||
/*
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return ruleName;
|
||||
}
|
||||
|
||||
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
@@ -127,6 +131,7 @@ public class MarkerRecord extends AbstractPMDRecord {
|
||||
/*
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getParent()
|
||||
*/
|
||||
@Override
|
||||
public AbstractPMDRecord getParent() {
|
||||
return parent;
|
||||
}
|
||||
@@ -134,6 +139,7 @@ public class MarkerRecord extends AbstractPMDRecord {
|
||||
/*
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getResource()
|
||||
*/
|
||||
@Override
|
||||
public IResource getResource() {
|
||||
return parent.getResource();
|
||||
}
|
||||
@@ -141,6 +147,7 @@ public class MarkerRecord extends AbstractPMDRecord {
|
||||
/*
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getResourceType()
|
||||
*/
|
||||
@Override
|
||||
public int getResourceType() {
|
||||
return TYPE_MARKER;
|
||||
}
|
||||
@@ -148,31 +155,35 @@ public class MarkerRecord extends AbstractPMDRecord {
|
||||
/*
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#removeResource(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
@Override
|
||||
public AbstractPMDRecord removeResource(IResource resource) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMarkers() {
|
||||
return markers.size() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMarker[] findMarkers() {
|
||||
return (IMarker[]) markers.toArray(new IMarker[markers.size()]);
|
||||
return markers.toArray(new IMarker[markers.size()]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getNumberOfViolationsToPriority(int)
|
||||
*/
|
||||
public int getNumberOfViolationsToPriority(int prio, boolean invertMarkerAndFileRecords) {
|
||||
@Override
|
||||
public int getNumberOfViolationsToPriority(int prio, boolean invertMarkerAndFileRecords) {
|
||||
int number = 0;
|
||||
if (prio == priority) {
|
||||
if (prio == priority) {
|
||||
if (invertMarkerAndFileRecords) {
|
||||
for (int i=0; i<children.length; i++) {
|
||||
number += children[i].getNumberOfViolationsToPriority(prio, false);
|
||||
}
|
||||
for (AbstractPMDRecord element : children) {
|
||||
number += element.getNumberOfViolationsToPriority(prio, false);
|
||||
}
|
||||
} else {
|
||||
number = getViolationsCounted();
|
||||
}
|
||||
}
|
||||
}
|
||||
return number;
|
||||
}
|
||||
@@ -180,6 +191,7 @@ public class MarkerRecord extends AbstractPMDRecord {
|
||||
/* (non-Javadoc)
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getLOC()
|
||||
*/
|
||||
@Override
|
||||
public int getLOC() {
|
||||
return parent.getLOC();
|
||||
}
|
||||
@@ -187,6 +199,7 @@ public class MarkerRecord extends AbstractPMDRecord {
|
||||
/* (non-Javadoc)
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getNumberOfMethods()
|
||||
*/
|
||||
@Override
|
||||
public int getNumberOfMethods() {
|
||||
return parent.getNumberOfMethods();
|
||||
}
|
||||
|
||||
+39
-26
@@ -7,7 +7,7 @@
|
||||
* 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
|
||||
@@ -20,7 +20,7 @@
|
||||
* * 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
|
||||
@@ -50,9 +50,9 @@ import org.eclipse.jdt.core.JavaModelException;
|
||||
|
||||
/**
|
||||
* AbstractPMDRecord for a Package creates Files when instantiated
|
||||
*
|
||||
*
|
||||
* @author SebastianRaffel ( 16.05.2005 ), Philippe Herlin, Sven Jacob
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class PackageRecord extends AbstractPMDRecord {
|
||||
final private IPackageFragment packageFragment;
|
||||
@@ -61,7 +61,7 @@ public class PackageRecord extends AbstractPMDRecord {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*
|
||||
* @param fragment, the PackageFragment
|
||||
* @param record, the Project
|
||||
*/
|
||||
@@ -84,6 +84,7 @@ public class PackageRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getParent()
|
||||
*/
|
||||
@Override
|
||||
public AbstractPMDRecord getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
@@ -91,6 +92,7 @@ public class PackageRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getChildren()
|
||||
*/
|
||||
@Override
|
||||
public AbstractPMDRecord[] getChildren() {
|
||||
return this.children; // NOPMD by Herlin on 09/10/06 00:22
|
||||
}
|
||||
@@ -98,6 +100,7 @@ public class PackageRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getResource()
|
||||
*/
|
||||
@Override
|
||||
public IResource getResource() {
|
||||
IResource resource = null;
|
||||
try {
|
||||
@@ -110,7 +113,7 @@ public class PackageRecord extends AbstractPMDRecord {
|
||||
|
||||
/**
|
||||
* Gets the Package's Fragment
|
||||
*
|
||||
*
|
||||
* @return the Fragment
|
||||
*/
|
||||
public IPackageFragment getFragment() {
|
||||
@@ -120,12 +123,13 @@ public class PackageRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#createChildren()
|
||||
*/
|
||||
@Override
|
||||
protected final AbstractPMDRecord[] createChildren() {
|
||||
final List fileList = new ArrayList();
|
||||
final List<FileRecord> fileList = new ArrayList<FileRecord>();
|
||||
try {
|
||||
final ICompilationUnit[] javaUnits = this.packageFragment.getCompilationUnits();
|
||||
for (int k = 0; k < javaUnits.length; k++) {
|
||||
final IResource javaResource = javaUnits[k].getCorrespondingResource();
|
||||
for (ICompilationUnit javaUnit : javaUnits) {
|
||||
final IResource javaResource = javaUnit.getCorrespondingResource();
|
||||
if (javaResource != null) {
|
||||
fileList.add(new FileRecord(javaResource, this)); // NOPMD
|
||||
// by
|
||||
@@ -139,12 +143,13 @@ public class PackageRecord extends AbstractPMDRecord {
|
||||
PMDPlugin.getDefault().logError(StringKeys.MSGKEY_ERROR_CORE_EXCEPTION + this.toString(), ce);
|
||||
}
|
||||
|
||||
return (AbstractPMDRecord[]) fileList.toArray(new AbstractPMDRecord[fileList.size()]);
|
||||
return fileList.toArray(new AbstractPMDRecord[fileList.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#addResource(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
@Override
|
||||
public AbstractPMDRecord addResource(IResource resource) {
|
||||
final ICompilationUnit unit = this.packageFragment.getCompilationUnit(resource.getName());
|
||||
FileRecord file = null;
|
||||
@@ -153,7 +158,7 @@ public class PackageRecord extends AbstractPMDRecord {
|
||||
if (unit != null) {
|
||||
// we create a new FileRecord and add it to the List
|
||||
file = new FileRecord(resource, this);
|
||||
final List files = getChildrenAsList();
|
||||
final List<AbstractPMDRecord> files = getChildrenAsList();
|
||||
files.add(file);
|
||||
|
||||
this.children = new AbstractPMDRecord[files.size()];
|
||||
@@ -166,13 +171,14 @@ public class PackageRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#removeResource(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
@Override
|
||||
public AbstractPMDRecord removeResource(IResource resource) {
|
||||
final List files = getChildrenAsList();
|
||||
final List<AbstractPMDRecord> files = getChildrenAsList();
|
||||
AbstractPMDRecord removedFile = null;
|
||||
boolean removed = false;
|
||||
|
||||
for (int i = 0; (i < files.size()) && !removed; i++) {
|
||||
final AbstractPMDRecord file = (AbstractPMDRecord) files.get(i);
|
||||
for (int i = 0; i < files.size() && !removed; i++) {
|
||||
final AbstractPMDRecord file = files.get(i);
|
||||
|
||||
// if the file is in here, remove it
|
||||
if (file.getResource().equals(resource)) {
|
||||
@@ -196,6 +202,7 @@ public class PackageRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
String name = this.packageFragment.getElementName();
|
||||
|
||||
@@ -210,6 +217,7 @@ public class PackageRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getResourceType()
|
||||
*/
|
||||
@Override
|
||||
public int getResourceType() {
|
||||
return AbstractPMDRecord.TYPE_PACKAGE;
|
||||
}
|
||||
@@ -217,6 +225,7 @@ public class PackageRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see Object#equals(Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof PackageRecord ? this.packageFragment.equals(((PackageRecord) obj).packageFragment) : false;
|
||||
}
|
||||
@@ -224,43 +233,47 @@ public class PackageRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.packageFragment.hashCode();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getNumberOfViolationsToPriority(int)
|
||||
*/
|
||||
@Override
|
||||
public int getNumberOfViolationsToPriority(int prio, boolean invertMarkerAndFileRecords) {
|
||||
int number = 0;
|
||||
for (int i=0; i<children.length; i++) {
|
||||
number += children[i].getNumberOfViolationsToPriority(prio, false);
|
||||
for (AbstractPMDRecord element : children) {
|
||||
number += element.getNumberOfViolationsToPriority(prio, false);
|
||||
}
|
||||
|
||||
|
||||
return number;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getLOC()
|
||||
*/
|
||||
@Override
|
||||
public int getLOC() {
|
||||
int number = 0;
|
||||
for (int i=0; i<children.length; i++) {
|
||||
number += children[i].getLOC();
|
||||
for (AbstractPMDRecord element : children) {
|
||||
number += element.getLOC();
|
||||
}
|
||||
|
||||
|
||||
return number;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getNumberOfMethods()
|
||||
*/
|
||||
@Override
|
||||
public int getNumberOfMethods() {
|
||||
int number = 0;
|
||||
for (int i=0; i<children.length; i++) {
|
||||
number += children[i].getNumberOfMethods();
|
||||
for (AbstractPMDRecord element : children) {
|
||||
number += element.getNumberOfMethods();
|
||||
}
|
||||
|
||||
|
||||
return number;
|
||||
}
|
||||
|
||||
|
||||
+39
-28
@@ -7,7 +7,7 @@
|
||||
* 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
|
||||
@@ -20,7 +20,7 @@
|
||||
* * 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
|
||||
@@ -56,9 +56,9 @@ import org.eclipse.jdt.core.JavaModelException;
|
||||
|
||||
/**
|
||||
* AbstractPMDRecord for Projects creates Packages when instantiated
|
||||
*
|
||||
*
|
||||
* @author SebastianRaffel ( 16.05.2005 ), Philippe Herlin, Sven Jacob
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ProjectRecord extends AbstractPMDRecord {
|
||||
final private IProject project;
|
||||
@@ -67,7 +67,7 @@ public class ProjectRecord extends AbstractPMDRecord {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*
|
||||
* @param proj, the Project
|
||||
* @param record, the RootRecord
|
||||
*/
|
||||
@@ -97,6 +97,7 @@ public class ProjectRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getParent()
|
||||
*/
|
||||
@Override
|
||||
public AbstractPMDRecord getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
@@ -104,6 +105,7 @@ public class ProjectRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getChildren()
|
||||
*/
|
||||
@Override
|
||||
public AbstractPMDRecord[] getChildren() {
|
||||
return this.children; // NOPMD by Herlin on 09/10/06 00:43
|
||||
}
|
||||
@@ -111,6 +113,7 @@ public class ProjectRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getResource()
|
||||
*/
|
||||
@Override
|
||||
public IResource getResource() {
|
||||
return this.project;
|
||||
}
|
||||
@@ -118,8 +121,9 @@ public class ProjectRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#createChildren()
|
||||
*/
|
||||
@Override
|
||||
protected final AbstractPMDRecord[] createChildren() {
|
||||
final Set packages = new HashSet();
|
||||
final Set<PackageRecord> packages = new HashSet<PackageRecord>();
|
||||
try {
|
||||
// search for Packages
|
||||
this.project.accept(new IResourceVisitor() {
|
||||
@@ -141,8 +145,8 @@ public class ProjectRecord extends AbstractPMDRecord {
|
||||
// "org.eclipse.core" the root is
|
||||
// "org.eclipse.core")
|
||||
packages.addAll(createPackagesFromFragmentRoot((IPackageFragmentRoot) javaMember));
|
||||
} else if ((javaMember instanceof IPackageFragment)
|
||||
&& (javaMember.getParent() instanceof IPackageFragmentRoot)) {
|
||||
} else if (javaMember instanceof IPackageFragment
|
||||
&& javaMember.getParent() instanceof IPackageFragmentRoot) {
|
||||
// if the Element is a Package get its Root and
|
||||
// do the same as above
|
||||
final IPackageFragment fragment = (IPackageFragment) javaMember;
|
||||
@@ -165,27 +169,27 @@ public class ProjectRecord extends AbstractPMDRecord {
|
||||
}
|
||||
|
||||
// return the List as an Array of Packages
|
||||
return (AbstractPMDRecord[]) packages.toArray(new AbstractPMDRecord[packages.size()]);
|
||||
return packages.toArray(new AbstractPMDRecord[packages.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for the Packages to a given FragmentRoot (Package-Root) and create
|
||||
* PackageRecords for them
|
||||
*
|
||||
*
|
||||
* @param root
|
||||
* @return
|
||||
*/
|
||||
protected final Set createPackagesFromFragmentRoot(IPackageFragmentRoot root) {
|
||||
final Set packages = new HashSet();
|
||||
protected final Set<PackageRecord> createPackagesFromFragmentRoot(IPackageFragmentRoot root) {
|
||||
final Set<PackageRecord> packages = new HashSet<PackageRecord>();
|
||||
IJavaElement[] fragments = null;
|
||||
try {
|
||||
// search for all children
|
||||
fragments = root.getChildren();
|
||||
for (int k = 0; k < fragments.length; k++) {
|
||||
if (fragments[k] instanceof IPackageFragment) {
|
||||
for (IJavaElement fragment : fragments) {
|
||||
if (fragment instanceof IPackageFragment) {
|
||||
// create a PackageRecord for the Fragment
|
||||
// and add it to the list
|
||||
packages.add(new PackageRecord((IPackageFragment) fragments[k], this)); // NOPMD
|
||||
packages.add(new PackageRecord((IPackageFragment) fragment, this)); // NOPMD
|
||||
// by
|
||||
// Herlin
|
||||
// on
|
||||
@@ -203,13 +207,14 @@ public class ProjectRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.project.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks, if the underlying Project is open
|
||||
*
|
||||
*
|
||||
* @return true, if the Project is open, false otherwise
|
||||
*/
|
||||
public boolean isProjectOpen() {
|
||||
@@ -219,6 +224,7 @@ public class ProjectRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getResourceType()
|
||||
*/
|
||||
@Override
|
||||
public int getResourceType() {
|
||||
return AbstractPMDRecord.TYPE_PROJECT;
|
||||
}
|
||||
@@ -226,6 +232,7 @@ public class ProjectRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#addResource(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
@Override
|
||||
public AbstractPMDRecord addResource(IResource resource) {
|
||||
AbstractPMDRecord addedResource = null;
|
||||
|
||||
@@ -240,7 +247,7 @@ public class ProjectRecord extends AbstractPMDRecord {
|
||||
|
||||
// we search int the children Packages for the File's Package
|
||||
// by comparing their Fragments
|
||||
for (int k = 0; (k < this.children.length) && (addedResource == null); k++) {
|
||||
for (int k = 0; k < this.children.length && addedResource == null; k++) {
|
||||
final PackageRecord packageRec = (PackageRecord) children[k];
|
||||
if (packageRec.getFragment().equals(fragment)) {
|
||||
// if the Package exists
|
||||
@@ -252,7 +259,7 @@ public class ProjectRecord extends AbstractPMDRecord {
|
||||
// ... else we create a new Record for the new Package
|
||||
if (addedResource == null) {
|
||||
final PackageRecord packageRec = new PackageRecord(fragment, this);
|
||||
final List packages = getChildrenAsList();
|
||||
final List<AbstractPMDRecord> packages = getChildrenAsList();
|
||||
packages.add(packageRec);
|
||||
|
||||
// ... and we add a new FileRecord to it
|
||||
@@ -268,6 +275,7 @@ public class ProjectRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#removeResource(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
@Override
|
||||
public AbstractPMDRecord removeResource(IResource resource) {
|
||||
AbstractPMDRecord removedResource = null;
|
||||
|
||||
@@ -284,7 +292,7 @@ public class ProjectRecord extends AbstractPMDRecord {
|
||||
PackageRecord packageRec;
|
||||
|
||||
// like above we compare Fragments to find the right Package
|
||||
for (int k = 0; (k < this.children.length) && (removedResource == null); k++) {
|
||||
for (int k = 0; k < this.children.length && removedResource == null; k++) {
|
||||
packageRec = (PackageRecord) this.children[k];
|
||||
if (packageRec.getFragment().equals(fragment)) {
|
||||
|
||||
@@ -293,7 +301,7 @@ public class ProjectRecord extends AbstractPMDRecord {
|
||||
if (packageRec.getChildren().length == 0) {
|
||||
// ... and if the Package is empty too
|
||||
// we also remove it
|
||||
final List packages = getChildrenAsList();
|
||||
final List<AbstractPMDRecord> packages = getChildrenAsList();
|
||||
packages.remove(packageRec);
|
||||
|
||||
this.children = new AbstractPMDRecord[packages.size()]; // NOPMD
|
||||
@@ -316,10 +324,11 @@ public class ProjectRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getNumberOfViolationsToPriority(int)
|
||||
*/
|
||||
@Override
|
||||
public int getNumberOfViolationsToPriority(int prio, boolean invertMarkerAndFileRecords) {
|
||||
int number = 0;
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
number += children[i].getNumberOfViolationsToPriority(prio, invertMarkerAndFileRecords);
|
||||
for (AbstractPMDRecord element : children) {
|
||||
number += element.getNumberOfViolationsToPriority(prio, invertMarkerAndFileRecords);
|
||||
}
|
||||
|
||||
return number;
|
||||
@@ -327,13 +336,14 @@ public class ProjectRecord extends AbstractPMDRecord {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getLOC()
|
||||
*/
|
||||
@Override
|
||||
public int getLOC() {
|
||||
int number = 0;
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
number += children[i].getLOC();
|
||||
for (AbstractPMDRecord element : children) {
|
||||
number += element.getLOC();
|
||||
}
|
||||
|
||||
return number;
|
||||
@@ -341,13 +351,14 @@ public class ProjectRecord extends AbstractPMDRecord {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getNumberOfMethods()
|
||||
*/
|
||||
@Override
|
||||
public int getNumberOfMethods() {
|
||||
int number = 0;
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
number += children[i].getNumberOfMethods();
|
||||
for (AbstractPMDRecord element : children) {
|
||||
number += element.getNumberOfMethods();
|
||||
}
|
||||
|
||||
return number;
|
||||
|
||||
+36
-25
@@ -7,7 +7,7 @@
|
||||
* 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
|
||||
@@ -20,7 +20,7 @@
|
||||
* * 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
|
||||
@@ -46,9 +46,9 @@ import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
/**
|
||||
* AbstractPMDRecord for the WorkspaceRoot creates ProjectRecords when
|
||||
* instantiated
|
||||
*
|
||||
*
|
||||
* @author SebastianRaffel ( 16.05.2005 ), Philippe Herlin, Sven Jacob
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class RootRecord extends AbstractPMDRecord {
|
||||
final private IWorkspaceRoot workspaceRoot;
|
||||
@@ -56,7 +56,7 @@ public class RootRecord extends AbstractPMDRecord {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*
|
||||
* @param root, the WorkspaceRoot
|
||||
*/
|
||||
public RootRecord(IWorkspaceRoot root) {
|
||||
@@ -73,6 +73,7 @@ public class RootRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getParent()
|
||||
*/
|
||||
@Override
|
||||
public AbstractPMDRecord getParent() {
|
||||
return this;
|
||||
}
|
||||
@@ -80,6 +81,7 @@ public class RootRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getChildren()
|
||||
*/
|
||||
@Override
|
||||
public AbstractPMDRecord[] getChildren() {
|
||||
return this.children; // NOPMD by Herlin on 09/10/06 00:56
|
||||
}
|
||||
@@ -87,6 +89,7 @@ public class RootRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getResource()
|
||||
*/
|
||||
@Override
|
||||
public IResource getResource() {
|
||||
return this.workspaceRoot;
|
||||
}
|
||||
@@ -94,26 +97,28 @@ public class RootRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#createChildren()
|
||||
*/
|
||||
@Override
|
||||
protected final AbstractPMDRecord[] createChildren() {
|
||||
// get the projects
|
||||
final IProject[] projects = this.workspaceRoot.getProjects();
|
||||
final List projectList = new ArrayList();
|
||||
final List<AbstractPMDRecord> projectList = new ArrayList<AbstractPMDRecord>();
|
||||
|
||||
// ... and create Records for them
|
||||
for (int i = 0; i < projects.length; i++) {
|
||||
projectList.add(new ProjectRecord(projects[i], this)); // NOPMD by
|
||||
for (IProject project : projects) {
|
||||
projectList.add(new ProjectRecord(project, this)); // NOPMD by
|
||||
// Herlin on
|
||||
// 09/10/06
|
||||
// 00:57
|
||||
}
|
||||
|
||||
// return the Array of children
|
||||
return (AbstractPMDRecord[]) projectList.toArray(new AbstractPMDRecord[projectList.size()]);
|
||||
return projectList.toArray(new AbstractPMDRecord[projectList.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#addResource(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
@Override
|
||||
public AbstractPMDRecord addResource(IResource resource) {
|
||||
return resource instanceof IProject ? addProject((IProject) resource) : null; // NOPMD
|
||||
// by
|
||||
@@ -126,6 +131,7 @@ public class RootRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#removeResource(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
@Override
|
||||
public AbstractPMDRecord removeResource(IResource resource) {
|
||||
return resource instanceof IProject ? removeProject((IProject) resource) : null; // NOPMD
|
||||
// by
|
||||
@@ -138,6 +144,7 @@ public class RootRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.workspaceRoot.getName();
|
||||
}
|
||||
@@ -145,13 +152,14 @@ public class RootRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getResourceType()
|
||||
*/
|
||||
@Override
|
||||
public int getResourceType() {
|
||||
return AbstractPMDRecord.TYPE_ROOT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new ProjectRecord and adds it to the List of ProjectRecords
|
||||
*
|
||||
*
|
||||
* @param project
|
||||
* @return the ProjectRecord created for the Project or null, if the Project
|
||||
* is not open
|
||||
@@ -159,7 +167,7 @@ public class RootRecord extends AbstractPMDRecord {
|
||||
private ProjectRecord addProject(IProject project) {
|
||||
ProjectRecord addedProject = null;
|
||||
if (project.isOpen()) {
|
||||
final List projects = getChildrenAsList();
|
||||
final List<AbstractPMDRecord> projects = getChildrenAsList();
|
||||
final ProjectRecord projectRec = new ProjectRecord(project, this);
|
||||
projects.add(projectRec);
|
||||
|
||||
@@ -173,15 +181,15 @@ public class RootRecord extends AbstractPMDRecord {
|
||||
/**
|
||||
* Searches with a given Project for a Record containing this Project;
|
||||
* removes and returns this ProjectRecord
|
||||
*
|
||||
*
|
||||
* @param project
|
||||
* @return the removed ProjectRecord
|
||||
*/
|
||||
private ProjectRecord removeProject(IProject project) {
|
||||
ProjectRecord removedProject = null;
|
||||
|
||||
final List projects = getChildrenAsList();
|
||||
for (int k = 0; (k < projects.size()) && (removedProject == null); k++) {
|
||||
final List<AbstractPMDRecord> projects = getChildrenAsList();
|
||||
for (int k = 0; k < projects.size() && removedProject == null; k++) {
|
||||
final ProjectRecord projectRec = (ProjectRecord) projects.get(k);
|
||||
final IProject proj = (IProject) projectRec.getResource();
|
||||
|
||||
@@ -202,40 +210,43 @@ public class RootRecord extends AbstractPMDRecord {
|
||||
|
||||
return removedProject;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getNumberOfViolationsToPriority(int)
|
||||
*/
|
||||
@Override
|
||||
public int getNumberOfViolationsToPriority(int prio, boolean invertMarkerAndFileRecords) {
|
||||
int number = 0;
|
||||
for (int i=0; i<children.length; i++) {
|
||||
number += children[i].getNumberOfViolationsToPriority(prio, invertMarkerAndFileRecords);
|
||||
for (AbstractPMDRecord element : children) {
|
||||
number += element.getNumberOfViolationsToPriority(prio, invertMarkerAndFileRecords);
|
||||
}
|
||||
|
||||
|
||||
return number;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getLOC()
|
||||
*/
|
||||
@Override
|
||||
public int getLOC() {
|
||||
int number = 0;
|
||||
for (int i=0; i<children.length; i++) {
|
||||
number += children[i].getLOC();
|
||||
for (AbstractPMDRecord element : children) {
|
||||
number += element.getLOC();
|
||||
}
|
||||
|
||||
|
||||
return number;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getNumberOfMethods()
|
||||
*/
|
||||
@Override
|
||||
public int getNumberOfMethods() {
|
||||
int number = 0;
|
||||
for (int i=0; i<children.length; i++) {
|
||||
number += children[i].getNumberOfMethods();
|
||||
for (AbstractPMDRecord element : children) {
|
||||
number += element.getNumberOfMethods();
|
||||
}
|
||||
|
||||
|
||||
return number;
|
||||
}
|
||||
}
|
||||
+35
-22
@@ -99,7 +99,8 @@ public class PMDPreferencePage extends PreferencePage implements IWorkbenchPrefe
|
||||
/**
|
||||
* @see org.eclipse.jface.preference.PreferencePage#performDefaults()
|
||||
*/
|
||||
protected void performDefaults() {
|
||||
@Override
|
||||
protected void performDefaults() {
|
||||
populateRuleTable();
|
||||
populateExcludePatternTable();
|
||||
populateIncludePatternTable();
|
||||
@@ -109,7 +110,8 @@ public class PMDPreferencePage extends PreferencePage implements IWorkbenchPrefe
|
||||
/**
|
||||
* @see org.eclipse.jface.preference.IPreferencePage#performOk()
|
||||
*/
|
||||
public boolean performOk() {
|
||||
@Override
|
||||
public boolean performOk() {
|
||||
if (modified) {
|
||||
updateRuleSet();
|
||||
rebuildProjects();
|
||||
@@ -121,7 +123,8 @@ public class PMDPreferencePage extends PreferencePage implements IWorkbenchPrefe
|
||||
/**
|
||||
* @see org.eclipse.jface.preference.PreferencePage#createContents(Composite)
|
||||
*/
|
||||
protected Control createContents(Composite parent) {
|
||||
@Override
|
||||
protected Control createContents(Composite parent) {
|
||||
Composite composite = new Composite(parent, SWT.NULL);
|
||||
layoutControls(composite);
|
||||
return composite;
|
||||
@@ -305,7 +308,7 @@ public class PMDPreferencePage extends PreferencePage implements IWorkbenchPrefe
|
||||
* Helper method to add new table columns
|
||||
*/
|
||||
private void addColumnTo(Table table, int alignment, boolean resizable, String text, int width,
|
||||
final Comparator comparator) {
|
||||
final Comparator<Rule> comparator) {
|
||||
|
||||
TableColumn newColumn = new TableColumn(table, alignment);
|
||||
newColumn.setResizable(resizable);
|
||||
@@ -313,7 +316,8 @@ public class PMDPreferencePage extends PreferencePage implements IWorkbenchPrefe
|
||||
newColumn.setWidth(width);
|
||||
if (comparator != null) {
|
||||
newColumn.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
ruleTableViewerSorter.setComparator(comparator);
|
||||
refresh();
|
||||
}
|
||||
@@ -410,7 +414,8 @@ public class PMDPreferencePage extends PreferencePage implements IWorkbenchPrefe
|
||||
button.setText(getMessage(StringKeys.MSGKEY_PREF_RULESET_BUTTON_REMOVERULE));
|
||||
button.setEnabled(false);
|
||||
button.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
IStructuredSelection selection = (IStructuredSelection)ruleTableViewer.getSelection();
|
||||
Rule selectedRule = (Rule)selection.getFirstElement();
|
||||
ruleSet.getRules().remove(selectedRule);
|
||||
@@ -434,7 +439,8 @@ public class PMDPreferencePage extends PreferencePage implements IWorkbenchPrefe
|
||||
button.setEnabled(false);
|
||||
|
||||
button.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
IStructuredSelection selection = (IStructuredSelection)ruleTableViewer.getSelection();
|
||||
Rule rule = (Rule)selection.getFirstElement();
|
||||
|
||||
@@ -463,7 +469,8 @@ public class PMDPreferencePage extends PreferencePage implements IWorkbenchPrefe
|
||||
button.setEnabled(true);
|
||||
|
||||
button.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
RuleDialog dialog = new RuleDialog(getShell());
|
||||
int result = dialog.open();
|
||||
if (result == RuleDialog.OK) {
|
||||
@@ -497,7 +504,8 @@ public class PMDPreferencePage extends PreferencePage implements IWorkbenchPrefe
|
||||
button.setText(getMessage(StringKeys.MSGKEY_PREF_RULESET_BUTTON_IMPORTRULESET));
|
||||
button.setEnabled(true);
|
||||
button.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
RuleSetSelectionDialog dialog = new RuleSetSelectionDialog(getShell());
|
||||
dialog.open();
|
||||
if (dialog.getReturnCode() == RuleSetSelectionDialog.OK) {
|
||||
@@ -507,9 +515,7 @@ public class PMDPreferencePage extends PreferencePage implements IWorkbenchPrefe
|
||||
ruleSet.addRuleSetByReference(selectedRuleSet, false);
|
||||
} else {
|
||||
// Set pmd-eclipse as new RuleSet name and add the Rule
|
||||
Iterator iter = selectedRuleSet.getRules().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Rule rule = (Rule)iter.next();
|
||||
for (Rule rule: selectedRuleSet.getRules()) {
|
||||
rule.setRuleSetName("pmd-eclipse");
|
||||
ruleSet.addRule(rule);
|
||||
}
|
||||
@@ -538,7 +544,8 @@ public class PMDPreferencePage extends PreferencePage implements IWorkbenchPrefe
|
||||
button.setText(getMessage(StringKeys.MSGKEY_PREF_RULESET_BUTTON_EXPORTRULESET));
|
||||
button.setEnabled(true);
|
||||
button.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
|
||||
String fileName = dialog.open();
|
||||
if (fileName != null) {
|
||||
@@ -590,7 +597,8 @@ public class PMDPreferencePage extends PreferencePage implements IWorkbenchPrefe
|
||||
button.setText(getMessage(StringKeys.MSGKEY_PREF_RULESET_BUTTON_CLEARALL));
|
||||
button.setEnabled(true);
|
||||
button.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
if (MessageDialog.openConfirm(getShell(), getMessage(StringKeys.MSGKEY_CONFIRM_TITLE),
|
||||
getMessage(StringKeys.MSGKEY_CONFIRM_CLEAR_RULESET))) {
|
||||
ruleSet.getRules().clear();
|
||||
@@ -615,7 +623,8 @@ public class PMDPreferencePage extends PreferencePage implements IWorkbenchPrefe
|
||||
button.setText(getMessage(StringKeys.MSGKEY_PREF_RULESET_BUTTON_RULEDESIGNER));
|
||||
button.setEnabled(true);
|
||||
button.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
// TODO Is this cool from Eclipse? Is there a nicer way to spawn a J2SE Application?
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
@@ -636,7 +645,8 @@ public class PMDPreferencePage extends PreferencePage implements IWorkbenchPrefe
|
||||
button.setText(getMessage(StringKeys.MSGKEY_PREF_RULESET_BUTTON_ADDPROPERTY));
|
||||
button.setEnabled(false);
|
||||
button.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
InputDialog input = new InputDialog(getShell(),
|
||||
getMessage(StringKeys.MSGKEY_PREF_RULESET_DIALOG_TITLE),
|
||||
getMessage(StringKeys.MSGKEY_PREF_RULESET_DIALOG_PROPERTY_NAME), "", null);
|
||||
@@ -734,7 +744,8 @@ public class PMDPreferencePage extends PreferencePage implements IWorkbenchPrefe
|
||||
button.setText(getMessage(StringKeys.MSGKEY_PREF_RULESET_BUTTON_ADD_EXCLUDE_PATTERN));
|
||||
button.setEnabled(true);
|
||||
button.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
ruleSet.addExcludePattern(".*/PATTERN/.*");
|
||||
setModified(true);
|
||||
excludePatternTableViewer.refresh();
|
||||
@@ -751,7 +762,8 @@ public class PMDPreferencePage extends PreferencePage implements IWorkbenchPrefe
|
||||
button.setText(getMessage(StringKeys.MSGKEY_PREF_RULESET_BUTTON_ADD_INCLUDE_PATTERN));
|
||||
button.setEnabled(true);
|
||||
button.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
ruleSet.addIncludePattern(".*/PATTERN/.*");
|
||||
setModified(true);
|
||||
includePatternTableViewer.refresh();
|
||||
@@ -818,7 +830,8 @@ public class PMDPreferencePage extends PreferencePage implements IWorkbenchPrefe
|
||||
/**
|
||||
* @see org.eclipse.jface.preference.PreferencePage#doGetPreferenceStore()
|
||||
*/
|
||||
protected IPreferenceStore doGetPreferenceStore() {
|
||||
@Override
|
||||
protected IPreferenceStore doGetPreferenceStore() {
|
||||
return PMDPlugin.getDefault().getPreferenceStore();
|
||||
}
|
||||
|
||||
@@ -914,10 +927,10 @@ public class PMDPreferencePage extends PreferencePage implements IWorkbenchPrefe
|
||||
protected void selectAndShowRule(Rule rule) {
|
||||
Table table = ruleTableViewer.getTable();
|
||||
TableItem[] items = table.getItems();
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
Rule itemRule = (Rule)items[i].getData();
|
||||
for (TableItem item : items) {
|
||||
Rule itemRule = (Rule)item.getData();
|
||||
if (itemRule.equals(rule)) {
|
||||
table.setSelection(table.indexOf(items[i]));
|
||||
table.setSelection(table.indexOf(item));
|
||||
table.showSelection();
|
||||
break;
|
||||
}
|
||||
|
||||
Loaded 30 of 54 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user