Skip to content

[core] Deprecate support for List attributes with XPath 2.0 #2451

@adangel

Description

@adangel

Part of #2523

When we update Saxon on PMD 7, attributes of type List (List<String>) won't work anymore, since with newer Saxon versions, attributes are supposed to be always non-sequences.

That's why we should deprecate the usage of such attributes for XPath (via @DeprecatedAttribute).

Affects PMD Version: 6.x + 7

Affected Attributes:
I grepped our code (find -wholename "*/lang/*/ast/*.java"|grep -i -v test|grep -v generated-sources | xargs grep "List<") and found only these usages:

./pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTReferenceExpression.java:51:    public List<String> getNames() {
./pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserTrigger.java:41:    public List<TriggerUsage> getUsages() {
./pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldDeclarationStatements.java:62:    public List<String> getTypeArguments() {

All are in Apex and could be potentially used by some XPath 2.0 rule. (TriggerUsage is a enum). I didn't find any usage of these getters/attributes in our apex rules.

Note

  • This is a requirement for PMD 7, so that we can update Saxon
  • It only affects XPath 2.0 rules, for Jaxen, we already filter out Lists (see net.sourceforge.pmd.lang.ast.xpath.DocumentNavigator.ListFilteringAttributeIterator).
  • Not sure, whether we really need to provide an alternative right now to make Lists accessible in XPath. I'd rather wait until we have a concrete use case before we start inventing something.
  • This also relates to List properties ([core] Make Saxon support multi valued XPath properties #736). I didn't investigate yet, what the consequences are.

Proposed Steps:

  • Deprecate the three apex getters for XPath
  • Update documentation, if any. Maybe fix xpath example queries.
  • Mention this in the release notes

Metadata

Metadata

Assignees

Labels

in:xpathRelating to xpath support at large, eg Jaxen / Saxon, custom functions, attribute resolutionis:deprecationThe main focus is deprecating public APIs or rules, eg to make them internal, or removing them

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions