Files
Boshen baf022d74d refactor(ast)!: remove old AstBuilder methods (#24563)
Closes the migration tracked in #23043.

The new builder API (methods on the AST types themselves) has been in place for a while, all Oxc crates are migrated, and every crate which uses `AstBuilder` already enables `disable_old_builder` in its tests. The module docs said "after a few weeks, we will remove `AstBuilder`'s own methods entirely" — this does that.

## What's removed

- `crates/oxc_ast/src/generated/ast_builder.rs` and `builder/methods.rs` — `AstBuilder`'s own node and primitive constructors.
- `AstBuilderGenerator`, which produced the former.
- The `disable_old_builder` Cargo feature, plus the dev-dependency hacks it required across 33 manifests. Eight crates depended on `oxc_ast` *purely* to turn the feature on; those deps and their `cargo-shear` ignore entries are gone too.

## One thing worth reviewing

`AstBuilderGenerator` owned the `#[builder(default)]` / `#[builder(skip)]` attr registration that `BuilderMethodsGenerator` only *reads* — its doc comment said as much. Deleting it naively would have silently dropped `skip`/`default` handling for the 12 AST types using those attrs, so `attrs()` and `parse_attr()` move to `BuilderMethodsGenerator`.

The evidence this was faithful: after regenerating, `builder_methods.rs` and every other generated file are **byte-identical**. The only generated change in the diff is the deletion.

## Breaking changes

- `AstBuilder`'s own methods are gone. Use the AST type methods: `Statement::new_expression_statement(span, expr, &builder)` instead of `builder.statement_expression(span, expr)`.
- `AstBuilder` is no longer `Copy`/`Clone`, and its `allocator` field is private — use the `allocator` method from `GetAllocator`.
- `AstBuilder` and `NONE` are no longer re-exported from the crate root; import them from `oxc_ast::builder`. (The `disable_old_builder` feature already gated these off, so nothing in-tree used the root path.)
- The `disable_old_builder` feature no longer exists — remove it from any manifest that sets it.

A migration note covering all of the above is in `crates/oxc_ast/src/builder/mod.rs`.

---

Implemented with AI assistance (Claude Code); design, review, and verification driven by the author per the repo AI-usage policy.
2026-07-21 15:22:46 +00:00

69 lines
2.3 KiB
TOML

[package]
name = "oxc_ast_tools"
version = "0.0.0"
edition.workspace = true
license.workspace = true
publish = false
[lints]
workspace = true
[[bin]]
name = "oxc_ast_tools"
test = true
doctest = false
[dependencies]
# These dependencies are only used by JS generators.
# So make them optional, and only enable them if `generate-js` feature is enabled.
# See comment on `js-generators` feature below.
#
# `features = ["serialize"]` on `oxc_span` and `oxc_syntax` is needed to work around a bug in `oxc_index`.
oxc_allocator = { workspace = true, optional = true }
oxc_ast = { workspace = true, optional = true }
oxc_ast_visit = { workspace = true, optional = true }
oxc_codegen = { workspace = true, optional = true, features = ["sourcemap"] }
oxc_minifier = { workspace = true, optional = true }
oxc_parser = { workspace = true, optional = true }
oxc_span = { workspace = true, features = ["serialize"], optional = true }
oxc_str = { workspace = true }
oxc_syntax = { workspace = true, features = ["serialize"], optional = true }
bitflags = { workspace = true }
bpaf = { workspace = true, features = ["autocomplete", "bright-color", "derive"] }
convert_case = { workspace = true }
cow-utils = { workspace = true }
indexmap = { workspace = true }
itertools = { workspace = true }
javascript-globals = { workspace = true }
lazy-regex = { workspace = true }
oxc_index = { workspace = true }
phf = { workspace = true, features = ["macros"] }
phf_codegen = { workspace = true }
prettyplease = { workspace = true }
proc-macro2 = { workspace = true }
quote = { workspace = true }
rayon = { workspace = true }
rustc-hash = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
syn = { workspace = true, features = ["extra-traits", "full", "parsing", "printing"] }
toml = { workspace = true }
[features]
default = ["generate-js"]
# Feature to enable JS generators that require `oxc_*` crates.
# Enabled by default, but can be disabled to break the circular dependency
# when AST changes prevent local crates from compiling.
# See: https://github.com/oxc-project/oxc/issues/15564
generate-js = [
"dep:oxc_allocator",
"dep:oxc_ast",
"dep:oxc_ast_visit",
"dep:oxc_codegen",
"dep:oxc_minifier",
"dep:oxc_parser",
"dep:oxc_span",
"dep:oxc_syntax",
]