mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-24 04:14:44 +00:00
Create PreorderVisitor
trait (#4658)
This commit is contained in:
parent
52deeb36ee
commit
33a7ed058f
12 changed files with 1301 additions and 1 deletions
|
@ -1,14 +1,19 @@
|
|||
//! AST visitor trait and walk functions.
|
||||
|
||||
pub mod preorder;
|
||||
|
||||
use rustpython_parser::ast::{
|
||||
self, Alias, Arg, Arguments, Boolop, Cmpop, Comprehension, Constant, Excepthandler, Expr,
|
||||
ExprContext, Keyword, MatchCase, Operator, Pattern, Stmt, Unaryop, Withitem,
|
||||
};
|
||||
|
||||
/// A trait for AST visitors. Visits all nodes in the AST recursively.
|
||||
/// A trait for AST visitors. Visits all nodes in the AST recursively in evaluation-order.
|
||||
///
|
||||
/// Prefer [`crate::statement_visitor::StatementVisitor`] for visitors that only need to visit
|
||||
/// statements.
|
||||
///
|
||||
/// Use the [`PreorderVisitor`](self::preorder::PreorderVisitor) if you want to visit the nodes
|
||||
/// in pre-order rather than evaluation order.
|
||||
pub trait Visitor<'a> {
|
||||
fn visit_stmt(&mut self, stmt: &'a Stmt) {
|
||||
walk_stmt(self, stmt);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue