Add a specialized StatementVisitor (#4349)

This commit is contained in:
Charlie Marsh 2023-05-10 12:42:20 -04:00 committed by GitHub
parent 6532455672
commit fd34797d0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 167 additions and 121 deletions

View file

@ -1,9 +1,15 @@
//! AST visitor trait and walk functions.
use rustpython_parser::ast::{
Alias, Arg, Arguments, Boolop, Cmpop, Comprehension, Constant, Excepthandler,
ExcepthandlerKind, Expr, ExprContext, ExprKind, Keyword, MatchCase, Operator, Pattern,
PatternKind, Stmt, StmtKind, Unaryop, Withitem,
};
/// A trait for AST visitors. Visits all nodes in the AST recursively.
///
/// Prefer [`crate::statement_visitor::StatementVisitor`] for visitors that only need to visit
/// statements.
pub trait Visitor<'a> {
fn visit_stmt(&mut self, stmt: &'a Stmt) {
walk_stmt(self, stmt);