1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use swc_ecma_ast::*;
use swc_ecma_visit::{Visit, VisitWith};
pub trait Check: Visit + Default {
fn should_handle(&self) -> bool;
}
pub fn should_work<C, T>(n: &T) -> bool
where
C: Check,
T: VisitWith<C>,
{
let mut checker = C::default();
n.visit_with(&mut checker);
checker.should_handle()
}
pub trait Parallel {
fn create(&self) -> Self;
fn merge(&mut self, other: Self);
fn after_stmts(&mut self, _stmts: &mut Vec<Stmt>) {}
fn after_module_items(&mut self, _stmts: &mut Vec<ModuleItem>) {}
}
pub trait ParExplode: Parallel {
fn after_one_stmt(&mut self, stmts: &mut Vec<Stmt>);
fn after_one_module_item(&mut self, stmts: &mut Vec<ModuleItem>);
}