Remove other specific XPath rules

This commit is contained in:
Clément Fournier
2020-08-10 11:59:38 +02:00
parent a591994f36
commit 37b9bfabaf
4 changed files with 6 additions and 100 deletions

View File

@@ -66,17 +66,6 @@ public class XPathRule extends AbstractRule {
// this is shared with rules forked by deepCopy, used by the XPathRuleQuery
private DeprecatedAttrLogger attrLogger = DeprecatedAttrLogger.create(this);
/**
* Creates a new XPathRule without the corresponding XPath query.
*
* @deprecated Use {@link #XPathRule(XPathVersion, String)}
*/
public XPathRule() {
definePropertyDescriptor(XPATH_DESCRIPTOR);
definePropertyDescriptor(VERSION_DESCRIPTOR);
}
/**
* Make a new XPath rule with the given version + expression
*
@@ -86,9 +75,12 @@ public class XPathRule extends AbstractRule {
* @throws NullPointerException If any of the arguments is null
*/
public XPathRule(XPathVersion version, String expression) {
this();
definePropertyDescriptor(XPATH_DESCRIPTOR);
definePropertyDescriptor(VERSION_DESCRIPTOR);
Objects.requireNonNull(version, "XPath version is null");
Objects.requireNonNull(expression, "XPath expression is null");
setXPath(expression);
setVersion(version.getXmlName());
}

View File

@@ -18,6 +18,7 @@ import net.sourceforge.pmd.lang.ast.DummyNode;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.rule.ParametricRuleViolation;
import net.sourceforge.pmd.lang.rule.XPathRule;
import net.sourceforge.pmd.lang.rule.xpath.XPathVersion;
public class CodeClimateRendererTest extends AbstractRendererTest {
@@ -94,8 +95,7 @@ public class CodeClimateRendererTest extends AbstractRendererTest {
RuleContext ctx = new RuleContext();
ctx.setSourceCodeFile(new File(getSourceCodeFilename()));
Report report = new Report();
XPathRule theRule = new XPathRule();
theRule.setProperty(XPathRule.XPATH_DESCRIPTOR, "//dummyNode");
XPathRule theRule = new XPathRule(XPathVersion.XPATH_3_1, "//dummyNode");
// Setup as FooRule
theRule.setDescription("desc");

View File

@@ -1,36 +0,0 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.ecmascript.rule;
import net.sourceforge.pmd.lang.LanguageRegistry;
import net.sourceforge.pmd.lang.ParserOptions;
import net.sourceforge.pmd.lang.ecmascript.EcmascriptLanguageModule;
import net.sourceforge.pmd.lang.ecmascript.EcmascriptParserOptions;
import net.sourceforge.pmd.lang.ecmascript.EcmascriptParserOptions.Version;
import net.sourceforge.pmd.lang.rule.XPathRule;
import net.sourceforge.pmd.properties.PropertyDescriptor;
/**
* @deprecated Parser options are deprecated, use {@link XPathRule} directly
*/
@Deprecated
public class EcmascriptXPathRule extends XPathRule {
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;
private static final PropertyDescriptor<Version> RHINO_LANGUAGE_VERSION = EcmascriptParserOptions.RHINO_LANGUAGE_VERSION;
public EcmascriptXPathRule() {
super.setLanguage(LanguageRegistry.getLanguage(EcmascriptLanguageModule.NAME));
definePropertyDescriptor(RECORDING_COMMENTS_DESCRIPTOR);
definePropertyDescriptor(RECORDING_LOCAL_JSDOC_COMMENTS_DESCRIPTOR);
definePropertyDescriptor(RHINO_LANGUAGE_VERSION);
}
@Override
public ParserOptions getParserOptions() {
return new EcmascriptParserOptions(this);
}
}

View File

@@ -1,50 +0,0 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.xml.rule;
import net.sourceforge.pmd.lang.LanguageRegistry;
import net.sourceforge.pmd.lang.ParserOptions;
import net.sourceforge.pmd.lang.rule.XPathRule;
import net.sourceforge.pmd.lang.xml.XmlLanguageModule;
import net.sourceforge.pmd.lang.xml.XmlParserOptions;
import net.sourceforge.pmd.properties.PropertyDescriptor;
/**
* @deprecated Parser options are deprecated, use {@link XPathRule} directly
*/
@Deprecated
public class XmlXPathRule extends XPathRule {
@Deprecated
public static final PropertyDescriptor<Boolean> COALESCING_DESCRIPTOR = XmlParserOptions.COALESCING_DESCRIPTOR;
@Deprecated
public static final PropertyDescriptor<Boolean> EXPAND_ENTITY_REFERENCES_DESCRIPTOR = XmlParserOptions.EXPAND_ENTITY_REFERENCES_DESCRIPTOR;
@Deprecated
public static final PropertyDescriptor<Boolean> IGNORING_COMMENTS_DESCRIPTOR = XmlParserOptions.IGNORING_COMMENTS_DESCRIPTOR;
@Deprecated
public static final PropertyDescriptor<Boolean> IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR = XmlParserOptions.IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR;
@Deprecated
public static final PropertyDescriptor<Boolean> NAMESPACE_AWARE_DESCRIPTOR = XmlParserOptions.NAMESPACE_AWARE_DESCRIPTOR;
@Deprecated
public static final PropertyDescriptor<Boolean> VALIDATING_DESCRIPTOR = XmlParserOptions.VALIDATING_DESCRIPTOR;
@Deprecated
public static final PropertyDescriptor<Boolean> XINCLUDE_AWARE_DESCRIPTOR = XmlParserOptions.XINCLUDE_AWARE_DESCRIPTOR;
public XmlXPathRule() {
super.setLanguage(LanguageRegistry.getLanguage(XmlLanguageModule.NAME));
definePropertyDescriptor(COALESCING_DESCRIPTOR);
definePropertyDescriptor(EXPAND_ENTITY_REFERENCES_DESCRIPTOR);
definePropertyDescriptor(IGNORING_COMMENTS_DESCRIPTOR);
definePropertyDescriptor(IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR);
definePropertyDescriptor(NAMESPACE_AWARE_DESCRIPTOR);
definePropertyDescriptor(VALIDATING_DESCRIPTOR);
definePropertyDescriptor(XINCLUDE_AWARE_DESCRIPTOR);
}
@Override
public ParserOptions getParserOptions() {
return new XmlParserOptions(this);
}
}