Skip to content

Add Support for the #set! directive and #is? predicate #131

Merged
bonede merged 10 commits intobonede:mainfrom
DavidBakerEffendi:dave/meta-directives
Feb 27, 2026
Merged

Add Support for the #set! directive and #is? predicate #131
bonede merged 10 commits intobonede:mainfrom
DavidBakerEffendi:dave/meta-directives

Conversation

@DavidBakerEffendi
Copy link
Contributor

This change introduces support for the #set! directive and #is? predicate within Tree-sitter queries. These additions allow users to associate arbitrary key-value metadata with query matches and perform conditional checks against that metadata.

Key changes include:

  • TSQueryMatch: Added a metadata map to store key-value pairs.
  • TSQueryCursor: Updated nextMatch and nextCapture to clear metadata between iterations, ensuring match isolation.
  • TSQueryPredicate: Implemented TSQueryPredicateSet and TSQueryPredicateIs logic.
  • TSQuery: Added internal handlers to parse and initialize these new predicate types from query source strings.
  • Optimization: Refactored getStringValueForId in TSQuery for direct lookup by ID, improving performance.
  • Tests: Added TSQueryMetadataTest to verify metadata persistence, isolation, and predicate logic.

Resolves #130

@bonede bonede merged commit eb9b533 into bonede:main Feb 27, 2026
0 of 4 checks passed
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.

Implement metadata directives #is? and #set! for Query Matches

2 participants