Skip to content

Comments

Implement Query Predicate Enforcement (#eq?, #match?, #any-of?)#128

Open
DavidBakerEffendi wants to merge 15 commits intobonede:mainfrom
DavidBakerEffendi:main
Open

Implement Query Predicate Enforcement (#eq?, #match?, #any-of?)#128
DavidBakerEffendi wants to merge 15 commits intobonede:mainfrom
DavidBakerEffendi:main

Conversation

@DavidBakerEffendi
Copy link

This PR implements Java-side evaluation for Tree-sitter query predicates, ensuring that matches are strictly filtered based on source text comparisons (e.g., #eq?, #match?) rather than returning all native candidates. The logic relies on the jtreesitter dependency as a reference implementation to ensure standard behavior.

Key changes

  • Implemented a TSQueryPredicate class hierarchy to evaluate #eq?, #match?, and #any-of? against captured nodes.
  • Updated TSQuery to parse raw predicate steps into executable objects and cache them per pattern.
  • Modified TSQueryCursor to iterate native matches and filter them using the parsed predicates and provided source text.
  • Added TSQueryPredicateTest to validate predicate logic, dynamically loading the JSON language for testing.

Future work

Metadata directives like #is? and #set! are currently handled as generic pass-throughs and need full implementation.

Resolves #105
Resolves #84

Note: Set as draft for now, will do another round of reviews on Monday or so (maybe adding more tests), but if you get to it before then and are happy, feel free to merge :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Query ignoring predicates #match? condition in S-expression queries not having any effect

1 participant