forked from M-Labs/nac3
Compare commits
2 Commits
5a5656e983
...
c94f407732
Author | SHA1 | Date | |
---|---|---|---|
c94f407732 | |||
d9ac662787 |
@ -863,14 +863,12 @@ impl Nac3 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the Name.id from a decorator, supports decorators with arguments.
|
|
||||||
fn decorator_id_string(decorator: &Located<ExprKind>) -> Option<String> {
|
fn decorator_id_string(decorator: &Located<ExprKind>) -> Option<String> {
|
||||||
if let ExprKind::Name { id, .. } = decorator.node {
|
if let ExprKind::Name { id, .. } = decorator.node {
|
||||||
// Bare decorator
|
|
||||||
return Some(id.to_string());
|
return Some(id.to_string());
|
||||||
} else if let ExprKind::Call { func, .. } = &decorator.node {
|
} else if let ExprKind::Call { func, .. } = &decorator.node {
|
||||||
// Decorators that are calls (e.g. "@rpc()") have Call for the node,
|
// decorators with flags (e.g. rpc async) have Call for the node,
|
||||||
// need to extract the id from within.
|
// extract the id from within
|
||||||
if let ExprKind::Name { id, .. } = func.node {
|
if let ExprKind::Name { id, .. } = func.node {
|
||||||
return Some(id.to_string());
|
return Some(id.to_string());
|
||||||
}
|
}
|
||||||
@ -878,11 +876,10 @@ fn decorator_id_string(decorator: &Located<ExprKind>) -> Option<String> {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves flags from a decorator, if any.
|
|
||||||
fn decorator_get_flags(decorator: &Located<ExprKind>) -> Vec<Constant> {
|
fn decorator_get_flags(decorator: &Located<ExprKind>) -> Vec<Constant> {
|
||||||
let mut flags = vec![];
|
let mut flags = vec![];
|
||||||
if let ExprKind::Call { keywords, .. } = &decorator.node {
|
if let ExprKind::Call { keywords, .. } = &decorator.node {
|
||||||
for keyword in keywords {
|
for keyword in keywords.iter() {
|
||||||
if keyword.node.arg != Some("flags".into()) {
|
if keyword.node.arg != Some("flags".into()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user