diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/ExpressionPrinter.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/ExpressionPrinter.java index 144b11ddd8..7719642a03 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/ExpressionPrinter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/ExpressionPrinter.java @@ -20,7 +20,7 @@ import net.sf.saxon.om.Axis; * printer.visit(query.xpathExpression.getInternalExpression()); * */ -public class ExpressionPrinter extends Visitor { +public class ExpressionPrinter extends SaxonExprVisitor { private int depth = 0; private void print(String s) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/RuleChainAnalyzer.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/RuleChainAnalyzer.java index 0055c02b0a..9c9bcdb855 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/RuleChainAnalyzer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/RuleChainAnalyzer.java @@ -34,7 +34,7 @@ import net.sf.saxon.type.Type; *

DocumentSorter expression is removed. The sorting of the resulting nodes needs to be done * after all (sub)expressions have been executed. */ -public class RuleChainAnalyzer extends Visitor { +public class RuleChainAnalyzer extends SaxonExprVisitor { private final Configuration configuration; private String rootElement; private boolean rootElementReplaced; @@ -107,9 +107,10 @@ public class RuleChainAnalyzer extends Visitor { @Override public Expression visit(LazyExpression e) { + boolean prevCtx = insideLazyExpression; insideLazyExpression = true; Expression result = super.visit(e); - insideLazyExpression = false; + insideLazyExpression = prevCtx; return result; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/Visitor.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonExprVisitor.java similarity index 99% rename from pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/Visitor.java rename to pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonExprVisitor.java index d67c34b3b2..d1dc8dd873 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/Visitor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonExprVisitor.java @@ -16,7 +16,7 @@ import net.sf.saxon.expr.RootExpression; import net.sf.saxon.expr.VennExpression; import net.sf.saxon.sort.DocumentSorter; -abstract class Visitor { +abstract class SaxonExprVisitor { public Expression visit(DocumentSorter e) { Expression base = visit(e.getBaseExpression()); return new DocumentSorter(base); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SplitUnions.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SplitUnions.java index 20120c65ef..7d45b544b3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SplitUnions.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SplitUnions.java @@ -17,7 +17,7 @@ import net.sf.saxon.expr.VennExpression; * *

E.g. "//A | //B | //C" will result in 3 expressions "//A", "//B", and "//C". */ -class SplitUnions extends Visitor { +class SplitUnions extends SaxonExprVisitor { private List expressions = new ArrayList<>(); @Override