Class: Prism::BasicVisitor
- Inherits:
-
Object
- Object
- Prism::BasicVisitor
- Defined in:
- lib/prism/visitor.rb
Overview
A class that knows how to walk down the tree. None of the individual visit methods are implemented on this visitor, so it forces the consumer to implement each one that they need. For a default implementation that continues walking the tree, see the Visitor class.
Direct Known Subclasses
Instance Method Summary collapse
-
#visit(node) ⇒ Object
Calls
accepton the given node if it is notnil, which in turn should call back into this visitor by calling the appropriatevisit_*method. -
#visit_all(nodes) ⇒ Object
Visits each node in
nodesby callingaccepton each one. -
#visit_child_nodes(node) ⇒ Object
Visits the child nodes of
nodeby callingaccepton each one.
Instance Method Details
#visit(node) ⇒ Object
Calls accept on the given node if it is not nil, which in turn should call back into this visitor by calling the appropriate visit_* method.
17 18 19 20 |
# File 'lib/prism/visitor.rb', line 17 def visit(node) # @type self: _Visitor node&.accept(self) end |
#visit_all(nodes) ⇒ Object
Visits each node in nodes by calling accept on each one.
23 24 25 26 |
# File 'lib/prism/visitor.rb', line 23 def visit_all(nodes) # @type self: _Visitor nodes.each { |node| node&.accept(self) } end |
#visit_child_nodes(node) ⇒ Object
Visits the child nodes of node by calling accept on each one.
29 30 31 32 |
# File 'lib/prism/visitor.rb', line 29 def visit_child_nodes(node) # @type self: _Visitor node.compact_child_nodes.each { |node| node.accept(self) } end |