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] Typesafe saxon node iterators #4968

Merged
merged 2 commits into from Apr 27, 2024
Merged

Conversation

adangel
Copy link
Member

@adangel adangel commented Apr 18, 2024

Describe the PR

This avoids the unchecked cast, but not sure, whether it's better readable at all.

The other point: Now I'm not extends saxon's ListIterator anymore, which seems to have a lot of optimizations (LastPositionFinder, Lookahead, ...). Maybe that has some performance impact?

So, overall, I'm not sure, whether this change is worth it...

Let's see, whether at least all our XPath rules still work :)

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

@adangel adangel added the in:pmd-internals Affects PMD's internals label Apr 18, 2024
@pmd-test
Copy link

pmd-test commented Apr 18, 2024

1 Message
📖 Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Download full report as build artifact
Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Download full report as build artifact

Generated by 🚫 Danger

@oowekyala
Copy link
Member

You could use NodeListIterator like before but wrap the nodes list into a Collections.unmodifiableList. That is a type-safe conversion of List<? extends T> to List<T>. I personally would prefer that over rolling our own list iterator implementation.

@adangel adangel added this to the 7.2.0 milestone Apr 25, 2024
@adangel adangel added the in:xpath Relating to xpath support at large, eg Jaxen / Saxon, custom functions, attribute resolution label Apr 26, 2024
@adangel
Copy link
Member Author

adangel commented Apr 27, 2024

You could use NodeListIterator like before but wrap the nodes list into a Collections.unmodifiableList. That is a type-safe conversion of List<? extends T> to List<T>. I personally would prefer that over rolling our own list iterator implementation.

Nice trick, this seems to work, thanks!

@jsotuyod jsotuyod merged commit cb092dd into pmd:master Apr 27, 2024
3 checks passed
@adangel adangel deleted the saxon-node-iterators branch April 28, 2024 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in:pmd-internals Affects PMD's internals 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