Run `rustfmt` only on individual files which codegen generates, rather than on the whole repo. This speeds up local development of `ast_tools` when you're on a slower machine.
1. Reduce the amount of code in `define_derive!` and `define_generator!` macros. This makes the code easier to read, and gives type hints in IDE.
2. Remove `generated_header!` macro and insert header as a blanket action, instead of repeated code in every generator.
- Added TypeScript annotation for `ParseResult.program`
- Modified the entrypoint for `oxc-parser` to allow wrapping the napi functions
- Updated `index.js` to parse the `program` string into a JSON object
- Updated tests
- Added a dependency on `@oxc/types`
#6740 and #6744 removed visitor type aliases (`#[visit(as(ClassHeritage))]`). Remove support for `#[visit(as(...))]` from `oxc_ast_tools`, since it's now dead code.
Add methods to `AstBuilder` to create AST nodes with `ScopeId`, `SymbolId`, `ReferenceId`, for use in transformer.
e.g. `identifier_reference_with_reference_id`, `binding_identifier_with_symbol_id`, `block_statement_with_scope_id `.
Follow-on after #5774. Correct the logic for calculating niches in enums.
It's still not quite correct - number of niches depends on how many spare discriminant "slots" there are at *start or end* of the range, not in total. But this is closer to correct than it was - we now don't take into account whether enum variant payloads have niches or not, which is not relevant.
Fixes a bug with how we were calculating the size of enums when there are different padding on variants and there aren't enough niches. Now it aligns the largest variant size to the largest alignment before consuming niches.
Follow-on after #6404. Add `Derive::snake_name` method which defaults to `Self::trait_name().to_case(Case::Snake)`, but can be overridden. This allows moving the "special case" code for `ESTree` filename into `estree.rs`.
This was originally in #6404 but I pulled it out to reduce that PR's diff.
Add ability (currently unused) to output arbitrary text files from `oxc_ast_tools` generators.
Follow-on after #6404.
`ArrayExpressionElement` and `Elision` are not used in the TS types, because `ArrayExpression` has an override for the field it uses.
002289b4b1/crates/oxc_ast/src/ast/js.rs (L293-L302)
Prevent these TS type defs being emitted by introducing a new `#[estree(custom_ts_def)]` attr, to go with `#[estree(custom_serialize)]`.
Beginning of #6347. Instead of using serde-derive, we generate
`Serialize` impls manually.
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
`just ast` panic due to
553262842c,
change the filename to makesure `ast_tool` still working
1. crates/oxc_span/src/source_type/types.rs is removed in
553262842c
I was so confused as to why the `AST Changes` step wasn't running at times. Turns out we weren't watching it at all😅
This means for a duration of time we weren't running the `AST Changes` step on PRs that edited only `ast_tools` that didn't update any side-effects.
As of now if we remove the implementation of a trait for a type and implement the method on that type directly it wouldn't break while it isn't the original trait anymore so that method might do something entirely different.
This change is more explicit on trait calls so we hit compile errors on these kinds of changes.
In an effort toward the implementation of #5256, this PR allows us to have a separately generated "derive" file for each crate.
This also eliminates a bunch of boilerplate when writing new "derive" generators and generally makes it more approachable.
We mostly use `allocator` as var name for an `Allocator`, but in some places used the shorter name `alloc`. Use `allocator` everywhere for consistency.
This PR renames the `oxc_ast_codegen` crate to `oxc_ast_tools`, It improves the readability and organization of the codebase by giving the crate a name that better reflects its purpose and contents.
It also improves the error message in CI.