-
Notifications
You must be signed in to change notification settings - Fork 2
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
Refactoring Query
and QueryMatch
#37
Merged
Merged
Conversation
This file contains 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
We essentially invoke the tree-sitter API at `build()` time to determine the starting offsets for each pattern of the full pattern string.
The change of field signature caused this. We want to retain this method for backwards-compatibility purposes.
May see revisions in terms of structure
May see revisions in terms of structure
The first term is treated equivalently to the second by the tree-sitter library, but I feel like the new name makes more sense to the programmer as it reflects its true purpose
The type of said field will soon be changed, so this will quickly become an invalid reference. But apart from that, we don't use it anywhere, so it's not a loss at all.
I fell that we can use some sort of `Capture` -> `Node` map to replace the now-confusingly-named `QueryCapture` class. However, since one `Capture` instance will be able to map to multiple nodes, we will need to introduce some kind of multi-value variant of `Map` to store captures
Documentation is also updated to reflect this change
The superclass will probably be renamed
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 introduces two new classes:
Capture
Pattern
Both are new members of
Query
, and serve as typed containers for querying information.To that end,
QueryMatch
was refactored to make better use of these new additions,with each match associating to a
Pattern
and containing mappings from aCapture
,to all
Node
instances captured.This PR will deprecate many methods, but most notably, it will deprecate
QueryCapture
.It no longer fits in to the overall structure, and will probably only serve to confuse users.