Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(ast_codegen): list input files explicitly #4708

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 16 additions & 29 deletions tasks/ast_codegen/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
const AST_CRATE: &str = "crates/oxc_ast";
const AST_SYNTAX: &str = "crates/oxc_syntax";
const AST_SPAN: &str = "crates/oxc_span";
#[allow(dead_code)]
const AST_MACROS_CRATE: &str = "crates/oxc_ast_macros";

mod fmt;
mod generators;
mod layout;
Expand Down Expand Up @@ -32,6 +26,21 @@ use util::{write_all_to, NormalizeError};

use crate::generators::ImplGetSpanGenerator;

static SOURCE_PATHS: &[&str] = &[
"oxc_ast/src/ast/literal.rs",
"oxc_ast/src/ast/js.rs",
"oxc_ast/src/ast/ts.rs",
"oxc_ast/src/ast/jsx.rs",
"oxc_syntax/src/number.rs",
"oxc_syntax/src/operator.rs",
"oxc_span/src/span/types.rs",
"oxc_span/src/source_type/types.rs",
];

const AST_CRATE: &str = "crates/oxc_ast";
#[allow(dead_code)]
const AST_MACROS_CRATE: &str = "crates/oxc_ast_macros";

type Result<R> = std::result::Result<R, String>;
type TypeId = usize;
type TypeTable = Vec<AstRef>;
Expand Down Expand Up @@ -245,29 +254,7 @@ impl AstCodegen {
}

fn files() -> impl std::iter::Iterator<Item = String> {
fn ast(path: &str) -> String {
format!("{AST_CRATE}/src/ast/{path}.rs")
}

fn syntax(path: &str) -> String {
format!("{AST_SYNTAX}/src/{path}.rs")
}

fn span(path: &str) -> String {
format!("{AST_SPAN}/src/{path}.rs")
}

vec![
ast("literal"),
ast("js"),
ast("ts"),
ast("jsx"),
syntax("number"),
syntax("operator"),
span("span/types"),
span("source_type/types"),
]
.into_iter()
SOURCE_PATHS.iter().map(|path| format!("crates/{path}"))
}

fn write_generated_streams(
Expand Down