mirror of
https://github.com/swc-project/swc.git
synced 2024-12-30 00:52:29 +03:00
6896a83d54
swc_ecma_codegen: - Emit pending semi on `~`. (#2091)
25 lines
513 B
Markdown
25 lines
513 B
Markdown
Visitor pattern implementation for Babel AST.
|
|
|
|
### Example
|
|
|
|
```rust
|
|
// 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);
|
|
```
|
|
|