diff --git a/nac3artiq/src/lib.rs b/nac3artiq/src/lib.rs index 93ebbbdc..8803c29d 100644 --- a/nac3artiq/src/lib.rs +++ b/nac3artiq/src/lib.rs @@ -191,14 +191,30 @@ impl Nac3 { }) .unwrap() }); - body.retain(|stmt| { - if let StmtKind::FunctionDef { ref decorator_list, .. } = stmt.node { - decorator_list.iter().any(|decorator| { + body.retain_mut(|stmt| { + if let StmtKind::FunctionDef { ref mut decorator_list, .. } = stmt.node { + decorator_list.iter_mut().any(|decorator| { if let ExprKind::Name { id, .. } = decorator.node { id.to_string() == "kernel" || id.to_string() == "portable" || id.to_string() == "rpc" + } else if let ExprKind::Call { func, .. } = &decorator.node { + // decorators with flags (e.g. rpc async) have Call for the node; + // this is to remove the middle + if let ExprKind::Name { id, .. } = func.node { + if id.to_string() == "rpc" { + println!("found rpc: {:?}", func); + println!("decorator node: {:?}", decorator.node); + decorator.node = func.clone().node; + true } else { + false + } + } else { + false + } + } + else { false } })