123456789_123456789_123456789_123456789_123456789_

Class: Prism::BasicVisitor

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.

Instance Method Summary

  • #visit(node) (also: #dispatch)

    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.

  • #visit_all(nodes)

    Visits each node in nodes by calling accept on each one.

  • #visit_child_nodes(node)

    Visits the child nodes of node by calling accept on each one.

Instance Method Details

#visit(node) Also known as: #dispatch

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.

[ GitHub ]

  
# File 'lib/prism/visitor.rb', line 20

def visit(node)
  # @type self: _Visitor
  node&.accept(self)
end

#visit_all(nodes)

Visits each node in nodes by calling accept on each one.

[ GitHub ]

  
# File 'lib/prism/visitor.rb', line 26

def visit_all(nodes)
  # @type self: _Visitor
  nodes.each { |node| node&.accept(self) }
end

#visit_child_nodes(node)

Visits the child nodes of node by calling accept on each one.

[ GitHub ]

  
# File 'lib/prism/visitor.rb', line 32

def visit_child_nodes(node)
  # @type self: _Visitor
  node.each_child_node { |node| node.accept(self) }
end