Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Support NoAttribute for XPath #1825

Merged
merged 5 commits into from
Sep 5, 2019

Conversation

adangel
Copy link
Member

@adangel adangel commented May 11, 2019

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
@pmd-test
Copy link

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
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 removed the is:WIP For PRs that are not fully ready, or issues that are actively being tackled label Jun 1, 2019
@jsotuyod
Copy link
Member

jsotuyod commented Sep 2, 2019

@oowekyala anything holding this from being merged?

@oowekyala
Copy link
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.

None yet

4 participants