pub struct Visitor<M, A = PreOrder> { /* private fields */ }Expand description
Configurable tree visitor that combines traversal algorithms with pattern matching.
Visitor allows you to traverse an AST while filtering nodes based on patterns.
It supports different traversal algorithms and provides fine-grained control
over matching behavior through reentrancy and node type filtering.
§Type Parameters
M: Matcher- The pattern matcher to filter nodesA- The traversal algorithm (defaults toPreOrder)
§Example
let ast = Tsx.ast_grep("let x = foo(); let y = bar();");
let root = ast.root();
// Find all identifiers, visiting only named nodes
let identifiers: Vec<_> = Visitor::new("$ID")
.named_only(true)
.reentrant(false)
.visit(root)
.collect();Implementations§
Auto Trait Implementations§
impl<M, A> Freeze for Visitor<M, A>where
M: Freeze,
impl<M, A> RefUnwindSafe for Visitor<M, A>where
M: RefUnwindSafe,
A: RefUnwindSafe,
impl<M, A> Send for Visitor<M, A>
impl<M, A> Sync for Visitor<M, A>
impl<M, A> Unpin for Visitor<M, A>
impl<M, A> UnsafeUnpin for Visitor<M, A>where
M: UnsafeUnpin,
impl<M, A> UnwindSafe for Visitor<M, A>where
M: UnwindSafe,
A: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more