Remove changes to XPathHandler

This commit is contained in:
Clément Fournier 2020-04-08 22:05:42 +02:00
parent 1de1d1c66d
commit 60087590e6
5 changed files with 18 additions and 50 deletions

View File

@ -26,7 +26,7 @@ public abstract class AbstractLanguageVersionHandler implements LanguageVersionH
@Override
public XPathHandler getXPathHandler() {
return XPathHandler.DEFAULT;
return XPathHandler.DUMMY;
}
@Override

View File

@ -6,65 +6,32 @@ package net.sourceforge.pmd.lang;
import org.jaxen.Navigator;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.xpath.DefaultASTXPathHandler;
import net.sourceforge.pmd.lang.rule.XPathRule;
import net.sourceforge.pmd.lang.rule.xpath.XPathVersion;
import net.sourceforge.pmd.lang.xpath.Initializer;
import net.sf.saxon.sxpath.IndependentContext;
/**
* Handles the XPath-specific behaviour of a language.
* Interface for performing Language specific XPath handling, such as
* initialization and navigation.
*/
// TODO move to rule.xpath package
@InternalApi
@Deprecated
public interface XPathHandler {
/**
* @deprecated Use {@link #DEFAULT}.
*/
@Deprecated
XPathHandler DUMMY = new DefaultASTXPathHandler();
/**
* Default instance. Declares no additional XPath functions.
*/
XPathHandler DEFAULT = new DefaultASTXPathHandler();
/**
* Creates a new XPath rule for the given version and expression.
* Note: this isn't used by the ruleset factory for the moment,
* XPath rules are created like normal rules. Programmatic usages
* of {@link XPathRule} should be replaced with calls to this method.
* The ruleset schema will get a new syntax for XPath rules in 7.0.0.
*
* @param version Version of the XPath language
* @param xpathExpression XPath expression
*
* @return A new rule
*
* @throws NullPointerException If any of the arguments is null
*/
Rule newXPathRule(XPathVersion version, String xpathExpression);
/**
* Initialize. This is intended to be called by {@link Initializer} to
* perform Language specific initialization.
*
* @deprecated Support for Jaxen will be removed come 7.0.0
*/
@Deprecated
void initialize();
/**
* Initialize. This is intended to be called by {@link Initializer} to
* perform Language specific initialization for Saxon.
*
* @deprecated Internal API
*/
@Deprecated
void initialize(IndependentContext context);
/**

View File

@ -25,4 +25,14 @@ public abstract class AbstractASTXPathHandler implements XPathHandler {
public void initialize(IndependentContext context, Language language, Class<?> functionsClass) {
context.declareNamespace("pmd-" + language.getTerseName(), "java:" + functionsClass.getName());
}
@Override
public void initialize() {
// override if needed
}
@Override
public void initialize(IndependentContext context) {
// override if needed
}
}

View File

@ -4,10 +4,7 @@
package net.sourceforge.pmd.lang.ast.xpath;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.rule.XPathRule;
import net.sourceforge.pmd.lang.rule.xpath.XPathVersion;
import net.sf.saxon.sxpath.IndependentContext;
@ -16,11 +13,6 @@ import net.sf.saxon.sxpath.IndependentContext;
@InternalApi
public class DefaultASTXPathHandler extends AbstractASTXPathHandler {
@Override
public Rule newXPathRule(XPathVersion version, String xpathExpression) {
return new XPathRule(version, xpathExpression);
}
@Override
public void initialize() {
// override if needed

View File

@ -17,7 +17,6 @@ import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.lang.XPathHandler;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.rule.xpath.JaxenXPathRuleQuery;
import net.sourceforge.pmd.lang.rule.xpath.SaxonXPathRuleQuery;
@ -32,7 +31,7 @@ import net.sourceforge.pmd.properties.StringProperty;
public class XPathRule extends AbstractRule {
/**
* @deprecated Use {@link XPathHandler#newXPathRule(XPathVersion, String)}
* @deprecated Use {@link #XPathRule(XPathVersion, String)}
*/
@Deprecated
public static final StringProperty XPATH_DESCRIPTOR = StringProperty.named("xpath")
@ -53,7 +52,7 @@ public class XPathRule extends AbstractRule {
/**
* @deprecated Use {@link XPathHandler#newXPathRule(XPathVersion, String)}
* @deprecated Use {@link #XPathRule(XPathVersion, String)}
*/
@Deprecated
public static final EnumeratedProperty<String> VERSION_DESCRIPTOR = EnumeratedProperty.<String>named("version")