pub trait Visitor<'ast> {
Show 23 methods
// Provided methods
fn traverse_function_bodies(&self) -> bool { ... }
fn enter_function_declaration(
&mut self,
_node: &'ast FunctionDeclaration,
_scope_stack: &[ScopeId],
) { ... }
fn leave_function_declaration(
&mut self,
_node: &'ast FunctionDeclaration,
_scope_stack: &[ScopeId],
) { ... }
fn enter_function_expression(
&mut self,
_node: &'ast FunctionExpression,
_scope_stack: &[ScopeId],
) { ... }
fn leave_function_expression(
&mut self,
_node: &'ast FunctionExpression,
_scope_stack: &[ScopeId],
) { ... }
fn enter_arrow_function_expression(
&mut self,
_node: &'ast ArrowFunctionExpression,
_scope_stack: &[ScopeId],
) { ... }
fn leave_arrow_function_expression(
&mut self,
_node: &'ast ArrowFunctionExpression,
_scope_stack: &[ScopeId],
) { ... }
fn enter_class_declaration(
&mut self,
_node: &'ast ClassDeclaration,
_scope_stack: &[ScopeId],
) { ... }
fn enter_class_expression(
&mut self,
_node: &'ast ClassExpression,
_scope_stack: &[ScopeId],
) { ... }
fn enter_object_method(
&mut self,
_node: &'ast ObjectMethod,
_scope_stack: &[ScopeId],
) { ... }
fn leave_object_method(
&mut self,
_node: &'ast ObjectMethod,
_scope_stack: &[ScopeId],
) { ... }
fn enter_assignment_expression(
&mut self,
_node: &'ast AssignmentExpression,
_scope_stack: &[ScopeId],
) { ... }
fn enter_update_expression(
&mut self,
_node: &'ast UpdateExpression,
_scope_stack: &[ScopeId],
) { ... }
fn enter_identifier(
&mut self,
_node: &'ast Identifier,
_scope_stack: &[ScopeId],
) { ... }
fn enter_jsx_identifier(
&mut self,
_node: &'ast JSXIdentifier,
_scope_stack: &[ScopeId],
) { ... }
fn enter_jsx_opening_element(
&mut self,
_node: &'ast JSXOpeningElement,
_scope_stack: &[ScopeId],
) { ... }
fn leave_jsx_opening_element(
&mut self,
_node: &'ast JSXOpeningElement,
_scope_stack: &[ScopeId],
) { ... }
fn enter_variable_declarator(
&mut self,
_node: &'ast VariableDeclarator,
_scope_stack: &[ScopeId],
) { ... }
fn leave_variable_declarator(
&mut self,
_node: &'ast VariableDeclarator,
_scope_stack: &[ScopeId],
) { ... }
fn enter_call_expression(
&mut self,
_node: &'ast CallExpression,
_scope_stack: &[ScopeId],
) { ... }
fn leave_call_expression(
&mut self,
_node: &'ast CallExpression,
_scope_stack: &[ScopeId],
) { ... }
fn enter_loop_expression(&mut self) { ... }
fn leave_loop_expression(&mut self) { ... }
}Expand description
Trait for visiting Babel AST nodes. All methods default to no-ops. Override specific methods to intercept nodes of interest.
The 'ast lifetime ties visitor hooks to the AST being walked, allowing
visitors to store references into the AST (e.g., for deferred processing).
The scope_stack parameter provides the current scope context during traversal.
The active scope is scope_stack.last().
Provided Methods§
Sourcefn traverse_function_bodies(&self) -> bool
fn traverse_function_bodies(&self) -> bool
Controls whether the walker recurses into function/arrow/method bodies.
Returns true by default. Override to false to skip function bodies
(similar to Babel’s path.skip() in traverse visitors).
When false, the walker still calls enter_* / leave_* for functions
but does not walk their params or body.
fn enter_function_declaration( &mut self, _node: &'ast FunctionDeclaration, _scope_stack: &[ScopeId], )
fn leave_function_declaration( &mut self, _node: &'ast FunctionDeclaration, _scope_stack: &[ScopeId], )
fn enter_function_expression( &mut self, _node: &'ast FunctionExpression, _scope_stack: &[ScopeId], )
fn leave_function_expression( &mut self, _node: &'ast FunctionExpression, _scope_stack: &[ScopeId], )
fn enter_arrow_function_expression( &mut self, _node: &'ast ArrowFunctionExpression, _scope_stack: &[ScopeId], )
fn leave_arrow_function_expression( &mut self, _node: &'ast ArrowFunctionExpression, _scope_stack: &[ScopeId], )
fn enter_class_declaration( &mut self, _node: &'ast ClassDeclaration, _scope_stack: &[ScopeId], )
fn enter_class_expression( &mut self, _node: &'ast ClassExpression, _scope_stack: &[ScopeId], )
fn enter_object_method( &mut self, _node: &'ast ObjectMethod, _scope_stack: &[ScopeId], )
fn leave_object_method( &mut self, _node: &'ast ObjectMethod, _scope_stack: &[ScopeId], )
fn enter_assignment_expression( &mut self, _node: &'ast AssignmentExpression, _scope_stack: &[ScopeId], )
fn enter_update_expression( &mut self, _node: &'ast UpdateExpression, _scope_stack: &[ScopeId], )
fn enter_identifier( &mut self, _node: &'ast Identifier, _scope_stack: &[ScopeId], )
fn enter_jsx_identifier( &mut self, _node: &'ast JSXIdentifier, _scope_stack: &[ScopeId], )
fn enter_jsx_opening_element( &mut self, _node: &'ast JSXOpeningElement, _scope_stack: &[ScopeId], )
fn leave_jsx_opening_element( &mut self, _node: &'ast JSXOpeningElement, _scope_stack: &[ScopeId], )
fn enter_variable_declarator( &mut self, _node: &'ast VariableDeclarator, _scope_stack: &[ScopeId], )
fn leave_variable_declarator( &mut self, _node: &'ast VariableDeclarator, _scope_stack: &[ScopeId], )
fn enter_call_expression( &mut self, _node: &'ast CallExpression, _scope_stack: &[ScopeId], )
fn leave_call_expression( &mut self, _node: &'ast CallExpression, _scope_stack: &[ScopeId], )
Sourcefn enter_loop_expression(&mut self)
fn enter_loop_expression(&mut self)
Called when the walker enters a loop expression context (while.test, do-while.test, for-in.right, for-of.right). Functions found in these positions are treated as non-program-scope by Babel, even though the walker doesn’t push a scope for them.
fn leave_loop_expression(&mut self)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".