forked from phoedos/pmd
Merge branch 'pr-2742' into pmd/7.0.x
[core] Remove deprecated things about rules #2742
This commit is contained in:
@ -12,10 +12,9 @@ import net.sourceforge.pmd.lang.apex.ApexParserOptions;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ApexParserVisitor;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.rule.AbstractRule;
|
||||
import net.sourceforge.pmd.lang.rule.ImmutableLanguage;
|
||||
|
||||
public abstract class AbstractApexRule extends AbstractRule
|
||||
implements ApexParserVisitor, ImmutableLanguage {
|
||||
implements ApexParserVisitor {
|
||||
|
||||
public AbstractApexRule() {
|
||||
super.setLanguage(LanguageRegistry.getLanguage(ApexLanguageModule.NAME));
|
||||
|
@ -5,8 +5,6 @@
|
||||
package net.sourceforge.pmd;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sourceforge.pmd.lang.LanguageVersion;
|
||||
@ -34,14 +32,13 @@ public class RuleContext {
|
||||
private Report report = new Report();
|
||||
private File sourceCodeFile;
|
||||
private LanguageVersion languageVersion;
|
||||
private final ConcurrentMap<String, Object> attributes;
|
||||
private boolean ignoreExceptions = true;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public RuleContext() {
|
||||
attributes = new ConcurrentHashMap<>();
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,7 +49,6 @@ public class RuleContext {
|
||||
* the context from which the values are shared
|
||||
*/
|
||||
public RuleContext(RuleContext ruleContext) {
|
||||
this.attributes = ruleContext.attributes;
|
||||
this.report.addListeners(ruleContext.getReport().getListeners());
|
||||
}
|
||||
|
||||
@ -146,92 +142,6 @@ public class RuleContext {
|
||||
this.languageVersion = languageVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an attribute value on the RuleContext, if it does not already exist.
|
||||
* <p>
|
||||
* Attributes can be shared between RuleContext instances. This operation is
|
||||
* thread-safe.
|
||||
* <p>
|
||||
* Attribute values should be modified directly via the reference provided.
|
||||
* It is not necessary to call <code>setAttribute(String, Object)</code> to
|
||||
* update an attribute value. Modifications made to the attribute value will
|
||||
* automatically be seen by other threads. Because of this, you must ensure
|
||||
* the attribute values are themselves thread safe.
|
||||
*
|
||||
* @param name
|
||||
* The attribute name.
|
||||
* @param value
|
||||
* The attribute value.
|
||||
* @exception IllegalArgumentException
|
||||
* if <code>name</code> or <code> value</code> are
|
||||
* <code>null</code>
|
||||
* @return <code>true</code> if the attribute was set, <code>false</code>
|
||||
* otherwise.
|
||||
*
|
||||
* @deprecated Stateful methods of the rule context will be removed.
|
||||
* Their interaction with incremental analysis are unspecified.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean setAttribute(String name, Object value) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Parameter 'name' cannot be null.");
|
||||
}
|
||||
if (value == null) {
|
||||
throw new IllegalArgumentException("Parameter 'value' cannot be null.");
|
||||
}
|
||||
return this.attributes.putIfAbsent(name, value) == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an attribute value on the RuleContext.
|
||||
* <p>
|
||||
* Attributes can be shared between RuleContext instances. This operation is
|
||||
* thread-safe.
|
||||
* <p>
|
||||
* Attribute values should be modified directly via the reference provided.
|
||||
* It is not necessary to call <code>setAttribute(String, Object)</code> to
|
||||
* update an attribute value. Modifications made to the attribute value will
|
||||
* automatically be seen by other threads. Because of this, you must ensure
|
||||
* the attribute values are themselves thread safe.
|
||||
*
|
||||
* @param name
|
||||
* The attribute name.
|
||||
* @return The current attribute value, or <code>null</code> if the
|
||||
* attribute does not exist.
|
||||
*
|
||||
* @deprecated Stateful methods of the rule context will be removed.
|
||||
* Their interaction with incremental analysis are unspecified.
|
||||
*/
|
||||
@Deprecated
|
||||
public Object getAttribute(String name) {
|
||||
return this.attributes.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an attribute value on the RuleContext.
|
||||
* <p>
|
||||
* Attributes can be shared between RuleContext instances. This operation is
|
||||
* thread-safe.
|
||||
* <p>
|
||||
* Attribute values should be modified directly via the reference provided.
|
||||
* It is not necessary to call <code>setAttribute(String, Object)</code> to
|
||||
* update an attribute value. Modifications made to the attribute value will
|
||||
* automatically be seen by other threads. Because of this, you must ensure
|
||||
* the attribute values are themselves thread safe.
|
||||
*
|
||||
* @param name
|
||||
* The attribute name.
|
||||
* @return The current attribute value, or <code>null</code> if the
|
||||
* attribute does not exist.
|
||||
*
|
||||
* @deprecated Stateful methods of the rule context will be removed.
|
||||
* Their interaction with incremental analysis are unspecified.
|
||||
*/
|
||||
@Deprecated
|
||||
public Object removeAttribute(String name) {
|
||||
return this.attributes.remove(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure whether exceptions during applying a rule should be ignored or
|
||||
* not. If set to <code>true</code> then such exceptions are logged as
|
||||
|
@ -36,7 +36,6 @@ import org.xml.sax.SAXException;
|
||||
import net.sourceforge.pmd.RuleSet.RuleSetBuilder;
|
||||
import net.sourceforge.pmd.lang.Language;
|
||||
import net.sourceforge.pmd.lang.LanguageRegistry;
|
||||
import net.sourceforge.pmd.lang.rule.MockRule;
|
||||
import net.sourceforge.pmd.lang.rule.RuleReference;
|
||||
import net.sourceforge.pmd.lang.rule.XPathRule;
|
||||
import net.sourceforge.pmd.rules.RuleFactory;
|
||||
@ -697,13 +696,6 @@ public class RuleSetFactory {
|
||||
+ ". PMD " + PMDVersion.getNextMajorRelease()
|
||||
+ " will remove support for this deprecated Rule name usage.");
|
||||
}
|
||||
} else if (referencedRule instanceof MockRule) {
|
||||
if (LOG.isLoggable(Level.WARNING)) {
|
||||
LOG.warning("Discontinue using Rule name " + otherRuleSetReferenceId
|
||||
+ " as it has been removed from PMD and no longer functions."
|
||||
+ " PMD " + PMDVersion.getNextMajorRelease()
|
||||
+ " will remove support for this Rule.");
|
||||
}
|
||||
} else {
|
||||
if (LOG.isLoggable(Level.WARNING)) {
|
||||
LOG.warning("Discontinue using Rule name " + otherRuleSetReferenceId
|
||||
|
@ -31,7 +31,6 @@ import org.w3c.dom.Text;
|
||||
|
||||
import net.sourceforge.pmd.lang.Language;
|
||||
import net.sourceforge.pmd.lang.LanguageVersion;
|
||||
import net.sourceforge.pmd.lang.rule.ImmutableLanguage;
|
||||
import net.sourceforge.pmd.lang.rule.RuleReference;
|
||||
import net.sourceforge.pmd.lang.rule.XPathRule;
|
||||
import net.sourceforge.pmd.properties.PropertyDescriptor;
|
||||
@ -169,7 +168,6 @@ public class RuleSetWriter {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
Language language = ruleReference.getOverriddenLanguage();
|
||||
LanguageVersion minimumLanguageVersion = ruleReference.getOverriddenMinimumLanguageVersion();
|
||||
LanguageVersion maximumLanguageVersion = ruleReference.getOverriddenMaximumLanguageVersion();
|
||||
Boolean deprecated = ruleReference.isOverriddenDeprecated();
|
||||
@ -185,18 +183,18 @@ public class RuleSetWriter {
|
||||
.getOverriddenPropertiesByPropertyDescriptor();
|
||||
List<String> examples = ruleReference.getOverriddenExamples();
|
||||
|
||||
return createSingleRuleElement(language, minimumLanguageVersion, maximumLanguageVersion, deprecated,
|
||||
return createSingleRuleElement(null, minimumLanguageVersion, maximumLanguageVersion, deprecated,
|
||||
name, null, ref, message, externalInfoUrl, null, description, priority,
|
||||
propertyDescriptors, propertiesByPropertyDescriptor, examples);
|
||||
}
|
||||
} else {
|
||||
return createSingleRuleElement(rule instanceof ImmutableLanguage ? null : rule.getLanguage(),
|
||||
rule.getMinimumLanguageVersion(), rule.getMaximumLanguageVersion(), rule.isDeprecated(),
|
||||
rule.getName(), rule.getSince(), null, rule.getMessage(), rule.getExternalInfoUrl(),
|
||||
rule.getRuleClass(),
|
||||
rule.getDescription(),
|
||||
rule.getPriority(), rule.getPropertyDescriptors(), rule.getPropertiesByPropertyDescriptor(),
|
||||
rule.getExamples());
|
||||
return createSingleRuleElement(rule.getLanguage(),
|
||||
rule.getMinimumLanguageVersion(), rule.getMaximumLanguageVersion(), rule.isDeprecated(),
|
||||
rule.getName(), rule.getSince(), null, rule.getMessage(), rule.getExternalInfoUrl(),
|
||||
rule.getRuleClass(),
|
||||
rule.getDescription(),
|
||||
rule.getPriority(), rule.getPropertyDescriptors(), rule.getPropertiesByPropertyDescriptor(),
|
||||
rule.getExamples());
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,7 +210,8 @@ public class RuleSetWriter {
|
||||
String description, RulePriority priority, List<PropertyDescriptor<?>> propertyDescriptors,
|
||||
Map<PropertyDescriptor<?>, Object> propertiesByPropertyDescriptor, List<String> examples) {
|
||||
Element ruleElement = createRuleElement();
|
||||
if (language != null) {
|
||||
// language is now a required attribute, unless this is a rule reference
|
||||
if (clazz != null) {
|
||||
ruleElement.setAttribute("language", language.getTerseName());
|
||||
}
|
||||
if (minimumLanguageVersion != null) {
|
||||
|
@ -23,8 +23,14 @@ public interface RuleViolation {
|
||||
* of a violation, filename first. The remaining parameters are compared
|
||||
* in an unspecified order.
|
||||
*/
|
||||
// TODO in java 8 this can be a chained Comparator.comparing call
|
||||
Comparator<RuleViolation> DEFAULT_COMPARATOR = RuleViolationComparator.INSTANCE;
|
||||
Comparator<RuleViolation> DEFAULT_COMPARATOR =
|
||||
Comparator.comparing(RuleViolation::getFilename)
|
||||
.thenComparingInt(RuleViolation::getBeginLine)
|
||||
.thenComparingInt(RuleViolation::getBeginColumn)
|
||||
.thenComparing(RuleViolation::getDescription, Comparator.nullsLast(Comparator.naturalOrder()))
|
||||
.thenComparingInt(RuleViolation::getEndLine)
|
||||
.thenComparingInt(RuleViolation::getEndColumn)
|
||||
.thenComparing(rv -> rv.getRule().getName());
|
||||
|
||||
/**
|
||||
* Get the Rule which identified this violation.
|
||||
|
@ -1,74 +0,0 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Compares RuleViolations using the following criteria:
|
||||
* <ol>
|
||||
* <li>Source file name</li>
|
||||
* <li>Begin line</li>
|
||||
* <li>Description</li>
|
||||
* <li>Begin column</li>
|
||||
* <li>End line</li>
|
||||
* <li>End column</li>
|
||||
* <li>Rule name</li>
|
||||
* </ol>
|
||||
*
|
||||
* TODO why is begin line/begin column split?? would make more sense to use
|
||||
* - filename
|
||||
* - begin line
|
||||
* - begin column
|
||||
* - description
|
||||
* - rule name
|
||||
* - end line
|
||||
* - end column
|
||||
*
|
||||
* @deprecated Use {@link RuleViolation#DEFAULT_COMPARATOR}
|
||||
*/
|
||||
@Deprecated
|
||||
public final class RuleViolationComparator implements Comparator<RuleViolation> {
|
||||
|
||||
public static final RuleViolationComparator INSTANCE = new RuleViolationComparator();
|
||||
|
||||
private RuleViolationComparator() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(final RuleViolation r1, final RuleViolation r2) {
|
||||
int cmp = r1.getFilename().compareTo(r2.getFilename());
|
||||
if (cmp == 0) {
|
||||
cmp = r1.getBeginLine() - r2.getBeginLine();
|
||||
if (cmp == 0) {
|
||||
cmp = compare(r1.getDescription(), r2.getDescription());
|
||||
if (cmp == 0) {
|
||||
cmp = r1.getBeginColumn() - r2.getBeginColumn();
|
||||
if (cmp == 0) {
|
||||
cmp = r1.getEndLine() - r2.getEndLine();
|
||||
if (cmp == 0) {
|
||||
cmp = r1.getEndColumn() - r2.getEndColumn();
|
||||
if (cmp == 0) {
|
||||
cmp = r1.getRule().getName().compareTo(r2.getRule().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return cmp;
|
||||
}
|
||||
|
||||
private static int compare(final String s1, final String s2) {
|
||||
// Treat null as larger
|
||||
if (s1 == null) {
|
||||
return 1;
|
||||
} else if (s2 == null) {
|
||||
return -1;
|
||||
} else {
|
||||
return s1.compareTo(s2);
|
||||
}
|
||||
}
|
||||
}
|
@ -93,7 +93,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul
|
||||
|
||||
@Override
|
||||
public void setLanguage(Language language) {
|
||||
if (this.language != null && this instanceof ImmutableLanguage && !this.language.equals(language)) {
|
||||
if (this.language != null && !this.language.equals(language)) {
|
||||
throw new UnsupportedOperationException("The Language for Rule class " + this.getClass().getName()
|
||||
+ " is immutable and cannot be changed.");
|
||||
}
|
||||
@ -107,6 +107,9 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul
|
||||
|
||||
@Override
|
||||
public void setMinimumLanguageVersion(LanguageVersion minimumLanguageVersion) {
|
||||
if (minimumLanguageVersion != null && !minimumLanguageVersion.getLanguage().equals(getLanguage())) {
|
||||
throw new IllegalArgumentException("Version " + minimumLanguageVersion + " does not belong to language " + getLanguage());
|
||||
}
|
||||
this.minimumLanguageVersion = minimumLanguageVersion;
|
||||
}
|
||||
|
||||
@ -117,6 +120,9 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul
|
||||
|
||||
@Override
|
||||
public void setMaximumLanguageVersion(LanguageVersion maximumLanguageVersion) {
|
||||
if (maximumLanguageVersion != null && !maximumLanguageVersion.getLanguage().equals(getLanguage())) {
|
||||
throw new IllegalArgumentException("Version " + maximumLanguageVersion + " does not belong to language " + getLanguage());
|
||||
}
|
||||
this.maximumLanguageVersion = maximumLanguageVersion;
|
||||
}
|
||||
|
||||
|
@ -1,15 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.rule;
|
||||
|
||||
import net.sourceforge.pmd.lang.rule.impl.DefaultRuleViolationFactory;
|
||||
|
||||
/**
|
||||
* @deprecated This is kept for binary compatibility with the 6.x designer, yet will
|
||||
* go away in 7.0. Use {@link DefaultRuleViolationFactory}
|
||||
*/
|
||||
@Deprecated
|
||||
public class AbstractRuleViolationFactory extends DefaultRuleViolationFactory {
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.rule;
|
||||
|
||||
/**
|
||||
* This is a tag interface to indicate that a Rule implementation class does not
|
||||
* support changes to it's Language. The Language is integral to the proper
|
||||
* functioning of the Rule.
|
||||
*
|
||||
* @deprecated No rule supports a change to their language. This will
|
||||
* be made the default behaviour with PMD 7.0.0.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ImmutableLanguage {
|
||||
}
|
@ -15,7 +15,6 @@ import java.util.Objects;
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.RulePriority;
|
||||
import net.sourceforge.pmd.RuleSetReference;
|
||||
import net.sourceforge.pmd.lang.Language;
|
||||
import net.sourceforge.pmd.lang.LanguageVersion;
|
||||
import net.sourceforge.pmd.lang.ast.AstProcessingStage;
|
||||
import net.sourceforge.pmd.properties.PropertyDescriptor;
|
||||
@ -30,7 +29,6 @@ import net.sourceforge.pmd.util.StringUtil;
|
||||
*/
|
||||
public class RuleReference extends AbstractDelegateRule {
|
||||
|
||||
private Language language;
|
||||
private LanguageVersion minimumLanguageVersion;
|
||||
private LanguageVersion maximumLanguageVersion;
|
||||
private Boolean deprecated;
|
||||
@ -69,7 +67,6 @@ public class RuleReference extends AbstractDelegateRule {
|
||||
/** copy constructor */
|
||||
private RuleReference(RuleReference ref) {
|
||||
|
||||
this.language = ref.language;
|
||||
this.minimumLanguageVersion = ref.minimumLanguageVersion;
|
||||
this.maximumLanguageVersion = ref.maximumLanguageVersion;
|
||||
this.deprecated = ref.deprecated;
|
||||
@ -86,30 +83,6 @@ public class RuleReference extends AbstractDelegateRule {
|
||||
this.setRule(ref.getRule().deepCopy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated overriding the language of a rule is not supported.
|
||||
*/
|
||||
@Deprecated
|
||||
public Language getOverriddenLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated overriding the language of a rule is not supported.
|
||||
*/
|
||||
// FIXME should we really allow overriding the language of a rule?
|
||||
// I don't see any case where this wouldn't just make the rule fail during execution
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setLanguage(Language language) {
|
||||
// Only override if different than current value, or if already
|
||||
// overridden.
|
||||
if (!Objects.equals(language, super.getLanguage()) || this.language != null) {
|
||||
this.language = language;
|
||||
super.setLanguage(language);
|
||||
}
|
||||
}
|
||||
|
||||
public LanguageVersion getOverriddenMinimumLanguageVersion() {
|
||||
return minimumLanguageVersion;
|
||||
}
|
||||
@ -119,8 +92,8 @@ public class RuleReference extends AbstractDelegateRule {
|
||||
// Only override if different than current value, or if already
|
||||
// overridden.
|
||||
if (!Objects.equals(minimumLanguageVersion, super.getMinimumLanguageVersion()) || this.minimumLanguageVersion != null) {
|
||||
super.setMinimumLanguageVersion(minimumLanguageVersion); // might throw
|
||||
this.minimumLanguageVersion = minimumLanguageVersion;
|
||||
super.setMinimumLanguageVersion(minimumLanguageVersion);
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,8 +106,8 @@ public class RuleReference extends AbstractDelegateRule {
|
||||
// Only override if different than current value, or if already
|
||||
// overridden.
|
||||
if (!Objects.equals(maximumLanguageVersion, super.getMaximumLanguageVersion()) || this.maximumLanguageVersion != null) {
|
||||
super.setMaximumLanguageVersion(maximumLanguageVersion); // might throw
|
||||
this.maximumLanguageVersion = maximumLanguageVersion;
|
||||
super.setMaximumLanguageVersion(maximumLanguageVersion);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,11 +5,7 @@
|
||||
package net.sourceforge.pmd;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@ -45,56 +41,6 @@ public class RuleContextTest {
|
||||
assertEquals("filename mismatch", new File("somefile.java"), ctx.getSourceCodeFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAttributes() {
|
||||
RuleContext ctx1 = new RuleContext();
|
||||
Object obj1 = new Object();
|
||||
Object obj2 = new Object();
|
||||
assertNull("attribute should be null", ctx1.getAttribute("attribute"));
|
||||
boolean set = ctx1.setAttribute("attribute", obj1);
|
||||
assertTrue("attribute should have been set", set);
|
||||
assertNotNull("attribute should not be null", ctx1.getAttribute("attribute"));
|
||||
assertSame("attribute should be expected instance", ctx1.getAttribute("attribute"), obj1);
|
||||
set = ctx1.setAttribute("attribute", obj2);
|
||||
assertFalse("attribute should not have been set", set);
|
||||
assertSame("attribute should be expected instance", ctx1.getAttribute("attribute"), obj1);
|
||||
Object value = ctx1.removeAttribute("attribute");
|
||||
assertSame("attribute value should be expected instance", value, obj1);
|
||||
assertNull("attribute should be null", ctx1.getAttribute("attribute"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSharedAttributes() {
|
||||
RuleContext ctx1 = new RuleContext();
|
||||
RuleContext ctx2 = new RuleContext(ctx1);
|
||||
StringBuilder obj1 = new StringBuilder();
|
||||
StringBuilder obj2 = new StringBuilder();
|
||||
|
||||
ctx1.setAttribute("attribute1", obj1);
|
||||
ctx2.setAttribute("attribute2", obj2);
|
||||
assertNotNull("attribute should not be null", ctx1.getAttribute("attribute1"));
|
||||
assertNotNull("attribute should not be null", ctx1.getAttribute("attribute2"));
|
||||
assertNotNull("attribute should not be null", ctx2.getAttribute("attribute1"));
|
||||
assertNotNull("attribute should not be null", ctx2.getAttribute("attribute2"));
|
||||
assertSame("attribute should be expected instance", ctx1.getAttribute("attribute1"), obj1);
|
||||
assertSame("attribute should be expected instance", ctx1.getAttribute("attribute2"), obj2);
|
||||
assertSame("attribute should be expected instance", ctx2.getAttribute("attribute1"), obj1);
|
||||
assertSame("attribute should be expected instance", ctx2.getAttribute("attribute2"), obj2);
|
||||
|
||||
ctx1.removeAttribute("attribute1");
|
||||
assertNull("attribute should be null", ctx1.getAttribute("attribute1"));
|
||||
assertNull("attribute should be null", ctx2.getAttribute("attribute1"));
|
||||
assertNotNull("attribute should not be null", ctx1.getAttribute("attribute2"));
|
||||
assertNotNull("attribute should not be null", ctx2.getAttribute("attribute2"));
|
||||
|
||||
StringBuilder value = (StringBuilder) ctx1.getAttribute("attribute2");
|
||||
assertEquals("attribute value should be empty", "", value.toString());
|
||||
value.append("x");
|
||||
StringBuilder value1 = (StringBuilder) ctx1.getAttribute("attribute2");
|
||||
assertEquals("attribute value should be 'x'", "x", value1.toString());
|
||||
StringBuilder value2 = (StringBuilder) ctx2.getAttribute("attribute2");
|
||||
assertEquals("attribute value should be 'x'", "x", value2.toString());
|
||||
}
|
||||
|
||||
public static junit.framework.Test suite() {
|
||||
return new JUnit4TestAdapter(RuleContextTest.class);
|
||||
|
@ -9,10 +9,12 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import net.sourceforge.pmd.lang.Dummy2LanguageModule;
|
||||
import net.sourceforge.pmd.lang.DummyLanguageModule;
|
||||
import net.sourceforge.pmd.lang.Language;
|
||||
import net.sourceforge.pmd.lang.LanguageRegistry;
|
||||
import net.sourceforge.pmd.lang.rule.MockRule;
|
||||
import net.sourceforge.pmd.lang.rule.RuleReference;
|
||||
@ -34,7 +36,8 @@ public class RuleReferenceTest {
|
||||
final PropertyDescriptor<String> PROPERTY1_DESCRIPTOR = PropertyFactory.stringProperty("property1").desc("Test property").defaultValue("").build();
|
||||
MockRule rule = new MockRule();
|
||||
rule.definePropertyDescriptor(PROPERTY1_DESCRIPTOR);
|
||||
rule.setLanguage(LanguageRegistry.getLanguage(Dummy2LanguageModule.NAME));
|
||||
Language dummyLang = LanguageRegistry.getLanguage(DummyLanguageModule.NAME);
|
||||
rule.setLanguage(dummyLang);
|
||||
rule.setName("name1");
|
||||
rule.setProperty(PROPERTY1_DESCRIPTOR, "value1");
|
||||
rule.setMessage("message1");
|
||||
@ -47,11 +50,8 @@ public class RuleReferenceTest {
|
||||
RuleReference ruleReference = new RuleReference();
|
||||
ruleReference.setRule(rule);
|
||||
ruleReference.definePropertyDescriptor(PROPERTY2_DESCRIPTOR);
|
||||
ruleReference.setLanguage(LanguageRegistry.getLanguage(DummyLanguageModule.NAME));
|
||||
ruleReference
|
||||
.setMinimumLanguageVersion(LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getVersion("1.3"));
|
||||
ruleReference
|
||||
.setMaximumLanguageVersion(LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getVersion("1.7"));
|
||||
ruleReference.setMinimumLanguageVersion(dummyLang.getVersion("1.3"));
|
||||
ruleReference.setMaximumLanguageVersion(dummyLang.getVersion("1.7"));
|
||||
ruleReference.setDeprecated(true);
|
||||
ruleReference.setName("name2");
|
||||
ruleReference.setProperty(PROPERTY1_DESCRIPTOR, "value2");
|
||||
@ -65,12 +65,30 @@ public class RuleReferenceTest {
|
||||
validateOverriddenValues(PROPERTY1_DESCRIPTOR, PROPERTY2_DESCRIPTOR, ruleReference);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLanguageOverrideDisallowed() {
|
||||
MockRule rule = new MockRule();
|
||||
Language dummyLang = LanguageRegistry.getLanguage(DummyLanguageModule.NAME);
|
||||
rule.setLanguage(dummyLang);
|
||||
|
||||
RuleReference ruleReference = new RuleReference();
|
||||
ruleReference.setRule(rule);
|
||||
|
||||
Assert.assertThrows(UnsupportedOperationException.class, () -> ruleReference.setLanguage(LanguageRegistry.getLanguage(Dummy2LanguageModule.NAME)));
|
||||
Assert.assertEquals(dummyLang, ruleReference.getLanguage());
|
||||
Assert.assertThrows(IllegalArgumentException.class, () -> ruleReference.setMaximumLanguageVersion(LanguageRegistry.getLanguage(Dummy2LanguageModule.NAME).getVersion("1.0")));
|
||||
Assert.assertEquals(rule.getMaximumLanguageVersion(), ruleReference.getOverriddenMaximumLanguageVersion());
|
||||
Assert.assertThrows(IllegalArgumentException.class, () -> ruleReference.setMinimumLanguageVersion(LanguageRegistry.getLanguage(Dummy2LanguageModule.NAME).getVersion("1.0")));
|
||||
Assert.assertEquals(rule.getMinimumLanguageVersion(), ruleReference.getMinimumLanguageVersion());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeepCopyOverride() {
|
||||
final PropertyDescriptor<String> PROPERTY1_DESCRIPTOR = PropertyFactory.stringProperty("property1").desc("Test property").defaultValue("").build();
|
||||
MockRule rule = new MockRule();
|
||||
rule.definePropertyDescriptor(PROPERTY1_DESCRIPTOR);
|
||||
rule.setLanguage(LanguageRegistry.getLanguage(Dummy2LanguageModule.NAME));
|
||||
Language dummyLang = LanguageRegistry.getLanguage(DummyLanguageModule.NAME);
|
||||
rule.setLanguage(dummyLang);
|
||||
rule.setName("name1");
|
||||
rule.setProperty(PROPERTY1_DESCRIPTOR, "value1");
|
||||
rule.setMessage("message1");
|
||||
@ -83,11 +101,9 @@ public class RuleReferenceTest {
|
||||
RuleReference ruleReference = new RuleReference();
|
||||
ruleReference.setRule(rule);
|
||||
ruleReference.definePropertyDescriptor(PROPERTY2_DESCRIPTOR);
|
||||
ruleReference.setLanguage(LanguageRegistry.getLanguage(DummyLanguageModule.NAME));
|
||||
ruleReference
|
||||
.setMinimumLanguageVersion(LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getVersion("1.3"));
|
||||
ruleReference
|
||||
.setMaximumLanguageVersion(LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getVersion("1.7"));
|
||||
ruleReference.setLanguage(dummyLang);
|
||||
ruleReference.setMinimumLanguageVersion(dummyLang.getVersion("1.3"));
|
||||
ruleReference.setMaximumLanguageVersion(dummyLang.getVersion("1.7"));
|
||||
ruleReference.setDeprecated(true);
|
||||
ruleReference.setName("name2");
|
||||
ruleReference.setProperty(PROPERTY1_DESCRIPTOR, "value2");
|
||||
@ -105,8 +121,6 @@ public class RuleReferenceTest {
|
||||
final PropertyDescriptor<String> propertyDescriptor2, RuleReference ruleReference) {
|
||||
assertEquals("Override failed", LanguageRegistry.getLanguage(DummyLanguageModule.NAME),
|
||||
ruleReference.getLanguage());
|
||||
assertEquals("Override failed", LanguageRegistry.getLanguage(DummyLanguageModule.NAME),
|
||||
ruleReference.getOverriddenLanguage());
|
||||
|
||||
assertEquals("Override failed", LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getVersion("1.3"),
|
||||
ruleReference.getMinimumLanguageVersion());
|
||||
@ -176,7 +190,6 @@ public class RuleReferenceTest {
|
||||
|
||||
RuleReference ruleReference = new RuleReference();
|
||||
ruleReference.setRule(rule);
|
||||
ruleReference.setLanguage(LanguageRegistry.getLanguage(DummyLanguageModule.NAME));
|
||||
ruleReference
|
||||
.setMinimumLanguageVersion(LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getVersion("1.3"));
|
||||
ruleReference
|
||||
@ -190,9 +203,6 @@ public class RuleReferenceTest {
|
||||
ruleReference.setExternalInfoUrl("externalInfoUrl1");
|
||||
ruleReference.setPriority(RulePriority.HIGH);
|
||||
|
||||
assertEquals("Override failed", LanguageRegistry.getLanguage(DummyLanguageModule.NAME),
|
||||
ruleReference.getLanguage());
|
||||
assertNull("Override failed", ruleReference.getOverriddenLanguage());
|
||||
|
||||
assertEquals("Override failed", LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getVersion("1.3"),
|
||||
ruleReference.getMinimumLanguageVersion());
|
||||
|
@ -31,16 +31,18 @@ import net.sourceforge.pmd.Report.ProcessingError;
|
||||
import net.sourceforge.pmd.RuleSet.RuleSetBuilder;
|
||||
import net.sourceforge.pmd.lang.Dummy2LanguageModule;
|
||||
import net.sourceforge.pmd.lang.DummyLanguageModule;
|
||||
import net.sourceforge.pmd.lang.Language;
|
||||
import net.sourceforge.pmd.lang.LanguageRegistry;
|
||||
import net.sourceforge.pmd.lang.ast.DummyNode;
|
||||
import net.sourceforge.pmd.lang.ast.DummyRoot;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.rule.MockRule;
|
||||
import net.sourceforge.pmd.lang.rule.RuleReference;
|
||||
import net.sourceforge.pmd.lang.rule.RuleTargetSelector;
|
||||
|
||||
public class RuleSetTest {
|
||||
|
||||
private final Language dummyLang = LanguageRegistry.getLanguage(DummyLanguageModule.NAME);
|
||||
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void testRuleSetRequiresName() {
|
||||
new RuleSetBuilder(new Random().nextLong())
|
||||
@ -169,7 +171,7 @@ public class RuleSetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApply0Rules() throws Exception {
|
||||
public void testApply0Rules() {
|
||||
RuleSet ruleset = createRuleSetBuilder("ruleset").build();
|
||||
verifyRuleSet(ruleset, 0, new HashSet<RuleViolation>());
|
||||
}
|
||||
@ -241,25 +243,23 @@ public class RuleSetTest {
|
||||
|
||||
Rule rule = new MockRule();
|
||||
|
||||
rule.setLanguage(LanguageRegistry.getLanguage(DummyLanguageModule.NAME));
|
||||
assertFalse("Different languages should not apply",
|
||||
RuleSet.applies(rule, LanguageRegistry.getLanguage(Dummy2LanguageModule.NAME).getDefaultVersion()));
|
||||
|
||||
rule.setLanguage(LanguageRegistry.getLanguage(DummyLanguageModule.NAME));
|
||||
assertTrue("Same language with no min/max should apply",
|
||||
RuleSet.applies(rule, LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getVersion("1.5")));
|
||||
RuleSet.applies(rule, dummyLang.getVersion("1.5")));
|
||||
|
||||
rule.setMinimumLanguageVersion(LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getVersion("1.5"));
|
||||
rule.setMinimumLanguageVersion(dummyLang.getVersion("1.5"));
|
||||
assertTrue("Same language with valid min only should apply",
|
||||
RuleSet.applies(rule, LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getVersion("1.5")));
|
||||
RuleSet.applies(rule, dummyLang.getVersion("1.5")));
|
||||
|
||||
rule.setMaximumLanguageVersion(LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getVersion("1.6"));
|
||||
rule.setMaximumLanguageVersion(dummyLang.getVersion("1.6"));
|
||||
assertTrue("Same language with valid min and max should apply",
|
||||
RuleSet.applies(rule, LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getVersion("1.5")));
|
||||
RuleSet.applies(rule, dummyLang.getVersion("1.5")));
|
||||
assertFalse("Same language with outside range of min/max should not apply",
|
||||
RuleSet.applies(rule, LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getVersion("1.4")));
|
||||
RuleSet.applies(rule, dummyLang.getVersion("1.4")));
|
||||
assertFalse("Same language with outside range of min/max should not apply",
|
||||
RuleSet.applies(rule, LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getVersion("1.7")));
|
||||
RuleSet.applies(rule, dummyLang.getVersion("1.7")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -404,7 +404,6 @@ public class RuleSetTest {
|
||||
|
||||
Rule rule = new FooRule();
|
||||
rule.setName("FooRule1");
|
||||
rule.setLanguage(LanguageRegistry.getLanguage(DummyLanguageModule.NAME));
|
||||
RuleSet ruleSet1 = createRuleSetBuilder("RuleSet1")
|
||||
.addRule(rule)
|
||||
.build();
|
||||
@ -420,7 +419,7 @@ public class RuleSetTest {
|
||||
Report r = new Report();
|
||||
ctx.setReport(r);
|
||||
ctx.setSourceCodeFile(file);
|
||||
ctx.setLanguageVersion(LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getDefaultVersion());
|
||||
ctx.setLanguageVersion(dummyLang.getDefaultVersion());
|
||||
ruleSets.apply(makeCompilationUnits(), ctx);
|
||||
assertEquals("Violations", 2, r.getViolations().size());
|
||||
|
||||
@ -442,7 +441,6 @@ public class RuleSetTest {
|
||||
public void copyConstructorDeepCopies() {
|
||||
Rule rule = new FooRule();
|
||||
rule.setName("FooRule1");
|
||||
rule.setLanguage(LanguageRegistry.getLanguage(DummyLanguageModule.NAME));
|
||||
RuleSet ruleSet1 = createRuleSetBuilder("RuleSet1")
|
||||
.addRule(rule)
|
||||
.build();
|
||||
@ -495,7 +493,7 @@ public class RuleSetTest {
|
||||
.build();
|
||||
RuleContext context = new RuleContext();
|
||||
context.setReport(new Report());
|
||||
context.setLanguageVersion(LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getDefaultVersion());
|
||||
context.setLanguageVersion(dummyLang.getDefaultVersion());
|
||||
context.setSourceCodeFile(new File(RuleSetTest.class.getName() + ".ruleExceptionShouldBeReported"));
|
||||
context.setIgnoreExceptions(true); // the default
|
||||
ruleset.apply(makeCompilationUnits(), context);
|
||||
@ -519,7 +517,7 @@ public class RuleSetTest {
|
||||
.build();
|
||||
RuleContext context = new RuleContext();
|
||||
context.setReport(new Report());
|
||||
context.setLanguageVersion(LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getDefaultVersion());
|
||||
context.setLanguageVersion(dummyLang.getDefaultVersion());
|
||||
context.setSourceCodeFile(new File(RuleSetTest.class.getName() + ".ruleExceptionShouldBeThrownIfNotIgnored"));
|
||||
context.setIgnoreExceptions(false);
|
||||
ruleset.apply(makeCompilationUnits(), context);
|
||||
@ -540,7 +538,7 @@ public class RuleSetTest {
|
||||
}).build();
|
||||
RuleContext context = new RuleContext();
|
||||
context.setReport(new Report());
|
||||
context.setLanguageVersion(LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getDefaultVersion());
|
||||
context.setLanguageVersion(dummyLang.getDefaultVersion());
|
||||
context.setSourceCodeFile(new File(RuleSetTest.class.getName() + ".ruleExceptionShouldBeReported"));
|
||||
context.setIgnoreExceptions(true); // the default
|
||||
ruleset.apply(makeCompilationUnits(), context);
|
||||
@ -581,7 +579,7 @@ public class RuleSetTest {
|
||||
}).build();
|
||||
RuleContext context = new RuleContext();
|
||||
context.setReport(new Report());
|
||||
context.setLanguageVersion(LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getDefaultVersion());
|
||||
context.setLanguageVersion(dummyLang.getDefaultVersion());
|
||||
context.setSourceCodeFile(new File(RuleSetTest.class.getName() + ".ruleExceptionShouldBeReported"));
|
||||
context.setIgnoreExceptions(true); // the default
|
||||
RuleSets rulesets = new RuleSets(ruleset);
|
||||
@ -595,4 +593,24 @@ public class RuleSetTest {
|
||||
assertEquals("There should be a violation", 1, context.getReport().getViolations().size());
|
||||
}
|
||||
|
||||
|
||||
class MockRule extends net.sourceforge.pmd.lang.rule.MockRule {
|
||||
|
||||
MockRule() {
|
||||
super();
|
||||
setLanguage(dummyLang);
|
||||
}
|
||||
|
||||
MockRule(String name, String description, String message, String ruleSetName, RulePriority priority) {
|
||||
super(name, description, message, ruleSetName, priority);
|
||||
setLanguage(dummyLang);
|
||||
}
|
||||
|
||||
MockRule(String name, String description, String message, String ruleSetName) {
|
||||
super(name, description, message, ruleSetName);
|
||||
setLanguage(dummyLang);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
@ -8,7 +8,6 @@ import static net.sourceforge.pmd.properties.constraints.NumericConstraints.inRa
|
||||
|
||||
import net.sourceforge.pmd.RuleContext;
|
||||
import net.sourceforge.pmd.RulePriority;
|
||||
import net.sourceforge.pmd.lang.LanguageRegistry;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.properties.PropertyFactory;
|
||||
|
||||
@ -18,17 +17,11 @@ import net.sourceforge.pmd.properties.PropertyFactory;
|
||||
* functional Rule is not needed. For example, during unit testing, or as an
|
||||
* editable surrogate used by IDE plugins. The Language of this Rule defaults to
|
||||
* Java.
|
||||
*
|
||||
* @deprecated This is not a supported API. You need the pmd-test module
|
||||
* on your classpath, or pmd-core's test sources. This will be removed
|
||||
* in 7.0.0
|
||||
*/
|
||||
@Deprecated
|
||||
public class MockRule extends AbstractRule {
|
||||
|
||||
public MockRule() {
|
||||
super();
|
||||
setLanguage(LanguageRegistry.getLanguage("Dummy"));
|
||||
definePropertyDescriptor(PropertyFactory.intProperty("testIntProperty").desc("testIntProperty").require(inRange(1, 100)).defaultValue(1).build());
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ import net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.JavaParserVisitor;
|
||||
import net.sourceforge.pmd.lang.java.internal.JavaProcessingStage;
|
||||
import net.sourceforge.pmd.lang.rule.AbstractRule;
|
||||
import net.sourceforge.pmd.lang.rule.ImmutableLanguage;
|
||||
|
||||
|
||||
/**
|
||||
@ -28,7 +27,7 @@ import net.sourceforge.pmd.lang.rule.ImmutableLanguage;
|
||||
* TODO add documentation
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractJavaRule extends AbstractRule implements JavaParserVisitor, ImmutableLanguage {
|
||||
public abstract class AbstractJavaRule extends AbstractRule implements JavaParserVisitor {
|
||||
|
||||
public AbstractJavaRule() {
|
||||
super.setLanguage(LanguageRegistry.getLanguage(JavaLanguageModule.NAME));
|
||||
|
@ -111,8 +111,8 @@ public class Bar {
|
||||
<rule-property name="enumConstantPattern">cons_[A-Z][A-Z0-9]+</rule-property>
|
||||
<expected-problems>2</expected-problems>
|
||||
<expected-messages>
|
||||
<message>The enum constant name 'NET' doesn't match 'cons_[A-Z][A-Z0-9]+'</message>
|
||||
<message>The enum constant name 'ORG' doesn't match 'cons_[A-Z][A-Z0-9]+'</message>
|
||||
<message>The enum constant name 'NET' doesn't match 'cons_[A-Z][A-Z0-9]+'</message>
|
||||
</expected-messages>
|
||||
<code><![CDATA[
|
||||
public class Bar {
|
||||
|
@ -13,12 +13,11 @@ import net.sourceforge.pmd.lang.ecmascript.EcmascriptParserOptions;
|
||||
import net.sourceforge.pmd.lang.ecmascript.EcmascriptParserOptions.Version;
|
||||
import net.sourceforge.pmd.lang.ecmascript.ast.EcmascriptParserVisitor;
|
||||
import net.sourceforge.pmd.lang.rule.AbstractRule;
|
||||
import net.sourceforge.pmd.lang.rule.ImmutableLanguage;
|
||||
import net.sourceforge.pmd.properties.PropertyDescriptor;
|
||||
|
||||
|
||||
public abstract class AbstractEcmascriptRule extends AbstractRule
|
||||
implements EcmascriptParserVisitor, ImmutableLanguage {
|
||||
implements EcmascriptParserVisitor {
|
||||
|
||||
private static final PropertyDescriptor<Boolean> RECORDING_COMMENTS_DESCRIPTOR = EcmascriptParserOptions.RECORDING_COMMENTS_DESCRIPTOR;
|
||||
private static final PropertyDescriptor<Boolean> RECORDING_LOCAL_JSDOC_COMMENTS_DESCRIPTOR = EcmascriptParserOptions.RECORDING_LOCAL_JSDOC_COMMENTS_DESCRIPTOR;
|
||||
|
@ -10,9 +10,8 @@ import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.jsp.JspLanguageModule;
|
||||
import net.sourceforge.pmd.lang.jsp.ast.JspParserVisitor;
|
||||
import net.sourceforge.pmd.lang.rule.AbstractRule;
|
||||
import net.sourceforge.pmd.lang.rule.ImmutableLanguage;
|
||||
|
||||
public abstract class AbstractJspRule extends AbstractRule implements JspParserVisitor, ImmutableLanguage {
|
||||
public abstract class AbstractJspRule extends AbstractRule implements JspParserVisitor {
|
||||
|
||||
public AbstractJspRule() {
|
||||
super.setLanguage(LanguageRegistry.getLanguage(JspLanguageModule.NAME));
|
||||
|
@ -13,12 +13,11 @@ import net.sourceforge.pmd.lang.modelica.ast.ModelicaNode;
|
||||
import net.sourceforge.pmd.lang.modelica.ast.ModelicaParserVisitor;
|
||||
import net.sourceforge.pmd.lang.modelica.internal.ModelicaProcessingStage;
|
||||
import net.sourceforge.pmd.lang.rule.AbstractRule;
|
||||
import net.sourceforge.pmd.lang.rule.ImmutableLanguage;
|
||||
|
||||
/**
|
||||
* Base class for rules for Modelica language.
|
||||
*/
|
||||
public abstract class AbstractModelicaRule extends AbstractRule implements ModelicaParserVisitor, ImmutableLanguage {
|
||||
public abstract class AbstractModelicaRule extends AbstractRule implements ModelicaParserVisitor {
|
||||
public AbstractModelicaRule() {
|
||||
super.setLanguage(LanguageRegistry.getLanguage(ModelicaLanguageModule.NAME));
|
||||
}
|
||||
|
@ -22,9 +22,8 @@ import net.sourceforge.pmd.lang.plsql.ast.ExecutableCode;
|
||||
import net.sourceforge.pmd.lang.plsql.ast.PLSQLNode;
|
||||
import net.sourceforge.pmd.lang.plsql.ast.PLSQLParserVisitor;
|
||||
import net.sourceforge.pmd.lang.rule.AbstractRule;
|
||||
import net.sourceforge.pmd.lang.rule.ImmutableLanguage;
|
||||
|
||||
public abstract class AbstractPLSQLRule extends AbstractRule implements PLSQLParserVisitor, ImmutableLanguage {
|
||||
public abstract class AbstractPLSQLRule extends AbstractRule implements PLSQLParserVisitor {
|
||||
private static final Logger LOGGER = Logger.getLogger(AbstractPLSQLRule.class.getName());
|
||||
private static final String CLASS_NAME = AbstractPLSQLRule.class.getName();
|
||||
|
||||
|
@ -446,8 +446,6 @@ public abstract class AbstractRuleSetFactoryTest {
|
||||
if (rule1 instanceof RuleReference) {
|
||||
RuleReference ruleReference1 = (RuleReference) rule1;
|
||||
RuleReference ruleReference2 = (RuleReference) rule2;
|
||||
assertEquals(message + ", RuleReference overridden language", ruleReference1.getOverriddenLanguage(),
|
||||
ruleReference2.getOverriddenLanguage());
|
||||
assertEquals(message + ", RuleReference overridden minimum language version",
|
||||
ruleReference1.getOverriddenMinimumLanguageVersion(),
|
||||
ruleReference2.getOverriddenMinimumLanguageVersion());
|
||||
|
@ -8,12 +8,11 @@ import net.sourceforge.pmd.RuleContext;
|
||||
import net.sourceforge.pmd.lang.LanguageRegistry;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.rule.AbstractRule;
|
||||
import net.sourceforge.pmd.lang.rule.ImmutableLanguage;
|
||||
import net.sourceforge.pmd.lang.vf.VfLanguageModule;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfNode;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
|
||||
public abstract class AbstractVfRule extends AbstractRule implements VfParserVisitor, ImmutableLanguage {
|
||||
public abstract class AbstractVfRule extends AbstractRule implements VfParserVisitor {
|
||||
|
||||
public AbstractVfRule() {
|
||||
super.setLanguage(LanguageRegistry.getLanguage(VfLanguageModule.NAME));
|
||||
|
@ -8,12 +8,11 @@ import net.sourceforge.pmd.RuleContext;
|
||||
import net.sourceforge.pmd.lang.LanguageRegistry;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.rule.AbstractRule;
|
||||
import net.sourceforge.pmd.lang.rule.ImmutableLanguage;
|
||||
import net.sourceforge.pmd.lang.vm.VmLanguageModule;
|
||||
import net.sourceforge.pmd.lang.vm.ast.VmNode;
|
||||
import net.sourceforge.pmd.lang.vm.ast.VmParserVisitor;
|
||||
|
||||
public abstract class AbstractVmRule extends AbstractRule implements VmParserVisitor, ImmutableLanguage {
|
||||
public abstract class AbstractVmRule extends AbstractRule implements VmParserVisitor {
|
||||
|
||||
public AbstractVmRule() {
|
||||
super.setLanguage(LanguageRegistry.getLanguage(VmLanguageModule.NAME));
|
||||
|
@ -10,7 +10,6 @@ import net.sourceforge.pmd.lang.LanguageRegistry;
|
||||
import net.sourceforge.pmd.lang.ParserOptions;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.rule.AbstractRule;
|
||||
import net.sourceforge.pmd.lang.rule.ImmutableLanguage;
|
||||
import net.sourceforge.pmd.lang.xml.XmlLanguageModule;
|
||||
import net.sourceforge.pmd.lang.xml.XmlParserOptions;
|
||||
import net.sourceforge.pmd.lang.xml.ast.XmlNode;
|
||||
@ -21,7 +20,7 @@ import net.sourceforge.pmd.properties.PropertyDescriptor;
|
||||
* {@link #visit(XmlNode, RuleContext)} and can call <code>super</code> to visit
|
||||
* children.
|
||||
*/
|
||||
public class AbstractXmlRule extends AbstractRule implements ImmutableLanguage {
|
||||
public class AbstractXmlRule extends AbstractRule {
|
||||
|
||||
@Deprecated
|
||||
public static final PropertyDescriptor<Boolean> COALESCING_DESCRIPTOR = XmlParserOptions.COALESCING_DESCRIPTOR;
|
||||
|
Reference in New Issue
Block a user