Skip to content

Commit

Permalink
refactor(minifier): add NodeUtil trait for accessing symbols on ast…
Browse files Browse the repository at this point in the history
… nodes (#4734)
  • Loading branch information
Boshen committed Aug 8, 2024
1 parent f36500a commit fbfd852
Show file tree
Hide file tree
Showing 11 changed files with 790 additions and 707 deletions.
151 changes: 92 additions & 59 deletions crates/oxc_minifier/src/ast_passes/fold_constants.rs

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions crates/oxc_minifier/src/ast_passes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,21 @@ pub use remove_syntax::RemoveSyntax;
pub use substitute_alternate_syntax::SubstituteAlternateSyntax;

use oxc_ast::ast::Program;
use oxc_semantic::{ScopeTree, SymbolTable};
use oxc_traverse::{walk_program, Traverse, TraverseCtx};

use crate::node_util::NodeUtil;

impl<'a> NodeUtil for TraverseCtx<'a> {
fn symbols(&self) -> &SymbolTable {
self.scoping.symbols()
}

fn scopes(&self) -> &ScopeTree {
self.scoping.scopes()
}
}

pub trait CompressorPass<'a> {
fn build(&mut self, program: &mut Program<'a>, ctx: &mut TraverseCtx<'a>)
where
Expand Down
Loading

0 comments on commit fbfd852

Please sign in to comment.