+
Skip to content

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 a team and dyc3 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

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载