Re-integrate RustPython parser repository (#4359)

Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
Jeong, YunWon 2023-05-11 16:47:17 +09:00 committed by GitHub
parent 865205d992
commit be6e00ef6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
270 changed files with 3061 additions and 3361 deletions

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{Expr, ExprKind};
use rustpython_parser::ast::{self, Expr, ExprKind};
use smallvec::smallvec;
/// A representation of a qualified name, like `typing.List`.
@ -6,16 +6,16 @@ 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 { value, attr, .. } => {
ExprKind::Attribute(ast::ExprAttribute { value, attr, .. }) => {
if collect_call_path_inner(value, parts) {
parts.push(attr);
parts.push(attr.as_str());
true
} else {
false
}
}
ExprKind::Name { id, .. } => {
parts.push(id);
ExprKind::Name(ast::ExprName { id, .. }) => {
parts.push(id.as_str());
true
}
_ => false,