mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
refactor(transformer/es2019): move all entry points to implementation of Traverse trait (#5065)
follow-up #4881
This commit is contained in:
parent
d50eb72399
commit
deda6ac136
3 changed files with 10 additions and 10 deletions
|
|
@ -4,7 +4,7 @@ mod options;
|
|||
pub use optional_catch_binding::OptionalCatchBinding;
|
||||
pub use options::ES2019Options;
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_traverse::TraverseCtx;
|
||||
use oxc_traverse::{Traverse, TraverseCtx};
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::context::Ctx;
|
||||
|
|
@ -22,14 +22,12 @@ impl<'a> ES2019<'a> {
|
|||
pub fn new(options: ES2019Options, ctx: Ctx<'a>) -> Self {
|
||||
Self { optional_catch_binding: OptionalCatchBinding::new(Rc::clone(&ctx)), ctx, options }
|
||||
}
|
||||
}
|
||||
|
||||
pub fn transform_catch_clause(
|
||||
&mut self,
|
||||
clause: &mut CatchClause<'a>,
|
||||
ctx: &mut TraverseCtx<'a>,
|
||||
) {
|
||||
impl<'a> Traverse<'a> for ES2019<'a> {
|
||||
fn enter_catch_clause(&mut self, clause: &mut CatchClause<'a>, ctx: &mut TraverseCtx<'a>) {
|
||||
if self.options.optional_catch_binding {
|
||||
self.optional_catch_binding.transform_catch_clause(clause, ctx);
|
||||
self.optional_catch_binding.enter_catch_clause(clause, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ use std::cell::Cell;
|
|||
use oxc_ast::ast::*;
|
||||
use oxc_semantic::SymbolFlags;
|
||||
use oxc_span::SPAN;
|
||||
use oxc_traverse::TraverseCtx;
|
||||
use oxc_traverse::{Traverse, TraverseCtx};
|
||||
|
||||
use crate::context::Ctx;
|
||||
|
||||
|
|
@ -49,10 +49,12 @@ impl<'a> OptionalCatchBinding<'a> {
|
|||
pub fn new(ctx: Ctx<'a>) -> Self {
|
||||
Self { _ctx: ctx }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Traverse<'a> for OptionalCatchBinding<'a> {
|
||||
/// If CatchClause has no param, add a parameter called `unused`.
|
||||
#[allow(clippy::unused_self)]
|
||||
pub fn transform_catch_clause(&self, clause: &mut CatchClause<'a>, ctx: &mut TraverseCtx<'a>) {
|
||||
fn enter_catch_clause(&mut self, clause: &mut CatchClause<'a>, ctx: &mut TraverseCtx<'a>) {
|
||||
if clause.param.is_some() {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ impl<'a> Traverse<'a> for Transformer<'a> {
|
|||
}
|
||||
|
||||
fn enter_catch_clause(&mut self, clause: &mut CatchClause<'a>, ctx: &mut TraverseCtx<'a>) {
|
||||
self.x2_es2019.transform_catch_clause(clause, ctx);
|
||||
self.x2_es2019.enter_catch_clause(clause, ctx);
|
||||
}
|
||||
|
||||
fn enter_ts_export_assignment(
|
||||
|
|
|
|||
Loading…
Reference in a new issue