Skip to content

Commit

Permalink
feat: 支持箭头函数的解析
Browse files Browse the repository at this point in the history
  • Loading branch information
heiazu committed Mar 13, 2024
1 parent 42e66d8 commit 96166e5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,9 @@ impl ModuleMutVisitor {
fn enable_nesting_for_function (&self, body: &mut Box<Function>) {
body.visit_mut_children_with(&mut &mut self.get_nesting_visitor());
}
fn enable_nesting_for_arrow_function (&self, body: &mut Box<BlockStmtOrExpr>) {
body.visit_mut_children_with(&mut &mut self.get_nesting_visitor());
}
}

impl VisitMut for ModuleMutVisitor {
Expand Down Expand Up @@ -614,10 +617,12 @@ impl VisitMut for ModuleMutVisitor {
Some(init) => {
match &mut **init {
Expr::Fn(FnExpr { function, .. }) => {
// const Index = function () {}
self.enable_nesting_for_function(function);
},
Expr::Arrow(ArrowExpr { body, .. }) => {
// Todo: support arrow funciton
// const Index = () => {}
self.enable_nesting_for_arrow_function(body);
},
_ => ()
}
Expand Down

0 comments on commit 96166e5

Please # to comment.