Skip to content

bar-fmt 1/3: bar-lua-codemod — tooling and tests - #2

Closed
keithharvey wants to merge 4 commits into
masterfrom
bar-fmt-01-tooling
Closed

bar-fmt 1/3: bar-lua-codemod — tooling and tests#2
keithharvey wants to merge 4 commits into
masterfrom
bar-fmt-01-tooling

Conversation

@keithharvey

@keithharvey keithharvey commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Layer 1 of the bar-fmt stack (tooling + tests → workspace integration → LLM layer).

The codemod crate, one atomic commit per piece: the span-edit framework over emmylua_parser, then bracket-to-dot, rename-aliases, and detach-bar-modules. Every commit builds and its tests pass in isolation (17 → 24 → 37 tests along the stack).

This is the emmylua_parser port of the full_moon codemod (one Lua front-end across the repo — same parser family as emmylua_check/emmylua_ls). Verified byte-identical to the full_moon binary over the BAR fmt tree (2,171 files): per-transform trees, composed pipeline trees, count reports, and the parse-failure set all match exactly — and the full generation pipeline has since been re-run end-to-end with this binary, rebuilding all migration branches cleanly. The pre-restack branch is bar-fmt-emmylua; the original full_moon history stays on bar-fmt.

🤖 Generated with Claude Code

keithharvey and others added 4 commits July 22, 2026 19:29
bar-lua-codemod parses BAR Lua with emmylua_parser (the same front-end
family as emmylua_check/emmylua_ls) at Lua51, doc-comment analysis off.
Transforms collect byte-range edits over the rowan CST and splice them
into the original source, so untouched bytes are untouched by
construction. cst.rs carries the shared helpers: parse gate on
SyntaxError-kind diagnostics only, bracketed-string-key extraction that
tolerates trivia, and the function-declaration-name exclusion.
codemod-cargo.sh runs cargo inside bar-dev, where the toolchain lives.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
x["y"] -> x.y and ["y"] = -> y = for string keys that are valid,
non-reserved identifiers. Raw quoted content only — escapes and long
strings never convert. Injects a space when ] abutted a word character
so .identifier doesn't merge with what follows.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Spring.GetMyTeamID / GetMyAllyTeamID / GetMyPlayerID -> the canonical
GetLocal* names, wherever the prefix is the bare Spring global. Bracket
access and non-Spring prefixes are left alone.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Spring.I18N / Utilities / Debug / Lava / GetModOptionsCopy — BAR's own
helpers riding the Spring table — move to the BAR namespace. Handles the
_G.Spring.Module spelling too; function-declaration names stay put.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@keithharvey

Copy link
Copy Markdown
Owner Author

Consolidating: bar-fmt reviews as one PR for now — the tip rollup at beyond-all-reason#57.

@keithharvey
keithharvey deleted the bar-fmt-01-tooling branch July 31, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant