refactor(ast_tools): search all crates which depend on oxc_ast_macros#20577
Merged
graphite-app[bot] merged 1 commit intomainfrom Mar 20, 2026
Conversation
Member
Author
This was referenced Mar 20, 2026
This was referenced Mar 20, 2026
Merging this PR will not alter performance
Comparing Footnotes
|
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors oxc_ast_tools to automatically discover which Rust crates/files contain AST definitions by querying workspace metadata, removing the need to maintain a hard-coded source file list in the codegen tool.
Changes:
- Add
find_crates_and_files()(viacargo metadata) to locate workspace crates depending onoxc_ast_macrosand enumerate theirsrc/**/*.rsinputs (excludingsrc/generated). - Thread the discovered
root_path/source_pathsintoCodegen::new(...)andparse_files(...), removing the previousSOURCE_PATHSlist. - Rework the CI watch-list YAML generation to watch relevant crate globs plus generated outputs, producing deterministic but reordered generated artifacts.
Reviewed changes
Copilot reviewed 5 out of 21 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tasks/ast_tools/src/parse/mod.rs | Updates parsing entrypoint to accept discovered Vec<String> file paths and simplifies collection. |
| tasks/ast_tools/src/output/yaml.rs | Reworks watch-list generation to use discovered crate paths + outputs and emit RawOutput. |
| tasks/ast_tools/src/main.rs | Removes hard-coded source list; integrates crate/file discovery and new watch-list generation flow. |
| tasks/ast_tools/src/find.rs | New metadata-driven crate/file discovery (workspace crates depending on oxc_ast_macros). |
| tasks/ast_tools/src/codegen.rs | Codegen::new now takes an explicit workspace root path. |
| npm/oxc-types/types.d.ts | Generated ordering change (no semantic change). |
| napi/parser/src-js/generated/lazy/constructors.js | Generated ordering change (no semantic change). |
| napi/parser/src-js/generated/deserialize/ts_range_parent.js | Generated ordering change (no semantic change). |
| napi/parser/src-js/generated/deserialize/ts_range.js | Generated ordering change (no semantic change). |
| napi/parser/src-js/generated/deserialize/ts_parent.js | Generated ordering change (no semantic change). |
| napi/parser/src-js/generated/deserialize/ts.js | Generated ordering change (no semantic change). |
| napi/parser/src-js/generated/deserialize/js_range_parent.js | Generated ordering change (no semantic change). |
| napi/parser/src-js/generated/deserialize/js_range.js | Generated ordering change (no semantic change). |
| napi/parser/src-js/generated/deserialize/js_parent.js | Generated ordering change (no semantic change). |
| napi/parser/src-js/generated/deserialize/js.js | Generated ordering change (no semantic change). |
| crates/oxc_syntax/src/generated/assert_layouts.rs | Generated ordering change (no semantic change). |
| crates/oxc_span/src/generated/derive_estree.rs | Generated ordering change (no semantic change). |
| crates/oxc_span/src/generated/assert_layouts.rs | Generated ordering change (no semantic change). |
| apps/oxlint/src-js/generated/types.d.ts | Generated ordering change (no semantic change). |
| apps/oxlint/src-js/generated/deserialize.js | Generated ordering change (no semantic change). |
| .github/generated/ast_changes_watch_list.yml | Updates watch patterns to crate src/**/*.rs globs + relevant generated outputs; header source updated. |
Contributor
Merge activity
|
…s` (#20577) One annoyance with `ast_tools`, our codegen, has been that when you want it to generate code from types in some file, you had to manually add the file paths to a list in `ast_tools` itself. This PR removes that list and instead finds crates in the monorepo which depend on `oxc_ast_macros` crate, via `cargo metadata`, and searches all files in those crates for types with `#[ast]` attributes etc - types that it need to act on. There is no longer a list to keep updated, you just mark types `#[ast]` and the codegen will find them. This produces some churn in generated files. None of the generated code changes, it just gets re-ordered in some places, due to the different order that files get found in now. This order is deterministic, and it should not change again.
98a1757 to
1be1ebe
Compare
graphite-app bot
pushed a commit
that referenced
this pull request
Mar 20, 2026
#20577 made `ast_tools` search for and parse all files in all crates that depend on `oxc_ast_macros`. The one downside of this change is that it makes running `ast_tools` slower. Speed it up again, by parsing files in parallel, using `rayon`. There is one annoyance. Due to feature unification, `syn` crate gets compiled with `proc-macro` feature enabled, which makes `syn`s ASTs not `Send`. We don't use the AST in ways which can produce data races (and we can't, because `ast_tools` isn't a proc macro), so it is safe in practice to send ASTs across threads here. So we have to hack it to make it compile (see comment in `tasks/ast_tools/src/parse/mod.rs`).
costajohnt
pushed a commit
to costajohnt/oxc
that referenced
this pull request
Mar 22, 2026
…s` (oxc-project#20577) One annoyance with `ast_tools`, our codegen, has been that when you want it to generate code from types in some file, you had to manually add the file paths to a list in `ast_tools` itself. This PR removes that list and instead finds crates in the monorepo which depend on `oxc_ast_macros` crate, via `cargo metadata`, and searches all files in those crates for types with `#[ast]` attributes etc - types that it need to act on. There is no longer a list to keep updated, you just mark types `#[ast]` and the codegen will find them. This produces some churn in generated files. None of the generated code changes, it just gets re-ordered in some places, due to the different order that files get found in now. This order is deterministic, and it should not change again.
costajohnt
pushed a commit
to costajohnt/oxc
that referenced
this pull request
Mar 22, 2026
oxc-project#20577 made `ast_tools` search for and parse all files in all crates that depend on `oxc_ast_macros`. The one downside of this change is that it makes running `ast_tools` slower. Speed it up again, by parsing files in parallel, using `rayon`. There is one annoyance. Due to feature unification, `syn` crate gets compiled with `proc-macro` feature enabled, which makes `syn`s ASTs not `Send`. We don't use the AST in ways which can produce data races (and we can't, because `ast_tools` isn't a proc macro), so it is safe in practice to send ASTs across threads here. So we have to hack it to make it compile (see comment in `tasks/ast_tools/src/parse/mod.rs`).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

One annoyance with
ast_tools, our codegen, has been that when you want it to generate code from types in some file, you had to manually add the file paths to a list inast_toolsitself.This PR removes that list and instead finds crates in the monorepo which depend on
oxc_ast_macroscrate, viacargo metadata, and searches all files in those crates for types with#[ast]attributes etc - types that it need to act on.There is no longer a list to keep updated, you just mark types
#[ast]and the codegen will find them.This produces some churn in generated files. None of the generated code changes, it just gets re-ordered in some places, due to the different order that files get found in now. This order is deterministic, and it should not change again.