Crates.io | swc_babel_visit |
lib.rs | swc_babel_visit |
version | 0.1.0 |
source | src |
created_at | 2021-11-22 12:41:33.031949 |
updated_at | 2021-11-22 12:41:33.031949 |
description | Visitor implementation for babel nodes |
homepage | |
repository | https://github.com/swc-project/swc.git |
max_upload_size | |
id | 485672 |
size | 70,671 |
Visitor pattern implementation for Babel AST.
// Visit all Identifier nodes in the Babel AST and change the optional field to
// Some(true) for each of them.
use swc_babel_visit::{VisitMut, VisitMutWith};
use swc_babel_ast::{Identifier, File};
struct Visitor;
impl VisitMut for Visitor {
fn visit_mut_identifier(&mut self, node: &mut Identifier) {
node.optional = Some(true);
}
}
let ast: File = get_babel_ast();
let mut v = Visitor {};
ast.visit_mut_with(&mut v);