From 8e8fcd0584366f989fe2bcd690d358c5c3da2f9f Mon Sep 17 00:00:00 2001 From: rzvxa <3788964+rzvxa@users.noreply.github.com> Date: Mon, 12 Aug 2024 14:33:58 +0000 Subject: [PATCH] refactor(ast_tools): rename `oxc_ast_codegen` to `oxc_ast_tools`. (#4846) 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. --- .github/.generated_ast_watch_list.yml | 2 +- .github/workflows/ci.yml | 8 ++++---- Cargo.lock | 20 +++++++++---------- crates/oxc_ast/src/ast/js.rs | 2 +- crates/oxc_ast/src/ast/jsx.rs | 2 +- crates/oxc_ast/src/ast/literal.rs | 2 +- crates/oxc_ast/src/ast/ts.rs | 2 +- .../oxc_ast/src/generated/assert_layouts.rs | 2 +- crates/oxc_ast/src/generated/ast_builder.rs | 2 +- crates/oxc_ast/src/generated/ast_kind.rs | 2 +- .../oxc_ast/src/generated/derive_clone_in.rs | 2 +- .../oxc_ast/src/generated/derive_get_span.rs | 2 +- .../src/generated/derive_get_span_mut.rs | 2 +- crates/oxc_ast/src/generated/visit.rs | 2 +- crates/oxc_ast/src/generated/visit_mut.rs | 2 +- justfile | 2 +- tasks/{ast_codegen => ast_tools}/Cargo.toml | 4 ++-- .../{ast_codegen => ast_tools}/src/codegen.rs | 0 tasks/{ast_codegen => ast_tools}/src/fmt.rs | 0 .../src/generators/assert_layouts.rs | 0 .../src/generators/ast_builder.rs | 0 .../src/generators/ast_kind.rs | 0 .../src/generators/derive_clone_in.rs | 0 .../src/generators/derive_get_span.rs | 0 .../src/generators/mod.rs | 0 .../src/generators/visit.rs | 0 .../{ast_codegen => ast_tools}/src/layout.rs | 0 tasks/{ast_codegen => ast_tools}/src/main.rs | 0 .../{ast_codegen => ast_tools}/src/markers.rs | 0 .../src/passes/calc_layout.rs | 2 +- .../src/passes/linker.rs | 0 .../src/passes/mod.rs | 0 .../src/rust_ast.rs | 0 .../src/schema/defs.rs | 0 .../src/schema/get_generics.rs | 0 .../src/schema/get_ident.rs | 0 .../src/schema/mod.rs | 0 .../src/schema/to_type.rs | 0 tasks/{ast_codegen => ast_tools}/src/util.rs | 0 39 files changed, 31 insertions(+), 31 deletions(-) rename tasks/{ast_codegen => ast_tools}/Cargo.toml (91%) rename tasks/{ast_codegen => ast_tools}/src/codegen.rs (100%) rename tasks/{ast_codegen => ast_tools}/src/fmt.rs (100%) rename tasks/{ast_codegen => ast_tools}/src/generators/assert_layouts.rs (100%) rename tasks/{ast_codegen => ast_tools}/src/generators/ast_builder.rs (100%) rename tasks/{ast_codegen => ast_tools}/src/generators/ast_kind.rs (100%) rename tasks/{ast_codegen => ast_tools}/src/generators/derive_clone_in.rs (100%) rename tasks/{ast_codegen => ast_tools}/src/generators/derive_get_span.rs (100%) rename tasks/{ast_codegen => ast_tools}/src/generators/mod.rs (100%) rename tasks/{ast_codegen => ast_tools}/src/generators/visit.rs (100%) rename tasks/{ast_codegen => ast_tools}/src/layout.rs (100%) rename tasks/{ast_codegen => ast_tools}/src/main.rs (100%) rename tasks/{ast_codegen => ast_tools}/src/markers.rs (100%) rename tasks/{ast_codegen => ast_tools}/src/passes/calc_layout.rs (99%) rename tasks/{ast_codegen => ast_tools}/src/passes/linker.rs (100%) rename tasks/{ast_codegen => ast_tools}/src/passes/mod.rs (100%) rename tasks/{ast_codegen => ast_tools}/src/rust_ast.rs (100%) rename tasks/{ast_codegen => ast_tools}/src/schema/defs.rs (100%) rename tasks/{ast_codegen => ast_tools}/src/schema/get_generics.rs (100%) rename tasks/{ast_codegen => ast_tools}/src/schema/get_ident.rs (100%) rename tasks/{ast_codegen => ast_tools}/src/schema/mod.rs (100%) rename tasks/{ast_codegen => ast_tools}/src/schema/to_type.rs (100%) rename tasks/{ast_codegen => ast_tools}/src/util.rs (100%) diff --git a/.github/.generated_ast_watch_list.yml b/.github/.generated_ast_watch_list.yml index 0b8a81ef3..ae30f7c98 100644 --- a/.github/.generated_ast_watch_list.yml +++ b/.github/.generated_ast_watch_list.yml @@ -1,4 +1,4 @@ -# To edit this generated file you have to edit `tasks/ast_codegen/src/main.rs` +# To edit this generated file you have to edit `tasks/ast_tools/src/main.rs` # Auto-generated code, DO NOT EDIT DIRECTLY! src: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58402a236..99cce7804 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -280,12 +280,12 @@ jobs: if: steps.filter.outputs.src == 'true' with: components: rustfmt - cache-key: codegen + cache-key: ast_changes save-cache: ${{ github.ref_name == 'main' }} - name: Check AST Changes if: steps.filter.outputs.src == 'true' run: | - cargo run -p oxc_ast_codegen - echo 'AST changes must be commited to the repo.' - git diff --exit-code + cargo run -p oxc_ast_tools + git diff --exit-code || + echo 'AST changes caused the "generated" code to get outdated. Have you forgotten to run the `just ast` command and/or commit generated codes?' diff --git a/Cargo.lock b/Cargo.lock index 976e1f80d..ca0490c46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1475,7 +1475,16 @@ dependencies = [ ] [[package]] -name = "oxc_ast_codegen" +name = "oxc_ast_macros" +version = "0.24.2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "oxc_ast_tools" version = "0.0.0" dependencies = [ "bpaf", @@ -1491,15 +1500,6 @@ dependencies = [ "syn", ] -[[package]] -name = "oxc_ast_macros" -version = "0.24.2" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "oxc_benchmark" version = "0.0.0" diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index 734266e0b..e19f5f817 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -1,6 +1,6 @@ // NB: `#[span]`, `#[scope(...)]` and `#[visit(...)]` do NOT do anything to the code. // They are purely markers for codegen used in -// `tasks/ast_codegen` and `crates/oxc_traverse/scripts`. See docs in those crates. +// `tasks/ast_tools` and `crates/oxc_traverse/scripts`. See docs in those crates. // Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]` #![allow(non_snake_case)] diff --git a/crates/oxc_ast/src/ast/jsx.rs b/crates/oxc_ast/src/ast/jsx.rs index c1f753779..87d31509c 100644 --- a/crates/oxc_ast/src/ast/jsx.rs +++ b/crates/oxc_ast/src/ast/jsx.rs @@ -2,7 +2,7 @@ // NB: `#[span]`, `#[scope(...)]` and `#[visit(...)]` do NOT do anything to the code. // They are purely markers for codegen used in -// `tasks/ast_codegen` and `crates/oxc_traverse/scripts`. See docs in those crates. +// `tasks/ast_tools` and `crates/oxc_traverse/scripts`. See docs in those crates. // Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]` #![allow(non_snake_case)] diff --git a/crates/oxc_ast/src/ast/literal.rs b/crates/oxc_ast/src/ast/literal.rs index d48ee8b11..5ee834378 100644 --- a/crates/oxc_ast/src/ast/literal.rs +++ b/crates/oxc_ast/src/ast/literal.rs @@ -2,7 +2,7 @@ // NB: `#[span]`, `#[scope(...)]` and `#[visit(...)]` do NOT do anything to the code. // They are purely markers for codegen used in -// `tasks/ast_codegen` and `crates/oxc_traverse/scripts`. See docs in those crates. +// `tasks/ast_tools` and `crates/oxc_traverse/scripts`. See docs in those crates. // Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]` #![allow(non_snake_case)] diff --git a/crates/oxc_ast/src/ast/ts.rs b/crates/oxc_ast/src/ast/ts.rs index 78d55a748..de80593dc 100644 --- a/crates/oxc_ast/src/ast/ts.rs +++ b/crates/oxc_ast/src/ast/ts.rs @@ -5,7 +5,7 @@ // NB: `#[span]`, `#[scope(...)]` and `#[visit(...)]` do NOT do anything to the code. // They are purely markers for codegen used in -// `tasks/ast_codegen` and `crates/oxc_traverse/scripts`. See docs in those crates. +// `tasks/ast_tools` and `crates/oxc_traverse/scripts`. See docs in those crates. // Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]` #![allow(non_snake_case)] diff --git a/crates/oxc_ast/src/generated/assert_layouts.rs b/crates/oxc_ast/src/generated/assert_layouts.rs index b3f25e45f..b8e3a0874 100644 --- a/crates/oxc_ast/src/generated/assert_layouts.rs +++ b/crates/oxc_ast/src/generated/assert_layouts.rs @@ -1,5 +1,5 @@ // Auto-generated code, DO NOT EDIT DIRECTLY! -// To edit this generated file you have to edit `tasks/ast_codegen/src/generators/assert_layouts.rs` +// To edit this generated file you have to edit `tasks/ast_tools/src/generators/assert_layouts.rs` use std::mem::{align_of, offset_of, size_of}; diff --git a/crates/oxc_ast/src/generated/ast_builder.rs b/crates/oxc_ast/src/generated/ast_builder.rs index c369ba5d9..1c81192b5 100644 --- a/crates/oxc_ast/src/generated/ast_builder.rs +++ b/crates/oxc_ast/src/generated/ast_builder.rs @@ -1,5 +1,5 @@ // Auto-generated code, DO NOT EDIT DIRECTLY! -// To edit this generated file you have to edit `tasks/ast_codegen/src/generators/ast_builder.rs` +// To edit this generated file you have to edit `tasks/ast_tools/src/generators/ast_builder.rs` #![allow( clippy::default_trait_access, diff --git a/crates/oxc_ast/src/generated/ast_kind.rs b/crates/oxc_ast/src/generated/ast_kind.rs index e448a50b2..7ae7dfbca 100644 --- a/crates/oxc_ast/src/generated/ast_kind.rs +++ b/crates/oxc_ast/src/generated/ast_kind.rs @@ -1,5 +1,5 @@ // Auto-generated code, DO NOT EDIT DIRECTLY! -// To edit this generated file you have to edit `tasks/ast_codegen/src/generators/ast_kind.rs` +// To edit this generated file you have to edit `tasks/ast_tools/src/generators/ast_kind.rs` use oxc_span::{GetSpan, Span}; diff --git a/crates/oxc_ast/src/generated/derive_clone_in.rs b/crates/oxc_ast/src/generated/derive_clone_in.rs index 3585af9ec..97468ac80 100644 --- a/crates/oxc_ast/src/generated/derive_clone_in.rs +++ b/crates/oxc_ast/src/generated/derive_clone_in.rs @@ -1,5 +1,5 @@ // Auto-generated code, DO NOT EDIT DIRECTLY! -// To edit this generated file you have to edit `tasks/ast_codegen/src/generators/derive_clone_in.rs` +// To edit this generated file you have to edit `tasks/ast_tools/src/generators/derive_clone_in.rs` #![allow(clippy::default_trait_access)] diff --git a/crates/oxc_ast/src/generated/derive_get_span.rs b/crates/oxc_ast/src/generated/derive_get_span.rs index 53afc6464..e68703287 100644 --- a/crates/oxc_ast/src/generated/derive_get_span.rs +++ b/crates/oxc_ast/src/generated/derive_get_span.rs @@ -1,5 +1,5 @@ // Auto-generated code, DO NOT EDIT DIRECTLY! -// To edit this generated file you have to edit `tasks/ast_codegen/src/generators/derive_get_span.rs` +// To edit this generated file you have to edit `tasks/ast_tools/src/generators/derive_get_span.rs` #![allow(clippy::match_same_arms)] diff --git a/crates/oxc_ast/src/generated/derive_get_span_mut.rs b/crates/oxc_ast/src/generated/derive_get_span_mut.rs index 36e17d884..fe8848f1d 100644 --- a/crates/oxc_ast/src/generated/derive_get_span_mut.rs +++ b/crates/oxc_ast/src/generated/derive_get_span_mut.rs @@ -1,5 +1,5 @@ // Auto-generated code, DO NOT EDIT DIRECTLY! -// To edit this generated file you have to edit `tasks/ast_codegen/src/generators/derive_get_span.rs` +// To edit this generated file you have to edit `tasks/ast_tools/src/generators/derive_get_span.rs` #![allow(clippy::match_same_arms)] diff --git a/crates/oxc_ast/src/generated/visit.rs b/crates/oxc_ast/src/generated/visit.rs index 636343ce3..4a6bf2581 100644 --- a/crates/oxc_ast/src/generated/visit.rs +++ b/crates/oxc_ast/src/generated/visit.rs @@ -1,5 +1,5 @@ // Auto-generated code, DO NOT EDIT DIRECTLY! -// To edit this generated file you have to edit `tasks/ast_codegen/src/generators/visit.rs` +// To edit this generated file you have to edit `tasks/ast_tools/src/generators/visit.rs` //! Visitor Pattern //! diff --git a/crates/oxc_ast/src/generated/visit_mut.rs b/crates/oxc_ast/src/generated/visit_mut.rs index 066f12adf..03fa292db 100644 --- a/crates/oxc_ast/src/generated/visit_mut.rs +++ b/crates/oxc_ast/src/generated/visit_mut.rs @@ -1,5 +1,5 @@ // Auto-generated code, DO NOT EDIT DIRECTLY! -// To edit this generated file you have to edit `tasks/ast_codegen/src/generators/visit.rs` +// To edit this generated file you have to edit `tasks/ast_tools/src/generators/visit.rs` //! Visitor Pattern //! diff --git a/justfile b/justfile index 064853922..9f4074dcd 100755 --- a/justfile +++ b/justfile @@ -174,5 +174,5 @@ website path: # sync ast changes ast: - cargo run -p oxc_ast_codegen + cargo run -p oxc_ast_tools just check diff --git a/tasks/ast_codegen/Cargo.toml b/tasks/ast_tools/Cargo.toml similarity index 91% rename from tasks/ast_codegen/Cargo.toml rename to tasks/ast_tools/Cargo.toml index 4c00c50fe..a050a6144 100644 --- a/tasks/ast_codegen/Cargo.toml +++ b/tasks/ast_tools/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "oxc_ast_codegen" +name = "oxc_ast_tools" version = "0.0.0" publish = false edition.workspace = true @@ -9,7 +9,7 @@ license.workspace = true workspace = true [[bin]] -name = "oxc_ast_codegen" +name = "oxc_ast_tools" test = false doctest = false diff --git a/tasks/ast_codegen/src/codegen.rs b/tasks/ast_tools/src/codegen.rs similarity index 100% rename from tasks/ast_codegen/src/codegen.rs rename to tasks/ast_tools/src/codegen.rs diff --git a/tasks/ast_codegen/src/fmt.rs b/tasks/ast_tools/src/fmt.rs similarity index 100% rename from tasks/ast_codegen/src/fmt.rs rename to tasks/ast_tools/src/fmt.rs diff --git a/tasks/ast_codegen/src/generators/assert_layouts.rs b/tasks/ast_tools/src/generators/assert_layouts.rs similarity index 100% rename from tasks/ast_codegen/src/generators/assert_layouts.rs rename to tasks/ast_tools/src/generators/assert_layouts.rs diff --git a/tasks/ast_codegen/src/generators/ast_builder.rs b/tasks/ast_tools/src/generators/ast_builder.rs similarity index 100% rename from tasks/ast_codegen/src/generators/ast_builder.rs rename to tasks/ast_tools/src/generators/ast_builder.rs diff --git a/tasks/ast_codegen/src/generators/ast_kind.rs b/tasks/ast_tools/src/generators/ast_kind.rs similarity index 100% rename from tasks/ast_codegen/src/generators/ast_kind.rs rename to tasks/ast_tools/src/generators/ast_kind.rs diff --git a/tasks/ast_codegen/src/generators/derive_clone_in.rs b/tasks/ast_tools/src/generators/derive_clone_in.rs similarity index 100% rename from tasks/ast_codegen/src/generators/derive_clone_in.rs rename to tasks/ast_tools/src/generators/derive_clone_in.rs diff --git a/tasks/ast_codegen/src/generators/derive_get_span.rs b/tasks/ast_tools/src/generators/derive_get_span.rs similarity index 100% rename from tasks/ast_codegen/src/generators/derive_get_span.rs rename to tasks/ast_tools/src/generators/derive_get_span.rs diff --git a/tasks/ast_codegen/src/generators/mod.rs b/tasks/ast_tools/src/generators/mod.rs similarity index 100% rename from tasks/ast_codegen/src/generators/mod.rs rename to tasks/ast_tools/src/generators/mod.rs diff --git a/tasks/ast_codegen/src/generators/visit.rs b/tasks/ast_tools/src/generators/visit.rs similarity index 100% rename from tasks/ast_codegen/src/generators/visit.rs rename to tasks/ast_tools/src/generators/visit.rs diff --git a/tasks/ast_codegen/src/layout.rs b/tasks/ast_tools/src/layout.rs similarity index 100% rename from tasks/ast_codegen/src/layout.rs rename to tasks/ast_tools/src/layout.rs diff --git a/tasks/ast_codegen/src/main.rs b/tasks/ast_tools/src/main.rs similarity index 100% rename from tasks/ast_codegen/src/main.rs rename to tasks/ast_tools/src/main.rs diff --git a/tasks/ast_codegen/src/markers.rs b/tasks/ast_tools/src/markers.rs similarity index 100% rename from tasks/ast_codegen/src/markers.rs rename to tasks/ast_tools/src/markers.rs diff --git a/tasks/ast_codegen/src/passes/calc_layout.rs b/tasks/ast_tools/src/passes/calc_layout.rs similarity index 99% rename from tasks/ast_codegen/src/passes/calc_layout.rs rename to tasks/ast_tools/src/passes/calc_layout.rs index 3e82dfe94..62e459e92 100644 --- a/tasks/ast_codegen/src/passes/calc_layout.rs +++ b/tasks/ast_tools/src/passes/calc_layout.rs @@ -17,7 +17,7 @@ use super::{define_pass, Pass}; /// We use compiler to infer 64bit type layouts. #[cfg(not(target_pointer_width = "64"))] -compile_error!("`oxc_ast_codegen::calc_layout` only supports 64 architectures."); +compile_error!("This module only supports 64bit architectures."); type WellKnown = HashMap<&'static str, PlatformLayout>; diff --git a/tasks/ast_codegen/src/passes/linker.rs b/tasks/ast_tools/src/passes/linker.rs similarity index 100% rename from tasks/ast_codegen/src/passes/linker.rs rename to tasks/ast_tools/src/passes/linker.rs diff --git a/tasks/ast_codegen/src/passes/mod.rs b/tasks/ast_tools/src/passes/mod.rs similarity index 100% rename from tasks/ast_codegen/src/passes/mod.rs rename to tasks/ast_tools/src/passes/mod.rs diff --git a/tasks/ast_codegen/src/rust_ast.rs b/tasks/ast_tools/src/rust_ast.rs similarity index 100% rename from tasks/ast_codegen/src/rust_ast.rs rename to tasks/ast_tools/src/rust_ast.rs diff --git a/tasks/ast_codegen/src/schema/defs.rs b/tasks/ast_tools/src/schema/defs.rs similarity index 100% rename from tasks/ast_codegen/src/schema/defs.rs rename to tasks/ast_tools/src/schema/defs.rs diff --git a/tasks/ast_codegen/src/schema/get_generics.rs b/tasks/ast_tools/src/schema/get_generics.rs similarity index 100% rename from tasks/ast_codegen/src/schema/get_generics.rs rename to tasks/ast_tools/src/schema/get_generics.rs diff --git a/tasks/ast_codegen/src/schema/get_ident.rs b/tasks/ast_tools/src/schema/get_ident.rs similarity index 100% rename from tasks/ast_codegen/src/schema/get_ident.rs rename to tasks/ast_tools/src/schema/get_ident.rs diff --git a/tasks/ast_codegen/src/schema/mod.rs b/tasks/ast_tools/src/schema/mod.rs similarity index 100% rename from tasks/ast_codegen/src/schema/mod.rs rename to tasks/ast_tools/src/schema/mod.rs diff --git a/tasks/ast_codegen/src/schema/to_type.rs b/tasks/ast_tools/src/schema/to_type.rs similarity index 100% rename from tasks/ast_codegen/src/schema/to_type.rs rename to tasks/ast_tools/src/schema/to_type.rs diff --git a/tasks/ast_codegen/src/util.rs b/tasks/ast_tools/src/util.rs similarity index 100% rename from tasks/ast_codegen/src/util.rs rename to tasks/ast_tools/src/util.rs