Make Query.Between default exclusive; add block wrapping helpers; improve region traversal#36
Merged
Merged
Conversation
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.
Summary
This PR adjusts
Query.Betweento default toinclusive: false(exclusive), fixes region-resolution semantics forBetweenQuerywhile keeping sequence-safe consumption, adds a new offset-capableRegionTraversaloverload for efficient region selection, and introduces convenience APIs to wrap existing block nodes into queries (Query.Wrap(...)/Query.Inner(...)). Tests and wiki docs are updated accordingly.Key Changes
Query.Betweendefaults to exclusive:Query.Between(start, end)now matches the content between start/end delimiters (delimiters excluded).inclusive: trueto include the delimiters in the matched region.BetweenQuerysemantics split “consumption” vs “edit region”:TryMatchalways consumes the full start→end span (safe in sequences).RegionTraversaloverload that supports offset regions (start slot offset + custom first-node/position), so queries likeBetweenQuerycan remain efficient without switching to a TreeWalker-based region scan.Query.Wrap(SyntaxBlock)returns aBlockNodeQueryso callers can use.Inner() / .Start() / .End()on an existing block instance.Query.Wrap(SyntaxNode)returns aBlockNodeQueryfor blocks, otherwise anExactNodeQuery.Query.Inner(SyntaxBlock)is shorthand forQuery.Wrap(block).Inner().Tests/Docs
inclusive: true.Query.Wrap(block).Inner()andQuery.Inner(block)edit only the intended block.Query.Betweendefault behavior and the new wrap/inner conveniences.Behavior Change / Migration Notes
Query.Between(start, end)included the delimiters must switch toQuery.Between(start, end, inclusive: true).