Skip to content

Commit

Permalink
refactor(traverse): move generated files into separate folder
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Aug 23, 2024
1 parent 76c66b4 commit 02529cf
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
6 changes: 4 additions & 2 deletions crates/oxc_traverse/scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ import generateWalkFunctionsCode from './lib/walk.mjs';

const execAsync = promisify(exec);

const PREAMBLE = '// Generated by `scripts/build.mjs`.\n\n';
const PREAMBLE = '// Auto-generated code, DO NOT EDIT DIRECTLY!\n'
+ '// Generated by `oxc_traverse/scripts/build.mjs`.\n'
+ '// To alter this generated file you have to edit the codegen.\n\n';

const types = await getTypesFromCode();

const outputDirPath = pathJoin(fileURLToPath(import.meta.url), '../../src');
const outputDirPath = pathJoin(fileURLToPath(import.meta.url), '../../src/generated');
await writeToFile('traverse.rs', generateTraverseTraitCode(types));
await writeToFile('ancestor.rs', generateAncestorsCode(types));
await writeToFile('walk.rs', generateWalkFunctionsCode(types));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Generated by `scripts/build.mjs`.
// Auto-generated code, DO NOT EDIT DIRECTLY!
// Generated by `oxc_traverse/scripts/build.mjs`.
// To alter this generated file you have to edit the codegen.

#![allow(
unsafe_code,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Generated by `scripts/build.mjs`.
// Auto-generated code, DO NOT EDIT DIRECTLY!
// Generated by `oxc_traverse/scripts/build.mjs`.
// To alter this generated file you have to edit the codegen.

use oxc_allocator::Vec;
#[allow(clippy::wildcard_imports)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Generated by `scripts/build.mjs`.
// Auto-generated code, DO NOT EDIT DIRECTLY!
// Generated by `oxc_traverse/scripts/build.mjs`.
// To alter this generated file you have to edit the codegen.

#![allow(
unsafe_code,
Expand Down
16 changes: 10 additions & 6 deletions crates/oxc_traverse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,18 @@ use oxc_allocator::Allocator;
use oxc_ast::ast::Program;
use oxc_semantic::{ScopeTree, SymbolTable};

pub mod ancestor;
pub use ancestor::Ancestor;
mod context;
pub use context::{TraverseAncestry, TraverseCtx, TraverseScoping};
#[allow(clippy::module_inception)]
mod traverse;
pub use traverse::Traverse;
mod walk;

mod generated {
pub mod ancestor;
pub mod traverse;
pub(super) mod walk;
}
pub use generated::ancestor;
pub use generated::ancestor::Ancestor;
pub use generated::traverse::Traverse;
use generated::walk;

mod compile_fail_tests;

Expand Down

0 comments on commit 02529cf

Please sign in to comment.