A visitor is a class that provides a default implementation for every accept method defined on the nodes. This means it can walk a tree without the caller needing to define any special handling. This allows you to handle a subset of the tree, while still walking the whole tree.
For example, to find all of the method calls that call the ‘foo` method, you could write:
class FooCalls < Prism::Visitor def visit_call_node(node) if node.name == "foo" # Do something with the node end # Call super so that the visitor continues walking the tree super end end