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

feat(grit): implement disregarded snippet nodes #4084

Merged
merged 4 commits into from
Sep 25, 2024

Conversation

arendjr
Copy link
Contributor

@arendjr arendjr commented Sep 25, 2024

Summary

As I was looking into #4077, I discovered the reason it didn't match was very silly: The query was lacking the trailing semicolon which is part of the syntax rule for type declarations. A fix wasn't entirely trivial however, but I discovered a TODO which could help out: Grit's own language bindings implement the notion of "disregarded snippet fields", which is a way of filtering out fields from the snippet pattern that are not relevant for a match.

Grit themselves don't use this functionality for filtering out semicolons (I guess they're treated differently in the TreeSitter grammar), but we can! So I implemented this, but there was one more hurdle: recognizing the semicolons depends on matching them by their slot index, which I would rather not hard-code. So I extended the codegen to generate the necessary constants as well.

Also thanks to the disregarded snippet fields, Grit queries for functions can now also match async functions by default.

Fixes #4077

Test Plan

Tests added.

@arendjr arendjr requested review from dyc3 and a team September 25, 2024 21:09
@github-actions github-actions bot added A-Tooling Area: internal tools L-Grit Language: GritQL labels Sep 25, 2024
@arendjr arendjr merged commit e184d45 into biomejs:main Sep 25, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Tooling Area: internal tools L-Grit Language: GritQL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 Search does not match type $T = $U
1 participant