diff --git a/crates/oxc/src/compiler.rs b/crates/oxc/src/compiler.rs index 12b0ed6e4ace2..baab56947e29a 100644 --- a/crates/oxc/src/compiler.rs +++ b/crates/oxc/src/compiler.rs @@ -2,7 +2,7 @@ use std::{mem, ops::ControlFlow, path::Path}; use oxc_allocator::Allocator; use oxc_ast::ast::Program; -use oxc_codegen::{CodeGenerator, CodegenOptions, CodegenReturn}; +use oxc_codegen::{Codegen, CodegenOptions, CodegenReturn}; use oxc_diagnostics::OxcDiagnostic; use oxc_isolated_declarations::{IsolatedDeclarations, IsolatedDeclarationsOptions}; use oxc_mangler::{MangleOptions, Mangler}; @@ -294,6 +294,6 @@ pub trait CompilerInterface { if self.enable_sourcemap() { options.source_map_path = Some(source_path.to_path_buf()); } - CodeGenerator::new().with_options(options).with_scoping(scoping).build(program) + Codegen::new().with_options(options).with_scoping(scoping).build(program) } } diff --git a/crates/oxc_codegen/examples/codegen.rs b/crates/oxc_codegen/examples/codegen.rs index 3e7d232f3a091..76f6f6bc920f0 100644 --- a/crates/oxc_codegen/examples/codegen.rs +++ b/crates/oxc_codegen/examples/codegen.rs @@ -2,7 +2,7 @@ use std::path::Path; use oxc_allocator::Allocator; -use oxc_codegen::{CodeGenerator, CodegenOptions}; +use oxc_codegen::{Codegen, CodegenOptions}; use oxc_parser::{ParseOptions, Parser, ParserReturn}; use oxc_span::SourceType; use pico_args::Arguments; @@ -68,7 +68,7 @@ fn parse<'a>( } fn codegen(ret: &ParserReturn<'_>, minify: bool) -> String { - CodeGenerator::new() + Codegen::new() .with_options(CodegenOptions { minify, ..CodegenOptions::default() }) .build(&ret.program) .code diff --git a/crates/oxc_codegen/examples/sourcemap.rs b/crates/oxc_codegen/examples/sourcemap.rs index 802a21d9357b5..51a9b208067da 100644 --- a/crates/oxc_codegen/examples/sourcemap.rs +++ b/crates/oxc_codegen/examples/sourcemap.rs @@ -3,7 +3,7 @@ use std::{env, path::Path}; use base64::{Engine, prelude::BASE64_STANDARD}; use oxc_allocator::Allocator; -use oxc_codegen::{CodeGenerator, CodegenOptions, CodegenReturn}; +use oxc_codegen::{Codegen, CodegenOptions, CodegenReturn}; use oxc_parser::Parser; use oxc_span::SourceType; @@ -27,7 +27,7 @@ fn main() -> std::io::Result<()> { return Ok(()); } - let CodegenReturn { code, map, .. } = CodeGenerator::new() + let CodegenReturn { code, map, .. } = Codegen::new() .with_options(CodegenOptions { source_map_path: Some(path.to_path_buf()), ..CodegenOptions::default() diff --git a/crates/oxc_codegen/src/lib.rs b/crates/oxc_codegen/src/lib.rs index 993c62c769516..2e1e98ebb9950 100644 --- a/crates/oxc_codegen/src/lib.rs +++ b/crates/oxc_codegen/src/lib.rs @@ -38,9 +38,6 @@ pub use crate::{ options::{CodegenOptions, LegalComment}, }; -/// Code generator without whitespace removal. -pub type CodeGenerator<'a> = Codegen<'a>; - /// Output from [`Codegen::build`] #[non_exhaustive] pub struct CodegenReturn { diff --git a/crates/oxc_codegen/tests/integration/main.rs b/crates/oxc_codegen/tests/integration/main.rs index 2469b6f950c42..03da1970a92b3 100644 --- a/crates/oxc_codegen/tests/integration/main.rs +++ b/crates/oxc_codegen/tests/integration/main.rs @@ -6,7 +6,7 @@ pub mod ts; pub mod unit; use oxc_allocator::Allocator; -use oxc_codegen::{CodeGenerator, CodegenOptions, CodegenReturn}; +use oxc_codegen::{Codegen, CodegenOptions, CodegenReturn}; use oxc_parser::Parser; use oxc_span::SourceType; @@ -20,7 +20,7 @@ pub fn codegen_options(source_text: &str, options: &CodegenOptions) -> CodegenRe let ret = Parser::new(&allocator, source_text, source_type).parse(); let mut options = options.clone(); options.single_quote = true; - CodeGenerator::new().with_options(options).build(&ret.program) + Codegen::new().with_options(options).build(&ret.program) } pub fn snapshot(name: &str, cases: &[&str]) { diff --git a/crates/oxc_codegen/tests/integration/tester.rs b/crates/oxc_codegen/tests/integration/tester.rs index 9a22a6a051a7a..55c15089d838f 100644 --- a/crates/oxc_codegen/tests/integration/tester.rs +++ b/crates/oxc_codegen/tests/integration/tester.rs @@ -1,5 +1,5 @@ use oxc_allocator::Allocator; -use oxc_codegen::{CodeGenerator, CodegenOptions}; +use oxc_codegen::{Codegen, CodegenOptions}; use oxc_parser::{ParseOptions, Parser}; use oxc_span::SourceType; @@ -8,7 +8,7 @@ pub fn test_with_parse_options(source_text: &str, expected: &str, parse_options: let allocator = Allocator::default(); let ret = Parser::new(&allocator, source_text, SourceType::tsx()).with_options(parse_options).parse(); - let result = CodeGenerator::new().build(&ret.program).code; + let result = Codegen::new().build(&ret.program).code; assert_eq!(result, expected, "\nfor source: {source_text}"); } @@ -46,7 +46,7 @@ pub fn test_options_with_source_type( ) { let allocator = Allocator::default(); let ret = Parser::new(&allocator, source_text, source_type).parse(); - let result = CodeGenerator::new().with_options(options).build(&ret.program).code; + let result = Codegen::new().with_options(options).build(&ret.program).code; assert_eq!(result, expected, "\nfor source: {source_text:?}"); } @@ -55,7 +55,7 @@ pub fn test_minify(source_text: &str, expected: &str) { let source_type = SourceType::jsx(); let allocator = Allocator::default(); let ret = Parser::new(&allocator, source_text, source_type).parse(); - let result = CodeGenerator::new() + let result = Codegen::new() .with_options(CodegenOptions { minify: true, ..CodegenOptions::default() }) .build(&ret.program) .code; diff --git a/crates/oxc_isolated_declarations/examples/isolated_declarations.rs b/crates/oxc_isolated_declarations/examples/isolated_declarations.rs index a163549b27fe8..05b6826fcb685 100644 --- a/crates/oxc_isolated_declarations/examples/isolated_declarations.rs +++ b/crates/oxc_isolated_declarations/examples/isolated_declarations.rs @@ -2,7 +2,7 @@ use std::{env, path::Path}; use oxc_allocator::Allocator; -use oxc_codegen::CodeGenerator; +use oxc_codegen::Codegen; use oxc_isolated_declarations::{IsolatedDeclarations, IsolatedDeclarationsOptions}; use oxc_parser::Parser; use oxc_span::SourceType; @@ -35,7 +35,7 @@ fn main() -> std::io::Result<()> { let id_ret = IsolatedDeclarations::new(&allocator, IsolatedDeclarationsOptions { strip_internal: true }) .build(&ret.program); - let printed = CodeGenerator::new().build(&id_ret.program).code; + let printed = Codegen::new().build(&id_ret.program).code; println!("Dts Emit:\n"); println!("{printed}\n"); diff --git a/crates/oxc_isolated_declarations/tests/deno/mod.rs b/crates/oxc_isolated_declarations/tests/deno/mod.rs index 992fe918620c5..746b9ea875fbf 100644 --- a/crates/oxc_isolated_declarations/tests/deno/mod.rs +++ b/crates/oxc_isolated_declarations/tests/deno/mod.rs @@ -4,7 +4,7 @@ #[cfg(test)] mod tests { use oxc_allocator::Allocator; - use oxc_codegen::CodeGenerator; + use oxc_codegen::Codegen; use oxc_isolated_declarations::{IsolatedDeclarations, IsolatedDeclarationsOptions}; use oxc_parser::Parser; use oxc_span::SourceType; @@ -18,9 +18,9 @@ mod tests { IsolatedDeclarationsOptions { strip_internal: true }, ) .build(&ret.program); - let actual = CodeGenerator::new().build(&ret.program).code; + let actual = Codegen::new().build(&ret.program).code; let expected_program = Parser::new(&allocator, expected, source_type).parse().program; - let expected = CodeGenerator::new().build(&expected_program).code; + let expected = Codegen::new().build(&expected_program).code; assert_eq!(actual.trim(), expected.trim()); } diff --git a/crates/oxc_linter/src/fixer/mod.rs b/crates/oxc_linter/src/fixer/mod.rs index f87a03b252f82..6cf637180ffe8 100644 --- a/crates/oxc_linter/src/fixer/mod.rs +++ b/crates/oxc_linter/src/fixer/mod.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -use oxc_codegen::{CodeGenerator, CodegenOptions}; +use oxc_codegen::{Codegen, CodegenOptions}; use oxc_diagnostics::OxcDiagnostic; use oxc_span::{GetSpan, Span}; @@ -186,8 +186,8 @@ impl<'c, 'a: 'c> RuleFixer<'c, 'a> { #[expect(clippy::unused_self)] #[must_use] - pub fn codegen(self) -> CodeGenerator<'a> { - CodeGenerator::new() + pub fn codegen(self) -> Codegen<'a> { + Codegen::new() .with_options(CodegenOptions { single_quote: true, ..CodegenOptions::default() }) } diff --git a/crates/oxc_minifier/examples/dce.rs b/crates/oxc_minifier/examples/dce.rs index a9c6b8754bc11..0ca38d05cd02d 100644 --- a/crates/oxc_minifier/examples/dce.rs +++ b/crates/oxc_minifier/examples/dce.rs @@ -2,7 +2,7 @@ use std::path::Path; use oxc_allocator::Allocator; -use oxc_codegen::{CodeGenerator, CodegenOptions}; +use oxc_codegen::{Codegen, CodegenOptions}; use oxc_minifier::{CompressOptions, Compressor}; use oxc_parser::Parser; use oxc_span::SourceType; @@ -41,7 +41,7 @@ fn dce(allocator: &Allocator, source_text: &str, source_type: SourceType, nospac let ret = Parser::new(allocator, source_text, source_type).parse(); let mut program = ret.program; Compressor::new(allocator, CompressOptions::default()).dead_code_elimination(&mut program); - CodeGenerator::new() + Codegen::new() .with_options(CodegenOptions { minify: nospace, ..CodegenOptions::default() }) .build(&program) .code diff --git a/crates/oxc_minifier/examples/mangler.rs b/crates/oxc_minifier/examples/mangler.rs index 232dbbed471d2..772ce49ee6d56 100644 --- a/crates/oxc_minifier/examples/mangler.rs +++ b/crates/oxc_minifier/examples/mangler.rs @@ -2,7 +2,7 @@ use std::path::Path; use oxc_allocator::Allocator; -use oxc_codegen::CodeGenerator; +use oxc_codegen::Codegen; use oxc_mangler::{MangleOptions, MangleOptionsKeepNames, Mangler}; use oxc_parser::Parser; use oxc_span::SourceType; @@ -45,5 +45,5 @@ fn mangler(source_text: &str, source_type: SourceType, options: MangleOptions) - let allocator = Allocator::default(); let ret = Parser::new(&allocator, source_text, source_type).parse(); let symbol_table = Mangler::new().with_options(options).build(&ret.program); - CodeGenerator::new().with_scoping(Some(symbol_table)).build(&ret.program).code + Codegen::new().with_scoping(Some(symbol_table)).build(&ret.program).code } diff --git a/crates/oxc_minifier/examples/minifier.rs b/crates/oxc_minifier/examples/minifier.rs index 6908f1a1b5976..36e6f5e753b0c 100644 --- a/crates/oxc_minifier/examples/minifier.rs +++ b/crates/oxc_minifier/examples/minifier.rs @@ -2,7 +2,7 @@ use std::path::Path; use oxc_allocator::Allocator; -use oxc_codegen::{CodeGenerator, CodegenOptions}; +use oxc_codegen::{Codegen, CodegenOptions}; use oxc_mangler::MangleOptions; use oxc_minifier::{CompressOptions, Minifier, MinifierOptions}; use oxc_parser::Parser; @@ -53,7 +53,7 @@ fn minify( compress: Some(CompressOptions::default()), }; let ret = Minifier::new(options).build(allocator, &mut program); - CodeGenerator::new() + Codegen::new() .with_options(CodegenOptions { minify: nospace, ..CodegenOptions::default() }) .with_scoping(ret.scoping) .build(&program) diff --git a/crates/oxc_minifier/src/tester.rs b/crates/oxc_minifier/src/tester.rs index 8e2599770cd16..e7551f3f82f5a 100644 --- a/crates/oxc_minifier/src/tester.rs +++ b/crates/oxc_minifier/src/tester.rs @@ -1,5 +1,5 @@ use oxc_allocator::Allocator; -use oxc_codegen::{CodeGenerator, CodegenOptions}; +use oxc_codegen::{Codegen, CodegenOptions}; use oxc_parser::{ParseOptions, Parser}; use oxc_span::SourceType; @@ -33,7 +33,7 @@ pub fn run(source_text: &str, options: Option) -> String { if let Some(options) = options { Compressor::new(&allocator, options).build(&mut program); } - CodeGenerator::new() + Codegen::new() .with_options(CodegenOptions { single_quote: true, minify: false, diff --git a/crates/oxc_minifier/tests/mangler/mod.rs b/crates/oxc_minifier/tests/mangler/mod.rs index e8ef8bbbd2699..c60acfa5344ab 100644 --- a/crates/oxc_minifier/tests/mangler/mod.rs +++ b/crates/oxc_minifier/tests/mangler/mod.rs @@ -1,7 +1,7 @@ use std::fmt::Write; use oxc_allocator::Allocator; -use oxc_codegen::CodeGenerator; +use oxc_codegen::Codegen; use oxc_mangler::{MangleOptions, MangleOptionsKeepNames, Mangler}; use oxc_parser::Parser; use oxc_span::SourceType; @@ -12,7 +12,7 @@ fn mangle(source_text: &str, options: MangleOptions) -> String { let ret = Parser::new(&allocator, source_text, source_type).parse(); let program = ret.program; let symbol_table = Mangler::new().with_options(options).build(&program); - CodeGenerator::new().with_scoping(Some(symbol_table)).build(&program).code + Codegen::new().with_scoping(Some(symbol_table)).build(&program).code } #[test] diff --git a/crates/oxc_minifier/tests/mod.rs b/crates/oxc_minifier/tests/mod.rs index aca65ee4b6bc8..7c36e68d30677 100644 --- a/crates/oxc_minifier/tests/mod.rs +++ b/crates/oxc_minifier/tests/mod.rs @@ -5,7 +5,7 @@ mod mangler; mod peephole; use oxc_allocator::Allocator; -use oxc_codegen::{CodeGenerator, CodegenOptions}; +use oxc_codegen::{Codegen, CodegenOptions}; use oxc_minifier::{CompressOptions, Compressor}; use oxc_parser::{ParseOptions, Parser}; use oxc_span::SourceType; @@ -43,7 +43,7 @@ pub(crate) fn run( if let Some(options) = options { Compressor::new(&allocator, options).build(&mut program); } - CodeGenerator::new() + Codegen::new() .with_options(CodegenOptions { single_quote: true, ..CodegenOptions::default() }) .build(&program) .code diff --git a/crates/oxc_transformer/examples/transformer.rs b/crates/oxc_transformer/examples/transformer.rs index ce46c11bd5f5b..06f92581c11d5 100644 --- a/crates/oxc_transformer/examples/transformer.rs +++ b/crates/oxc_transformer/examples/transformer.rs @@ -2,7 +2,7 @@ use std::path::Path; use oxc_allocator::Allocator; -use oxc_codegen::CodeGenerator; +use oxc_codegen::Codegen; use oxc_parser::Parser; use oxc_semantic::SemanticBuilder; use oxc_span::SourceType; @@ -85,7 +85,7 @@ fn main() { } } - let printed = CodeGenerator::new().build(&program).code; + let printed = Codegen::new().build(&program).code; println!("Transformed:\n"); println!("{printed}"); } diff --git a/crates/oxc_transformer/tests/integrations/main.rs b/crates/oxc_transformer/tests/integrations/main.rs index b383af58caaf0..067c0eca819e5 100644 --- a/crates/oxc_transformer/tests/integrations/main.rs +++ b/crates/oxc_transformer/tests/integrations/main.rs @@ -4,7 +4,7 @@ mod targets; use std::path::Path; use oxc_allocator::Allocator; -use oxc_codegen::{CodeGenerator, CodegenOptions}; +use oxc_codegen::{Codegen, CodegenOptions}; use oxc_diagnostics::OxcDiagnostic; use oxc_parser::Parser; use oxc_semantic::SemanticBuilder; @@ -14,7 +14,7 @@ use oxc_transformer::{TransformOptions, Transformer}; pub fn codegen(source_text: &str, source_type: SourceType) -> String { let allocator = Allocator::default(); let ret = Parser::new(&allocator, source_text, source_type).parse(); - CodeGenerator::new() + Codegen::new() .with_options(CodegenOptions { single_quote: true, ..CodegenOptions::default() }) .build(&ret.program) .code @@ -34,7 +34,7 @@ pub(crate) fn test( if !ret.errors.is_empty() { return Err(ret.errors); } - let code = CodeGenerator::new() + let code = Codegen::new() .with_options(CodegenOptions { single_quote: true, ..CodegenOptions::default() }) .build(&program) .code; diff --git a/crates/oxc_transformer_plugins/src/module_runner_transform.rs b/crates/oxc_transformer_plugins/src/module_runner_transform.rs index 42dfdbcb723d9..721d0d9b9c9de 100644 --- a/crates/oxc_transformer_plugins/src/module_runner_transform.rs +++ b/crates/oxc_transformer_plugins/src/module_runner_transform.rs @@ -850,7 +850,7 @@ mod test { use similar::TextDiff; use oxc_allocator::Allocator; - use oxc_codegen::{CodeGenerator, CodegenOptions}; + use oxc_codegen::{Codegen, CodegenOptions}; use oxc_diagnostics::OxcDiagnostic; use oxc_parser::Parser; use oxc_semantic::SemanticBuilder; @@ -885,7 +885,7 @@ mod test { if !ret.errors.is_empty() { return Err(ret.errors); } - let code = CodeGenerator::new() + let code = Codegen::new() .with_options(CodegenOptions { comments: false, single_quote: true, @@ -902,7 +902,7 @@ mod test { let allocator = Allocator::default(); let ret = Parser::new(&allocator, source_text, source_type).parse(); - CodeGenerator::new() + Codegen::new() .with_options(CodegenOptions { comments: false, single_quote: true, diff --git a/crates/oxc_transformer_plugins/tests/integrations/inject_global_variables.rs b/crates/oxc_transformer_plugins/tests/integrations/inject_global_variables.rs index 4c9b9209db30f..043f91212cbb2 100644 --- a/crates/oxc_transformer_plugins/tests/integrations/inject_global_variables.rs +++ b/crates/oxc_transformer_plugins/tests/integrations/inject_global_variables.rs @@ -3,7 +3,7 @@ //! * use oxc_allocator::Allocator; -use oxc_codegen::{CodeGenerator, CodegenOptions}; +use oxc_codegen::{Codegen, CodegenOptions}; use oxc_parser::Parser; use oxc_semantic::SemanticBuilder; use oxc_span::SourceType; @@ -19,7 +19,7 @@ fn test(source_text: &str, expected: &str, config: InjectGlobalVariablesConfig) let mut program = ret.program; let scoping = SemanticBuilder::new().build(&program).semantic.into_scoping(); let _ = InjectGlobalVariables::new(&allocator, config).build(scoping, &mut program); - let result = CodeGenerator::new() + let result = Codegen::new() .with_options(CodegenOptions { single_quote: true, ..CodegenOptions::default() }) .build(&program) .code; diff --git a/crates/oxc_transformer_plugins/tests/integrations/main.rs b/crates/oxc_transformer_plugins/tests/integrations/main.rs index 507d2b5b2d6f3..55c259af01acd 100644 --- a/crates/oxc_transformer_plugins/tests/integrations/main.rs +++ b/crates/oxc_transformer_plugins/tests/integrations/main.rs @@ -2,14 +2,14 @@ mod inject_global_variables; mod replace_global_defines; use oxc_allocator::Allocator; -use oxc_codegen::{CodeGenerator, CodegenOptions}; +use oxc_codegen::{Codegen, CodegenOptions}; use oxc_parser::Parser; use oxc_span::SourceType; pub fn codegen(source_text: &str, source_type: SourceType) -> String { let allocator = Allocator::default(); let ret = Parser::new(&allocator, source_text, source_type).parse(); - CodeGenerator::new() + Codegen::new() .with_options(CodegenOptions { single_quote: true, ..CodegenOptions::default() }) .build(&ret.program) .code diff --git a/crates/oxc_transformer_plugins/tests/integrations/replace_global_defines.rs b/crates/oxc_transformer_plugins/tests/integrations/replace_global_defines.rs index 8757f239f3668..046c1cb6ce79b 100644 --- a/crates/oxc_transformer_plugins/tests/integrations/replace_global_defines.rs +++ b/crates/oxc_transformer_plugins/tests/integrations/replace_global_defines.rs @@ -1,5 +1,5 @@ use oxc_allocator::Allocator; -use oxc_codegen::{CodeGenerator, CodegenOptions}; +use oxc_codegen::{Codegen, CodegenOptions}; use oxc_minifier::{CompressOptions, Compressor}; use oxc_parser::Parser; use oxc_semantic::SemanticBuilder; @@ -20,7 +20,7 @@ pub fn test(source_text: &str, expected: &str, config: ReplaceGlobalDefinesConfi let scoping = SemanticBuilder::new().build(&program).semantic.into_scoping(); Compressor::new(&allocator, CompressOptions::default()) .dead_code_elimination_with_scoping(scoping, &mut program); - let result = CodeGenerator::new() + let result = Codegen::new() .with_options(CodegenOptions { single_quote: true, ..CodegenOptions::default() }) .build(&program) .code; @@ -277,7 +277,7 @@ log(__MEMBER__); let mut program = ret.program; let scoping = SemanticBuilder::new().build(&program).semantic.into_scoping(); let _ = ReplaceGlobalDefines::new(&allocator, config).build(scoping, &mut program); - let result = CodeGenerator::new() + let result = Codegen::new() .with_options(CodegenOptions { single_quote: true, source_map_path: Some(std::path::Path::new(&"test.js.map").to_path_buf()), diff --git a/napi/playground/src/lib.rs b/napi/playground/src/lib.rs index e290138e5c43c..94b067f628404 100644 --- a/napi/playground/src/lib.rs +++ b/napi/playground/src/lib.rs @@ -12,7 +12,7 @@ use oxc::{ allocator::Allocator, ast::ast::Program, ast_visit::Visit, - codegen::{CodeGenerator, CodegenOptions}, + codegen::{Codegen, CodegenOptions}, diagnostics::OxcDiagnostic, isolated_declarations::{IsolatedDeclarations, IsolatedDeclarationsOptions}, minifier::{CompressOptions, MangleOptions, Minifier, MinifierOptions}, @@ -169,7 +169,7 @@ impl Oxc { IsolatedDeclarations::new(&allocator, IsolatedDeclarationsOptions::default()) .build(&program); if ret.errors.is_empty() { - let codegen_result = CodeGenerator::new() + let codegen_result = Codegen::new() .with_options(CodegenOptions { source_map_path: codegen_options .enable_sourcemap @@ -228,7 +228,7 @@ impl Oxc { None }; - let codegen_result = CodeGenerator::new() + let codegen_result = Codegen::new() .with_scoping(symbol_table) .with_options(CodegenOptions { minify: minifier_options.whitespace.unwrap_or_default(), diff --git a/napi/transform/src/isolated_declaration.rs b/napi/transform/src/isolated_declaration.rs index 36c59806f4e37..afee3b10d7a48 100644 --- a/napi/transform/src/isolated_declaration.rs +++ b/napi/transform/src/isolated_declaration.rs @@ -4,7 +4,7 @@ use napi_derive::napi; use oxc::{ allocator::Allocator, - codegen::{CodeGenerator, CodegenOptions}, + codegen::{Codegen, CodegenOptions}, isolated_declarations::IsolatedDeclarations, parser::Parser, span::SourceType, @@ -66,7 +66,7 @@ pub fn isolated_declaration( Some(true) => Some(source_path.to_path_buf()), _ => None, }; - let codegen_ret = CodeGenerator::new() + let codegen_ret = Codegen::new() .with_options(CodegenOptions { source_map_path, ..CodegenOptions::default() }) .build(&transformed_ret.program); diff --git a/napi/transform/src/transformer.rs b/napi/transform/src/transformer.rs index a93f043eac218..21f16d6eff02c 100644 --- a/napi/transform/src/transformer.rs +++ b/napi/transform/src/transformer.rs @@ -13,7 +13,7 @@ use rustc_hash::FxHashMap; use oxc::{ CompilerInterface, allocator::Allocator, - codegen::{CodeGenerator, CodegenOptions, CodegenReturn}, + codegen::{Codegen, CodegenOptions, CodegenReturn}, diagnostics::OxcDiagnostic, parser::Parser, semantic::{SemanticBuilder, SemanticBuilderReturn}, @@ -888,7 +888,7 @@ pub fn module_runner_transform( let (deps, dynamic_deps) = ModuleRunnerTransform::default().transform(&allocator, &mut program, scoping); - let CodegenReturn { code, map, .. } = CodeGenerator::new() + let CodegenReturn { code, map, .. } = Codegen::new() .with_options(CodegenOptions { source_map_path: options.and_then(|opts| { opts.sourcemap.as_ref().and_then(|s| s.then(|| file_path.to_path_buf())) diff --git a/tasks/benchmark/benches/codegen.rs b/tasks/benchmark/benches/codegen.rs index f7fd8cc6bdcfe..ff630cae688ba 100644 --- a/tasks/benchmark/benches/codegen.rs +++ b/tasks/benchmark/benches/codegen.rs @@ -2,7 +2,7 @@ use std::path::{Path, PathBuf}; use oxc_allocator::Allocator; use oxc_benchmark::{BenchmarkId, Criterion, criterion_group, criterion_main}; -use oxc_codegen::{CodeGenerator, CodegenOptions}; +use oxc_codegen::{Codegen, CodegenOptions}; use oxc_parser::Parser; use oxc_semantic::SemanticBuilder; use oxc_span::SourceType; @@ -23,7 +23,7 @@ fn bench_codegen(criterion: &mut Criterion) { let mut group = criterion.benchmark_group("codegen"); group.bench_function(id.clone(), |b| { - b.iter_with_large_drop(|| CodeGenerator::new().build(&program).map); + b.iter_with_large_drop(|| Codegen::new().build(&program).map); }); group.finish(); @@ -39,7 +39,7 @@ fn bench_codegen(criterion: &mut Criterion) { let mut group = criterion.benchmark_group("codegen_sourcemap"); group.bench_function(id, |b| { b.iter_with_large_drop(|| { - CodeGenerator::new() + Codegen::new() .with_options(CodegenOptions { source_map_path: Some(PathBuf::from(&file.file_name)), ..CodegenOptions::default() diff --git a/tasks/coverage/src/runtime/mod.rs b/tasks/coverage/src/runtime/mod.rs index b4636f39fa00f..2d6965c22db5e 100644 --- a/tasks/coverage/src/runtime/mod.rs +++ b/tasks/coverage/src/runtime/mod.rs @@ -4,7 +4,7 @@ use serde_json::json; use oxc::{ allocator::Allocator, - codegen::{CodeGenerator, CodegenOptions}, + codegen::{Codegen, CodegenOptions}, minifier::{Minifier, MinifierOptions}, parser::Parser, semantic::SemanticBuilder, @@ -200,7 +200,7 @@ impl Test262RuntimeCase { None }; - let mut text = CodeGenerator::new() + let mut text = Codegen::new() .with_options(CodegenOptions { minify, ..CodegenOptions::default() }) .with_scoping(symbol_table) .build(&program) diff --git a/tasks/coverage/src/typescript/meta.rs b/tasks/coverage/src/typescript/meta.rs index 5c6d1d8a19eb8..065099298defd 100644 --- a/tasks/coverage/src/typescript/meta.rs +++ b/tasks/coverage/src/typescript/meta.rs @@ -7,7 +7,7 @@ use rustc_hash::FxHashMap; use oxc::{ allocator::Allocator, - codegen::CodeGenerator, + codegen::Codegen, diagnostics::{NamedSource, OxcDiagnostic}, parser::Parser, span::SourceType, @@ -201,7 +201,7 @@ impl Baseline { let allocator = Allocator::default(); let source_type = SourceType::from_path(Path::new(&self.name)).unwrap(); let ret = Parser::new(&allocator, &self.original, source_type).parse(); - let printed = CodeGenerator::new().build(&ret.program).code; + let printed = Codegen::new().build(&ret.program).code; self.oxc_printed = printed; } diff --git a/tasks/coverage/src/typescript/transpile_runner.rs b/tasks/coverage/src/typescript/transpile_runner.rs index 398d0dcc634e3..2f051650d8c98 100644 --- a/tasks/coverage/src/typescript/transpile_runner.rs +++ b/tasks/coverage/src/typescript/transpile_runner.rs @@ -4,7 +4,7 @@ use std::path::{Path, PathBuf}; use oxc::{ allocator::Allocator, - codegen::CodeGenerator, + codegen::Codegen, diagnostics::OxcDiagnostic, isolated_declarations::{IsolatedDeclarations, IsolatedDeclarationsOptions}, parser::Parser, @@ -181,6 +181,6 @@ fn transpile(path: &Path, source_text: &str) -> (String, Vec) { let ret = IsolatedDeclarations::new(&allocator, IsolatedDeclarationsOptions { strip_internal: true }) .build(&ret.program); - let printed = CodeGenerator::new().build(&ret.program).code; + let printed = Codegen::new().build(&ret.program).code; (printed, ret.errors) } diff --git a/tasks/minsize/src/lib.rs b/tasks/minsize/src/lib.rs index cd0b0b77d5a41..b88ea72ca7543 100644 --- a/tasks/minsize/src/lib.rs +++ b/tasks/minsize/src/lib.rs @@ -11,7 +11,7 @@ use cow_utils::CowUtils; use flate2::{Compression, write::GzEncoder}; use humansize::{DECIMAL, format_size}; use oxc_allocator::Allocator; -use oxc_codegen::{CodeGenerator, CodegenOptions}; +use oxc_codegen::{Codegen, CodegenOptions}; use oxc_minifier::{Minifier, MinifierOptions}; use oxc_parser::Parser; use oxc_semantic::SemanticBuilder; @@ -149,7 +149,7 @@ fn minify(source_text: &str, source_type: SourceType) -> String { ) .build(scoping, &mut program); let ret = Minifier::new(MinifierOptions::default()).build(&allocator, &mut program); - CodeGenerator::new() + Codegen::new() .with_options(CodegenOptions { minify: true, comments: false, ..CodegenOptions::default() }) .with_scoping(ret.scoping) .build(&program) diff --git a/tasks/transform_conformance/src/test_case.rs b/tasks/transform_conformance/src/test_case.rs index fa4bbbc833d3e..d4bad7884d0fe 100644 --- a/tasks/transform_conformance/src/test_case.rs +++ b/tasks/transform_conformance/src/test_case.rs @@ -8,7 +8,7 @@ use similar::TextDiff; use oxc::{ allocator::Allocator, - codegen::{CodeGenerator, CodegenOptions}, + codegen::{Codegen, CodegenOptions}, diagnostics::{NamedSource, OxcDiagnostic}, parser::{ParseOptions, Parser}, span::{SourceType, VALID_EXTENSIONS}, @@ -325,7 +325,7 @@ impl TestCase { // Clear comments to avoid pure annotation comments that cause mismatch. ret.program.comments.clear(); - CodeGenerator::new() + Codegen::new() .with_options(CodegenOptions { comments: false, // Disable pure annotation comments for async_to_generator plugin,