forked from M-Labs/nac3
nac3artiq: detect decorators with arguments
This commit is contained in:
parent
7204513a9f
commit
987d17b5e8
@ -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
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user