diff --git a/pmd-eclipse-feature/feature.xml b/pmd-eclipse-feature/feature.xml
index 651752b775..2b719d34b3 100644
--- a/pmd-eclipse-feature/feature.xml
+++ b/pmd-eclipse-feature/feature.xml
@@ -2,7 +2,7 @@
@@ -41,6 +41,6 @@
id="net.sourceforge.pmd.eclipse"
download-size="596 038"
install-size="598 016"
- version="3.0.2"/>
+ version="3.1.0"/>
diff --git a/pmd-eclipse/.classpath b/pmd-eclipse/.classpath
index 9284c8f355..d0f15da36c 100644
--- a/pmd-eclipse/.classpath
+++ b/pmd-eclipse/.classpath
@@ -1,6 +1,6 @@
-
+
diff --git a/pmd-eclipse/.project b/pmd-eclipse/.project
index dc63903401..9017825a67 100644
--- a/pmd-eclipse/.project
+++ b/pmd-eclipse/.project
@@ -26,10 +26,16 @@
+
+ net.sourceforge.metrics.builder
+
+
+
org.eclipse.jdt.core.javanature
org.eclipse.pde.PluginNature
net.sourceforge.pmd.eclipse.pmdNature
+ net.sourceforge.metrics.nature
diff --git a/pmd-eclipse/.ruleset b/pmd-eclipse/.ruleset
index 30157da627..465dee52ea 100644
--- a/pmd-eclipse/.ruleset
+++ b/pmd-eclipse/.ruleset
@@ -1,6 +1,6 @@
-
- PMD Plugin preferences rule set
+
+
An explicit call was made to a finalize method. Finalize methods are meant to be executed at most once (by the garbage collector). Calling it explicitly could result in the method being executed twice for that object (once by you, once by the garbage collector).
- 3
+ 4
- 3
+ 4
-
+
@@ -76,7 +76,7 @@ import java.lang.*;
public class Foo {}
]]>
- 3
+ 4
- 3
+ 4
@@ -116,7 +116,7 @@ public abstract class Foo { // should be AbstractFoo
}
]]>
- 3
+ 4
- 3
+ 4
- 3
+ 4
-
- Exposing internal arrays directly allows the user to modify some code that could be critical. It is safer to return a copy of the array.
-
- 3
-
-
Non-constructor methods should not have the same name as the enclosing class.
- 3
+ 4
@@ -224,7 +207,7 @@ public class Foo extends Bar{
}
]]>
- 3
+ 4
+
+ When doing a String.toLowerCase()/toUpperCase() call, use a Locale. This avoids problems with certain locales, i.e. Turkish.
+
+ 4
+
+
+
+
+
+
A large amount of public methods and attributes declared in an object can indicate the class may need to be broken up as increased effort will be required to thoroughly test such a class.
- 3
+ 4
-
- When doing a String.toLowerCase()/toUpperCase() call, use a Locale. This avoids problems with certain locales, i.e. Turkish.
-
- 3
-
-
-
-
-
-
Avoid using dollar signs in variable/method/class/interface names.
- 3
+ 4
- 3
+ 4
- 1
+ 2
- 3
+ 4
@@ -416,7 +399,7 @@ try {
}
]]>
- 3
+ 4
@@ -428,7 +411,7 @@ public class Foo {
}
]]>
- 3
+ 4
- 3
+ 4
- 3
+ 4
- 1
+ 2
@@ -543,7 +526,7 @@ public abstract class Foo {
}
]]>
- 3
+ 4
- 3
+ 4
- 3
+ 4
@@ -619,7 +602,7 @@ public void doSomething() {
}
]]>
- 3
+ 4
@@ -642,7 +625,7 @@ try {
}
]]>
- 3
+ 4
@@ -656,7 +639,7 @@ try {
}
}
]]>
- 3
+ 4
- 1
+ 2
- 3
+ 4
- 3
+ 4
@@ -797,7 +780,7 @@ public class Foo {
}
]]>
- 3
+ 4
@@ -823,7 +806,7 @@ public class Foo {
}
]]>
- 3
+ 4
+
+ Avoid unused import statements.
+
+ 4
+
+
Avoid empty try blocks - what's the point?
- 1
+ 2
- 3
+ 4
-
- Avoid unused import statements.
-
- 3
-
-
An empty statement (aka a semicolon by itself) that is not used as the sole body of a for loop or while loop is probably a bug. It could also be a double semicolon, which is useless and should be removed.
- 3
+ 4
+
+
+ Sometimes return statement expressions are wrapped in unnecessary parentheses,
+ making them look like a function call.
+
+
+ 4
+
+
+
+
+
+
It is somewhat confusing to have a field name with the same name as a method. While this is totally legal, having information (field) and actions (method) is not clear naming.
- 3
+ 4
@@ -963,7 +974,7 @@ public class Foo {
}
]]>
- 3
+ 4
- 3
+ 4
- 3
+ 4
@@ -1029,7 +1040,7 @@ public class Something {
}
]]>
- 3
+ 4
@@ -1080,7 +1091,7 @@ public class Something {
}
]]>
- 3
+ 4
@@ -1094,7 +1105,7 @@ public class Foo {
}
]]>
- 1
+ 4
@@ -1116,7 +1127,7 @@ public class Foo {
]]>
- 3
+ 4
- 3
+ 4
@@ -1160,7 +1171,7 @@ public void doSomething() {
public class Bar{}
]]>
- 3
+ 4
@@ -1186,7 +1197,7 @@ public void doSomething() {
}
]]>
- 3
+ 4
@@ -1201,7 +1212,7 @@ public class Foo extends Bar {
}
]]>
- 3
+ 4
@@ -1216,7 +1227,7 @@ public class Foo extends Bar {
}
]]>
- 3
+ 4
@@ -1229,7 +1240,7 @@ public class Foo {
}
]]>
- 1
+ 2
@@ -1246,7 +1257,7 @@ public class Foo {
}
]]>
- 3
+ 4
@@ -1276,7 +1287,7 @@ public class Foo {
}
}
]]>
- 3
+ 4
- 3
+ 4
@@ -1329,7 +1340,7 @@ public class Foo {}
return Integer.toString(x);
}
]]>
- 3
+ 4
@@ -1345,7 +1356,7 @@ public class Foo {}
}
]]>
- 3
+ 4
- 3
+ 4
@@ -1403,7 +1414,7 @@ public class Foo {
}
]]>
- 3
+ 4
- 3
+ 4
-
- Avoid unnecessary comparisons in boolean expressions - this makes simple code seem complicated.
+
+
+ Finds usages of += for appending strings.
+
- 3
+ a = "foo";
+ a += " bar";
+
+ // better would be:
+ StringBuffer a = new StringBuffer("foo");
+ a.append(" bar);
+
+ ]]>
+ 4
+
+//StatementExpression
+ [PrimaryExpression/PrimaryPrefix/Name
+ [@Image = ancestor::MethodDeclaration//LocalVariableDeclaration
+ [./Type//ClassOrInterfaceType[@Image =
+'String']]/VariableDeclarator/VariableDeclaratorId/@Image]]
+ //AssignmentOperator[@Compound='true']
+
+ ]]>
@@ -1483,7 +1502,7 @@ return 3;
]]>
- 3
+ 4
+
+ Avoid unnecessary comparisons in boolean expressions - this makes simple code seem complicated.
+
+ 4
+
+
+
+
+
+
Unnecessary constructor detects when a constructor is not necessary; i.e., when there's only one constructor, it's public, has an empty body, and takes no arguments.
- 3
+ 4
- 3
+ 4
-
- Constructors and methods receiving arrays shuold clone objects and store the copy. This prevents that future changes from the user affect the internal functionallity.
-
- 3
-
-
Object clone() should be implemented with super.clone()
- 1
+ 2
- 3
+ 4
+
+
+ No need to check for null before an instanceof; the instanceof keyword returns false when given a null argument.
+
+
+ 4
+
+
+
+
+
+
Avoid unnecessary if..then..else statements when returning a boolean
- 3
+ 4
@@ -1642,7 +1708,7 @@ public class Foo {
return (x != y) ? diff : same;
]]>
- 3
+ 4
@@ -1654,7 +1720,7 @@ public class Foo {
return;
}
]]>
- 3
+ 4
- 1
+ 2
- 3
+ 4
+
+
+ A field that's only used by one method could perhaps be replaced by a local variable
+
+
+ 4
+
+
A suspicious octal escape sequence was found inside a String literal. The Java language specification (section 3.10.6) says an octal escape sequence inside a literal String shall consist of a backslash followed by: OctalDigit | OctalDigit OctalDigit | ZeroToThree OctalDigit OctalDigit Any octal escape sequence followed by non-octal digits can be confusing, e.g. "\038" is interpreted as the octal escape sequence "\03" followed by the literal character "8".
- 3
+ 4
@@ -1744,7 +1828,7 @@ class Foo{
}
}
]]>
- 3
+ 4
- 3
+ 4
- 3
+ 4
- 3
+ 4
@@ -1831,7 +1915,7 @@ public class Foo {
}
]]>
- 3
+ 4
- 3
+ 4
@@ -1875,7 +1959,7 @@ public class Something {
}
]]>
- 3
+ 4
@@ -1886,7 +1970,7 @@ public class Something {
static {}
}
]]>
- 3
+ 4
- 3
+ 4
- 3
+ 4
- 3
+ 4
- 1
+ 2
- 3
+ 4
-
- Avoid instantiating Boolean objects, instead use Boolean.valueOf().
-
- 1
-
-
-
-
-
-
Avoid empty switch statements.
- 3
+ 4
+
+ Avoid instantiating Boolean objects, instead use Boolean.valueOf().
+
+ 2
+
+
+
+
+
+
Avoid jumbled loop incrementers - it's usually a mistake, and it's confusing even if it's what's intended.
- 3
+ 4
- 3
+ 4
@@ -2115,7 +2199,7 @@ public class MaybeASingleton {
}
]]>
- 3
+ 4
- 3
+ 4
+
+ Do not use "if" statements that are always true or always false.
+
+ 4
+
+
+
+
+
+
finalize() is called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
- 3
+ 4
-
- Do not use "if" statements that are always true or always false.
-
- 3
-
-
-
-
-
-
Do not use protected fields in final classes since they cannot be subclassed. Clarify your intent by using private or package access modifiers instead.
- 3
+ 4
- 1
+ 2
- 3
+ 4
@@ -2261,7 +2345,7 @@ try {
}
]]>
- 3
+ 4
- 3
+ 4
-
+
-
- This checks to make sure that the Parameter Lists in the project aren't getting too long. If there are long parameter lists, then that is generally indicative that another object is hiding around there. Basically, try to group the parameters together. Default value is 2.5 sigma greater than the mean. NOTE: In version 0.9 and higher, their are three parameters available: minimum - Minimum Length before reporting. sigma - Std Deviations away from the mean before reporting. topscore - The Maximum Number of reports to generate. At this time, only one can be used at a time.
+
+
+ Since it passes in a literal of length 1, this call to String.startsWith can be rewritten using String.charAt(0) to save some time.
+
- 3
+ ]]>
+ 4
-
+
+
+
@@ -2328,9 +2426,26 @@ public class Something {
}
]]>
- 3
+ 4
+
+ This checks to make sure that the Parameter Lists in the project aren't getting too long. If there are long parameter lists, then that is generally indicative that another object is hiding around there. Basically, try to group the parameters together. Default value is 2.5 sigma greater than the mean. NOTE: In version 0.9 and higher, their are three parameters available: minimum - Minimum Length before reporting. sigma - Std Deviations away from the mean before reporting. topscore - The Maximum Number of reports to generate. At this time, only one can be used at a time.
+
+ 4
+
+
+
+
Assigning a "null" to a variable (outside of its declaration) is usually in bad form. Some times, the assignment is an indication that the programmer doesn't completely understand what is going on in the code. NOTE: This sort of assignment may in rare cases be useful to encourage garbage collection. If that's what you're using it for, by all means, disregard this rule :-)
- 3
+ 4
@@ -2367,7 +2482,7 @@ public class Something {
}
]]>
- 3
+ 4
-
- Empty If Statement finds instances where a condition is checked but nothing is done about it.
-
- 1
-
-
-
-
-
-
Avoid instantiating String objects; this is usually unnecessary.
- 1
+ 2
+
+ Empty If Statement finds instances where a condition is checked but nothing is done about it.
+
+ 2
+
+
+
+
+
+
Avoid using 'while' statements without using curly braces
- 3
+ 4
- 1
+ 2
- 3
+ 4
@@ -2496,7 +2611,7 @@ int x = (y == Double.NaN);
}
]]>
- 3
+ 4
- 3
+ 4
32]]]>
@@ -2543,7 +2658,7 @@ public class Something {
public class Foo {}
]]>
- 1
+ 2
@@ -2563,9 +2678,39 @@ public class Foo {}
}
}
]]>
- 1
+ 2
+
+
+ Sometimes two 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.
+
+
+ 5
+
+
+
+
+
+
notify() awakens a thread monitoring the object. If more than one thread is monitoring, then only one is chosen. The thread chosen is arbitrary; thus it's usually safer to call notifyAll() instead.
- 3
+ 4
-
- Detects when very short method names are used.
-
- 3
-
-
-
-
-
-
A local variable assigned only once can be declared final.
- 3
+ 4
+
+ Detects when very short method names are used.
+
+ 4
+
+
+
+
+
+
Avoid concatenating non literals in a StringBuffer constructor or append().
- 1
+ 2
@@ -2664,7 +2809,7 @@ class Foo{
}
]]>
- 1
+ 2
- 3
+ 4
- 3
+ 4
-
- Switch statements should have a default label.
-
- 3
-
-
-
-
-
-
When a class has the final modifier, all the methods are marked finally.
- 3
+ 4
+
+ Switch statements should have a default label.
+
+ 4
+
+
+
+
+
+
+
+ Methods named finalize() should not have parameters. It is confusing and probably a bug to overload finalize(). It will not be called by the VM.
+
+ 4
+
+
+ 0]]
+
+ ]]>
+
+
+
Identifies private fields whose values never change once they are initialized either in the declaration of the field or by a constructor. This aids in converting existing classes to immutable classes.
- 3
+ 4
-
- Methods named finalize() should not have parameters. It is confusing and probably a bug to overload finalize(). It will not be called by the VM.
-
- 3
-
-
- 0]]
-
- ]]>
-
-
-
diff --git a/pmd-eclipse/CHANGELOG.txt b/pmd-eclipse/CHANGELOG.txt
index 6188161c58..cad858fa89 100644
--- a/pmd-eclipse/CHANGELOG.txt
+++ b/pmd-eclipse/CHANGELOG.txt
@@ -2,6 +2,21 @@ Change log for the PMD Eclipse plugin
-------------------------------------
+v3.0.2 - xx/06/2005
+
+Runtime
+-------
+. Fix Bug#1190624 (Completly refactor the CPD feature. see release notes)
+
+Development
+-----------
+. Continuing the refactoring.
+. Forgive "small" commands.
+. Use Castor to serialize project properties inside the project itself and no more inside
+ the workspace .metadata
+
+
+----------------------------------------------------------------------------------------
v3.0.1 - 07/05/2005
Runtime
diff --git a/pmd-eclipse/RELNOTES.txt b/pmd-eclipse/RELNOTES.txt
index 574adc2df4..3e89a11bda 100644
--- a/pmd-eclipse/RELNOTES.txt
+++ b/pmd-eclipse/RELNOTES.txt
@@ -6,6 +6,18 @@ IMPORTANT : SINCE v2.0 THE INSTALLATION PROCEDURE HAS BEEN CHANGED.
FOR INSTRUCTIONS.
+v3.0RC3 (alias v3.0.2) - xx/06/2005
+-----------------------------------
+
+FIXED/UPDATED : CPD report window for Mac users
+--------------------------------------------------
+Because the bug #1190624 cannot be fixed, the CPD integration has been refactored.
+Now CPD can be launched on one project at a time only.
+The results are produced in a report file inside the report folder.
+The SimpleRenderer is used to render the report.
+
+
+----------------------------------------------------------------------------------------
v3.0RC2 (alias v3.0.1) - 07/05/2005
-----------------------------------
diff --git a/pmd-eclipse/log4j.xml b/pmd-eclipse/log4j.xml
index f8ac9aad57..930425ff86 100644
--- a/pmd-eclipse/log4j.xml
+++ b/pmd-eclipse/log4j.xml
@@ -11,7 +11,7 @@
-
+
diff --git a/pmd-eclipse/plugin.xml b/pmd-eclipse/plugin.xml
index 7dbc88539d..61349dde47 100644
--- a/pmd-eclipse/plugin.xml
+++ b/pmd-eclipse/plugin.xml
@@ -3,7 +3,7 @@
diff --git a/pmd-eclipse/src/net/sourceforge/pmd/eclipse/PMDPlugin.java b/pmd-eclipse/src/net/sourceforge/pmd/eclipse/PMDPlugin.java
index 4e9104c110..a73dc0a1c1 100644
--- a/pmd-eclipse/src/net/sourceforge/pmd/eclipse/PMDPlugin.java
+++ b/pmd-eclipse/src/net/sourceforge/pmd/eclipse/PMDPlugin.java
@@ -50,13 +50,14 @@ import org.osgi.framework.BundleContext;
* @version $Revision$
*
* $Log$
- * Revision 1.23 2005/05/31 20:33:02 phherlin
+ * Revision 1.24 2005/06/29 20:10:33 phherlin
+ * Moving dev environment to Eclipse v3.1
+ * Revision 1.23 2005/05/31 20:33:02 phherlin
* Continuing refactoring
- *
- * Revision 1.22 2004/06/29 22:00:30 phherlin
- * Adapting the plugin to the new OSGi standards
- * Revision 1.21 2004/05/26 15:55:23 phherlin Upgrading
- * to PMD 1.8: adding finalizers ruleset to the default rulesets list
+ *
+ * Revision 1.22 2004/06/29 22:00:30 phherlin Adapting the plugin to the new
+ * OSGi standards Revision 1.21 2004/05/26 15:55:23 phherlin Upgrading to PMD
+ * 1.8: adding finalizers ruleset to the default rulesets list
*
* Revision 1.20 2003/12/18 23:58:37 phherlin Fixing malformed UTF-8 characters
* in generated xml files
@@ -106,7 +107,7 @@ import org.osgi.framework.BundleContext;
public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
// Static attributes
- private static PMDPlugin plugin;
+ private static PMDPlugin soleInstance;
private static Log log;
// Private attributes
@@ -116,28 +117,29 @@ public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
private String reviewAdditionalComment;
/**
- * The constructor.
+ * Private constructor ensures it remains a singleton.
*/
- public PMDPlugin() {
+ private PMDPlugin() {
super();
- plugin = this;
}
/**
* Returns the shared instance.
*/
public static PMDPlugin getDefault() {
- return plugin;
+ if (soleInstance == null)
+ soleInstance = new PMDPlugin();
+ return soleInstance;
}
/**
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
- public void start(BundleContext context) throws Exception {
+public void start(BundleContext context) throws Exception {
super.start(context);
try {
- URL messageTableUrl = this.find(new Path("$nl$/messages.properties"));
+ URL messageTableUrl = find(new Path("$nl$/messages.properties"));
if (messageTableUrl != null) {
messageTable = new Properties();
messageTable.load(messageTableUrl.openStream());
@@ -145,24 +147,22 @@ public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
if (log == null) {
DOMConfigurator.configure(find(new Path("log4j.xml")));
- log = LogFactory.getLog("net.sourceforge.pmd.eclipse.PMDPlugin");
+ log = LogFactory.getLog(getClass().toString()); // always derive the name
}
log.info("PMD plugin loaded");
} catch (IOException e) {
logError("Can't load message table", e);
}
- }
-
- /**
- * Returns the string from the message table
- *
- * @param key
- * the message key
- * @param defaultMessage
- * the returned message if key is not found
- * @return the requested message
- */
+ } /**
+ * Returns the string from the message table
+ *
+ * @param key
+ * the message key
+ * @param defaultMessage
+ * the returned message if key is not found
+ * @return the requested message
+ */
public String getMessage(String key, String defaultMessage) {
String result = defaultMessage;
@@ -226,7 +226,6 @@ public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
logError("Ignored runtime exception from PMD : ", e);
}
}
-
return subRuleSet;
}
@@ -237,31 +236,28 @@ public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
public RuleSet getRuleSetForResource(IResource resource, boolean flCreateProperty) {
log.debug("Asking a ruleset for resource " + resource.getName());
IProject project = resource.getProject();
- RuleSet projectRuleSet = null;
- if (isRuleSetStoredInProject(project)) {
- projectRuleSet = getRuleSetForResourceFromProject(project);
- } else {
- projectRuleSet = getRuleSetForResourceFromProperties(resource, flCreateProperty);
- }
-
- return projectRuleSet;
+ return isRuleSetStoredInProject(project) ? getRuleSetForResourceFromProject(project) : getRuleSetForResourceFromProperties(
+ resource, flCreateProperty);
}
/**
* Get the rulset configured for the resouce. Currently, it is the one
* configured for the resource's project
*/
- public RuleSet getRuleSetForResourceFromProperties(IResource resource, boolean flCreateProperty) {
- log.debug("Searching a ruleset for resource " + resource.getName() + " in properties");
+public RuleSet getRuleSetForResourceFromProperties(IResource resource,
+boolean flCreateProperty) {
+ log.debug("Searching a ruleset for resource " + resource.getName() + "in properties");
boolean flNeedSave = false;
RuleSet projectRuleSet = null;
RuleSet configuredRuleSet = getRuleSet();
IProject project = resource.getProject();
try {
- projectRuleSet = (RuleSet) project.getSessionProperty(SESSION_PROPERTY_ACTIVE_RULESET);
+ projectRuleSet = (RuleSet)
+project.getSessionProperty(SESSION_PROPERTY_ACTIVE_RULESET);
if (projectRuleSet == null) {
- String activeRulesList = project.getPersistentProperty(PERSISTENT_PROPERTY_ACTIVE_RULESET);
+ String activeRulesList =
+project.getPersistentProperty(PERSISTENT_PROPERTY_ACTIVE_RULESET);
if (activeRulesList != null) {
projectRuleSet = getRuleSetFromRuleList(activeRulesList);
flNeedSave = true;
@@ -298,32 +294,38 @@ public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
}
return projectRuleSet;
- }
-
- /**
- * Retrieve a project ruleset from a ruleset file in the project instead of
- * the plugin properties/preferences
- *
- * @param project
- * @return
- */
- public RuleSet getRuleSetForResourceFromProject(IProject project) {
- log.debug("Searching a ruleset for project " + project.getName() + " in the project file");
+ } /**
+ * Retrieve a project ruleset from a ruleset file in the project
+ * instead of the plugin properties/preferences
+ *
+ * @param project
+ * @return
+ */
+public RuleSet getRuleSetForResourceFromProject(IProject project) {
+ log.debug("Searching a ruleset for project " + project.getName() + " inthe project file");
RuleSet projectRuleSet = null;
- IFile ruleSetFile = project.getFile(".ruleset");
+ IFile ruleSetFile =
+project.getFile(PMDPluginConstants.PROJECT_RULESET_FILE);
if (ruleSetFile.exists()) {
try {
- projectRuleSet = (RuleSet) project.getSessionProperty(SESSION_PROPERTY_ACTIVE_RULESET);
- Long oldModificationStamp = (Long) project.getSessionProperty(SESSION_PROPERTY_RULESET_MODIFICATION_STAMP);
+ projectRuleSet = (RuleSet)
+project.getSessionProperty(SESSION_PROPERTY_ACTIVE_RULESET);
+ Long oldModificationStamp = (Long)
+project.getSessionProperty(SESSION_PROPERTY_RULESET_MODIFICATION_STAMP);
long newModificationStamp = ruleSetFile.getModificationStamp();
- if ((oldModificationStamp == null) || (oldModificationStamp.longValue() != newModificationStamp)) {
+ if ((oldModificationStamp == null) ||
+(oldModificationStamp.longValue() != newModificationStamp)) {
RuleSetFactory ruleSetFactory = new RuleSetFactory();
- projectRuleSet = ruleSetFactory.createRuleSet(ruleSetFile.getContents());
- project.setSessionProperty(SESSION_PROPERTY_ACTIVE_RULESET, projectRuleSet);
- project.setSessionProperty(SESSION_PROPERTY_RULESET_MODIFICATION_STAMP, new Long(newModificationStamp));
+ projectRuleSet =
+ruleSetFactory.createRuleSet(ruleSetFile.getContents());
+ project.setSessionProperty(SESSION_PROPERTY_ACTIVE_RULESET,
+projectRuleSet);
+
+project.setSessionProperty(SESSION_PROPERTY_RULESET_MODIFICATION_STAMP, new
+Long(newModificationStamp));
}
} catch (Exception e) {
- PMDPlugin.getDefault().showError(getMessage(PMDConstants.MSGKEY_ERROR_LOADING_RULESET), e);
+ showError(getMessage(PMDConstants.MSGKEY_ERROR_LOADING_RULESET), e);
log.debug("", e);
projectRuleSet = null;
}
@@ -336,11 +338,9 @@ public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
}
return projectRuleSet;
- }
-
- /**
- * Store the rules selection in resource property
- */
+ } /**
+ * Store the rules selection in resource property
+ */
public void storeRuleSetForResource(IResource resource, RuleSet ruleSet) {
try {
StringBuffer ruleSelectionList = new StringBuffer();
@@ -355,7 +355,7 @@ public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
resource.setSessionProperty(SESSION_PROPERTY_ACTIVE_RULESET, ruleSet);
} catch (CoreException e) {
- PMDPlugin.getDefault().showError(getMessage(PMDConstants.MSGKEY_ERROR_STORING_PROPERTY), e);
+ showError(getMessage(PMDConstants.MSGKEY_ERROR_STORING_PROPERTY), e);
}
}
@@ -376,8 +376,10 @@ public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
preferedRuleSet = factory.createRuleSet(in);
in.close();
} catch (FileNotFoundException e) {
+
showError(getMessage(PMDConstants.MSGKEY_ERROR_READING_PREFERENCE), e);
} catch (IOException e) {
+
showError(getMessage(PMDConstants.MSGKEY_ERROR_READING_PREFERENCE), e);
}
}
@@ -394,9 +396,10 @@ public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
// Finally, build a default ruleset
if (preferedRuleSet == null) {
- preferedRuleSet = factory.createRuleSet(getClass().getClassLoader().getResourceAsStream(RULESET_DEFAULTLIST[0]));
+ ClassLoader loader = getClass().getClassLoader();
+ preferedRuleSet = factory.createRuleSet(loader.getResourceAsStream(RULESET_DEFAULTLIST[0]));
for (int i = 1; i < RULESET_DEFAULTLIST.length; i++) {
- RuleSet tmpRuleSet = factory.createRuleSet(getClass().getClassLoader().getResourceAsStream(RULESET_DEFAULTLIST[i]));
+ RuleSet tmpRuleSet = factory.createRuleSet(loader.getResourceAsStream(RULESET_DEFAULTLIST[i]));
preferedRuleSet.addRuleSet(tmpRuleSet);
}
@@ -405,7 +408,6 @@ public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
}
return preferedRuleSet;
-
}
/**
@@ -422,12 +424,12 @@ public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
preferedRuleSet = factory.createRuleSet(ruleSetStream);
ruleSetStream.close();
} catch (IOException e) {
+
logError(getMessage(PMDConstants.MSGKEY_ERROR_READING_PREFERENCE), e);
}
}
return preferedRuleSet;
-
}
/**
@@ -442,9 +444,9 @@ public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
out.flush();
out.close();
} catch (IOException e) {
- PMDPlugin.getDefault().showError(getMessage(PMDConstants.MSGKEY_ERROR_WRITING_PREFERENCE), e);
+ showError(getMessage(PMDConstants.MSGKEY_ERROR_WRITING_PREFERENCE), e);
} catch (PMDEclipseException e) {
- PMDPlugin.getDefault().showError(getMessage(PMDConstants.MSGKEY_ERROR_WRITING_PREFERENCE), e);
+ showError(getMessage(PMDConstants.MSGKEY_ERROR_WRITING_PREFERENCE), e);
}
}
@@ -465,7 +467,7 @@ public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
* Get an image corresponding to the severity
*/
public Image getImage(String key, String iconPath) {
- ImageRegistry registry = PMDPlugin.getDefault().getImageRegistry();
+ ImageRegistry registry = getImageRegistry();
Image image = registry.get(key);
if (image == null) {
ImageDescriptor descriptor = getImageDescriptor(iconPath);
@@ -560,6 +562,7 @@ public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
for (int i = 0; i < projects.length; i++) {
if (monitor != null) {
+
monitor.subTask(getMessage(PMDConstants.MSGKEY_MONITOR_UPDATING_PROJECTS) + projects[i].getName());
}
@@ -584,6 +587,7 @@ public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
*/
public String getReviewAdditionalComment() {
if (reviewAdditionalComment == null) {
+
getPreferenceStore().setDefault(REVIEW_ADDITIONAL_COMMENT_PREFERENCE, REVIEW_ADDITIONAL_COMMENT_DEFAULT);
reviewAdditionalComment = getPreferenceStore().getString(REVIEW_ADDITIONAL_COMMENT_PREFERENCE);
}
@@ -605,16 +609,19 @@ public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
* Get the current working set selected of a project Only one working set is
* allowed.
*/
- public IWorkingSet getProjectWorkingSet(IProject project) {
+public IWorkingSet getProjectWorkingSet(IProject project) {
IWorkingSet workingSet = null;
boolean flNeedSave = false;
try {
- workingSet = (IWorkingSet) project.getSessionProperty(SESSION_PROPERTY_WORKINGSET);
+ workingSet = (IWorkingSet)
+project.getSessionProperty(SESSION_PROPERTY_WORKINGSET);
if (workingSet == null) {
- String workingSetName = project.getPersistentProperty(PERSISTENT_PROPERTY_WORKINGSET);
+ String workingSetName =
+project.getPersistentProperty(PERSISTENT_PROPERTY_WORKINGSET);
if (workingSetName != null) {
- IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
+ IWorkingSetManager workingSetManager =
+PlatformUI.getWorkbench().getWorkingSetManager();
workingSet = workingSetManager.getWorkingSet(workingSetName);
if (workingSet != null) {
flNeedSave = true;
@@ -631,18 +638,16 @@ public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
}
return workingSet;
- }
-
- /**
- * Store a workingset for a project
- */
+ } /**
+ * Store a workingset for a project
+ */
public void setProjectWorkingSet(IProject project, IWorkingSet workingSet) {
try {
project.setPersistentProperty(PERSISTENT_PROPERTY_WORKINGSET, workingSet == null ? null : workingSet.getName());
project.setSessionProperty(SESSION_PROPERTY_WORKINGSET, workingSet);
} catch (CoreException e) {
- PMDPlugin.getDefault().showError(getMessage(PMDConstants.MSGKEY_ERROR_CORE_EXCEPTION), e);
+ showError(getMessage(PMDConstants.MSGKEY_ERROR_CORE_EXCEPTION), e);
}
}
@@ -660,7 +665,7 @@ public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
if (ruleSetStoredInProject == null) {
String property = project.getPersistentProperty(PERSISTENT_PROPERTY_STORE_RULESET_PROJECT);
if (property != null) {
- ruleSetStoredInProject = new Boolean(property);
+ ruleSetStoredInProject = Boolean.valueOf(property);
flNeedSave = true;
}
}
@@ -677,7 +682,7 @@ public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
return ruleSetStoredInProject == null ? false : ruleSetStoredInProject.booleanValue();
}
-
+
/**
* Set the store_ruleset_project property
*
@@ -686,13 +691,14 @@ public class PMDPlugin extends AbstractUIPlugin implements PMDPluginConstants {
*/
public void setRuleSetStoredInProject(IProject project, Boolean ruleSetStoredInProject) {
try {
+
project.setPersistentProperty(PERSISTENT_PROPERTY_STORE_RULESET_PROJECT, ruleSetStoredInProject == null
? null
: ruleSetStoredInProject.toString());
project.setSessionProperty(SESSION_PROPERTY_STORE_RULESET_PROJECT, ruleSetStoredInProject);
} catch (CoreException e) {
- PMDPlugin.getDefault().showError(getMessage(PMDConstants.MSGKEY_ERROR_CORE_EXCEPTION), e);
+ showError(getMessage(PMDConstants.MSGKEY_ERROR_CORE_EXCEPTION), e);
}
}