From eebd21a2bf96bcccf65012c57e7148f93ed596e9 Mon Sep 17 00:00:00 2001 From: Xavier Le Vourch Date: Wed, 16 Jul 2008 02:16:02 +0000 Subject: [PATCH] deprecated method Rule.getExample() removed git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@6328 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd/etc/changelog.txt | 1 + .../net/sourceforge/pmd/RuleReferenceTest.java | 3 --- .../sourceforge/pmd/RuleSetFactoryTest.java | 15 +++++++++------ pmd/src/net/sourceforge/pmd/Rule.java | 18 +++++------------- .../pmd/lang/rule/AbstractDelegateRule.java | 4 ---- .../pmd/lang/rule/AbstractRule.java | 14 ++------------ 6 files changed, 17 insertions(+), 38 deletions(-) diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index 7b1149af8e..57dbb07404 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -256,6 +256,7 @@ The following is relatively complete list of the major changes (this may not be Removed - boolean Rule.include() Removed - void Rule.setInclude(boolean) Removed - String Rule.getRulePriorityName() + Removed - String Rule.getExample() Removed - Rule.LOWEST_PRIORITY Removed - Rule.PRIORITIES Removed - RuleSet.applies(Language,Language) diff --git a/pmd/regress/test/net/sourceforge/pmd/RuleReferenceTest.java b/pmd/regress/test/net/sourceforge/pmd/RuleReferenceTest.java index 2b2cbee05e..4b5abb5fd4 100644 --- a/pmd/regress/test/net/sourceforge/pmd/RuleReferenceTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/RuleReferenceTest.java @@ -73,8 +73,6 @@ public class RuleReferenceTest { assertEquals("Override failed", "description2", ruleReference.getDescription()); assertEquals("Override failed", "description2", ruleReference.getOverriddenDescription()); - // TODO Examples is being tested as currently working, but needs to be fixed at some point - assertEquals("Override failed", "example2", ruleReference.getExample()); assertEquals("Override failed", 2, ruleReference.getExamples().size()); assertEquals("Override failed", "example1", ruleReference.getExamples().get(0)); assertEquals("Override failed", "example2", ruleReference.getExamples().get(1)); @@ -139,7 +137,6 @@ public class RuleReferenceTest { assertEquals("Override failed", "description1", ruleReference.getDescription()); assertNull("Override failed", ruleReference.getOverriddenDescription()); - assertEquals("Override failed", "example1", ruleReference.getExample()); assertEquals("Override failed", 1, ruleReference.getExamples().size()); assertEquals("Override failed", "example1", ruleReference.getExamples().get(0)); assertNull("Override failed", ruleReference.getOverriddenExamples()); diff --git a/pmd/regress/test/net/sourceforge/pmd/RuleSetFactoryTest.java b/pmd/regress/test/net/sourceforge/pmd/RuleSetFactoryTest.java index 86532b187c..f84259ee74 100644 --- a/pmd/regress/test/net/sourceforge/pmd/RuleSetFactoryTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/RuleSetFactoryTest.java @@ -18,7 +18,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Properties; import java.util.Set; @@ -125,8 +124,8 @@ public class RuleSetFactoryTest { Set expected = new HashSet(); expected.add("MockRuleName1"); expected.add("MockRuleName2"); - for (Iterator i = rs.getRules().iterator(); i.hasNext();) { - assertTrue(expected.contains(i.next().getName())); + for (Rule rule : rs.getRules()) { + assertTrue(expected.contains(rule.getName())); } } @@ -179,8 +178,8 @@ public class RuleSetFactoryTest { assertEquals("TestNameOverride", r.getName()); assertEquals("Test message override", r.getMessage()); assertEquals("Test description override", r.getDescription()); - assertEquals("Test example override", r.getExample()); assertEquals("Test that both example are stored", 2, r.getExamples().size()); + assertEquals("Test example override", r.getExamples().get(1)); assertEquals(RulePriority.MEDIUM, r.getPriority()); assertTrue(r.hasProperty("test2")); assertEquals("override2", r.getStringProperty("test2")); @@ -501,8 +500,8 @@ public class RuleSetFactoryTest { Rule rule2 = ((List) ruleSet2.getRules()).get(i); assertFalse(message + ", Different RuleReference", - ((rule1 instanceof RuleReference) && !(rule2 instanceof RuleReference)) - || (!(rule1 instanceof RuleReference) && (rule2 instanceof RuleReference))); + rule1 instanceof RuleReference && !(rule2 instanceof RuleReference) + || !(rule1 instanceof RuleReference) && rule2 instanceof RuleReference); if (rule1 instanceof RuleReference) { RuleReference ruleReference1 = (RuleReference) rule1; @@ -652,14 +651,17 @@ public class RuleSetFactoryTest { return valid; } + @Override public void error(SAXParseException e) throws SAXException { log("Error", e); } + @Override public void fatalError(SAXParseException e) throws SAXException { log("FatalError", e); } + @Override public void warning(SAXParseException e) throws SAXException { log("Warning", e); } @@ -670,6 +672,7 @@ public class RuleSetFactoryTest { valid = false; } + @Override public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException { if ("http://pmd.sf.net/ruleset_xml_schema.xsd".equals(systemId) || systemId.endsWith("ruleset.dtd")) { try { diff --git a/pmd/src/net/sourceforge/pmd/Rule.java b/pmd/src/net/sourceforge/pmd/Rule.java index 5fb0f1f381..3ad09cef58 100644 --- a/pmd/src/net/sourceforge/pmd/Rule.java +++ b/pmd/src/net/sourceforge/pmd/Rule.java @@ -108,14 +108,14 @@ public interface Rule { /** * Get the name of the RuleSet containing this Rule. - * + * * @see RuleSet */ String getRuleSetName(); /** * Set the name of the RuleSet containing this Rule. - * + * * @see RuleSet */ void setRuleSetName(String name); @@ -145,14 +145,6 @@ public interface Rule { */ List getExamples(); - /** - * Still used by the JDeveloper plugin - * - * @deprecated use getExamples(), since we now support multiple examples - */ - @Deprecated - String getExample(); - /** * Add a single example for this Rule. */ @@ -180,7 +172,7 @@ public interface Rule { /** * Get all properties for this Rule. - * + * * @return the properties for the rule */ Properties getProperties(); @@ -273,7 +265,7 @@ public interface Rule { void addRuleChainVisit(String astNodeName); /** - * Start processing. Called once, before apply() is first called. + * Start processing. Called once, before apply() is first called. */ void start(RuleContext ctx); @@ -284,7 +276,7 @@ public interface Rule { void apply(List nodes, RuleContext ctx); /** - * End processing. Called once, after apply() is last called. + * End processing. Called once, after apply() is last called. */ void end(RuleContext ctx); } diff --git a/pmd/src/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java b/pmd/src/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java index 0a60dbd807..c269119468 100644 --- a/pmd/src/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java +++ b/pmd/src/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java @@ -112,10 +112,6 @@ public abstract class AbstractDelegateRule implements Rule { return rule.getExamples(); } - public String getExample() { - return rule.getExample(); - } - public void addExample(String example) { rule.addExample(example); } diff --git a/pmd/src/net/sourceforge/pmd/lang/rule/AbstractRule.java b/pmd/src/net/sourceforge/pmd/lang/rule/AbstractRule.java index ecaa054ff9..398e493528 100644 --- a/pmd/src/net/sourceforge/pmd/lang/rule/AbstractRule.java +++ b/pmd/src/net/sourceforge/pmd/lang/rule/AbstractRule.java @@ -21,7 +21,7 @@ import net.sourceforge.pmd.lang.ast.Node; /** * Basic abstract implementation of all parser-independent methods of the Rule * interface. - * + * * @author pieter_van_raemdonck - Application Engineers NV/SA - www.ae.be */ // FUTURE Move PropertyDescriptor APIs up to Rule interface @@ -138,16 +138,6 @@ public abstract class AbstractRule implements Rule { return examples; } - // FUTURE Remove when cleaning up @deprecated - public String getExample() { - if (examples.isEmpty()) { - return null; - } else { - // We return the last example, so the override still works - return examples.get(examples.size() - 1); - } - } - public void addExample(String example) { examples.add(example); } @@ -334,7 +324,7 @@ public abstract class AbstractRule implements Rule { /** * Return all the relevant properties for the receiver by overriding in * subclasses as necessary. - * + * * @return Map */ protected Map propertiesByName() {