diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/AbstractLanguageVersionHandler.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/AbstractLanguageVersionHandler.java index f28567827b..634e00fe24 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/AbstractLanguageVersionHandler.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/AbstractLanguageVersionHandler.java @@ -26,7 +26,7 @@ public abstract class AbstractLanguageVersionHandler implements LanguageVersionH @Override public XPathHandler getXPathHandler() { - return XPathHandler.DEFAULT; + return XPathHandler.DUMMY; } @Override diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/XPathHandler.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/XPathHandler.java index 108a473eb5..2895550346 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/XPathHandler.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/XPathHandler.java @@ -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); /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AbstractASTXPathHandler.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AbstractASTXPathHandler.java index f4c1e8ddbe..eb470c94bd 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AbstractASTXPathHandler.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AbstractASTXPathHandler.java @@ -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 + } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/DefaultASTXPathHandler.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/DefaultASTXPathHandler.java index 9510e04f84..3fa844f28a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/DefaultASTXPathHandler.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/DefaultASTXPathHandler.java @@ -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 diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java index f6a36b903f..25451cd860 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java @@ -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 VERSION_DESCRIPTOR = EnumeratedProperty.named("version")