refactor(transformer): re-order fields of Common and TransformCtx (#6562)

Follow-on after #6162.

Tiny refactor. Put `HelperLoader` first, so order of fields is same order the common transforms run in.
This commit is contained in:
overlookmotel 2024-10-14 20:22:16 +00:00
parent 06b09b2022
commit 602df9df63
2 changed files with 5 additions and 5 deletions

View file

@ -17,19 +17,19 @@ use top_level_statements::TopLevelStatements;
use var_declarations::VarDeclarations;
pub struct Common<'a, 'ctx> {
helper_loader: HelperLoader<'a, 'ctx>,
module_imports: ModuleImports<'a, 'ctx>,
var_declarations: VarDeclarations<'a, 'ctx>,
top_level_statements: TopLevelStatements<'a, 'ctx>,
helper_loader: HelperLoader<'a, 'ctx>,
}
impl<'a, 'ctx> Common<'a, 'ctx> {
pub fn new(ctx: &'ctx TransformCtx<'a>) -> Self {
Self {
helper_loader: HelperLoader::new(ctx),
module_imports: ModuleImports::new(ctx),
var_declarations: VarDeclarations::new(ctx),
top_level_statements: TopLevelStatements::new(ctx),
helper_loader: HelperLoader::new(ctx),
}
}
}

View file

@ -29,14 +29,14 @@ pub struct TransformCtx<'a> {
pub source_text: &'a str,
// Helpers
/// Manage helper loading
pub helper_loader: HelperLoaderStore<'a>,
/// Manage import statement globally
pub module_imports: ModuleImportsStore<'a>,
/// Manage inserting `var` statements globally
pub var_declarations: VarDeclarationsStore<'a>,
/// Manage inserting statements at top of program globally
pub top_level_statements: TopLevelStatementsStore<'a>,
/// Manage helper loading
pub helper_loader: HelperLoaderStore<'a>,
}
impl<'a> TransformCtx<'a> {
@ -55,10 +55,10 @@ impl<'a> TransformCtx<'a> {
source_path,
source_type: SourceType::default(),
source_text: "",
helper_loader: HelperLoaderStore::new(&options.helper_loader),
module_imports: ModuleImportsStore::new(),
var_declarations: VarDeclarationsStore::new(),
top_level_statements: TopLevelStatementsStore::new(),
helper_loader: HelperLoaderStore::new(&options.helper_loader),
}
}