Skip to content
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 33 commits into from
Oct 1, 2023
Merged

Refactoring Query and QueryMatch #37

merged 33 commits into from
Oct 1, 2023

Conversation

dabico
Copy link
Member

@dabico dabico commented Sep 29, 2023

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 a Capture,
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.

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
@dabico dabico merged commit bc0556d into master Oct 1, 2023
2 checks passed
@dabico dabico deleted the enhancement/query branch October 1, 2023 08:54
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.

1 participant