explore: ReScript (.res/.resi) language support (#532)#533
Conversation
Adds issue-532 tests asserting .res/.resi detect as `rescript` and that a .res file's module/type/let/external symbols and `open` import are parsed. Both fail on the current branch: .res falls through detectLanguage to .unknown, so no parser runs and the outline is empty. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds a `rescript` language with .res/.resi detection and a line-based parseRescriptLine that extracts: let/and bindings (function when the RHS has a `=>` arrow, constant otherwise), type → type_alias, module → struct_def (module type → interface_def), external → function, and open/include → import. Leading @decorators are stripped so a decorated `@val external` / `@react.component let` still resolves; // and /* */ comments are skipped. ReScript joins the C-style block-comment group and isCommentOrBlank; langHasCallSites/isCheckableCode fall through correctly. Closes #532. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Benchmark Regression ReportThresholds: 10.00% and 50,000 ns absolute delta
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 96e941d0b1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| llvm_ir, | ||
| mlir, | ||
| tablegen, | ||
| rescript, |
There was a problem hiding this comment.
Avoid overflowing telemetry's language mask
When a project contains a .res/.resi file and telemetry is enabled (the default), recordCodebaseStats casts @intFromEnum(entry.value_ptr.language) to u5 before shifting a u32 mask. Adding rescript after tablegen gives it enum value 32, which cannot fit in u5, so startup/status telemetry collection traps instead of completing the scan; the telemetry mask/list needs to be widened or otherwise updated for the new language.
Useful? React with 👍 / 👎.
Closes #532.
Adds ReScript as a first-class indexed language, following the existing per-language line-parser pattern (mirrors how
.r#215 and.tf#108 were added).What
.resand.resi→ newrescriptlanguage.parseRescriptLineextracts:let f = (…) => …/let rec/and f = … =>functionlet x = value(no arrow)constanttype t = …type_aliasmodule M = { … }struct_defmodule type S = { … }interface_defexternal name: T = "…"functionopen M/include Mimport@decorator/@decorator(args)are stripped first, so a decorated@val external …or@react.component\nlet makestill resolves.//and/* */comments are skipped (ReScript joins the C-style block-comment group +isCommentOrBlank).langHasCallSites/isCheckableCodefall through theirelsearms correctly (call-sites: yes, delimiter-balance check: no).Tests (failing-first, per CLAUDE.md)
Commit 1 adds
issue-532tests that fail on the base branch (.res→.unknown, empty outline); commit 2 implements support and turns them green:test_parser.zig— full outline of a.resfile (module/type/let/external/open).test_explore.zig—detectLanguagefor.res/.resi.zig build testpasses clean (0 failures).End-to-end (
codedb outlineon a real.res)Known limitations (v1, additive)
Line-based like the sibling parsers: nested module members are flattened into the top-level outline, and
exception/variant constructors are not yet emitted as symbols. These can be follow-ups; nothing here is a filter, so recall is never reduced.🤖 Generated with Claude Code