mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 13:25:17 +00:00
Refactor range from Attributed
to Node
s (#4422)
This commit is contained in:
parent
140e0acf54
commit
fa26860296
330 changed files with 4816 additions and 3946 deletions
|
@ -1,19 +1,19 @@
|
|||
use rustpython_parser::ast::{self, Expr, Stmt, StmtKind};
|
||||
use rustpython_parser::ast::{self, Expr, Stmt};
|
||||
|
||||
pub fn name(stmt: &Stmt) -> &str {
|
||||
match &stmt.node {
|
||||
StmtKind::FunctionDef(ast::StmtFunctionDef { name, .. })
|
||||
| StmtKind::AsyncFunctionDef(ast::StmtAsyncFunctionDef { name, .. }) => name.as_str(),
|
||||
_ => panic!("Expected StmtKind::FunctionDef | StmtKind::AsyncFunctionDef"),
|
||||
match stmt {
|
||||
Stmt::FunctionDef(ast::StmtFunctionDef { name, .. })
|
||||
| Stmt::AsyncFunctionDef(ast::StmtAsyncFunctionDef { name, .. }) => name.as_str(),
|
||||
_ => panic!("Expected Stmt::FunctionDef | Stmt::AsyncFunctionDef"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn decorator_list(stmt: &Stmt) -> &Vec<Expr> {
|
||||
match &stmt.node {
|
||||
StmtKind::FunctionDef(ast::StmtFunctionDef { decorator_list, .. })
|
||||
| StmtKind::AsyncFunctionDef(ast::StmtAsyncFunctionDef { decorator_list, .. }) => {
|
||||
pub fn decorator_list(stmt: &Stmt) -> &[Expr] {
|
||||
match stmt {
|
||||
Stmt::FunctionDef(ast::StmtFunctionDef { decorator_list, .. })
|
||||
| Stmt::AsyncFunctionDef(ast::StmtAsyncFunctionDef { decorator_list, .. }) => {
|
||||
decorator_list
|
||||
}
|
||||
_ => panic!("Expected StmtKind::FunctionDef | StmtKind::AsyncFunctionDef"),
|
||||
_ => panic!("Expected Stmt::FunctionDef | Stmt::AsyncFunctionDef"),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue