Skip to content

Conversation

rriski
Copy link
Contributor

@rriski rriski commented Sep 15, 2025

Implements #7339

Summary

This PR adds support for matching native Biome AST nodes in GritQL patterns. Previously, only a curated list of TreeSitter-compatible snake_case names were available. Now, patterns can reference native Biome AST node using its PascalCase name (e.g., JsIfStatement, CssClassSelector).

Example

engine biome(1.0)
language js(typescript,jsx)

or {
  // TreeSitter-compatible pattern
  if_statement(),

  // Native Biome AST node pattern
  JsIfStatement()
} as $stmt where {
  register_diagnostic(
    span=$stmt,
    message="Found an if statement"
  )
}

AI disclosure: The change in this PR was assisted by Sonnet 4 and gemini 2.5 Pro. All changed lines were reviewed and the overall change tested by me.

@changeset-bot
Copy link

changeset-bot bot commented Sep 15, 2025

🦋 Changeset detected

Latest commit: 9c355f2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 15, 2025

Walkthrough

Adds generated mapping modules that resolve GritQL pattern names to internal syntax kinds for CSS and JavaScript. New generated_mappings.rs files for CSS and JS implement kind_by_name; the JS mapping also includes legacy Tree‑sitter compatibility metadata (LegacyTreeSitterPattern, legacy names, and slot maps) and helper functions. JsTargetLanguage and CssTargetLanguage now delegate name→kind and slot resolution to these generated modules. Tests and specs for CSS and TS/JS Tree‑sitter compatibility were added. The xtask codegen gained generate_grit_mappings and wiring to emit these mapping files during generation.

Possibly related PRs

Suggested reviewers

  • arendjr
  • ematipico

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly and accurately summarises the primary change — enabling matching of native Biome AST nodes in GritQL — and follows conventional commit style with a clear scope (grit). It is concise, specific, and directly related to the changeset.
Description Check ✅ Passed The PR description is on-topic and informative: it references issue #7339, summarises the behaviour change (support for PascalCase native AST node names alongside TreeSitter snake_case names), and includes a concrete example demonstrating the feature. This satisfies the lenient requirement for a descriptive PR body.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added A-Tooling Area: internal tools L-Grit Language: GritQL labels Sep 15, 2025
@rriski rriski changed the title feat(grit): Allow matching native Biome AST nodes feat(grit): allow matching native Biome AST nodes Sep 15, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (11)
crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.css (1)

1-11: Consider one more selector to exercise mappings

Add an attribute or pseudo-class selector to hit another native node (e.g., CssAttributeSelector or CssPseudoClassSelector).

crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.grit (2)

31-31: Nit: trailing comma for easier diffs

Add a trailing comma after the last item for consistency.

-  JsConditionalExpression() // L24
+  JsConditionalExpression(), // L24

20-31: Parity check: include JsIfStatement

You test legacy if_statement(); consider adding JsIfStatement() in the native list to mirror it.

   JsTemplateExpression(), // L20
   JsArrowFunctionExpression(), // L21
   JsCallExpression(), // L22
   JsBinaryExpression(), // L23
-  JsConditionalExpression() // L24
+  JsConditionalExpression(), // L24
+  JsIfStatement() // L25
crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs (2)

8-9: Doc nit: “legacy or native” wording

This CSS mapping only lists native Biome nodes. Either update the comment to “native” or add legacy mappings if applicable.


13-186: Stability of taking the first KIND_SET element

Relying on KIND_SET.iter().next() assumes a stable order. If generation or enum order changes, the chosen representative kind may drift. Consider encoding a canonical kind in codegen, or returning a small fixed mapping when multiple kinds exist.

crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.grit (1)

4-9: LGTM; maybe assert more shapes

Nice smoke test for native names. Consider adding CssQualifiedRule() or CssSupportsAtRule() to cover rule/at‑rule paths too.

xtask/codegen/src/generate_grit_mappings.rs (3)

93-95: Duplicate import of the same type.

You're importing {syntax_kind_type} twice on consecutive lines.

 use biome_rowan::AstNode;
 use {syntax_module}::{syntax_kind_type};
-use {syntax_module}::{syntax_kind_type}::*;
+use {syntax_module}::{{syntax_kind_type}, {syntax_kind_type}::*};

101-102: Redundant imports in the generated function.

The function already imports these at the module level (lines 93-95), making these redundant.

 pub fn kind_by_name(node_name: &str) -> Option<{syntax_kind_type}> {{
-    use {syntax_module}::*;
-    use {syntax_kind_type}::*;
     match node_name {{

142-142: Consider a more descriptive error message.

The unimplemented macro provides minimal context. Consider including what language kinds are currently supported.

-            _ => unimplemented!("Grit mappings are not supported for {:?}", language_kind),
+            _ => unimplemented!("Grit mappings are not supported for {:?}. Currently supported: Js, Css", language_kind),
crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs (2)

1-1: Consider adding a more prominent warning comment.

While the current comment mentions this is generated, consider making it more prominent to prevent accidental edits.

-//! Generated file, do not edit by hand, see `xtask/codegen`
+//! GENERATED FILE - DO NOT EDIT BY HAND
+//! This file is automatically generated by `xtask/codegen`.
+//! Any manual changes will be overwritten on the next generation.

163-505: Consider optimising the native patterns section.

The repeated pattern of SomeType::KIND_SET.iter().next() could potentially be extracted into a helper macro for cleaner generated code, though this is a very minor optimisation.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a8c64f8 and 73aeae8.

⛔ Files ignored due to path filters (2)
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (10)
  • crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs (1 hunks)
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs (5 hunks)
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs (1 hunks)
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.css (1 hunks)
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.grit (1 hunks)
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.grit (1 hunks)
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.ts (1 hunks)
  • xtask/codegen/src/ast.rs (2 hunks)
  • xtask/codegen/src/generate_grit_mappings.rs (1 hunks)
  • xtask/codegen/src/lib.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.css
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.ts
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.grit
  • crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.grit
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs
**/tests/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place test files under a tests/ directory in each crate

Files:

  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.css
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.ts
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.grit
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.grit
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format all Rust source files before committing (just f)

Files:

  • xtask/codegen/src/ast.rs
  • xtask/codegen/src/lib.rs
  • crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs
  • xtask/codegen/src/generate_grit_mappings.rs
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs
🧠 Learnings (17)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-08-17T08:57:34.751Z
Learning: Applies to crates/biome_parser/xtask/codegen/src/*_kinds_src.rs : Add src/<language>_kinds_src.rs under xtask/codegen that returns a static KindSrc
📚 Learning: 2025-08-11T11:48:27.774Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:48:27.774Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/spec_tests.rs : Create tests/spec_tests.rs in the biome_html_formatter crate that generates tests via tests_macros::gen_tests! for all HTML files at tests/specs/html/**/*.html

Applied to files:

  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.css
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.grit
📚 Learning: 2025-08-11T11:48:27.774Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:48:27.774Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/specs/html/**/*.html : Place HTML test fixtures under tests/specs/html and subfolders, using .html files

Applied to files:

  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.css
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.grit
📚 Learning: 2025-09-10T08:05:22.867Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-09-10T08:05:22.867Z
Learning: Applies to crates/biome_analyze/crates/biome_rule_options/lib/**/*.rs : Define per-rule options types in `biome_rule_options` crate (one file per rule, e.g., `lib/use_my_rule.rs`)

Applied to files:

  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.css
  • xtask/codegen/src/lib.rs
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.grit
📚 Learning: 2025-08-17T08:57:34.751Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-08-17T08:57:34.751Z
Learning: Applies to crates/biome_parser/xtask/codegen/src/*_kinds_src.rs : Add src/<language>_kinds_src.rs under xtask/codegen that returns a static KindSrc

Applied to files:

  • xtask/codegen/src/ast.rs
  • crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs
  • xtask/codegen/src/generate_grit_mappings.rs
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs
📚 Learning: 2025-08-17T08:57:34.751Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-08-17T08:57:34.751Z
Learning: After covering all new language variants and files, run just gen-grammar (optionally with language list) or cargo codegen grammar to generate sources

Applied to files:

  • xtask/codegen/src/ast.rs
📚 Learning: 2025-09-10T08:05:22.867Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-09-10T08:05:22.867Z
Learning: Applies to crates/biome_analyze/crates/**/tests/specs/**/*.jsonc : Snapshot test `.jsonc` files must contain an array of code snippets (strings); these run in script mode (no ESM syntax)

Applied to files:

  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.grit
📚 Learning: 2025-08-11T11:48:27.774Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:48:27.774Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/spec_test.rs : Create tests/spec_test.rs implementing the run(spec_input_file, _expected_file, test_directory, _file_type) function as shown and include!("language.rs")

Applied to files:

  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.grit
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.grit
📚 Learning: 2025-08-11T11:48:27.774Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:48:27.774Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/src/cst.rs : Define FormatHtmlSyntaxNode in cst.rs and implement FormatRule<HtmlSyntaxNode>, plus AsFormat and IntoFormat for HtmlSyntaxNode using the provided mapping code

Applied to files:

  • crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs
📚 Learning: 2025-08-17T08:57:34.751Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-08-17T08:57:34.751Z
Learning: From the repository root, start new language work in the xtask/codegen area and follow the listed steps to add grammar, kinds source, crates, language kind variant/prefix, and run codegen

Applied to files:

  • xtask/codegen/src/generate_grit_mappings.rs
📚 Learning: 2025-08-17T08:57:34.751Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-08-17T08:57:34.751Z
Learning: Applies to crates/biome_parser/crates/biome_*_{syntax,factory}/src/generated/** : Each new language crate must contain a src/generated/ directory for codegen outputs

Applied to files:

  • xtask/codegen/src/generate_grit_mappings.rs
📚 Learning: 2025-08-11T11:53:15.299Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:53:15.299Z
Learning: Applies to crates/biome_service/../biome_lsp/src/server.tests.rs : Keep end-to-end LSP tests in biome_lsp’s server.tests.rs

Applied to files:

  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.grit
📚 Learning: 2025-08-11T11:48:27.774Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:48:27.774Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/language.rs : Create tests/language.rs defining HtmlTestFormatLanguage and implement TestFormatLanguage for it

Applied to files:

  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.grit
📚 Learning: 2025-09-10T08:05:22.867Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-09-10T08:05:22.867Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/tests/quick_test.rs : Quick test: edit `tests/quick_test.rs`, remove or comment `#[ignore]`, set `SOURCE`, and adjust `RuleFilter`

Applied to files:

  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.grit
📚 Learning: 2025-08-11T11:48:27.774Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:48:27.774Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/specs/html/**/options.json : When non-default formatting options are needed for a test group, place an options.json (biome.json format) alongside the .html files in that folder

Applied to files:

  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.grit
📚 Learning: 2025-08-17T08:55:30.118Z
Learnt from: CR
PR: biomejs/biome#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-17T08:55:30.118Z
Learning: Applies to crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/** : Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}

Applied to files:

  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.grit
📚 Learning: 2025-08-11T11:50:12.090Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:50:12.090Z
Learning: Applies to crates/biome_js_type_info/src/**/*.rs : Represent links between types using TypeReference (not Arc) to avoid cross-module retention and recursive structures; store type data in linear vectors

Applied to files:

  • crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs
🧬 Code graph analysis (3)
xtask/codegen/src/ast.rs (2)
xtask/codegen/src/generate_grit_mappings.rs (2)
  • generate_grit_mappings (4-121)
  • ast (8-19)
xtask/codegen/src/lib.rs (1)
  • update (55-75)
xtask/codegen/src/lib.rs (1)
xtask/codegen/src/generate_grit_mappings.rs (1)
  • generate_grit_mappings (4-121)
crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs (1)
crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs (2)
  • legacy_treesitter_name_for_kind (120-125)
  • legacy_treesitter_slots_for_kind (128-133)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (27)
  • GitHub Check: Validate PR title
  • GitHub Check: Parser conformance
  • GitHub Check: autofix
  • GitHub Check: Bench (biome_html_formatter)
  • GitHub Check: Bench (biome_package)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: End-to-end tests
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Bench (biome_json_analyze)
  • GitHub Check: Bench (biome_json_parser)
  • GitHub Check: Bench (biome_css_parser)
  • GitHub Check: Bench (biome_module_graph)
  • GitHub Check: Bench (biome_graphql_formatter)
  • GitHub Check: Bench (biome_html_parser)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Documentation
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: Bench (biome_graphql_parser)
  • GitHub Check: Check Dependencies
  • GitHub Check: Bench (biome_json_formatter)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_css_formatter)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Test Node.js API
🔇 Additional comments (6)
crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.css (1)

1-11: Fixture looks good

Covers class, id, and type selectors plus a declaration – nice minimal spread.

crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.ts (1)

1-24: Solid coverage

Exercises most legacy nodes plus native constructs (template, arrow, call, binary, conditional). Looks good.

xtask/codegen/src/ast.rs (1)

116-118: LGTM! Clean integration of GRIT mappings generation.

The implementation follows the existing pattern for conditional code generation and properly handles the generated mappings file alongside constants.

xtask/codegen/src/lib.rs (1)

8-8: LGTM! Proper module declaration and export.

The new module is correctly declared and its public function is properly re-exported.

Also applies to: 44-44

crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs (2)

2-2: LGTM! Well-structured module reorganisation.

The delegation to the generated module nicely centralises the mapping logic and keeps the implementation clean.

Also applies to: 15-17


43-46: Clear and helpful documentation update.

Good job documenting the dual support for TreeSitter and native Biome patterns with the precedence order.

Comment on lines 4 to 9
use biome_css_syntax::CssSyntaxKind;
use biome_css_syntax::CssSyntaxKind::*;
use biome_rowan::AstNode;

/// Returns the syntax kind for a legacy or native node name.
pub fn kind_by_name(node_name: &str) -> Option<CssSyntaxKind> {
use CssSyntaxKind::*;
use biome_css_syntax::*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Remove unused imports to avoid warnings in generated code

CssSyntaxKind::* and AstNode aren’t used; the inner use CssSyntaxKind::* is also redundant. Trim them in the generator to keep builds warning‑free.

 use biome_css_syntax::CssSyntaxKind;
-use biome_css_syntax::CssSyntaxKind::*;
-use biome_rowan::AstNode;
@@
-pub fn kind_by_name(node_name: &str) -> Option<CssSyntaxKind> {
-    use CssSyntaxKind::*;
+pub fn kind_by_name(node_name: &str) -> Option<CssSyntaxKind> {
     use biome_css_syntax::*;

🏁 Script executed:

#!/bin/bash
# Find unused AstNode imports in generated_mappings files
rg -n -C1 $'^use\\s+biome_rowan::AstNode;\\s*$' crates/biome_grit_patterns/src/grit_target_language/**/generated_mappings.rs

Length of output: 707


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Print top of each generated_mappings.rs and search for AstNode / wildcard imports
for f in crates/biome_grit_patterns/src/grit_target_language/*/generated_mappings.rs; do
  echo "=== $f ==="
  if [ -f "$f" ]; then
    nl -ba -w3 -s': ' "$f" | sed -n '1,240p'
    echo
    echo "-- AstNode occurrences --"
    rg -n 'AstNode' "$f" || true
    echo "-- '::*' wildcard import lines --"
    rg -n '::\*;' "$f" || true
    echo "-- CssSyntaxKind occurrences --"
    rg -n 'CssSyntaxKind' "$f" || true
  else
    echo "File not found: $f"
  fi
  echo
done

Length of output: 142


🏁 Script executed:

#!/bin/bash
set -euo pipefail

for f in crates/biome_grit_patterns/src/grit_target_language/*/generated_mappings.rs; do
  echo "=== $f ==="
  if [ -f "$f" ]; then
    echo "-- head (lines 1..240) --"
    sed -n '1,240p' "$f" || cat "$f"
    echo
    echo "-- specific import / usage checks --"
    rg -n 'use biome_css_syntax|use biome_rowan::AstNode|CssSyntaxKind::\*|use biome_css_syntax::\*|use CssSyntaxKind::\*' "$f" || true
    echo
    echo "-- occurrences of 'AstNode' elsewhere in file --"
    rg -n '\bAstNode\b' "$f" || true
    echo
    echo "-- unqualified returns like Some(IDENT) --"
    rg -n 'Some\(\s*[A-Za-z_][A-Za-z0-9_]*\s*\)' "$f" || true
    echo
    echo "-- qualified returns using CssSyntaxKind:: --"
    rg -n 'CssSyntaxKind::' "$f" || true
  else
    echo "File not found: $f"
  fi
  echo
done

Length of output: 26170


Remove unused imports in generated mappings (css + js)

Trim the generator output to avoid warnings:

  • crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs: remove the top-level use biome_css_syntax::CssSyntaxKind::*; and use biome_rowan::AstNode;, and drop the inner use CssSyntaxKind::*; (keep use biome_css_syntax::CssSyntaxKind; and use biome_css_syntax::*; inside the fn).
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs: remove the unused use biome_rowan::AstNode; (keep the existing JsSyntaxKind wildcard).

Suggested diffs:

--- css/generated_mappings.rs
 use biome_css_syntax::CssSyntaxKind;
-use biome_css_syntax::CssSyntaxKind::*;
-use biome_rowan::AstNode;
@@
-pub fn kind_by_name(node_name: &str) -> Option<CssSyntaxKind> {
-    use CssSyntaxKind::*;
+pub fn kind_by_name(node_name: &str) -> Option<CssSyntaxKind> {
     use biome_css_syntax::*;
--- js/generated_mappings.rs
 use biome_js_syntax::JsSyntaxKind;
 use biome_js_syntax::JsSyntaxKind::*;
-use biome_rowan::AstNode;

This will silence compiler warnings from generated code.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
use biome_css_syntax::CssSyntaxKind;
use biome_css_syntax::CssSyntaxKind::*;
use biome_rowan::AstNode;
/// Returns the syntax kind for a legacy or native node name.
pub fn kind_by_name(node_name: &str) -> Option<CssSyntaxKind> {
use CssSyntaxKind::*;
use biome_css_syntax::*;
use biome_css_syntax::CssSyntaxKind;
/// Returns the syntax kind for a legacy or native node name.
pub fn kind_by_name(node_name: &str) -> Option<CssSyntaxKind> {
use biome_css_syntax::*;
🤖 Prompt for AI Agents
In
crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs
around lines 4 to 11, remove the unused top-level imports `use
biome_css_syntax::CssSyntaxKind::*;` and `use biome_rowan::AstNode;` and also
drop the inner `use CssSyntaxKind::*;`, keeping only `use
biome_css_syntax::CssSyntaxKind;` and `use biome_css_syntax::*;` inside the
function; likewise in
crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
remove the unused `use biome_rowan::AstNode;` while leaving the existing
wildcard `JsSyntaxKind` import intact so the generated files no longer trigger
unused-import warnings.

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 15, 2025

CodSpeed Performance Report

Merging #7510 will not alter performance

Comparing rriski:feat/add-biome-ast-nodes-to-gritql-engine (9c355f2) with main (c9f00eb)

Summary

✅ 133 untouched

@rriski rriski force-pushed the feat/add-biome-ast-nodes-to-gritql-engine branch 2 times, most recently from 62c887d to b18b6e7 Compare September 15, 2025 14:11
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs (1)

4-7: Remove unused imports in generated file (fix generator).

CssSyntaxKind::* and AstNode aren’t used; also the inner use CssSyntaxKind::*; is redundant. Prefer fixing the generator and re‑running.

 use biome_css_syntax::CssSyntaxKind;
-use biome_css_syntax::CssSyntaxKind::*;
-use biome_rowan::AstNode;
@@
 pub fn kind_by_name(node_name: &str) -> Option<CssSyntaxKind> {
-    use CssSyntaxKind::*;
     use biome_css_syntax::*;

Also applies to: 9-12

🧹 Nitpick comments (5)
.changeset/fruity-towns-repair.md (1)

5-5: Tighten wording to follow changeset style (past tense + brand spelling).

Use past tense for what changed, then present tense for current behaviour. Also prefer “Tree‑sitter” spelling.

-Implements #7339. GritQL patterns can now use native Biome AST nodes using their `PascalCase` names, in addition to the existing TreeSitter-compatible `snake_case` names.
+Added support for native Biome AST node names in GritQL patterns (#7339).
+Biome now supports using `PascalCase` native nodes alongside legacy Tree‑sitter‑compatible `snake_case` names.
crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs (1)

56-61: Optional: improve unknown-name fallback for diagnostics.

Today, non‑legacy kinds show “(unknown node)”. Consider adding a native-name fallback to aid tooling output (e.g. show JsIfStatement). Would require exposing a native reverse‑lookup in generated_mappings.

xtask/codegen/src/generate_grit_mappings.rs (2)

90-106: Stop emitting unused imports in generated files (gate wildcard; drop AstNode).

CSS has no legacy patterns, so use {syntax_kind_type}::*; and use biome_rowan::AstNode; are unused. Gate the wildcard import on has_legacy_patterns and remove AstNode.

-    let result = format!(
+    let kind_wildcard_import = if has_legacy_patterns {
+        format!("use {syntax_module}::{syntax_kind_type}::*;\n")
+    } else {
+        String::new()
+    };
+
+    let fn_kind_wildcard_use = if has_legacy_patterns {
+        format!("    use {syntax_kind_type}::*;\n")
+    } else {
+        String::new()
+    };
+
+    let result = format!(
         r#"
 {header}
-use biome_rowan::AstNode;
 use {syntax_module}::{syntax_kind_type};
-use {syntax_module}::{syntax_kind_type}::*;
+{kind_wildcard_import}
 
 {legacy_section}
 
 /// Returns the syntax kind for a legacy or native node name.
 pub fn kind_by_name(node_name: &str) -> Option<{syntax_kind_type}> {{
     use {syntax_module}::*;
-    use {syntax_kind_type}::*;
+{fn_kind_wildcard_use}\
     match node_name {{

8-21: Deterministic output: sort native patterns by name.

Stable ordering makes diffs friendlier across grammar churn.

-    let native_patterns = ast
-        .nodes
-        .iter()
+    let mut native_nodes: Vec<_> = ast
+        .nodes
+        .iter()
         // Filter out nodes that are lists or start with "Any"
         .filter(|node| !node.name.contains("List") && !node.name.starts_with("Any"))
-        .map(|node| {
+        .collect();
+    native_nodes.sort_unstable_by(|a, b| a.name.cmp(&b.name));
+    let native_patterns = native_nodes
+        .into_iter()
+        .map(|node| {
             format!(
                 r#"        "{}" => {}::KIND_SET.iter().next(),"#,
                 node.name, node.name
             )
         })
         .collect::<Vec<_>>()
         .join("\n");
crates/biome_grit_patterns/src/grit_target_language/css_target_language.rs (1)

33-38: Doc tweak for clarity.

Consider noting explicitly that CSS has no Tree‑sitter compatibility layer yet (unlike JS), so only native Biome names are supported here.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 73aeae8 and 62c887d.

⛔ Files ignored due to path filters (2)
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (13)
  • .changeset/fruity-towns-repair.md (1 hunks)
  • crates/biome_grit_patterns/src/grit_target_language/css_target_language.rs (3 hunks)
  • crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs (1 hunks)
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs (5 hunks)
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs (1 hunks)
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.css (1 hunks)
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.grit (1 hunks)
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.grit (1 hunks)
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.ts (1 hunks)
  • xtask/codegen/src/ast.rs (2 hunks)
  • xtask/codegen/src/generate_grit_mappings.rs (1 hunks)
  • xtask/codegen/src/js_kinds_src.rs (0 hunks)
  • xtask/codegen/src/lib.rs (2 hunks)
💤 Files with no reviewable changes (1)
  • xtask/codegen/src/js_kinds_src.rs
🚧 Files skipped from review as they are similar to previous changes (7)
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.grit
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.css
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.ts
  • xtask/codegen/src/ast.rs
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.grit
  • xtask/codegen/src/lib.rs
🧰 Additional context used
📓 Path-based instructions (3)
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_grit_patterns/src/grit_target_language/css_target_language.rs
  • crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format all Rust source files before committing (just f)

Files:

  • crates/biome_grit_patterns/src/grit_target_language/css_target_language.rs
  • crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs
  • xtask/codegen/src/generate_grit_mappings.rs
.changeset/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

.changeset/*.md: In changeset files, only use #### or ##### headers; avoid other header levels
Changeset descriptions should use past tense for what you did (e.g., "Added...")
Describe current Biome behavior in present tense within changesets (e.g., "Biome now supports...")
For bug fixes in changesets, start with a link to the issue (e.g., "Fixed #1234: ...")
When referencing rules or assists in changesets, include links to their documentation pages
Include a minimal code block in the changeset when applicable to demonstrate the change
End every sentence in the changeset description with a period

Files:

  • .changeset/fruity-towns-repair.md
🧠 Learnings (9)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-08-17T08:57:34.751Z
Learning: Applies to crates/biome_parser/xtask/codegen/src/*_kinds_src.rs : Add src/<language>_kinds_src.rs under xtask/codegen that returns a static KindSrc
📚 Learning: 2025-08-17T08:57:34.751Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-08-17T08:57:34.751Z
Learning: Applies to crates/biome_parser/xtask/codegen/src/*_kinds_src.rs : Add src/<language>_kinds_src.rs under xtask/codegen that returns a static KindSrc

Applied to files:

  • crates/biome_grit_patterns/src/grit_target_language/css_target_language.rs
  • crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs
  • xtask/codegen/src/generate_grit_mappings.rs
📚 Learning: 2025-08-11T11:48:27.774Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:48:27.774Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/src/comments.rs : Define HtmlComments alias and HtmlCommentStyle in comments.rs, and implement CommentStyle for the language

Applied to files:

  • crates/biome_grit_patterns/src/grit_target_language/css_target_language.rs
📚 Learning: 2025-09-07T17:35:00.517Z
Learnt from: CR
PR: biomejs/biome#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-09-07T17:35:00.517Z
Learning: Applies to .changeset/*.md : Describe current Biome behavior in present tense within changesets (e.g., "Biome now supports...")

Applied to files:

  • .changeset/fruity-towns-repair.md
📚 Learning: 2025-08-11T11:48:27.774Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:48:27.774Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/src/cst.rs : Define FormatHtmlSyntaxNode in cst.rs and implement FormatRule<HtmlSyntaxNode>, plus AsFormat and IntoFormat for HtmlSyntaxNode using the provided mapping code

Applied to files:

  • crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs
📚 Learning: 2025-09-10T08:05:22.867Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-09-10T08:05:22.867Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/{lint,assist}/**/*.rs : When banning globals (e.g., `noConsoleLog`), check the semantic model to avoid false positives from locally shadowed bindings

Applied to files:

  • crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs
📚 Learning: 2025-08-11T11:50:12.090Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:50:12.090Z
Learning: Applies to crates/biome_js_type_info/src/**/*.rs : Use TypeData::Unknown for unimplemented inference and TypeData::UnknownKeyword for the explicit TypeScript unknown keyword; treat them semantically the same but keep them distinct for measurement

Applied to files:

  • crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs
📚 Learning: 2025-08-11T11:50:12.090Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:50:12.090Z
Learning: Applies to crates/biome_js_type_info/src/**/*.rs : Represent links between types using TypeReference (not Arc) to avoid cross-module retention and recursive structures; store type data in linear vectors

Applied to files:

  • crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs
📚 Learning: 2025-08-17T08:57:34.751Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-08-17T08:57:34.751Z
Learning: From the repository root, start new language work in the xtask/codegen area and follow the listed steps to add grammar, kinds source, crates, language kind variant/prefix, and run codegen

Applied to files:

  • xtask/codegen/src/generate_grit_mappings.rs
🧬 Code graph analysis (1)
crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs (1)
crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs (2)
  • legacy_treesitter_name_for_kind (120-125)
  • legacy_treesitter_slots_for_kind (128-133)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (24)
  • GitHub Check: Parser conformance
  • GitHub Check: Bench (biome_package)
  • GitHub Check: Documentation
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Bench (biome_html_parser)
  • GitHub Check: autofix
  • GitHub Check: Bench (biome_json_analyze)
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: Bench (biome_html_formatter)
  • GitHub Check: Check Dependencies
  • GitHub Check: Bench (biome_graphql_parser)
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: Bench (biome_module_graph)
  • GitHub Check: Bench (biome_graphql_formatter)
  • GitHub Check: Bench (biome_css_formatter)
  • GitHub Check: Bench (biome_css_parser)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_json_formatter)
  • GitHub Check: Bench (biome_json_parser)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Test Node.js API
🔇 Additional comments (4)
crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs (1)

15-17: Nice extraction: mapping delegated cleanly to generated module.

Docs match behaviour (legacy first), and the calls are succinct. Looks good.

Also applies to: 41-49, 60-60, 72-73

xtask/codegen/src/generate_grit_mappings.rs (1)

154-255: Sanity check legacy slots.

Slot indices are hand‑coded; a mismatch will degrade matching. Please confirm these against the current JS grammar (tests cover common nodes, but a quick audit helps).

crates/biome_grit_patterns/src/grit_target_language/css_target_language.rs (1)

2-2: LGTM: module wiring.

Delegation to generated_mappings::kind_by_name is tidy and keeps the surface small.

Also applies to: 15-16

crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs (1)

13-187: LGTM: native mappings look comprehensive and idiomatic.

Using KIND_SET.iter().next() keeps this resilient across multi‑kind nodes.

@rriski rriski force-pushed the feat/add-biome-ast-nodes-to-gritql-engine branch from a92989d to 4559acc Compare September 15, 2025 15:55
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (7)
crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs (7)

4-6: Drop unused import to keep CI quiet

AstNode isn’t used here.

Apply this diff:

 use biome_js_syntax as lang;
-use biome_rowan::AstNode;
 use lang::JsSyntaxKind;

33-36: Fix legacy mapping for property_identifier

Tree‑sitter’s property_identifier corresponds to a member/property name, not a reference identifier. Mapping it to JS_REFERENCE_IDENTIFIER will misclassify obj.foo’s foo.

Apply this diff (and mirror in the match arm):

     LegacyTreeSitterPattern {
         name: "property_identifier",
-        kind: JsSyntaxKind::JS_REFERENCE_IDENTIFIER,
+        kind: JsSyntaxKind::JS_LITERAL_MEMBER_NAME,
         slots: &[],
     },
-        "property_identifier" => Some(JsSyntaxKind::JS_REFERENCE_IDENTIFIER),
+        "property_identifier" => Some(JsSyntaxKind::JS_LITERAL_MEMBER_NAME),

Also applies to: 142-143


42-46: Add missing legacy subscript_expression

Tree‑sitter JavaScript exposes bracket access as subscript_expression. Without it, legacy patterns can’t match obj[expr].

Apply this diff to the legacy table and dispatcher:

     LegacyTreeSitterPattern {
         name: "member_expression",
         kind: JsSyntaxKind::JS_STATIC_MEMBER_EXPRESSION,
         slots: &[("object", 0), ("property", 2)],
     },
+    LegacyTreeSitterPattern {
+        name: "subscript_expression",
+        kind: JsSyntaxKind::JS_COMPUTED_MEMBER_EXPRESSION,
+        slots: &[("object", 0), ("index", 2)],
+    },
         "member_expression" => Some(JsSyntaxKind::JS_STATIC_MEMBER_EXPRESSION),
+        "subscript_expression" => Some(JsSyntaxKind::JS_COMPUTED_MEMBER_EXPRESSION),

Also applies to: 144-146


37-116: Double‑check legacy slot indices

Hard‑coding slot indices is brittle across parser regenerations. A mismatch will produce subtly wrong bindings in GritQL.

  • Please verify representative nodes (call_expression, member_expression, conditional_expression, loops, functions) against current AstNode field order.
  • Consider emitting slots programmatically from the generator (introspecting the rowan model) rather than freezing numeric literals here.

274-275: Potential ambiguity: unions resolved via KIND_SET.iter().next()

For union types like JsName, picking the first kind is arbitrary and may not match user expectations.

If feasible in codegen, select a canonical “primary” kind per union (or return a small set) rather than the first iterator element. At minimum, document the chosen canonical kind.


9-13: Narrow visibility to crate scope

These are internal plumbing; no need to expose outside the crate.

Apply these diffs:

-pub struct LegacyTreeSitterPattern {
+pub(crate) struct LegacyTreeSitterPattern {
-pub const LEGACY_TREESITTER_COMPATIBILITY_PATTERNS: &[LegacyTreeSitterPattern] = &[
+pub(crate) const LEGACY_TREESITTER_COMPATIBILITY_PATTERNS: &[LegacyTreeSitterPattern] = &[
-pub fn legacy_treesitter_name_for_kind(kind: JsSyntaxKind) -> Option<&'static str> {
+pub(crate) fn legacy_treesitter_name_for_kind(kind: JsSyntaxKind) -> Option<&'static str> {
-pub fn legacy_treesitter_slots_for_kind(kind: JsSyntaxKind) -> &'static [(&'static str, u32)] {
+pub(crate) fn legacy_treesitter_slots_for_kind(kind: JsSyntaxKind) -> &'static [(&'static str, u32)] {
-pub fn kind_by_name(node_name: &str) -> Option<JsSyntaxKind> {
+pub(crate) fn kind_by_name(node_name: &str) -> Option<JsSyntaxKind> {

Also applies to: 16-17, 119-141


119-126: Canonical legacy name lookup returns first match

Multiple legacy names map to the same kind (e.g., identifier and property_identifier once fixed). legacy_treesitter_name_for_kind will return the first entry only.

If round‑tripping matters, either:

  • canonicalise the table order intentionally and document it, or
  • return all aliases.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a92989d and 4559acc.

⛔ Files ignored due to path filters (2)
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (13)
  • .changeset/fruity-towns-repair.md (1 hunks)
  • crates/biome_grit_patterns/src/grit_target_language/css_target_language.rs (3 hunks)
  • crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs (1 hunks)
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs (5 hunks)
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs (1 hunks)
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.css (1 hunks)
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.grit (1 hunks)
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.grit (1 hunks)
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.ts (1 hunks)
  • xtask/codegen/src/ast.rs (2 hunks)
  • xtask/codegen/src/generate_grit_mappings.rs (1 hunks)
  • xtask/codegen/src/js_kinds_src.rs (0 hunks)
  • xtask/codegen/src/lib.rs (2 hunks)
💤 Files with no reviewable changes (1)
  • xtask/codegen/src/js_kinds_src.rs
✅ Files skipped from review due to trivial changes (1)
  • .changeset/fruity-towns-repair.md
🚧 Files skipped from review as they are similar to previous changes (10)
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.css
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.grit
  • xtask/codegen/src/ast.rs
  • xtask/codegen/src/lib.rs
  • crates/biome_grit_patterns/src/grit_target_language/css_target_language.rs
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.grit
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.ts
  • crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs
  • xtask/codegen/src/generate_grit_mappings.rs
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs
🧰 Additional context used
📓 Path-based instructions (2)
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format all Rust source files before committing (just f)

Files:

  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-08-17T08:57:34.751Z
Learning: Applies to crates/biome_parser/xtask/codegen/src/*_kinds_src.rs : Add src/<language>_kinds_src.rs under xtask/codegen that returns a static KindSrc
📚 Learning: 2025-08-17T08:57:34.751Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-08-17T08:57:34.751Z
Learning: Applies to crates/biome_parser/xtask/codegen/src/*_kinds_src.rs : Add src/<language>_kinds_src.rs under xtask/codegen that returns a static KindSrc

Applied to files:

  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
🧬 Code graph analysis (1)
crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs (1)
crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs (1)
  • kind_by_name (47-49)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (25)
  • GitHub Check: Bench (biome_css_parser)
  • GitHub Check: Bench (biome_graphql_parser)
  • GitHub Check: Bench (biome_json_analyze)
  • GitHub Check: Bench (biome_json_parser)
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: Bench (biome_module_graph)
  • GitHub Check: Bench (biome_html_parser)
  • GitHub Check: Bench (biome_package)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_html_formatter)
  • GitHub Check: Bench (biome_css_formatter)
  • GitHub Check: Bench (biome_json_formatter)
  • GitHub Check: Bench (biome_graphql_formatter)
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Test Node.js API
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Documentation
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: autofix
  • GitHub Check: Parser conformance
🔇 Additional comments (1)
crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs (1)

1-3: Nice addition: generated bridge looks solid

Overall approach and API line‑up with js_target_language.rs looks good. This should unblock PascalCase native node matching without breaking legacy patterns.

Please confirm the new specs in crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.grit cover a mix of legacy and native nodes (incl. negative cases).

Copy link
Contributor

@arendjr arendjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very well done, thank you!

@arendjr
Copy link
Contributor

arendjr commented Sep 15, 2025

There is still a test failure though.

@rriski rriski force-pushed the feat/add-biome-ast-nodes-to-gritql-engine branch from 4559acc to 2c65ef2 Compare September 15, 2025 17:59
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs (1)

209-586: Native pattern arms return Option<&JsSyntaxKind>; needs copying.

The arms like lang::JsXxx::KIND_SET.iter().next() return Option<&JsSyntaxKind> but kind_by_name returns Option<JsSyntaxKind>. Fix in the generator (preferred) and re‑generate; locally that becomes .iter().copied().next().

Example fix after regenerating:

- "JsAccessorModifier" => lang::JsAccessorModifier::KIND_SET.iter().next(),
+ "JsAccessorModifier" => lang::JsAccessorModifier::KIND_SET.iter().copied().next(),

Verification script:

#!/bin/bash
# Fail if any generated mapping still uses .iter().next() without .copied()
rg -nP '\bKIND_SET\.iter\(\)(?!\.copied\(\))\.next\(\)' crates/**/generated_mappings.rs

# Expect: no matches
🧹 Nitpick comments (4)
xtask/codegen/src/generate_grit_mappings.rs (2)

103-106: Drop unused import from the generated file.

use biome_rowan::AstNode; isn’t used in the emitted module and can trigger warnings/failing CI with -Dwarnings. Remove it from the template.

 use {syntax_module} as lang;
-use biome_rowan::AstNode;
 use lang::{syntax_kind_type};

141-154: Prefer a typed error over unimplemented! for unsupported languages.

Panicking in codegen makes failures noisier. Consider returning a Result<Self> from LanguageConfig::new and bubbling an error up to the caller.

crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs (2)

5-5: Unused import.

AstNode isn’t referenced; please remove via generator and re‑emit.


8-16: Nit: spelling/branding.

Use “Tree‑sitter” (hyphen, lower‑s) in docs for consistency.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4559acc and 2c65ef2.

⛔ Files ignored due to path filters (2)
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (13)
  • .changeset/fruity-towns-repair.md (1 hunks)
  • crates/biome_grit_patterns/src/grit_target_language/css_target_language.rs (3 hunks)
  • crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs (1 hunks)
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs (5 hunks)
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs (1 hunks)
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.css (1 hunks)
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.grit (1 hunks)
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.grit (1 hunks)
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.ts (1 hunks)
  • xtask/codegen/src/ast.rs (2 hunks)
  • xtask/codegen/src/generate_grit_mappings.rs (1 hunks)
  • xtask/codegen/src/js_kinds_src.rs (0 hunks)
  • xtask/codegen/src/lib.rs (2 hunks)
💤 Files with no reviewable changes (1)
  • xtask/codegen/src/js_kinds_src.rs
✅ Files skipped from review due to trivial changes (1)
  • .changeset/fruity-towns-repair.md
🚧 Files skipped from review as they are similar to previous changes (9)
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.css
  • crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs
  • crates/biome_grit_patterns/tests/specs/css/biomeCompatibility.grit
  • xtask/codegen/src/lib.rs
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.ts
  • xtask/codegen/src/ast.rs
  • crates/biome_grit_patterns/src/grit_target_language/css_target_language.rs
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.grit
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format all Rust source files before committing (just f)

Files:

  • xtask/codegen/src/generate_grit_mappings.rs
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-08-17T08:57:34.751Z
Learning: Applies to crates/biome_parser/xtask/codegen/src/*_kinds_src.rs : Add src/<language>_kinds_src.rs under xtask/codegen that returns a static KindSrc
📚 Learning: 2025-08-17T08:57:34.751Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-08-17T08:57:34.751Z
Learning: Applies to crates/biome_parser/xtask/codegen/src/*_kinds_src.rs : Add src/<language>_kinds_src.rs under xtask/codegen that returns a static KindSrc

Applied to files:

  • xtask/codegen/src/generate_grit_mappings.rs
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
📚 Learning: 2025-08-17T08:57:34.751Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-08-17T08:57:34.751Z
Learning: From the repository root, start new language work in the xtask/codegen area and follow the listed steps to add grammar, kinds source, crates, language kind variant/prefix, and run codegen

Applied to files:

  • xtask/codegen/src/generate_grit_mappings.rs
📚 Learning: 2025-08-17T08:57:34.751Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-08-17T08:57:34.751Z
Learning: Applies to crates/biome_parser/crates/biome_*_{syntax,factory}/src/generated/** : Each new language crate must contain a src/generated/ directory for codegen outputs

Applied to files:

  • xtask/codegen/src/generate_grit_mappings.rs
🧬 Code graph analysis (1)
crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs (1)
crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs (1)
  • kind_by_name (47-49)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (25)
  • GitHub Check: Bench (biome_package)
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: Bench (biome_html_formatter)
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: Bench (biome_json_parser)
  • GitHub Check: Bench (biome_html_parser)
  • GitHub Check: Bench (biome_module_graph)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_graphql_formatter)
  • GitHub Check: Bench (biome_json_analyze)
  • GitHub Check: Bench (biome_css_formatter)
  • GitHub Check: Bench (biome_graphql_parser)
  • GitHub Check: Bench (biome_css_parser)
  • GitHub Check: Bench (biome_json_formatter)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Documentation
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Test Node.js API
  • GitHub Check: autofix
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Parser conformance

Comment on lines +14 to +18
format!(
r#" "{}" => lang::{}::KIND_SET.iter().next(),"#,
node.name, node.name,
)
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix return type: native arms currently return Option<&SyntaxKind>.

KIND_SET.iter().next() yields Option<&T>, but kind_by_name expects Option<T>. Add .copied() (or .cloned()) so the generated code compiles.

-                r#"        "{}" => lang::{}::KIND_SET.iter().next(),"#,
+                r#"        "{}" => lang::{}::KIND_SET.iter().copied().next(),"#,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
format!(
r#" "{}" => lang::{}::KIND_SET.iter().next(),"#,
node.name, node.name,
)
})
format!(
r#" "{}" => lang::{}::KIND_SET.iter().copied().next(),"#,
node.name, node.name,
)
})
🤖 Prompt for AI Agents
In xtask/codegen/src/generate_grit_mappings.rs around lines 14 to 18, the
generated arms return Option<&SyntaxKind> because KIND_SET.iter().next() yields
Option<&T>, but the consumer expects Option<T>; update the formatter to call
.copied() (or .cloned()) on the iterator result (e.g.,
KIND_SET.iter().next().copied()) so the generated code returns
Option<SyntaxKind> and compiles.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
xtask/codegen/src/generate_grit_mappings.rs (1)

15-18: Fix return type: native arms must yield Option (not Option<&SyntaxKind>).

Add .copied() before .next() in the generated match arms. This unblocks compilation and aligns with the function signature.

-                r#"        "{}" => lang::{}::KIND_SET.iter().next(),"#,
+                r#"        "{}" => lang::{}::KIND_SET.iter().copied().next(),"#,
🧹 Nitpick comments (5)
xtask/codegen/src/generate_grit_mappings.rs (3)

102-109: Remove unused import from generated header.

AstNode isn’t used; the generated file fails unused_imports.

- use biome_rowan::AstNode;
  use {syntax_module} as lang;
  use lang::{syntax_kind_type};

12-13: Name-based filtering is brittle.

Filtering out nodes by contains("List") / starts_with("Any") can drift. Prefer metadata (e.g. a flag on AstSrc nodes) to identify abstract/list kinds.

Would you like a quick follow-up to add a boolean on AstSrc and use that instead?


141-154: Avoid unimplemented! in codegen path.

Return a structured error (bubble up via Result) instead of panicking; improves DX when wiring new languages.

-            _ => unimplemented!("Grit mappings are not supported for {:?}", language_kind),
+            _ => {
+                // Prefer surfacing a proper error to callers
+                panic!("Grit mappings are not supported for {:?}", language_kind)
+            }

Or better: change LanguageConfig::new to return Result<Self> and ? it in generate_grit_mappings.

crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs (2)

5-6: Drop unused import.

use biome_rowan::AstNode; is unused here.

-use biome_rowan::AstNode;
 use lang::JsSyntaxKind;

164-178: Linear scans in legacy helpers are fine; consider map if hot.

If legacy_treesitter_*_for_kind end up on a hot path, switch to a precomputed map keyed by JsSyntaxKind.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2c65ef2 and 9c355f2.

⛔ Files ignored due to path filters (1)
  • crates/biome_grit_patterns/tests/specs/ts/treeSitterCompatibility.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (2)
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs (1 hunks)
  • xtask/codegen/src/generate_grit_mappings.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format all Rust source files before committing (just f)

Files:

  • xtask/codegen/src/generate_grit_mappings.rs
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-08-17T08:57:34.751Z
Learning: Applies to crates/biome_parser/xtask/codegen/src/*_kinds_src.rs : Add src/<language>_kinds_src.rs under xtask/codegen that returns a static KindSrc
📚 Learning: 2025-08-17T08:57:34.751Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-08-17T08:57:34.751Z
Learning: Applies to crates/biome_parser/xtask/codegen/src/*_kinds_src.rs : Add src/<language>_kinds_src.rs under xtask/codegen that returns a static KindSrc

Applied to files:

  • xtask/codegen/src/generate_grit_mappings.rs
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
📚 Learning: 2025-08-17T08:57:34.751Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-08-17T08:57:34.751Z
Learning: From the repository root, start new language work in the xtask/codegen area and follow the listed steps to add grammar, kinds source, crates, language kind variant/prefix, and run codegen

Applied to files:

  • xtask/codegen/src/generate_grit_mappings.rs
🧬 Code graph analysis (1)
crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs (1)
crates/biome_grit_patterns/src/grit_target_language/js_target_language.rs (1)
  • kind_by_name (47-49)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (24)
  • GitHub Check: Parser conformance
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: Bench (biome_package)
  • GitHub Check: Bench (biome_module_graph)
  • GitHub Check: Bench (biome_css_parser)
  • GitHub Check: Bench (biome_graphql_parser)
  • GitHub Check: Test Node.js API
  • GitHub Check: Bench (biome_html_parser)
  • GitHub Check: Bench (biome_json_parser)
  • GitHub Check: Bench (biome_html_formatter)
  • GitHub Check: Bench (biome_graphql_formatter)
  • GitHub Check: autofix
  • GitHub Check: Bench (biome_json_analyze)
  • GitHub Check: Bench (biome_json_formatter)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_css_formatter)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Check Dependencies
🔇 Additional comments (1)
crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs (1)

214-432: Sanity-check emitted native type names exist.

A few spellings look easy to fat‑finger (e.g. JsExpressionSnipped). I couldn't complete the sandbox verification — please confirm every lang::::KIND_SET referenced in crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs exists and is exported from crates/biome_js_syntax.

Comment on lines +181 to +594
pub fn kind_by_name(node_name: &str) -> Option<JsSyntaxKind> {
match node_name {
// Legacy TreeSitter patterns
"identifier" => Some(JsSyntaxKind::JS_REFERENCE_IDENTIFIER),
"string" => Some(JsSyntaxKind::JS_STRING_LITERAL_EXPRESSION),
"number" => Some(JsSyntaxKind::JS_NUMBER_LITERAL_EXPRESSION),
"property_identifier" => Some(JsSyntaxKind::JS_LITERAL_MEMBER_NAME),
"call_expression" => Some(JsSyntaxKind::JS_CALL_EXPRESSION),
"member_expression" => Some(JsSyntaxKind::JS_STATIC_MEMBER_EXPRESSION),
"subscript_expression" => Some(JsSyntaxKind::JS_COMPUTED_MEMBER_EXPRESSION),
"binary_expression" => Some(JsSyntaxKind::JS_BINARY_EXPRESSION),
"assignment_expression" => Some(JsSyntaxKind::JS_ASSIGNMENT_EXPRESSION),
"conditional_expression" => Some(JsSyntaxKind::JS_CONDITIONAL_EXPRESSION),
"arrow_function" => Some(JsSyntaxKind::JS_ARROW_FUNCTION_EXPRESSION),
"object" => Some(JsSyntaxKind::JS_OBJECT_EXPRESSION),
"array" => Some(JsSyntaxKind::JS_ARRAY_EXPRESSION),
"pair" => Some(JsSyntaxKind::JS_PROPERTY_OBJECT_MEMBER),
"if_statement" => Some(JsSyntaxKind::JS_IF_STATEMENT),
"for_statement" => Some(JsSyntaxKind::JS_FOR_STATEMENT),
"while_statement" => Some(JsSyntaxKind::JS_WHILE_STATEMENT),
"function_declaration" => Some(JsSyntaxKind::JS_FUNCTION_DECLARATION),
"return_statement" => Some(JsSyntaxKind::JS_RETURN_STATEMENT),
"variable_declaration" => Some(JsSyntaxKind::JS_VARIABLE_DECLARATION),
"expression_statement" => Some(JsSyntaxKind::JS_EXPRESSION_STATEMENT),
"jsx_expression" => Some(JsSyntaxKind::JSX_EXPRESSION_CHILD),
"jsx_attribute" => Some(JsSyntaxKind::JSX_ATTRIBUTE),
"jsx_element" => Some(JsSyntaxKind::JSX_ELEMENT),
"jsx_self_closing_element" => Some(JsSyntaxKind::JSX_SELF_CLOSING_ELEMENT),
"jsx_opening_element" => Some(JsSyntaxKind::JSX_OPENING_ELEMENT),
"jsx_closing_element" => Some(JsSyntaxKind::JSX_CLOSING_ELEMENT),
"jsx_text" => Some(JsSyntaxKind::JSX_TEXT),
"jsx_namespace_name" => Some(JsSyntaxKind::JSX_NAMESPACE_NAME),

// Native Biome AST patterns
"JsAccessorModifier" => lang::JsAccessorModifier::KIND_SET.iter().next(),
"JsArrayAssignmentPattern" => lang::JsArrayAssignmentPattern::KIND_SET.iter().next(),
"JsArrayAssignmentPatternElement" => lang::JsArrayAssignmentPatternElement::KIND_SET
.iter()
.next(),
"JsArrayAssignmentPatternRestElement" => {
lang::JsArrayAssignmentPatternRestElement::KIND_SET
.iter()
.next()
}
"JsArrayBindingPattern" => lang::JsArrayBindingPattern::KIND_SET.iter().next(),
"JsArrayBindingPatternElement" => {
lang::JsArrayBindingPatternElement::KIND_SET.iter().next()
}
"JsArrayBindingPatternRestElement" => lang::JsArrayBindingPatternRestElement::KIND_SET
.iter()
.next(),
"JsArrayExpression" => lang::JsArrayExpression::KIND_SET.iter().next(),
"JsArrayHole" => lang::JsArrayHole::KIND_SET.iter().next(),
"JsArrowFunctionExpression" => lang::JsArrowFunctionExpression::KIND_SET.iter().next(),
"JsAssignmentExpression" => lang::JsAssignmentExpression::KIND_SET.iter().next(),
"JsAwaitExpression" => lang::JsAwaitExpression::KIND_SET.iter().next(),
"JsBigintLiteralExpression" => lang::JsBigintLiteralExpression::KIND_SET.iter().next(),
"JsBinaryExpression" => lang::JsBinaryExpression::KIND_SET.iter().next(),
"JsBlockStatement" => lang::JsBlockStatement::KIND_SET.iter().next(),
"JsBooleanLiteralExpression" => lang::JsBooleanLiteralExpression::KIND_SET.iter().next(),
"JsBreakStatement" => lang::JsBreakStatement::KIND_SET.iter().next(),
"JsCallArguments" => lang::JsCallArguments::KIND_SET.iter().next(),
"JsCallExpression" => lang::JsCallExpression::KIND_SET.iter().next(),
"JsCaseClause" => lang::JsCaseClause::KIND_SET.iter().next(),
"JsCatchClause" => lang::JsCatchClause::KIND_SET.iter().next(),
"JsCatchDeclaration" => lang::JsCatchDeclaration::KIND_SET.iter().next(),
"JsClassDeclaration" => lang::JsClassDeclaration::KIND_SET.iter().next(),
"JsClassExportDefaultDeclaration" => lang::JsClassExportDefaultDeclaration::KIND_SET
.iter()
.next(),
"JsClassExpression" => lang::JsClassExpression::KIND_SET.iter().next(),
"JsComputedMemberAssignment" => lang::JsComputedMemberAssignment::KIND_SET.iter().next(),
"JsComputedMemberExpression" => lang::JsComputedMemberExpression::KIND_SET.iter().next(),
"JsComputedMemberName" => lang::JsComputedMemberName::KIND_SET.iter().next(),
"JsConditionalExpression" => lang::JsConditionalExpression::KIND_SET.iter().next(),
"JsConstructorClassMember" => lang::JsConstructorClassMember::KIND_SET.iter().next(),
"JsConstructorParameters" => lang::JsConstructorParameters::KIND_SET.iter().next(),
"JsContinueStatement" => lang::JsContinueStatement::KIND_SET.iter().next(),
"JsDebuggerStatement" => lang::JsDebuggerStatement::KIND_SET.iter().next(),
"JsDecorator" => lang::JsDecorator::KIND_SET.iter().next(),
"JsDefaultClause" => lang::JsDefaultClause::KIND_SET.iter().next(),
"JsDefaultImportSpecifier" => lang::JsDefaultImportSpecifier::KIND_SET.iter().next(),
"JsDirective" => lang::JsDirective::KIND_SET.iter().next(),
"JsDoWhileStatement" => lang::JsDoWhileStatement::KIND_SET.iter().next(),
"JsElseClause" => lang::JsElseClause::KIND_SET.iter().next(),
"JsEmptyClassMember" => lang::JsEmptyClassMember::KIND_SET.iter().next(),
"JsEmptyStatement" => lang::JsEmptyStatement::KIND_SET.iter().next(),
"JsExport" => lang::JsExport::KIND_SET.iter().next(),
"JsExportAsClause" => lang::JsExportAsClause::KIND_SET.iter().next(),
"JsExportDefaultDeclarationClause" => lang::JsExportDefaultDeclarationClause::KIND_SET
.iter()
.next(),
"JsExportDefaultExpressionClause" => lang::JsExportDefaultExpressionClause::KIND_SET
.iter()
.next(),
"JsExportFromClause" => lang::JsExportFromClause::KIND_SET.iter().next(),
"JsExportNamedClause" => lang::JsExportNamedClause::KIND_SET.iter().next(),
"JsExportNamedFromClause" => lang::JsExportNamedFromClause::KIND_SET.iter().next(),
"JsExportNamedFromSpecifier" => lang::JsExportNamedFromSpecifier::KIND_SET.iter().next(),
"JsExportNamedShorthandSpecifier" => lang::JsExportNamedShorthandSpecifier::KIND_SET
.iter()
.next(),
"JsExportNamedSpecifier" => lang::JsExportNamedSpecifier::KIND_SET.iter().next(),
"JsExpressionSnipped" => lang::JsExpressionSnipped::KIND_SET.iter().next(),
"JsExpressionStatement" => lang::JsExpressionStatement::KIND_SET.iter().next(),
"JsExtendsClause" => lang::JsExtendsClause::KIND_SET.iter().next(),
"JsFinallyClause" => lang::JsFinallyClause::KIND_SET.iter().next(),
"JsForInStatement" => lang::JsForInStatement::KIND_SET.iter().next(),
"JsForOfStatement" => lang::JsForOfStatement::KIND_SET.iter().next(),
"JsForStatement" => lang::JsForStatement::KIND_SET.iter().next(),
"JsForVariableDeclaration" => lang::JsForVariableDeclaration::KIND_SET.iter().next(),
"JsFormalParameter" => lang::JsFormalParameter::KIND_SET.iter().next(),
"JsFunctionBody" => lang::JsFunctionBody::KIND_SET.iter().next(),
"JsFunctionDeclaration" => lang::JsFunctionDeclaration::KIND_SET.iter().next(),
"JsFunctionExportDefaultDeclaration" => lang::JsFunctionExportDefaultDeclaration::KIND_SET
.iter()
.next(),
"JsFunctionExpression" => lang::JsFunctionExpression::KIND_SET.iter().next(),
"JsGetterClassMember" => lang::JsGetterClassMember::KIND_SET.iter().next(),
"JsGetterObjectMember" => lang::JsGetterObjectMember::KIND_SET.iter().next(),
"JsIdentifierAssignment" => lang::JsIdentifierAssignment::KIND_SET.iter().next(),
"JsIdentifierBinding" => lang::JsIdentifierBinding::KIND_SET.iter().next(),
"JsIdentifierExpression" => lang::JsIdentifierExpression::KIND_SET.iter().next(),
"JsIfStatement" => lang::JsIfStatement::KIND_SET.iter().next(),
"JsImport" => lang::JsImport::KIND_SET.iter().next(),
"JsImportAssertion" => lang::JsImportAssertion::KIND_SET.iter().next(),
"JsImportAssertionEntry" => lang::JsImportAssertionEntry::KIND_SET.iter().next(),
"JsImportBareClause" => lang::JsImportBareClause::KIND_SET.iter().next(),
"JsImportCallExpression" => lang::JsImportCallExpression::KIND_SET.iter().next(),
"JsImportCombinedClause" => lang::JsImportCombinedClause::KIND_SET.iter().next(),
"JsImportDefaultClause" => lang::JsImportDefaultClause::KIND_SET.iter().next(),
"JsImportMetaExpression" => lang::JsImportMetaExpression::KIND_SET.iter().next(),
"JsImportNamedClause" => lang::JsImportNamedClause::KIND_SET.iter().next(),
"JsImportNamespaceClause" => lang::JsImportNamespaceClause::KIND_SET.iter().next(),
"JsInExpression" => lang::JsInExpression::KIND_SET.iter().next(),
"JsInitializerClause" => lang::JsInitializerClause::KIND_SET.iter().next(),
"JsInstanceofExpression" => lang::JsInstanceofExpression::KIND_SET.iter().next(),
"JsLabel" => lang::JsLabel::KIND_SET.iter().next(),
"JsLabeledStatement" => lang::JsLabeledStatement::KIND_SET.iter().next(),
"JsLiteralExportName" => lang::JsLiteralExportName::KIND_SET.iter().next(),
"JsLiteralMemberName" => lang::JsLiteralMemberName::KIND_SET.iter().next(),
"JsLogicalExpression" => lang::JsLogicalExpression::KIND_SET.iter().next(),
"JsMetavariable" => lang::JsMetavariable::KIND_SET.iter().next(),
"JsMethodClassMember" => lang::JsMethodClassMember::KIND_SET.iter().next(),
"JsMethodObjectMember" => lang::JsMethodObjectMember::KIND_SET.iter().next(),
"JsModule" => lang::JsModule::KIND_SET.iter().next(),
"JsModuleSource" => lang::JsModuleSource::KIND_SET.iter().next(),
"JsName" => lang::JsName::KIND_SET.iter().next(),
"JsNamedImportSpecifier" => lang::JsNamedImportSpecifier::KIND_SET.iter().next(),
"JsNamedImportSpecifiers" => lang::JsNamedImportSpecifiers::KIND_SET.iter().next(),
"JsNamespaceImportSpecifier" => lang::JsNamespaceImportSpecifier::KIND_SET.iter().next(),
"JsNewExpression" => lang::JsNewExpression::KIND_SET.iter().next(),
"JsNewTargetExpression" => lang::JsNewTargetExpression::KIND_SET.iter().next(),
"JsNullLiteralExpression" => lang::JsNullLiteralExpression::KIND_SET.iter().next(),
"JsNumberLiteralExpression" => lang::JsNumberLiteralExpression::KIND_SET.iter().next(),
"JsObjectAssignmentPattern" => lang::JsObjectAssignmentPattern::KIND_SET.iter().next(),
"JsObjectAssignmentPatternProperty" => lang::JsObjectAssignmentPatternProperty::KIND_SET
.iter()
.next(),
"JsObjectAssignmentPatternRest" => {
lang::JsObjectAssignmentPatternRest::KIND_SET.iter().next()
}
"JsObjectAssignmentPatternShorthandProperty" => {
lang::JsObjectAssignmentPatternShorthandProperty::KIND_SET
.iter()
.next()
}
"JsObjectBindingPattern" => lang::JsObjectBindingPattern::KIND_SET.iter().next(),
"JsObjectBindingPatternProperty" => {
lang::JsObjectBindingPatternProperty::KIND_SET.iter().next()
}
"JsObjectBindingPatternRest" => lang::JsObjectBindingPatternRest::KIND_SET.iter().next(),
"JsObjectBindingPatternShorthandProperty" => {
lang::JsObjectBindingPatternShorthandProperty::KIND_SET
.iter()
.next()
}
"JsObjectExpression" => lang::JsObjectExpression::KIND_SET.iter().next(),
"JsParameters" => lang::JsParameters::KIND_SET.iter().next(),
"JsParenthesizedAssignment" => lang::JsParenthesizedAssignment::KIND_SET.iter().next(),
"JsParenthesizedExpression" => lang::JsParenthesizedExpression::KIND_SET.iter().next(),
"JsPostUpdateExpression" => lang::JsPostUpdateExpression::KIND_SET.iter().next(),
"JsPreUpdateExpression" => lang::JsPreUpdateExpression::KIND_SET.iter().next(),
"JsPrivateClassMemberName" => lang::JsPrivateClassMemberName::KIND_SET.iter().next(),
"JsPrivateName" => lang::JsPrivateName::KIND_SET.iter().next(),
"JsPropertyClassMember" => lang::JsPropertyClassMember::KIND_SET.iter().next(),
"JsPropertyObjectMember" => lang::JsPropertyObjectMember::KIND_SET.iter().next(),
"JsReferenceIdentifier" => lang::JsReferenceIdentifier::KIND_SET.iter().next(),
"JsRegexLiteralExpression" => lang::JsRegexLiteralExpression::KIND_SET.iter().next(),
"JsRestParameter" => lang::JsRestParameter::KIND_SET.iter().next(),
"JsReturnStatement" => lang::JsReturnStatement::KIND_SET.iter().next(),
"JsScript" => lang::JsScript::KIND_SET.iter().next(),
"JsSequenceExpression" => lang::JsSequenceExpression::KIND_SET.iter().next(),
"JsSetterClassMember" => lang::JsSetterClassMember::KIND_SET.iter().next(),
"JsSetterObjectMember" => lang::JsSetterObjectMember::KIND_SET.iter().next(),
"JsShorthandNamedImportSpecifier" => lang::JsShorthandNamedImportSpecifier::KIND_SET
.iter()
.next(),
"JsShorthandPropertyObjectMember" => lang::JsShorthandPropertyObjectMember::KIND_SET
.iter()
.next(),
"JsSpread" => lang::JsSpread::KIND_SET.iter().next(),
"JsStaticInitializationBlockClassMember" => {
lang::JsStaticInitializationBlockClassMember::KIND_SET
.iter()
.next()
}
"JsStaticMemberAssignment" => lang::JsStaticMemberAssignment::KIND_SET.iter().next(),
"JsStaticMemberExpression" => lang::JsStaticMemberExpression::KIND_SET.iter().next(),
"JsStaticModifier" => lang::JsStaticModifier::KIND_SET.iter().next(),
"JsStringLiteralExpression" => lang::JsStringLiteralExpression::KIND_SET.iter().next(),
"JsSuperExpression" => lang::JsSuperExpression::KIND_SET.iter().next(),
"JsSwitchStatement" => lang::JsSwitchStatement::KIND_SET.iter().next(),
"JsTemplateChunkElement" => lang::JsTemplateChunkElement::KIND_SET.iter().next(),
"JsTemplateElement" => lang::JsTemplateElement::KIND_SET.iter().next(),
"JsTemplateExpression" => lang::JsTemplateExpression::KIND_SET.iter().next(),
"JsThisExpression" => lang::JsThisExpression::KIND_SET.iter().next(),
"JsThrowStatement" => lang::JsThrowStatement::KIND_SET.iter().next(),
"JsTryFinallyStatement" => lang::JsTryFinallyStatement::KIND_SET.iter().next(),
"JsTryStatement" => lang::JsTryStatement::KIND_SET.iter().next(),
"JsUnaryExpression" => lang::JsUnaryExpression::KIND_SET.iter().next(),
"JsVariableDeclaration" => lang::JsVariableDeclaration::KIND_SET.iter().next(),
"JsVariableDeclarationClause" => lang::JsVariableDeclarationClause::KIND_SET.iter().next(),
"JsVariableDeclarator" => lang::JsVariableDeclarator::KIND_SET.iter().next(),
"JsVariableStatement" => lang::JsVariableStatement::KIND_SET.iter().next(),
"JsWhileStatement" => lang::JsWhileStatement::KIND_SET.iter().next(),
"JsWithStatement" => lang::JsWithStatement::KIND_SET.iter().next(),
"JsYieldArgument" => lang::JsYieldArgument::KIND_SET.iter().next(),
"JsYieldExpression" => lang::JsYieldExpression::KIND_SET.iter().next(),
"JsxAttribute" => lang::JsxAttribute::KIND_SET.iter().next(),
"JsxAttributeInitializerClause" => {
lang::JsxAttributeInitializerClause::KIND_SET.iter().next()
}
"JsxClosingElement" => lang::JsxClosingElement::KIND_SET.iter().next(),
"JsxClosingFragment" => lang::JsxClosingFragment::KIND_SET.iter().next(),
"JsxElement" => lang::JsxElement::KIND_SET.iter().next(),
"JsxExpressionAttributeValue" => lang::JsxExpressionAttributeValue::KIND_SET.iter().next(),
"JsxExpressionChild" => lang::JsxExpressionChild::KIND_SET.iter().next(),
"JsxFragment" => lang::JsxFragment::KIND_SET.iter().next(),
"JsxMemberName" => lang::JsxMemberName::KIND_SET.iter().next(),
"JsxName" => lang::JsxName::KIND_SET.iter().next(),
"JsxNamespaceName" => lang::JsxNamespaceName::KIND_SET.iter().next(),
"JsxOpeningElement" => lang::JsxOpeningElement::KIND_SET.iter().next(),
"JsxOpeningFragment" => lang::JsxOpeningFragment::KIND_SET.iter().next(),
"JsxReferenceIdentifier" => lang::JsxReferenceIdentifier::KIND_SET.iter().next(),
"JsxSelfClosingElement" => lang::JsxSelfClosingElement::KIND_SET.iter().next(),
"JsxSpreadAttribute" => lang::JsxSpreadAttribute::KIND_SET.iter().next(),
"JsxSpreadChild" => lang::JsxSpreadChild::KIND_SET.iter().next(),
"JsxString" => lang::JsxString::KIND_SET.iter().next(),
"JsxTagExpression" => lang::JsxTagExpression::KIND_SET.iter().next(),
"JsxText" => lang::JsxText::KIND_SET.iter().next(),
"TsAbstractModifier" => lang::TsAbstractModifier::KIND_SET.iter().next(),
"TsAccessibilityModifier" => lang::TsAccessibilityModifier::KIND_SET.iter().next(),
"TsAnyType" => lang::TsAnyType::KIND_SET.iter().next(),
"TsArrayType" => lang::TsArrayType::KIND_SET.iter().next(),
"TsAsAssignment" => lang::TsAsAssignment::KIND_SET.iter().next(),
"TsAsExpression" => lang::TsAsExpression::KIND_SET.iter().next(),
"TsAssertsCondition" => lang::TsAssertsCondition::KIND_SET.iter().next(),
"TsAssertsReturnType" => lang::TsAssertsReturnType::KIND_SET.iter().next(),
"TsBigintLiteralType" => lang::TsBigintLiteralType::KIND_SET.iter().next(),
"TsBigintType" => lang::TsBigintType::KIND_SET.iter().next(),
"TsBooleanLiteralType" => lang::TsBooleanLiteralType::KIND_SET.iter().next(),
"TsBooleanType" => lang::TsBooleanType::KIND_SET.iter().next(),
"TsCallSignatureTypeMember" => lang::TsCallSignatureTypeMember::KIND_SET.iter().next(),
"TsConditionalType" => lang::TsConditionalType::KIND_SET.iter().next(),
"TsConstModifier" => lang::TsConstModifier::KIND_SET.iter().next(),
"TsConstructSignatureTypeMember" => {
lang::TsConstructSignatureTypeMember::KIND_SET.iter().next()
}
"TsConstructorSignatureClassMember" => lang::TsConstructorSignatureClassMember::KIND_SET
.iter()
.next(),
"TsConstructorType" => lang::TsConstructorType::KIND_SET.iter().next(),
"TsDeclarationModule" => lang::TsDeclarationModule::KIND_SET.iter().next(),
"TsDeclareFunctionDeclaration" => {
lang::TsDeclareFunctionDeclaration::KIND_SET.iter().next()
}
"TsDeclareFunctionExportDefaultDeclaration" => {
lang::TsDeclareFunctionExportDefaultDeclaration::KIND_SET
.iter()
.next()
}
"TsDeclareModifier" => lang::TsDeclareModifier::KIND_SET.iter().next(),
"TsDeclareStatement" => lang::TsDeclareStatement::KIND_SET.iter().next(),
"TsDefaultTypeClause" => lang::TsDefaultTypeClause::KIND_SET.iter().next(),
"TsDefinitePropertyAnnotation" => {
lang::TsDefinitePropertyAnnotation::KIND_SET.iter().next()
}
"TsDefiniteVariableAnnotation" => {
lang::TsDefiniteVariableAnnotation::KIND_SET.iter().next()
}
"TsEmptyExternalModuleDeclarationBody" => {
lang::TsEmptyExternalModuleDeclarationBody::KIND_SET
.iter()
.next()
}
"TsEnumDeclaration" => lang::TsEnumDeclaration::KIND_SET.iter().next(),
"TsEnumMember" => lang::TsEnumMember::KIND_SET.iter().next(),
"TsExportAsNamespaceClause" => lang::TsExportAsNamespaceClause::KIND_SET.iter().next(),
"TsExportAssignmentClause" => lang::TsExportAssignmentClause::KIND_SET.iter().next(),
"TsExportDeclareClause" => lang::TsExportDeclareClause::KIND_SET.iter().next(),
"TsExtendsClause" => lang::TsExtendsClause::KIND_SET.iter().next(),
"TsExternalModuleDeclaration" => lang::TsExternalModuleDeclaration::KIND_SET.iter().next(),
"TsExternalModuleReference" => lang::TsExternalModuleReference::KIND_SET.iter().next(),
"TsFunctionType" => lang::TsFunctionType::KIND_SET.iter().next(),
"TsGetterSignatureClassMember" => {
lang::TsGetterSignatureClassMember::KIND_SET.iter().next()
}
"TsGetterSignatureTypeMember" => lang::TsGetterSignatureTypeMember::KIND_SET.iter().next(),
"TsGlobalDeclaration" => lang::TsGlobalDeclaration::KIND_SET.iter().next(),
"TsIdentifierBinding" => lang::TsIdentifierBinding::KIND_SET.iter().next(),
"TsImplementsClause" => lang::TsImplementsClause::KIND_SET.iter().next(),
"TsImportEqualsDeclaration" => lang::TsImportEqualsDeclaration::KIND_SET.iter().next(),
"TsImportType" => lang::TsImportType::KIND_SET.iter().next(),
"TsImportTypeArguments" => lang::TsImportTypeArguments::KIND_SET.iter().next(),
"TsImportTypeAssertion" => lang::TsImportTypeAssertion::KIND_SET.iter().next(),
"TsImportTypeAssertionBlock" => lang::TsImportTypeAssertionBlock::KIND_SET.iter().next(),
"TsImportTypeQualifier" => lang::TsImportTypeQualifier::KIND_SET.iter().next(),
"TsInModifier" => lang::TsInModifier::KIND_SET.iter().next(),
"TsIndexSignatureClassMember" => lang::TsIndexSignatureClassMember::KIND_SET.iter().next(),
"TsIndexSignatureParameter" => lang::TsIndexSignatureParameter::KIND_SET.iter().next(),
"TsIndexSignatureTypeMember" => lang::TsIndexSignatureTypeMember::KIND_SET.iter().next(),
"TsIndexedAccessType" => lang::TsIndexedAccessType::KIND_SET.iter().next(),
"TsInferType" => lang::TsInferType::KIND_SET.iter().next(),
"TsInitializedPropertySignatureClassMember" => {
lang::TsInitializedPropertySignatureClassMember::KIND_SET
.iter()
.next()
}
"TsInstantiationExpression" => lang::TsInstantiationExpression::KIND_SET.iter().next(),
"TsInterfaceDeclaration" => lang::TsInterfaceDeclaration::KIND_SET.iter().next(),
"TsIntersectionType" => lang::TsIntersectionType::KIND_SET.iter().next(),
"TsLiteralEnumMemberName" => lang::TsLiteralEnumMemberName::KIND_SET.iter().next(),
"TsMappedType" => lang::TsMappedType::KIND_SET.iter().next(),
"TsMappedTypeAsClause" => lang::TsMappedTypeAsClause::KIND_SET.iter().next(),
"TsMappedTypeOptionalModifierClause" => lang::TsMappedTypeOptionalModifierClause::KIND_SET
.iter()
.next(),
"TsMappedTypeReadonlyModifierClause" => lang::TsMappedTypeReadonlyModifierClause::KIND_SET
.iter()
.next(),
"TsMethodSignatureClassMember" => {
lang::TsMethodSignatureClassMember::KIND_SET.iter().next()
}
"TsMethodSignatureTypeMember" => lang::TsMethodSignatureTypeMember::KIND_SET.iter().next(),
"TsModuleBlock" => lang::TsModuleBlock::KIND_SET.iter().next(),
"TsModuleDeclaration" => lang::TsModuleDeclaration::KIND_SET.iter().next(),
"TsNamedTupleTypeElement" => lang::TsNamedTupleTypeElement::KIND_SET.iter().next(),
"TsNeverType" => lang::TsNeverType::KIND_SET.iter().next(),
"TsNonNullAssertionAssignment" => {
lang::TsNonNullAssertionAssignment::KIND_SET.iter().next()
}
"TsNonNullAssertionExpression" => {
lang::TsNonNullAssertionExpression::KIND_SET.iter().next()
}
"TsNonPrimitiveType" => lang::TsNonPrimitiveType::KIND_SET.iter().next(),
"TsNullLiteralType" => lang::TsNullLiteralType::KIND_SET.iter().next(),
"TsNumberLiteralType" => lang::TsNumberLiteralType::KIND_SET.iter().next(),
"TsNumberType" => lang::TsNumberType::KIND_SET.iter().next(),
"TsObjectType" => lang::TsObjectType::KIND_SET.iter().next(),
"TsOptionalPropertyAnnotation" => {
lang::TsOptionalPropertyAnnotation::KIND_SET.iter().next()
}
"TsOptionalTupleTypeElement" => lang::TsOptionalTupleTypeElement::KIND_SET.iter().next(),
"TsOutModifier" => lang::TsOutModifier::KIND_SET.iter().next(),
"TsOverrideModifier" => lang::TsOverrideModifier::KIND_SET.iter().next(),
"TsParenthesizedType" => lang::TsParenthesizedType::KIND_SET.iter().next(),
"TsPredicateReturnType" => lang::TsPredicateReturnType::KIND_SET.iter().next(),
"TsPropertyParameter" => lang::TsPropertyParameter::KIND_SET.iter().next(),
"TsPropertySignatureClassMember" => {
lang::TsPropertySignatureClassMember::KIND_SET.iter().next()
}
"TsPropertySignatureTypeMember" => {
lang::TsPropertySignatureTypeMember::KIND_SET.iter().next()
}
"TsQualifiedModuleName" => lang::TsQualifiedModuleName::KIND_SET.iter().next(),
"TsQualifiedName" => lang::TsQualifiedName::KIND_SET.iter().next(),
"TsReadonlyModifier" => lang::TsReadonlyModifier::KIND_SET.iter().next(),
"TsReferenceType" => lang::TsReferenceType::KIND_SET.iter().next(),
"TsRestTupleTypeElement" => lang::TsRestTupleTypeElement::KIND_SET.iter().next(),
"TsReturnTypeAnnotation" => lang::TsReturnTypeAnnotation::KIND_SET.iter().next(),
"TsSatisfiesAssignment" => lang::TsSatisfiesAssignment::KIND_SET.iter().next(),
"TsSatisfiesExpression" => lang::TsSatisfiesExpression::KIND_SET.iter().next(),
"TsSetterSignatureClassMember" => {
lang::TsSetterSignatureClassMember::KIND_SET.iter().next()
}
"TsSetterSignatureTypeMember" => lang::TsSetterSignatureTypeMember::KIND_SET.iter().next(),
"TsStringLiteralType" => lang::TsStringLiteralType::KIND_SET.iter().next(),
"TsStringType" => lang::TsStringType::KIND_SET.iter().next(),
"TsSymbolType" => lang::TsSymbolType::KIND_SET.iter().next(),
"TsTemplateChunkElement" => lang::TsTemplateChunkElement::KIND_SET.iter().next(),
"TsTemplateElement" => lang::TsTemplateElement::KIND_SET.iter().next(),
"TsTemplateLiteralType" => lang::TsTemplateLiteralType::KIND_SET.iter().next(),
"TsThisParameter" => lang::TsThisParameter::KIND_SET.iter().next(),
"TsThisType" => lang::TsThisType::KIND_SET.iter().next(),
"TsTupleType" => lang::TsTupleType::KIND_SET.iter().next(),
"TsTypeAliasDeclaration" => lang::TsTypeAliasDeclaration::KIND_SET.iter().next(),
"TsTypeAnnotation" => lang::TsTypeAnnotation::KIND_SET.iter().next(),
"TsTypeArguments" => lang::TsTypeArguments::KIND_SET.iter().next(),
"TsTypeAssertionAssignment" => lang::TsTypeAssertionAssignment::KIND_SET.iter().next(),
"TsTypeAssertionExpression" => lang::TsTypeAssertionExpression::KIND_SET.iter().next(),
"TsTypeConstraintClause" => lang::TsTypeConstraintClause::KIND_SET.iter().next(),
"TsTypeOperatorType" => lang::TsTypeOperatorType::KIND_SET.iter().next(),
"TsTypeParameter" => lang::TsTypeParameter::KIND_SET.iter().next(),
"TsTypeParameterName" => lang::TsTypeParameterName::KIND_SET.iter().next(),
"TsTypeParameters" => lang::TsTypeParameters::KIND_SET.iter().next(),
"TsTypeofType" => lang::TsTypeofType::KIND_SET.iter().next(),
"TsUndefinedType" => lang::TsUndefinedType::KIND_SET.iter().next(),
"TsUnionType" => lang::TsUnionType::KIND_SET.iter().next(),
"TsUnknownType" => lang::TsUnknownType::KIND_SET.iter().next(),
"TsVoidType" => lang::TsVoidType::KIND_SET.iter().next(),
_ => None,
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Compilation break: native arms return Option<&JsSyntaxKind>.

The match arms under “Native Biome AST patterns” must return Option<JsSyntaxKind>. Add .copied() before .next() (best fixed in the generator, then re‑generate).

Example fix (applies to every native arm):

-        "JsIfStatement" => lang::JsIfStatement::KIND_SET.iter().next(),
+        "JsIfStatement" => lang::JsIfStatement::KIND_SET.iter().copied().next(),
🤖 Prompt for AI Agents
In
crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
around lines 181–594, the match arms for the “Native Biome AST patterns” return
Option<&JsSyntaxKind> because they call .iter().next(); change each of those
arms to return Option<JsSyntaxKind> by inserting .copied() before .next() (i.e.,
use .iter().copied().next() or .into_iter().copied().next() in the generator)
for every native arm and then re-generate the file.

@arendjr arendjr merged commit 527cec2 into biomejs:main Sep 15, 2025
31 checks passed
@github-actions github-actions bot mentioned this pull request Sep 15, 2025
TheAlexLichter pushed a commit to TheAlexLichter/biome that referenced this pull request Sep 18, 2025
kedevked pushed a commit to kedevked/biome that referenced this pull request Sep 22, 2025
@ematipico
Copy link
Member

ematipico commented Oct 6, 2025

@rriski

The PR was merged with haste, and know we don't have a documentation page that actually shows the ASTs that can be queried, as well as an example that talks about it.

Could you please send a PR to biomejs/website with some information?

@rriski
Copy link
Contributor Author

rriski commented Oct 7, 2025

Could you please send a PR to biomejs/website with some information?

Sure thing, here: biomejs/website#3202

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.

3 participants