I am trying to follow this SWC documentation for developing a plugin that can compile to wasm. The visit_mut_callee
function has a conditional statement
if let Callee::Expr(expr) = callee {
Callee::Expr(expr)
accepts a Box<Expr>
as per documentation, being new to rust I am unsure of what exactly needs to be passed.
use swc_plugin::*;
struct MatchExample;
impl VisitMut for MatchExample {
fn visit_mut_callee(&mut self, callee: &mut Callee) {
callee.visit_mut_children_with(self);
if let Callee::Expr(expr) = callee {
// expr is `Box<Expr>`
if let Expr::Ident(i) = &mut **expr {
i.sym = "foo".into();
}
}
}
}
Goal
To use the visit_mut_callee
to detect a function expression within a codebase, the expression I would like to detect is getMyFileMetaInfo
.
Example,
<SomeReactComponent metaInfo={getMyFileMetaInfo()} />