Implement Query Predicate Enforcement (#eq?, #match?, #any-of?)#128
Open
DavidBakerEffendi wants to merge 15 commits intobonede:mainfrom
Open
Implement Query Predicate Enforcement (#eq?, #match?, #any-of?)#128DavidBakerEffendi wants to merge 15 commits intobonede:mainfrom
DavidBakerEffendi wants to merge 15 commits intobonede:mainfrom
Conversation
- Replace manual language loading with `TreeSitterJson` in tests. - Expand `TSQueryCursorTest` with a larger JSON document for better coverage of `execWithOptions`. - Clean up redundant `assumeTrue` checks in predicate tests.
- Rename `isPatternNonLocal` to `isPatterNonLocal` in `TSQuery` - Add capture ID validation in `getCaptureNameForId` - Update `TSQueryCursorTest` to use queries with predicates
98c5161 to
7f90a8a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 thejtreesitterdependency as a reference implementation to ensure standard behavior.Key changes
TSQueryPredicateclass hierarchy to evaluate#eq?,#match?, and#any-of?against captured nodes.TSQueryto parse raw predicate steps into executable objects and cache them per pattern.TSQueryCursorto iterate native matches and filter them using the parsed predicates and provided source text.TSQueryPredicateTestto 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 :)