Refactor range from Attributed to Nodes (#4422)

This commit is contained in:
Micha Reiser 2023-05-16 08:36:32 +02:00 committed by GitHub
parent 140e0acf54
commit fa26860296
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
330 changed files with 4816 additions and 3946 deletions

View file

@ -1,12 +1,12 @@
use rustpython_parser::ast::{self, Expr, ExprKind};
use rustpython_parser::ast::{self, Expr};
use smallvec::smallvec;
/// A representation of a qualified name, like `typing.List`.
pub type CallPath<'a> = smallvec::SmallVec<[&'a str; 8]>;
fn collect_call_path_inner<'a>(expr: &'a Expr, parts: &mut CallPath<'a>) -> bool {
match &expr.node {
ExprKind::Attribute(ast::ExprAttribute { value, attr, .. }) => {
match expr {
Expr::Attribute(ast::ExprAttribute { value, attr, .. }) => {
if collect_call_path_inner(value, parts) {
parts.push(attr.as_str());
true
@ -14,7 +14,7 @@ fn collect_call_path_inner<'a>(expr: &'a Expr, parts: &mut CallPath<'a>) -> bool
false
}
}
ExprKind::Name(ast::ExprName { id, .. }) => {
Expr::Name(ast::ExprName { id, .. }) => {
parts.push(id.as_str());
true
}