Skip to content

[core] Support NoAttribute for XPath#1825

Merged
jsotuyod merged 5 commits into
pmd:pmd/7.0.xfrom
adangel:pmd7-xpath-no-attribute
Sep 5, 2019
Merged

[core] Support NoAttribute for XPath#1825
jsotuyod merged 5 commits into
pmd:pmd/7.0.xfrom
adangel:pmd7-xpath-no-attribute

Conversation

@adangel

@adangel adangel commented May 11, 2019

Copy link
Copy Markdown
Member

Changes:

  • Adds the @net.sourceforge.pmd.lang.ast.xpath.NoAttribute annotation
  • With that, you can annotate getters in AST nodes, that should not be exposed as XPath attributes and thus cannot be used for xpath expressions/queries.
  • The annotation can also be applied to the whole AST class - then all methods are not exposed.

Todo:

@adangel adangel added an:enhancement An improvement on existing features / rules in:xpath Relating to xpath support at large, eg Jaxen / Saxon, custom functions, attribute resolution labels May 11, 2019
@adangel adangel added this to the 7.0.0 milestone May 11, 2019
@ghost

ghost commented May 11, 2019

Copy link
Copy Markdown
1 Message
📖 No java rules are changed!

Generated by 🚫 Danger

@oowekyala oowekyala added the is:WIP For PRs that are not fully ready, or issues that are actively being tackled label May 18, 2019
@oowekyala

Copy link
Copy Markdown
Member

I added some unit tests. I also changed a bit the contract of @NoAttribute:

  • Attributes from Node and AbstractNode are never suppressed. I don't know what might go wrong if we do suppress them.
  • The scope INHERITED suppresses the attributes inherited from supertypes
  • The scope ALL suppresses the attributes defined in the class + INHERITED
  • In any case, if an attribute accessor is overridden in a concrete class C, then it is only suppressed if either
    1. the accessor has its own NoAttribute annotation
    2. C has a @NoAttribute(scope = ALL).

This last point means that if you can override the method, then you can expose it as an attribute again.

@oowekyala oowekyala force-pushed the pmd7-xpath-no-attribute branch from 433fedf to 4fa15ce Compare May 25, 2019 06:54
@oowekyala oowekyala removed the is:WIP For PRs that are not fully ready, or issues that are actively being tackled label Jun 1, 2019
@jsotuyod

jsotuyod commented Sep 2, 2019

Copy link
Copy Markdown
Member

@oowekyala anything holding this from being merged?

@oowekyala

Copy link
Copy Markdown
Member

@jsotuyod nope, i might have forgotten about it

@jsotuyod jsotuyod merged commit 1989662 into pmd:pmd/7.0.x Sep 5, 2019
@adangel adangel mentioned this pull request May 23, 2020
14 tasks
@adangel adangel mentioned this pull request Jan 23, 2023
55 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

an:enhancement An improvement on existing features / rules in:xpath Relating to xpath support at large, eg Jaxen / Saxon, custom functions, attribute resolution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants