# frozen_string_literal: true
# :markup: markdown

=begin
--
This file is generated by the templates/template.rb script and should not be
modified manually. See templates/lib/prism/dispatcher.rb.erb
if you are looking to modify the template
++
=end

#--
# rbs_inline: enabled

module Prism
  # The dispatcher class fires events for nodes that are found while walking an
  # AST to all registered listeners. It's useful for performing different types
  # of analysis on the AST while only having to walk the tree once.
  #
  # To use the dispatcher, you would first instantiate it and register listeners
  # for the events you're interested in:
  #
  #     class OctalListener
  #       def on_integer_node_enter(node)
  #         if node.octal? && !node.slice.start_with?("0o")
  #           warn("Octal integers should be written with the 0o prefix")
  #         end
  #       end
  #     end
  #
  #     listener = OctalListener.new
  #     dispatcher = Prism::Dispatcher.new
  #     dispatcher.register(listener, :on_integer_node_enter)
  #
  # Then, you can walk any number of trees and dispatch events to the listeners:
  #
  #     result = Prism.parse("001 + 002 + 003")
  #     dispatcher.dispatch(result.value)
  #
  # Optionally, you can also use `#dispatch_once` to dispatch enter and leave
  # events for a single node without recursing further down the tree. This can
  # be useful in circumstances where you want to reuse the listeners you already
  # have registers but want to stop walking the tree at a certain point.
  #
  #     integer = result.value.statements.body.first.receiver.receiver
  #     dispatcher.dispatch_once(integer)
  #
  class Dispatcher < Visitor
    # A hash mapping event names to arrays of listeners that should be notified
    # when that event is fired.
    attr_reader :listeners #: Hash[Symbol, Array[untyped]]

    # Initialize a new dispatcher.
    #--
    #: () -> void
    def initialize
      @listeners = {}
    end

    # Register a listener for one or more events.
    #--
    #: (untyped, *Symbol) -> void
    def register(listener, *events)
      register_events(listener, events)
    end

    # Register all public methods of a listener that match the pattern
    # `on_<node_name>_(enter|leave)`.
    #--
    #: (untyped) -> void
    def register_public_methods(listener)
      register_events(listener, listener.public_methods(false).grep(/\Aon_.+_(?:enter|leave)\z/))
    end

    # Register a listener for the given events.
    #--
    #: (untyped, Array[Symbol]) -> void
    private def register_events(listener, events) # :nodoc:
      events.each { |event| (listeners[event] ||= []) << listener }
    end

    # Walks `root` dispatching events to all registered listeners.
    alias dispatch visit

    # Dispatches a single event for `node` to all registered listeners.
    #--
    #: (node node) -> void
    def dispatch_once(node)
      node.accept(DispatchOnce.new(listeners))
    end

    #: (AliasGlobalVariableNode node) -> void
    def visit_alias_global_variable_node(node) # :nodoc:
      listeners[:on_alias_global_variable_node_enter]&.each { |listener| listener.on_alias_global_variable_node_enter(node) }
      super
      listeners[:on_alias_global_variable_node_leave]&.each { |listener| listener.on_alias_global_variable_node_leave(node) }
    end

    #: (AliasMethodNode node) -> void
    def visit_alias_method_node(node) # :nodoc:
      listeners[:on_alias_method_node_enter]&.each { |listener| listener.on_alias_method_node_enter(node) }
      super
      listeners[:on_alias_method_node_leave]&.each { |listener| listener.on_alias_method_node_leave(node) }
    end

    #: (AlternationPatternNode node) -> void
    def visit_alternation_pattern_node(node) # :nodoc:
      listeners[:on_alternation_pattern_node_enter]&.each { |listener| listener.on_alternation_pattern_node_enter(node) }
      super
      listeners[:on_alternation_pattern_node_leave]&.each { |listener| listener.on_alternation_pattern_node_leave(node) }
    end

    #: (AndNode node) -> void
    def visit_and_node(node) # :nodoc:
      listeners[:on_and_node_enter]&.each { |listener| listener.on_and_node_enter(node) }
      super
      listeners[:on_and_node_leave]&.each { |listener| listener.on_and_node_leave(node) }
    end

    #: (ArgumentsNode node) -> void
    def visit_arguments_node(node) # :nodoc:
      listeners[:on_arguments_node_enter]&.each { |listener| listener.on_arguments_node_enter(node) }
      super
      listeners[:on_arguments_node_leave]&.each { |listener| listener.on_arguments_node_leave(node) }
    end

    #: (ArrayNode node) -> void
    def visit_array_node(node) # :nodoc:
      listeners[:on_array_node_enter]&.each { |listener| listener.on_array_node_enter(node) }
      super
      listeners[:on_array_node_leave]&.each { |listener| listener.on_array_node_leave(node) }
    end

    #: (ArrayPatternNode node) -> void
    def visit_array_pattern_node(node) # :nodoc:
      listeners[:on_array_pattern_node_enter]&.each { |listener| listener.on_array_pattern_node_enter(node) }
      super
      listeners[:on_array_pattern_node_leave]&.each { |listener| listener.on_array_pattern_node_leave(node) }
    end

    #: (AssocNode node) -> void
    def visit_assoc_node(node) # :nodoc:
      listeners[:on_assoc_node_enter]&.each { |listener| listener.on_assoc_node_enter(node) }
      super
      listeners[:on_assoc_node_leave]&.each { |listener| listener.on_assoc_node_leave(node) }
    end

    #: (AssocSplatNode node) -> void
    def visit_assoc_splat_node(node) # :nodoc:
      listeners[:on_assoc_splat_node_enter]&.each { |listener| listener.on_assoc_splat_node_enter(node) }
      super
      listeners[:on_assoc_splat_node_leave]&.each { |listener| listener.on_assoc_splat_node_leave(node) }
    end

    #: (BackReferenceReadNode node) -> void
    def visit_back_reference_read_node(node) # :nodoc:
      listeners[:on_back_reference_read_node_enter]&.each { |listener| listener.on_back_reference_read_node_enter(node) }
      super
      listeners[:on_back_reference_read_node_leave]&.each { |listener| listener.on_back_reference_read_node_leave(node) }
    end

    #: (BeginNode node) -> void
    def visit_begin_node(node) # :nodoc:
      listeners[:on_begin_node_enter]&.each { |listener| listener.on_begin_node_enter(node) }
      super
      listeners[:on_begin_node_leave]&.each { |listener| listener.on_begin_node_leave(node) }
    end

    #: (BlockArgumentNode node) -> void
    def visit_block_argument_node(node) # :nodoc:
      listeners[:on_block_argument_node_enter]&.each { |listener| listener.on_block_argument_node_enter(node) }
      super
      listeners[:on_block_argument_node_leave]&.each { |listener| listener.on_block_argument_node_leave(node) }
    end

    #: (BlockLocalVariableNode node) -> void
    def visit_block_local_variable_node(node) # :nodoc:
      listeners[:on_block_local_variable_node_enter]&.each { |listener| listener.on_block_local_variable_node_enter(node) }
      super
      listeners[:on_block_local_variable_node_leave]&.each { |listener| listener.on_block_local_variable_node_leave(node) }
    end

    #: (BlockNode node) -> void
    def visit_block_node(node) # :nodoc:
      listeners[:on_block_node_enter]&.each { |listener| listener.on_block_node_enter(node) }
      super
      listeners[:on_block_node_leave]&.each { |listener| listener.on_block_node_leave(node) }
    end

    #: (BlockParameterNode node) -> void
    def visit_block_parameter_node(node) # :nodoc:
      listeners[:on_block_parameter_node_enter]&.each { |listener| listener.on_block_parameter_node_enter(node) }
      super
      listeners[:on_block_parameter_node_leave]&.each { |listener| listener.on_block_parameter_node_leave(node) }
    end

    #: (BlockParametersNode node) -> void
    def visit_block_parameters_node(node) # :nodoc:
      listeners[:on_block_parameters_node_enter]&.each { |listener| listener.on_block_parameters_node_enter(node) }
      super
      listeners[:on_block_parameters_node_leave]&.each { |listener| listener.on_block_parameters_node_leave(node) }
    end

    #: (BreakNode node) -> void
    def visit_break_node(node) # :nodoc:
      listeners[:on_break_node_enter]&.each { |listener| listener.on_break_node_enter(node) }
      super
      listeners[:on_break_node_leave]&.each { |listener| listener.on_break_node_leave(node) }
    end

    #: (CallAndWriteNode node) -> void
    def visit_call_and_write_node(node) # :nodoc:
      listeners[:on_call_and_write_node_enter]&.each { |listener| listener.on_call_and_write_node_enter(node) }
      super
      listeners[:on_call_and_write_node_leave]&.each { |listener| listener.on_call_and_write_node_leave(node) }
    end

    #: (CallNode node) -> void
    def visit_call_node(node) # :nodoc:
      listeners[:on_call_node_enter]&.each { |listener| listener.on_call_node_enter(node) }
      super
      listeners[:on_call_node_leave]&.each { |listener| listener.on_call_node_leave(node) }
    end

    #: (CallOperatorWriteNode node) -> void
    def visit_call_operator_write_node(node) # :nodoc:
      listeners[:on_call_operator_write_node_enter]&.each { |listener| listener.on_call_operator_write_node_enter(node) }
      super
      listeners[:on_call_operator_write_node_leave]&.each { |listener| listener.on_call_operator_write_node_leave(node) }
    end

    #: (CallOrWriteNode node) -> void
    def visit_call_or_write_node(node) # :nodoc:
      listeners[:on_call_or_write_node_enter]&.each { |listener| listener.on_call_or_write_node_enter(node) }
      super
      listeners[:on_call_or_write_node_leave]&.each { |listener| listener.on_call_or_write_node_leave(node) }
    end

    #: (CallTargetNode node) -> void
    def visit_call_target_node(node) # :nodoc:
      listeners[:on_call_target_node_enter]&.each { |listener| listener.on_call_target_node_enter(node) }
      super
      listeners[:on_call_target_node_leave]&.each { |listener| listener.on_call_target_node_leave(node) }
    end

    #: (CapturePatternNode node) -> void
    def visit_capture_pattern_node(node) # :nodoc:
      listeners[:on_capture_pattern_node_enter]&.each { |listener| listener.on_capture_pattern_node_enter(node) }
      super
      listeners[:on_capture_pattern_node_leave]&.each { |listener| listener.on_capture_pattern_node_leave(node) }
    end

    #: (CaseMatchNode node) -> void
    def visit_case_match_node(node) # :nodoc:
      listeners[:on_case_match_node_enter]&.each { |listener| listener.on_case_match_node_enter(node) }
      super
      listeners[:on_case_match_node_leave]&.each { |listener| listener.on_case_match_node_leave(node) }
    end

    #: (CaseNode node) -> void
    def visit_case_node(node) # :nodoc:
      listeners[:on_case_node_enter]&.each { |listener| listener.on_case_node_enter(node) }
      super
      listeners[:on_case_node_leave]&.each { |listener| listener.on_case_node_leave(node) }
    end

    #: (ClassNode node) -> void
    def visit_class_node(node) # :nodoc:
      listeners[:on_class_node_enter]&.each { |listener| listener.on_class_node_enter(node) }
      super
      listeners[:on_class_node_leave]&.each { |listener| listener.on_class_node_leave(node) }
    end

    #: (ClassVariableAndWriteNode node) -> void
    def visit_class_variable_and_write_node(node) # :nodoc:
      listeners[:on_class_variable_and_write_node_enter]&.each { |listener| listener.on_class_variable_and_write_node_enter(node) }
      super
      listeners[:on_class_variable_and_write_node_leave]&.each { |listener| listener.on_class_variable_and_write_node_leave(node) }
    end

    #: (ClassVariableOperatorWriteNode node) -> void
    def visit_class_variable_operator_write_node(node) # :nodoc:
      listeners[:on_class_variable_operator_write_node_enter]&.each { |listener| listener.on_class_variable_operator_write_node_enter(node) }
      super
      listeners[:on_class_variable_operator_write_node_leave]&.each { |listener| listener.on_class_variable_operator_write_node_leave(node) }
    end

    #: (ClassVariableOrWriteNode node) -> void
    def visit_class_variable_or_write_node(node) # :nodoc:
      listeners[:on_class_variable_or_write_node_enter]&.each { |listener| listener.on_class_variable_or_write_node_enter(node) }
      super
      listeners[:on_class_variable_or_write_node_leave]&.each { |listener| listener.on_class_variable_or_write_node_leave(node) }
    end

    #: (ClassVariableReadNode node) -> void
    def visit_class_variable_read_node(node) # :nodoc:
      listeners[:on_class_variable_read_node_enter]&.each { |listener| listener.on_class_variable_read_node_enter(node) }
      super
      listeners[:on_class_variable_read_node_leave]&.each { |listener| listener.on_class_variable_read_node_leave(node) }
    end

    #: (ClassVariableTargetNode node) -> void
    def visit_class_variable_target_node(node) # :nodoc:
      listeners[:on_class_variable_target_node_enter]&.each { |listener| listener.on_class_variable_target_node_enter(node) }
      super
      listeners[:on_class_variable_target_node_leave]&.each { |listener| listener.on_class_variable_target_node_leave(node) }
    end

    #: (ClassVariableWriteNode node) -> void
    def visit_class_variable_write_node(node) # :nodoc:
      listeners[:on_class_variable_write_node_enter]&.each { |listener| listener.on_class_variable_write_node_enter(node) }
      super
      listeners[:on_class_variable_write_node_leave]&.each { |listener| listener.on_class_variable_write_node_leave(node) }
    end

    #: (ConstantAndWriteNode node) -> void
    def visit_constant_and_write_node(node) # :nodoc:
      listeners[:on_constant_and_write_node_enter]&.each { |listener| listener.on_constant_and_write_node_enter(node) }
      super
      listeners[:on_constant_and_write_node_leave]&.each { |listener| listener.on_constant_and_write_node_leave(node) }
    end

    #: (ConstantOperatorWriteNode node) -> void
    def visit_constant_operator_write_node(node) # :nodoc:
      listeners[:on_constant_operator_write_node_enter]&.each { |listener| listener.on_constant_operator_write_node_enter(node) }
      super
      listeners[:on_constant_operator_write_node_leave]&.each { |listener| listener.on_constant_operator_write_node_leave(node) }
    end

    #: (ConstantOrWriteNode node) -> void
    def visit_constant_or_write_node(node) # :nodoc:
      listeners[:on_constant_or_write_node_enter]&.each { |listener| listener.on_constant_or_write_node_enter(node) }
      super
      listeners[:on_constant_or_write_node_leave]&.each { |listener| listener.on_constant_or_write_node_leave(node) }
    end

    #: (ConstantPathAndWriteNode node) -> void
    def visit_constant_path_and_write_node(node) # :nodoc:
      listeners[:on_constant_path_and_write_node_enter]&.each { |listener| listener.on_constant_path_and_write_node_enter(node) }
      super
      listeners[:on_constant_path_and_write_node_leave]&.each { |listener| listener.on_constant_path_and_write_node_leave(node) }
    end

    #: (ConstantPathNode node) -> void
    def visit_constant_path_node(node) # :nodoc:
      listeners[:on_constant_path_node_enter]&.each { |listener| listener.on_constant_path_node_enter(node) }
      super
      listeners[:on_constant_path_node_leave]&.each { |listener| listener.on_constant_path_node_leave(node) }
    end

    #: (ConstantPathOperatorWriteNode node) -> void
    def visit_constant_path_operator_write_node(node) # :nodoc:
      listeners[:on_constant_path_operator_write_node_enter]&.each { |listener| listener.on_constant_path_operator_write_node_enter(node) }
      super
      listeners[:on_constant_path_operator_write_node_leave]&.each { |listener| listener.on_constant_path_operator_write_node_leave(node) }
    end

    #: (ConstantPathOrWriteNode node) -> void
    def visit_constant_path_or_write_node(node) # :nodoc:
      listeners[:on_constant_path_or_write_node_enter]&.each { |listener| listener.on_constant_path_or_write_node_enter(node) }
      super
      listeners[:on_constant_path_or_write_node_leave]&.each { |listener| listener.on_constant_path_or_write_node_leave(node) }
    end

    #: (ConstantPathTargetNode node) -> void
    def visit_constant_path_target_node(node) # :nodoc:
      listeners[:on_constant_path_target_node_enter]&.each { |listener| listener.on_constant_path_target_node_enter(node) }
      super
      listeners[:on_constant_path_target_node_leave]&.each { |listener| listener.on_constant_path_target_node_leave(node) }
    end

    #: (ConstantPathWriteNode node) -> void
    def visit_constant_path_write_node(node) # :nodoc:
      listeners[:on_constant_path_write_node_enter]&.each { |listener| listener.on_constant_path_write_node_enter(node) }
      super
      listeners[:on_constant_path_write_node_leave]&.each { |listener| listener.on_constant_path_write_node_leave(node) }
    end

    #: (ConstantReadNode node) -> void
    def visit_constant_read_node(node) # :nodoc:
      listeners[:on_constant_read_node_enter]&.each { |listener| listener.on_constant_read_node_enter(node) }
      super
      listeners[:on_constant_read_node_leave]&.each { |listener| listener.on_constant_read_node_leave(node) }
    end

    #: (ConstantTargetNode node) -> void
    def visit_constant_target_node(node) # :nodoc:
      listeners[:on_constant_target_node_enter]&.each { |listener| listener.on_constant_target_node_enter(node) }
      super
      listeners[:on_constant_target_node_leave]&.each { |listener| listener.on_constant_target_node_leave(node) }
    end

    #: (ConstantWriteNode node) -> void
    def visit_constant_write_node(node) # :nodoc:
      listeners[:on_constant_write_node_enter]&.each { |listener| listener.on_constant_write_node_enter(node) }
      super
      listeners[:on_constant_write_node_leave]&.each { |listener| listener.on_constant_write_node_leave(node) }
    end

    #: (DefNode node) -> void
    def visit_def_node(node) # :nodoc:
      listeners[:on_def_node_enter]&.each { |listener| listener.on_def_node_enter(node) }
      super
      listeners[:on_def_node_leave]&.each { |listener| listener.on_def_node_leave(node) }
    end

    #: (DefinedNode node) -> void
    def visit_defined_node(node) # :nodoc:
      listeners[:on_defined_node_enter]&.each { |listener| listener.on_defined_node_enter(node) }
      super
      listeners[:on_defined_node_leave]&.each { |listener| listener.on_defined_node_leave(node) }
    end

    #: (ElseNode node) -> void
    def visit_else_node(node) # :nodoc:
      listeners[:on_else_node_enter]&.each { |listener| listener.on_else_node_enter(node) }
      super
      listeners[:on_else_node_leave]&.each { |listener| listener.on_else_node_leave(node) }
    end

    #: (EmbeddedStatementsNode node) -> void
    def visit_embedded_statements_node(node) # :nodoc:
      listeners[:on_embedded_statements_node_enter]&.each { |listener| listener.on_embedded_statements_node_enter(node) }
      super
      listeners[:on_embedded_statements_node_leave]&.each { |listener| listener.on_embedded_statements_node_leave(node) }
    end

    #: (EmbeddedVariableNode node) -> void
    def visit_embedded_variable_node(node) # :nodoc:
      listeners[:on_embedded_variable_node_enter]&.each { |listener| listener.on_embedded_variable_node_enter(node) }
      super
      listeners[:on_embedded_variable_node_leave]&.each { |listener| listener.on_embedded_variable_node_leave(node) }
    end

    #: (EnsureNode node) -> void
    def visit_ensure_node(node) # :nodoc:
      listeners[:on_ensure_node_enter]&.each { |listener| listener.on_ensure_node_enter(node) }
      super
      listeners[:on_ensure_node_leave]&.each { |listener| listener.on_ensure_node_leave(node) }
    end

    #: (ErrorRecoveryNode node) -> void
    def visit_error_recovery_node(node) # :nodoc:
      listeners[:on_error_recovery_node_enter]&.each { |listener| listener.on_error_recovery_node_enter(node) }
      super
      listeners[:on_error_recovery_node_leave]&.each { |listener| listener.on_error_recovery_node_leave(node) }
    end

    #: (FalseNode node) -> void
    def visit_false_node(node) # :nodoc:
      listeners[:on_false_node_enter]&.each { |listener| listener.on_false_node_enter(node) }
      super
      listeners[:on_false_node_leave]&.each { |listener| listener.on_false_node_leave(node) }
    end

    #: (FindPatternNode node) -> void
    def visit_find_pattern_node(node) # :nodoc:
      listeners[:on_find_pattern_node_enter]&.each { |listener| listener.on_find_pattern_node_enter(node) }
      super
      listeners[:on_find_pattern_node_leave]&.each { |listener| listener.on_find_pattern_node_leave(node) }
    end

    #: (FlipFlopNode node) -> void
    def visit_flip_flop_node(node) # :nodoc:
      listeners[:on_flip_flop_node_enter]&.each { |listener| listener.on_flip_flop_node_enter(node) }
      super
      listeners[:on_flip_flop_node_leave]&.each { |listener| listener.on_flip_flop_node_leave(node) }
    end

    #: (FloatNode node) -> void
    def visit_float_node(node) # :nodoc:
      listeners[:on_float_node_enter]&.each { |listener| listener.on_float_node_enter(node) }
      super
      listeners[:on_float_node_leave]&.each { |listener| listener.on_float_node_leave(node) }
    end

    #: (ForNode node) -> void
    def visit_for_node(node) # :nodoc:
      listeners[:on_for_node_enter]&.each { |listener| listener.on_for_node_enter(node) }
      super
      listeners[:on_for_node_leave]&.each { |listener| listener.on_for_node_leave(node) }
    end

    #: (ForwardingArgumentsNode node) -> void
    def visit_forwarding_arguments_node(node) # :nodoc:
      listeners[:on_forwarding_arguments_node_enter]&.each { |listener| listener.on_forwarding_arguments_node_enter(node) }
      super
      listeners[:on_forwarding_arguments_node_leave]&.each { |listener| listener.on_forwarding_arguments_node_leave(node) }
    end

    #: (ForwardingParameterNode node) -> void
    def visit_forwarding_parameter_node(node) # :nodoc:
      listeners[:on_forwarding_parameter_node_enter]&.each { |listener| listener.on_forwarding_parameter_node_enter(node) }
      super
      listeners[:on_forwarding_parameter_node_leave]&.each { |listener| listener.on_forwarding_parameter_node_leave(node) }
    end

    #: (ForwardingSuperNode node) -> void
    def visit_forwarding_super_node(node) # :nodoc:
      listeners[:on_forwarding_super_node_enter]&.each { |listener| listener.on_forwarding_super_node_enter(node) }
      super
      listeners[:on_forwarding_super_node_leave]&.each { |listener| listener.on_forwarding_super_node_leave(node) }
    end

    #: (GlobalVariableAndWriteNode node) -> void
    def visit_global_variable_and_write_node(node) # :nodoc:
      listeners[:on_global_variable_and_write_node_enter]&.each { |listener| listener.on_global_variable_and_write_node_enter(node) }
      super
      listeners[:on_global_variable_and_write_node_leave]&.each { |listener| listener.on_global_variable_and_write_node_leave(node) }
    end

    #: (GlobalVariableOperatorWriteNode node) -> void
    def visit_global_variable_operator_write_node(node) # :nodoc:
      listeners[:on_global_variable_operator_write_node_enter]&.each { |listener| listener.on_global_variable_operator_write_node_enter(node) }
      super
      listeners[:on_global_variable_operator_write_node_leave]&.each { |listener| listener.on_global_variable_operator_write_node_leave(node) }
    end

    #: (GlobalVariableOrWriteNode node) -> void
    def visit_global_variable_or_write_node(node) # :nodoc:
      listeners[:on_global_variable_or_write_node_enter]&.each { |listener| listener.on_global_variable_or_write_node_enter(node) }
      super
      listeners[:on_global_variable_or_write_node_leave]&.each { |listener| listener.on_global_variable_or_write_node_leave(node) }
    end

    #: (GlobalVariableReadNode node) -> void
    def visit_global_variable_read_node(node) # :nodoc:
      listeners[:on_global_variable_read_node_enter]&.each { |listener| listener.on_global_variable_read_node_enter(node) }
      super
      listeners[:on_global_variable_read_node_leave]&.each { |listener| listener.on_global_variable_read_node_leave(node) }
    end

    #: (GlobalVariableTargetNode node) -> void
    def visit_global_variable_target_node(node) # :nodoc:
      listeners[:on_global_variable_target_node_enter]&.each { |listener| listener.on_global_variable_target_node_enter(node) }
      super
      listeners[:on_global_variable_target_node_leave]&.each { |listener| listener.on_global_variable_target_node_leave(node) }
    end

    #: (GlobalVariableWriteNode node) -> void
    def visit_global_variable_write_node(node) # :nodoc:
      listeners[:on_global_variable_write_node_enter]&.each { |listener| listener.on_global_variable_write_node_enter(node) }
      super
      listeners[:on_global_variable_write_node_leave]&.each { |listener| listener.on_global_variable_write_node_leave(node) }
    end

    #: (HashNode node) -> void
    def visit_hash_node(node) # :nodoc:
      listeners[:on_hash_node_enter]&.each { |listener| listener.on_hash_node_enter(node) }
      super
      listeners[:on_hash_node_leave]&.each { |listener| listener.on_hash_node_leave(node) }
    end

    #: (HashPatternNode node) -> void
    def visit_hash_pattern_node(node) # :nodoc:
      listeners[:on_hash_pattern_node_enter]&.each { |listener| listener.on_hash_pattern_node_enter(node) }
      super
      listeners[:on_hash_pattern_node_leave]&.each { |listener| listener.on_hash_pattern_node_leave(node) }
    end

    #: (IfNode node) -> void
    def visit_if_node(node) # :nodoc:
      listeners[:on_if_node_enter]&.each { |listener| listener.on_if_node_enter(node) }
      super
      listeners[:on_if_node_leave]&.each { |listener| listener.on_if_node_leave(node) }
    end

    #: (ImaginaryNode node) -> void
    def visit_imaginary_node(node) # :nodoc:
      listeners[:on_imaginary_node_enter]&.each { |listener| listener.on_imaginary_node_enter(node) }
      super
      listeners[:on_imaginary_node_leave]&.each { |listener| listener.on_imaginary_node_leave(node) }
    end

    #: (ImplicitNode node) -> void
    def visit_implicit_node(node) # :nodoc:
      listeners[:on_implicit_node_enter]&.each { |listener| listener.on_implicit_node_enter(node) }
      super
      listeners[:on_implicit_node_leave]&.each { |listener| listener.on_implicit_node_leave(node) }
    end

    #: (ImplicitRestNode node) -> void
    def visit_implicit_rest_node(node) # :nodoc:
      listeners[:on_implicit_rest_node_enter]&.each { |listener| listener.on_implicit_rest_node_enter(node) }
      super
      listeners[:on_implicit_rest_node_leave]&.each { |listener| listener.on_implicit_rest_node_leave(node) }
    end

    #: (InNode node) -> void
    def visit_in_node(node) # :nodoc:
      listeners[:on_in_node_enter]&.each { |listener| listener.on_in_node_enter(node) }
      super
      listeners[:on_in_node_leave]&.each { |listener| listener.on_in_node_leave(node) }
    end

    #: (IndexAndWriteNode node) -> void
    def visit_index_and_write_node(node) # :nodoc:
      listeners[:on_index_and_write_node_enter]&.each { |listener| listener.on_index_and_write_node_enter(node) }
      super
      listeners[:on_index_and_write_node_leave]&.each { |listener| listener.on_index_and_write_node_leave(node) }
    end

    #: (IndexOperatorWriteNode node) -> void
    def visit_index_operator_write_node(node) # :nodoc:
      listeners[:on_index_operator_write_node_enter]&.each { |listener| listener.on_index_operator_write_node_enter(node) }
      super
      listeners[:on_index_operator_write_node_leave]&.each { |listener| listener.on_index_operator_write_node_leave(node) }
    end

    #: (IndexOrWriteNode node) -> void
    def visit_index_or_write_node(node) # :nodoc:
      listeners[:on_index_or_write_node_enter]&.each { |listener| listener.on_index_or_write_node_enter(node) }
      super
      listeners[:on_index_or_write_node_leave]&.each { |listener| listener.on_index_or_write_node_leave(node) }
    end

    #: (IndexTargetNode node) -> void
    def visit_index_target_node(node) # :nodoc:
      listeners[:on_index_target_node_enter]&.each { |listener| listener.on_index_target_node_enter(node) }
      super
      listeners[:on_index_target_node_leave]&.each { |listener| listener.on_index_target_node_leave(node) }
    end

    #: (InstanceVariableAndWriteNode node) -> void
    def visit_instance_variable_and_write_node(node) # :nodoc:
      listeners[:on_instance_variable_and_write_node_enter]&.each { |listener| listener.on_instance_variable_and_write_node_enter(node) }
      super
      listeners[:on_instance_variable_and_write_node_leave]&.each { |listener| listener.on_instance_variable_and_write_node_leave(node) }
    end

    #: (InstanceVariableOperatorWriteNode node) -> void
    def visit_instance_variable_operator_write_node(node) # :nodoc:
      listeners[:on_instance_variable_operator_write_node_enter]&.each { |listener| listener.on_instance_variable_operator_write_node_enter(node) }
      super
      listeners[:on_instance_variable_operator_write_node_leave]&.each { |listener| listener.on_instance_variable_operator_write_node_leave(node) }
    end

    #: (InstanceVariableOrWriteNode node) -> void
    def visit_instance_variable_or_write_node(node) # :nodoc:
      listeners[:on_instance_variable_or_write_node_enter]&.each { |listener| listener.on_instance_variable_or_write_node_enter(node) }
      super
      listeners[:on_instance_variable_or_write_node_leave]&.each { |listener| listener.on_instance_variable_or_write_node_leave(node) }
    end

    #: (InstanceVariableReadNode node) -> void
    def visit_instance_variable_read_node(node) # :nodoc:
      listeners[:on_instance_variable_read_node_enter]&.each { |listener| listener.on_instance_variable_read_node_enter(node) }
      super
      listeners[:on_instance_variable_read_node_leave]&.each { |listener| listener.on_instance_variable_read_node_leave(node) }
    end

    #: (InstanceVariableTargetNode node) -> void
    def visit_instance_variable_target_node(node) # :nodoc:
      listeners[:on_instance_variable_target_node_enter]&.each { |listener| listener.on_instance_variable_target_node_enter(node) }
      super
      listeners[:on_instance_variable_target_node_leave]&.each { |listener| listener.on_instance_variable_target_node_leave(node) }
    end

    #: (InstanceVariableWriteNode node) -> void
    def visit_instance_variable_write_node(node) # :nodoc:
      listeners[:on_instance_variable_write_node_enter]&.each { |listener| listener.on_instance_variable_write_node_enter(node) }
      super
      listeners[:on_instance_variable_write_node_leave]&.each { |listener| listener.on_instance_variable_write_node_leave(node) }
    end

    #: (IntegerNode node) -> void
    def visit_integer_node(node) # :nodoc:
      listeners[:on_integer_node_enter]&.each { |listener| listener.on_integer_node_enter(node) }
      super
      listeners[:on_integer_node_leave]&.each { |listener| listener.on_integer_node_leave(node) }
    end

    #: (InterpolatedMatchLastLineNode node) -> void
    def visit_interpolated_match_last_line_node(node) # :nodoc:
      listeners[:on_interpolated_match_last_line_node_enter]&.each { |listener| listener.on_interpolated_match_last_line_node_enter(node) }
      super
      listeners[:on_interpolated_match_last_line_node_leave]&.each { |listener| listener.on_interpolated_match_last_line_node_leave(node) }
    end

    #: (InterpolatedRegularExpressionNode node) -> void
    def visit_interpolated_regular_expression_node(node) # :nodoc:
      listeners[:on_interpolated_regular_expression_node_enter]&.each { |listener| listener.on_interpolated_regular_expression_node_enter(node) }
      super
      listeners[:on_interpolated_regular_expression_node_leave]&.each { |listener| listener.on_interpolated_regular_expression_node_leave(node) }
    end

    #: (InterpolatedStringNode node) -> void
    def visit_interpolated_string_node(node) # :nodoc:
      listeners[:on_interpolated_string_node_enter]&.each { |listener| listener.on_interpolated_string_node_enter(node) }
      super
      listeners[:on_interpolated_string_node_leave]&.each { |listener| listener.on_interpolated_string_node_leave(node) }
    end

    #: (InterpolatedSymbolNode node) -> void
    def visit_interpolated_symbol_node(node) # :nodoc:
      listeners[:on_interpolated_symbol_node_enter]&.each { |listener| listener.on_interpolated_symbol_node_enter(node) }
      super
      listeners[:on_interpolated_symbol_node_leave]&.each { |listener| listener.on_interpolated_symbol_node_leave(node) }
    end

    #: (InterpolatedXStringNode node) -> void
    def visit_interpolated_x_string_node(node) # :nodoc:
      listeners[:on_interpolated_x_string_node_enter]&.each { |listener| listener.on_interpolated_x_string_node_enter(node) }
      super
      listeners[:on_interpolated_x_string_node_leave]&.each { |listener| listener.on_interpolated_x_string_node_leave(node) }
    end

    #: (ItLocalVariableReadNode node) -> void
    def visit_it_local_variable_read_node(node) # :nodoc:
      listeners[:on_it_local_variable_read_node_enter]&.each { |listener| listener.on_it_local_variable_read_node_enter(node) }
      super
      listeners[:on_it_local_variable_read_node_leave]&.each { |listener| listener.on_it_local_variable_read_node_leave(node) }
    end

    #: (ItParametersNode node) -> void
    def visit_it_parameters_node(node) # :nodoc:
      listeners[:on_it_parameters_node_enter]&.each { |listener| listener.on_it_parameters_node_enter(node) }
      super
      listeners[:on_it_parameters_node_leave]&.each { |listener| listener.on_it_parameters_node_leave(node) }
    end

    #: (KeywordHashNode node) -> void
    def visit_keyword_hash_node(node) # :nodoc:
      listeners[:on_keyword_hash_node_enter]&.each { |listener| listener.on_keyword_hash_node_enter(node) }
      super
      listeners[:on_keyword_hash_node_leave]&.each { |listener| listener.on_keyword_hash_node_leave(node) }
    end

    #: (KeywordRestParameterNode node) -> void
    def visit_keyword_rest_parameter_node(node) # :nodoc:
      listeners[:on_keyword_rest_parameter_node_enter]&.each { |listener| listener.on_keyword_rest_parameter_node_enter(node) }
      super
      listeners[:on_keyword_rest_parameter_node_leave]&.each { |listener| listener.on_keyword_rest_parameter_node_leave(node) }
    end

    #: (LambdaNode node) -> void
    def visit_lambda_node(node) # :nodoc:
      listeners[:on_lambda_node_enter]&.each { |listener| listener.on_lambda_node_enter(node) }
      super
      listeners[:on_lambda_node_leave]&.each { |listener| listener.on_lambda_node_leave(node) }
    end

    #: (LocalVariableAndWriteNode node) -> void
    def visit_local_variable_and_write_node(node) # :nodoc:
      listeners[:on_local_variable_and_write_node_enter]&.each { |listener| listener.on_local_variable_and_write_node_enter(node) }
      super
      listeners[:on_local_variable_and_write_node_leave]&.each { |listener| listener.on_local_variable_and_write_node_leave(node) }
    end

    #: (LocalVariableOperatorWriteNode node) -> void
    def visit_local_variable_operator_write_node(node) # :nodoc:
      listeners[:on_local_variable_operator_write_node_enter]&.each { |listener| listener.on_local_variable_operator_write_node_enter(node) }
      super
      listeners[:on_local_variable_operator_write_node_leave]&.each { |listener| listener.on_local_variable_operator_write_node_leave(node) }
    end

    #: (LocalVariableOrWriteNode node) -> void
    def visit_local_variable_or_write_node(node) # :nodoc:
      listeners[:on_local_variable_or_write_node_enter]&.each { |listener| listener.on_local_variable_or_write_node_enter(node) }
      super
      listeners[:on_local_variable_or_write_node_leave]&.each { |listener| listener.on_local_variable_or_write_node_leave(node) }
    end

    #: (LocalVariableReadNode node) -> void
    def visit_local_variable_read_node(node) # :nodoc:
      listeners[:on_local_variable_read_node_enter]&.each { |listener| listener.on_local_variable_read_node_enter(node) }
      super
      listeners[:on_local_variable_read_node_leave]&.each { |listener| listener.on_local_variable_read_node_leave(node) }
    end

    #: (LocalVariableTargetNode node) -> void
    def visit_local_variable_target_node(node) # :nodoc:
      listeners[:on_local_variable_target_node_enter]&.each { |listener| listener.on_local_variable_target_node_enter(node) }
      super
      listeners[:on_local_variable_target_node_leave]&.each { |listener| listener.on_local_variable_target_node_leave(node) }
    end

    #: (LocalVariableWriteNode node) -> void
    def visit_local_variable_write_node(node) # :nodoc:
      listeners[:on_local_variable_write_node_enter]&.each { |listener| listener.on_local_variable_write_node_enter(node) }
      super
      listeners[:on_local_variable_write_node_leave]&.each { |listener| listener.on_local_variable_write_node_leave(node) }
    end

    #: (MatchLastLineNode node) -> void
    def visit_match_last_line_node(node) # :nodoc:
      listeners[:on_match_last_line_node_enter]&.each { |listener| listener.on_match_last_line_node_enter(node) }
      super
      listeners[:on_match_last_line_node_leave]&.each { |listener| listener.on_match_last_line_node_leave(node) }
    end

    #: (MatchPredicateNode node) -> void
    def visit_match_predicate_node(node) # :nodoc:
      listeners[:on_match_predicate_node_enter]&.each { |listener| listener.on_match_predicate_node_enter(node) }
      super
      listeners[:on_match_predicate_node_leave]&.each { |listener| listener.on_match_predicate_node_leave(node) }
    end

    #: (MatchRequiredNode node) -> void
    def visit_match_required_node(node) # :nodoc:
      listeners[:on_match_required_node_enter]&.each { |listener| listener.on_match_required_node_enter(node) }
      super
      listeners[:on_match_required_node_leave]&.each { |listener| listener.on_match_required_node_leave(node) }
    end

    #: (MatchWriteNode node) -> void
    def visit_match_write_node(node) # :nodoc:
      listeners[:on_match_write_node_enter]&.each { |listener| listener.on_match_write_node_enter(node) }
      super
      listeners[:on_match_write_node_leave]&.each { |listener| listener.on_match_write_node_leave(node) }
    end

    #: (ModuleNode node) -> void
    def visit_module_node(node) # :nodoc:
      listeners[:on_module_node_enter]&.each { |listener| listener.on_module_node_enter(node) }
      super
      listeners[:on_module_node_leave]&.each { |listener| listener.on_module_node_leave(node) }
    end

    #: (MultiTargetNode node) -> void
    def visit_multi_target_node(node) # :nodoc:
      listeners[:on_multi_target_node_enter]&.each { |listener| listener.on_multi_target_node_enter(node) }
      super
      listeners[:on_multi_target_node_leave]&.each { |listener| listener.on_multi_target_node_leave(node) }
    end

    #: (MultiWriteNode node) -> void
    def visit_multi_write_node(node) # :nodoc:
      listeners[:on_multi_write_node_enter]&.each { |listener| listener.on_multi_write_node_enter(node) }
      super
      listeners[:on_multi_write_node_leave]&.each { |listener| listener.on_multi_write_node_leave(node) }
    end

    #: (NextNode node) -> void
    def visit_next_node(node) # :nodoc:
      listeners[:on_next_node_enter]&.each { |listener| listener.on_next_node_enter(node) }
      super
      listeners[:on_next_node_leave]&.each { |listener| listener.on_next_node_leave(node) }
    end

    #: (NilNode node) -> void
    def visit_nil_node(node) # :nodoc:
      listeners[:on_nil_node_enter]&.each { |listener| listener.on_nil_node_enter(node) }
      super
      listeners[:on_nil_node_leave]&.each { |listener| listener.on_nil_node_leave(node) }
    end

    #: (NoBlockParameterNode node) -> void
    def visit_no_block_parameter_node(node) # :nodoc:
      listeners[:on_no_block_parameter_node_enter]&.each { |listener| listener.on_no_block_parameter_node_enter(node) }
      super
      listeners[:on_no_block_parameter_node_leave]&.each { |listener| listener.on_no_block_parameter_node_leave(node) }
    end

    #: (NoKeywordsParameterNode node) -> void
    def visit_no_keywords_parameter_node(node) # :nodoc:
      listeners[:on_no_keywords_parameter_node_enter]&.each { |listener| listener.on_no_keywords_parameter_node_enter(node) }
      super
      listeners[:on_no_keywords_parameter_node_leave]&.each { |listener| listener.on_no_keywords_parameter_node_leave(node) }
    end

    #: (NumberedParametersNode node) -> void
    def visit_numbered_parameters_node(node) # :nodoc:
      listeners[:on_numbered_parameters_node_enter]&.each { |listener| listener.on_numbered_parameters_node_enter(node) }
      super
      listeners[:on_numbered_parameters_node_leave]&.each { |listener| listener.on_numbered_parameters_node_leave(node) }
    end

    #: (NumberedReferenceReadNode node) -> void
    def visit_numbered_reference_read_node(node) # :nodoc:
      listeners[:on_numbered_reference_read_node_enter]&.each { |listener| listener.on_numbered_reference_read_node_enter(node) }
      super
      listeners[:on_numbered_reference_read_node_leave]&.each { |listener| listener.on_numbered_reference_read_node_leave(node) }
    end

    #: (OptionalKeywordParameterNode node) -> void
    def visit_optional_keyword_parameter_node(node) # :nodoc:
      listeners[:on_optional_keyword_parameter_node_enter]&.each { |listener| listener.on_optional_keyword_parameter_node_enter(node) }
      super
      listeners[:on_optional_keyword_parameter_node_leave]&.each { |listener| listener.on_optional_keyword_parameter_node_leave(node) }
    end

    #: (OptionalParameterNode node) -> void
    def visit_optional_parameter_node(node) # :nodoc:
      listeners[:on_optional_parameter_node_enter]&.each { |listener| listener.on_optional_parameter_node_enter(node) }
      super
      listeners[:on_optional_parameter_node_leave]&.each { |listener| listener.on_optional_parameter_node_leave(node) }
    end

    #: (OrNode node) -> void
    def visit_or_node(node) # :nodoc:
      listeners[:on_or_node_enter]&.each { |listener| listener.on_or_node_enter(node) }
      super
      listeners[:on_or_node_leave]&.each { |listener| listener.on_or_node_leave(node) }
    end

    #: (ParametersNode node) -> void
    def visit_parameters_node(node) # :nodoc:
      listeners[:on_parameters_node_enter]&.each { |listener| listener.on_parameters_node_enter(node) }
      super
      listeners[:on_parameters_node_leave]&.each { |listener| listener.on_parameters_node_leave(node) }
    end

    #: (ParenthesesNode node) -> void
    def visit_parentheses_node(node) # :nodoc:
      listeners[:on_parentheses_node_enter]&.each { |listener| listener.on_parentheses_node_enter(node) }
      super
      listeners[:on_parentheses_node_leave]&.each { |listener| listener.on_parentheses_node_leave(node) }
    end

    #: (PinnedExpressionNode node) -> void
    def visit_pinned_expression_node(node) # :nodoc:
      listeners[:on_pinned_expression_node_enter]&.each { |listener| listener.on_pinned_expression_node_enter(node) }
      super
      listeners[:on_pinned_expression_node_leave]&.each { |listener| listener.on_pinned_expression_node_leave(node) }
    end

    #: (PinnedVariableNode node) -> void
    def visit_pinned_variable_node(node) # :nodoc:
      listeners[:on_pinned_variable_node_enter]&.each { |listener| listener.on_pinned_variable_node_enter(node) }
      super
      listeners[:on_pinned_variable_node_leave]&.each { |listener| listener.on_pinned_variable_node_leave(node) }
    end

    #: (PostExecutionNode node) -> void
    def visit_post_execution_node(node) # :nodoc:
      listeners[:on_post_execution_node_enter]&.each { |listener| listener.on_post_execution_node_enter(node) }
      super
      listeners[:on_post_execution_node_leave]&.each { |listener| listener.on_post_execution_node_leave(node) }
    end

    #: (PreExecutionNode node) -> void
    def visit_pre_execution_node(node) # :nodoc:
      listeners[:on_pre_execution_node_enter]&.each { |listener| listener.on_pre_execution_node_enter(node) }
      super
      listeners[:on_pre_execution_node_leave]&.each { |listener| listener.on_pre_execution_node_leave(node) }
    end

    #: (ProgramNode node) -> void
    def visit_program_node(node) # :nodoc:
      listeners[:on_program_node_enter]&.each { |listener| listener.on_program_node_enter(node) }
      super
      listeners[:on_program_node_leave]&.each { |listener| listener.on_program_node_leave(node) }
    end

    #: (RangeNode node) -> void
    def visit_range_node(node) # :nodoc:
      listeners[:on_range_node_enter]&.each { |listener| listener.on_range_node_enter(node) }
      super
      listeners[:on_range_node_leave]&.each { |listener| listener.on_range_node_leave(node) }
    end

    #: (RationalNode node) -> void
    def visit_rational_node(node) # :nodoc:
      listeners[:on_rational_node_enter]&.each { |listener| listener.on_rational_node_enter(node) }
      super
      listeners[:on_rational_node_leave]&.each { |listener| listener.on_rational_node_leave(node) }
    end

    #: (RedoNode node) -> void
    def visit_redo_node(node) # :nodoc:
      listeners[:on_redo_node_enter]&.each { |listener| listener.on_redo_node_enter(node) }
      super
      listeners[:on_redo_node_leave]&.each { |listener| listener.on_redo_node_leave(node) }
    end

    #: (RegularExpressionNode node) -> void
    def visit_regular_expression_node(node) # :nodoc:
      listeners[:on_regular_expression_node_enter]&.each { |listener| listener.on_regular_expression_node_enter(node) }
      super
      listeners[:on_regular_expression_node_leave]&.each { |listener| listener.on_regular_expression_node_leave(node) }
    end

    #: (RequiredKeywordParameterNode node) -> void
    def visit_required_keyword_parameter_node(node) # :nodoc:
      listeners[:on_required_keyword_parameter_node_enter]&.each { |listener| listener.on_required_keyword_parameter_node_enter(node) }
      super
      listeners[:on_required_keyword_parameter_node_leave]&.each { |listener| listener.on_required_keyword_parameter_node_leave(node) }
    end

    #: (RequiredParameterNode node) -> void
    def visit_required_parameter_node(node) # :nodoc:
      listeners[:on_required_parameter_node_enter]&.each { |listener| listener.on_required_parameter_node_enter(node) }
      super
      listeners[:on_required_parameter_node_leave]&.each { |listener| listener.on_required_parameter_node_leave(node) }
    end

    #: (RescueModifierNode node) -> void
    def visit_rescue_modifier_node(node) # :nodoc:
      listeners[:on_rescue_modifier_node_enter]&.each { |listener| listener.on_rescue_modifier_node_enter(node) }
      super
      listeners[:on_rescue_modifier_node_leave]&.each { |listener| listener.on_rescue_modifier_node_leave(node) }
    end

    #: (RescueNode node) -> void
    def visit_rescue_node(node) # :nodoc:
      listeners[:on_rescue_node_enter]&.each { |listener| listener.on_rescue_node_enter(node) }
      super
      listeners[:on_rescue_node_leave]&.each { |listener| listener.on_rescue_node_leave(node) }
    end

    #: (RestParameterNode node) -> void
    def visit_rest_parameter_node(node) # :nodoc:
      listeners[:on_rest_parameter_node_enter]&.each { |listener| listener.on_rest_parameter_node_enter(node) }
      super
      listeners[:on_rest_parameter_node_leave]&.each { |listener| listener.on_rest_parameter_node_leave(node) }
    end

    #: (RetryNode node) -> void
    def visit_retry_node(node) # :nodoc:
      listeners[:on_retry_node_enter]&.each { |listener| listener.on_retry_node_enter(node) }
      super
      listeners[:on_retry_node_leave]&.each { |listener| listener.on_retry_node_leave(node) }
    end

    #: (ReturnNode node) -> void
    def visit_return_node(node) # :nodoc:
      listeners[:on_return_node_enter]&.each { |listener| listener.on_return_node_enter(node) }
      super
      listeners[:on_return_node_leave]&.each { |listener| listener.on_return_node_leave(node) }
    end

    #: (SelfNode node) -> void
    def visit_self_node(node) # :nodoc:
      listeners[:on_self_node_enter]&.each { |listener| listener.on_self_node_enter(node) }
      super
      listeners[:on_self_node_leave]&.each { |listener| listener.on_self_node_leave(node) }
    end

    #: (ShareableConstantNode node) -> void
    def visit_shareable_constant_node(node) # :nodoc:
      listeners[:on_shareable_constant_node_enter]&.each { |listener| listener.on_shareable_constant_node_enter(node) }
      super
      listeners[:on_shareable_constant_node_leave]&.each { |listener| listener.on_shareable_constant_node_leave(node) }
    end

    #: (SingletonClassNode node) -> void
    def visit_singleton_class_node(node) # :nodoc:
      listeners[:on_singleton_class_node_enter]&.each { |listener| listener.on_singleton_class_node_enter(node) }
      super
      listeners[:on_singleton_class_node_leave]&.each { |listener| listener.on_singleton_class_node_leave(node) }
    end

    #: (SourceEncodingNode node) -> void
    def visit_source_encoding_node(node) # :nodoc:
      listeners[:on_source_encoding_node_enter]&.each { |listener| listener.on_source_encoding_node_enter(node) }
      super
      listeners[:on_source_encoding_node_leave]&.each { |listener| listener.on_source_encoding_node_leave(node) }
    end

    #: (SourceFileNode node) -> void
    def visit_source_file_node(node) # :nodoc:
      listeners[:on_source_file_node_enter]&.each { |listener| listener.on_source_file_node_enter(node) }
      super
      listeners[:on_source_file_node_leave]&.each { |listener| listener.on_source_file_node_leave(node) }
    end

    #: (SourceLineNode node) -> void
    def visit_source_line_node(node) # :nodoc:
      listeners[:on_source_line_node_enter]&.each { |listener| listener.on_source_line_node_enter(node) }
      super
      listeners[:on_source_line_node_leave]&.each { |listener| listener.on_source_line_node_leave(node) }
    end

    #: (SplatNode node) -> void
    def visit_splat_node(node) # :nodoc:
      listeners[:on_splat_node_enter]&.each { |listener| listener.on_splat_node_enter(node) }
      super
      listeners[:on_splat_node_leave]&.each { |listener| listener.on_splat_node_leave(node) }
    end

    #: (StatementsNode node) -> void
    def visit_statements_node(node) # :nodoc:
      listeners[:on_statements_node_enter]&.each { |listener| listener.on_statements_node_enter(node) }
      super
      listeners[:on_statements_node_leave]&.each { |listener| listener.on_statements_node_leave(node) }
    end

    #: (StringNode node) -> void
    def visit_string_node(node) # :nodoc:
      listeners[:on_string_node_enter]&.each { |listener| listener.on_string_node_enter(node) }
      super
      listeners[:on_string_node_leave]&.each { |listener| listener.on_string_node_leave(node) }
    end

    #: (SuperNode node) -> void
    def visit_super_node(node) # :nodoc:
      listeners[:on_super_node_enter]&.each { |listener| listener.on_super_node_enter(node) }
      super
      listeners[:on_super_node_leave]&.each { |listener| listener.on_super_node_leave(node) }
    end

    #: (SymbolNode node) -> void
    def visit_symbol_node(node) # :nodoc:
      listeners[:on_symbol_node_enter]&.each { |listener| listener.on_symbol_node_enter(node) }
      super
      listeners[:on_symbol_node_leave]&.each { |listener| listener.on_symbol_node_leave(node) }
    end

    #: (TrueNode node) -> void
    def visit_true_node(node) # :nodoc:
      listeners[:on_true_node_enter]&.each { |listener| listener.on_true_node_enter(node) }
      super
      listeners[:on_true_node_leave]&.each { |listener| listener.on_true_node_leave(node) }
    end

    #: (UndefNode node) -> void
    def visit_undef_node(node) # :nodoc:
      listeners[:on_undef_node_enter]&.each { |listener| listener.on_undef_node_enter(node) }
      super
      listeners[:on_undef_node_leave]&.each { |listener| listener.on_undef_node_leave(node) }
    end

    #: (UnlessNode node) -> void
    def visit_unless_node(node) # :nodoc:
      listeners[:on_unless_node_enter]&.each { |listener| listener.on_unless_node_enter(node) }
      super
      listeners[:on_unless_node_leave]&.each { |listener| listener.on_unless_node_leave(node) }
    end

    #: (UntilNode node) -> void
    def visit_until_node(node) # :nodoc:
      listeners[:on_until_node_enter]&.each { |listener| listener.on_until_node_enter(node) }
      super
      listeners[:on_until_node_leave]&.each { |listener| listener.on_until_node_leave(node) }
    end

    #: (WhenNode node) -> void
    def visit_when_node(node) # :nodoc:
      listeners[:on_when_node_enter]&.each { |listener| listener.on_when_node_enter(node) }
      super
      listeners[:on_when_node_leave]&.each { |listener| listener.on_when_node_leave(node) }
    end

    #: (WhileNode node) -> void
    def visit_while_node(node) # :nodoc:
      listeners[:on_while_node_enter]&.each { |listener| listener.on_while_node_enter(node) }
      super
      listeners[:on_while_node_leave]&.each { |listener| listener.on_while_node_leave(node) }
    end

    #: (XStringNode node) -> void
    def visit_x_string_node(node) # :nodoc:
      listeners[:on_x_string_node_enter]&.each { |listener| listener.on_x_string_node_enter(node) }
      super
      listeners[:on_x_string_node_leave]&.each { |listener| listener.on_x_string_node_leave(node) }
    end

    #: (YieldNode node) -> void
    def visit_yield_node(node) # :nodoc:
      listeners[:on_yield_node_enter]&.each { |listener| listener.on_yield_node_enter(node) }
      super
      listeners[:on_yield_node_leave]&.each { |listener| listener.on_yield_node_leave(node) }
    end

    class DispatchOnce < Visitor # :nodoc:
      attr_reader :listeners #: Hash[Symbol, Array[untyped]]

      #: (Hash[Symbol, Array[untyped]] listeners) -> void
      def initialize(listeners)
        @listeners = listeners
      end

      # Dispatch enter and leave events for AliasGlobalVariableNode nodes.
      #--
      #: (AliasGlobalVariableNode node) -> void
      def visit_alias_global_variable_node(node)
        listeners[:on_alias_global_variable_node_enter]&.each { |listener| listener.on_alias_global_variable_node_enter(node) }
        listeners[:on_alias_global_variable_node_leave]&.each { |listener| listener.on_alias_global_variable_node_leave(node) }
      end

      # Dispatch enter and leave events for AliasMethodNode nodes.
      #--
      #: (AliasMethodNode node) -> void
      def visit_alias_method_node(node)
        listeners[:on_alias_method_node_enter]&.each { |listener| listener.on_alias_method_node_enter(node) }
        listeners[:on_alias_method_node_leave]&.each { |listener| listener.on_alias_method_node_leave(node) }
      end

      # Dispatch enter and leave events for AlternationPatternNode nodes.
      #--
      #: (AlternationPatternNode node) -> void
      def visit_alternation_pattern_node(node)
        listeners[:on_alternation_pattern_node_enter]&.each { |listener| listener.on_alternation_pattern_node_enter(node) }
        listeners[:on_alternation_pattern_node_leave]&.each { |listener| listener.on_alternation_pattern_node_leave(node) }
      end

      # Dispatch enter and leave events for AndNode nodes.
      #--
      #: (AndNode node) -> void
      def visit_and_node(node)
        listeners[:on_and_node_enter]&.each { |listener| listener.on_and_node_enter(node) }
        listeners[:on_and_node_leave]&.each { |listener| listener.on_and_node_leave(node) }
      end

      # Dispatch enter and leave events for ArgumentsNode nodes.
      #--
      #: (ArgumentsNode node) -> void
      def visit_arguments_node(node)
        listeners[:on_arguments_node_enter]&.each { |listener| listener.on_arguments_node_enter(node) }
        listeners[:on_arguments_node_leave]&.each { |listener| listener.on_arguments_node_leave(node) }
      end

      # Dispatch enter and leave events for ArrayNode nodes.
      #--
      #: (ArrayNode node) -> void
      def visit_array_node(node)
        listeners[:on_array_node_enter]&.each { |listener| listener.on_array_node_enter(node) }
        listeners[:on_array_node_leave]&.each { |listener| listener.on_array_node_leave(node) }
      end

      # Dispatch enter and leave events for ArrayPatternNode nodes.
      #--
      #: (ArrayPatternNode node) -> void
      def visit_array_pattern_node(node)
        listeners[:on_array_pattern_node_enter]&.each { |listener| listener.on_array_pattern_node_enter(node) }
        listeners[:on_array_pattern_node_leave]&.each { |listener| listener.on_array_pattern_node_leave(node) }
      end

      # Dispatch enter and leave events for AssocNode nodes.
      #--
      #: (AssocNode node) -> void
      def visit_assoc_node(node)
        listeners[:on_assoc_node_enter]&.each { |listener| listener.on_assoc_node_enter(node) }
        listeners[:on_assoc_node_leave]&.each { |listener| listener.on_assoc_node_leave(node) }
      end

      # Dispatch enter and leave events for AssocSplatNode nodes.
      #--
      #: (AssocSplatNode node) -> void
      def visit_assoc_splat_node(node)
        listeners[:on_assoc_splat_node_enter]&.each { |listener| listener.on_assoc_splat_node_enter(node) }
        listeners[:on_assoc_splat_node_leave]&.each { |listener| listener.on_assoc_splat_node_leave(node) }
      end

      # Dispatch enter and leave events for BackReferenceReadNode nodes.
      #--
      #: (BackReferenceReadNode node) -> void
      def visit_back_reference_read_node(node)
        listeners[:on_back_reference_read_node_enter]&.each { |listener| listener.on_back_reference_read_node_enter(node) }
        listeners[:on_back_reference_read_node_leave]&.each { |listener| listener.on_back_reference_read_node_leave(node) }
      end

      # Dispatch enter and leave events for BeginNode nodes.
      #--
      #: (BeginNode node) -> void
      def visit_begin_node(node)
        listeners[:on_begin_node_enter]&.each { |listener| listener.on_begin_node_enter(node) }
        listeners[:on_begin_node_leave]&.each { |listener| listener.on_begin_node_leave(node) }
      end

      # Dispatch enter and leave events for BlockArgumentNode nodes.
      #--
      #: (BlockArgumentNode node) -> void
      def visit_block_argument_node(node)
        listeners[:on_block_argument_node_enter]&.each { |listener| listener.on_block_argument_node_enter(node) }
        listeners[:on_block_argument_node_leave]&.each { |listener| listener.on_block_argument_node_leave(node) }
      end

      # Dispatch enter and leave events for BlockLocalVariableNode nodes.
      #--
      #: (BlockLocalVariableNode node) -> void
      def visit_block_local_variable_node(node)
        listeners[:on_block_local_variable_node_enter]&.each { |listener| listener.on_block_local_variable_node_enter(node) }
        listeners[:on_block_local_variable_node_leave]&.each { |listener| listener.on_block_local_variable_node_leave(node) }
      end

      # Dispatch enter and leave events for BlockNode nodes.
      #--
      #: (BlockNode node) -> void
      def visit_block_node(node)
        listeners[:on_block_node_enter]&.each { |listener| listener.on_block_node_enter(node) }
        listeners[:on_block_node_leave]&.each { |listener| listener.on_block_node_leave(node) }
      end

      # Dispatch enter and leave events for BlockParameterNode nodes.
      #--
      #: (BlockParameterNode node) -> void
      def visit_block_parameter_node(node)
        listeners[:on_block_parameter_node_enter]&.each { |listener| listener.on_block_parameter_node_enter(node) }
        listeners[:on_block_parameter_node_leave]&.each { |listener| listener.on_block_parameter_node_leave(node) }
      end

      # Dispatch enter and leave events for BlockParametersNode nodes.
      #--
      #: (BlockParametersNode node) -> void
      def visit_block_parameters_node(node)
        listeners[:on_block_parameters_node_enter]&.each { |listener| listener.on_block_parameters_node_enter(node) }
        listeners[:on_block_parameters_node_leave]&.each { |listener| listener.on_block_parameters_node_leave(node) }
      end

      # Dispatch enter and leave events for BreakNode nodes.
      #--
      #: (BreakNode node) -> void
      def visit_break_node(node)
        listeners[:on_break_node_enter]&.each { |listener| listener.on_break_node_enter(node) }
        listeners[:on_break_node_leave]&.each { |listener| listener.on_break_node_leave(node) }
      end

      # Dispatch enter and leave events for CallAndWriteNode nodes.
      #--
      #: (CallAndWriteNode node) -> void
      def visit_call_and_write_node(node)
        listeners[:on_call_and_write_node_enter]&.each { |listener| listener.on_call_and_write_node_enter(node) }
        listeners[:on_call_and_write_node_leave]&.each { |listener| listener.on_call_and_write_node_leave(node) }
      end

      # Dispatch enter and leave events for CallNode nodes.
      #--
      #: (CallNode node) -> void
      def visit_call_node(node)
        listeners[:on_call_node_enter]&.each { |listener| listener.on_call_node_enter(node) }
        listeners[:on_call_node_leave]&.each { |listener| listener.on_call_node_leave(node) }
      end

      # Dispatch enter and leave events for CallOperatorWriteNode nodes.
      #--
      #: (CallOperatorWriteNode node) -> void
      def visit_call_operator_write_node(node)
        listeners[:on_call_operator_write_node_enter]&.each { |listener| listener.on_call_operator_write_node_enter(node) }
        listeners[:on_call_operator_write_node_leave]&.each { |listener| listener.on_call_operator_write_node_leave(node) }
      end

      # Dispatch enter and leave events for CallOrWriteNode nodes.
      #--
      #: (CallOrWriteNode node) -> void
      def visit_call_or_write_node(node)
        listeners[:on_call_or_write_node_enter]&.each { |listener| listener.on_call_or_write_node_enter(node) }
        listeners[:on_call_or_write_node_leave]&.each { |listener| listener.on_call_or_write_node_leave(node) }
      end

      # Dispatch enter and leave events for CallTargetNode nodes.
      #--
      #: (CallTargetNode node) -> void
      def visit_call_target_node(node)
        listeners[:on_call_target_node_enter]&.each { |listener| listener.on_call_target_node_enter(node) }
        listeners[:on_call_target_node_leave]&.each { |listener| listener.on_call_target_node_leave(node) }
      end

      # Dispatch enter and leave events for CapturePatternNode nodes.
      #--
      #: (CapturePatternNode node) -> void
      def visit_capture_pattern_node(node)
        listeners[:on_capture_pattern_node_enter]&.each { |listener| listener.on_capture_pattern_node_enter(node) }
        listeners[:on_capture_pattern_node_leave]&.each { |listener| listener.on_capture_pattern_node_leave(node) }
      end

      # Dispatch enter and leave events for CaseMatchNode nodes.
      #--
      #: (CaseMatchNode node) -> void
      def visit_case_match_node(node)
        listeners[:on_case_match_node_enter]&.each { |listener| listener.on_case_match_node_enter(node) }
        listeners[:on_case_match_node_leave]&.each { |listener| listener.on_case_match_node_leave(node) }
      end

      # Dispatch enter and leave events for CaseNode nodes.
      #--
      #: (CaseNode node) -> void
      def visit_case_node(node)
        listeners[:on_case_node_enter]&.each { |listener| listener.on_case_node_enter(node) }
        listeners[:on_case_node_leave]&.each { |listener| listener.on_case_node_leave(node) }
      end

      # Dispatch enter and leave events for ClassNode nodes.
      #--
      #: (ClassNode node) -> void
      def visit_class_node(node)
        listeners[:on_class_node_enter]&.each { |listener| listener.on_class_node_enter(node) }
        listeners[:on_class_node_leave]&.each { |listener| listener.on_class_node_leave(node) }
      end

      # Dispatch enter and leave events for ClassVariableAndWriteNode nodes.
      #--
      #: (ClassVariableAndWriteNode node) -> void
      def visit_class_variable_and_write_node(node)
        listeners[:on_class_variable_and_write_node_enter]&.each { |listener| listener.on_class_variable_and_write_node_enter(node) }
        listeners[:on_class_variable_and_write_node_leave]&.each { |listener| listener.on_class_variable_and_write_node_leave(node) }
      end

      # Dispatch enter and leave events for ClassVariableOperatorWriteNode nodes.
      #--
      #: (ClassVariableOperatorWriteNode node) -> void
      def visit_class_variable_operator_write_node(node)
        listeners[:on_class_variable_operator_write_node_enter]&.each { |listener| listener.on_class_variable_operator_write_node_enter(node) }
        listeners[:on_class_variable_operator_write_node_leave]&.each { |listener| listener.on_class_variable_operator_write_node_leave(node) }
      end

      # Dispatch enter and leave events for ClassVariableOrWriteNode nodes.
      #--
      #: (ClassVariableOrWriteNode node) -> void
      def visit_class_variable_or_write_node(node)
        listeners[:on_class_variable_or_write_node_enter]&.each { |listener| listener.on_class_variable_or_write_node_enter(node) }
        listeners[:on_class_variable_or_write_node_leave]&.each { |listener| listener.on_class_variable_or_write_node_leave(node) }
      end

      # Dispatch enter and leave events for ClassVariableReadNode nodes.
      #--
      #: (ClassVariableReadNode node) -> void
      def visit_class_variable_read_node(node)
        listeners[:on_class_variable_read_node_enter]&.each { |listener| listener.on_class_variable_read_node_enter(node) }
        listeners[:on_class_variable_read_node_leave]&.each { |listener| listener.on_class_variable_read_node_leave(node) }
      end

      # Dispatch enter and leave events for ClassVariableTargetNode nodes.
      #--
      #: (ClassVariableTargetNode node) -> void
      def visit_class_variable_target_node(node)
        listeners[:on_class_variable_target_node_enter]&.each { |listener| listener.on_class_variable_target_node_enter(node) }
        listeners[:on_class_variable_target_node_leave]&.each { |listener| listener.on_class_variable_target_node_leave(node) }
      end

      # Dispatch enter and leave events for ClassVariableWriteNode nodes.
      #--
      #: (ClassVariableWriteNode node) -> void
      def visit_class_variable_write_node(node)
        listeners[:on_class_variable_write_node_enter]&.each { |listener| listener.on_class_variable_write_node_enter(node) }
        listeners[:on_class_variable_write_node_leave]&.each { |listener| listener.on_class_variable_write_node_leave(node) }
      end

      # Dispatch enter and leave events for ConstantAndWriteNode nodes.
      #--
      #: (ConstantAndWriteNode node) -> void
      def visit_constant_and_write_node(node)
        listeners[:on_constant_and_write_node_enter]&.each { |listener| listener.on_constant_and_write_node_enter(node) }
        listeners[:on_constant_and_write_node_leave]&.each { |listener| listener.on_constant_and_write_node_leave(node) }
      end

      # Dispatch enter and leave events for ConstantOperatorWriteNode nodes.
      #--
      #: (ConstantOperatorWriteNode node) -> void
      def visit_constant_operator_write_node(node)
        listeners[:on_constant_operator_write_node_enter]&.each { |listener| listener.on_constant_operator_write_node_enter(node) }
        listeners[:on_constant_operator_write_node_leave]&.each { |listener| listener.on_constant_operator_write_node_leave(node) }
      end

      # Dispatch enter and leave events for ConstantOrWriteNode nodes.
      #--
      #: (ConstantOrWriteNode node) -> void
      def visit_constant_or_write_node(node)
        listeners[:on_constant_or_write_node_enter]&.each { |listener| listener.on_constant_or_write_node_enter(node) }
        listeners[:on_constant_or_write_node_leave]&.each { |listener| listener.on_constant_or_write_node_leave(node) }
      end

      # Dispatch enter and leave events for ConstantPathAndWriteNode nodes.
      #--
      #: (ConstantPathAndWriteNode node) -> void
      def visit_constant_path_and_write_node(node)
        listeners[:on_constant_path_and_write_node_enter]&.each { |listener| listener.on_constant_path_and_write_node_enter(node) }
        listeners[:on_constant_path_and_write_node_leave]&.each { |listener| listener.on_constant_path_and_write_node_leave(node) }
      end

      # Dispatch enter and leave events for ConstantPathNode nodes.
      #--
      #: (ConstantPathNode node) -> void
      def visit_constant_path_node(node)
        listeners[:on_constant_path_node_enter]&.each { |listener| listener.on_constant_path_node_enter(node) }
        listeners[:on_constant_path_node_leave]&.each { |listener| listener.on_constant_path_node_leave(node) }
      end

      # Dispatch enter and leave events for ConstantPathOperatorWriteNode nodes.
      #--
      #: (ConstantPathOperatorWriteNode node) -> void
      def visit_constant_path_operator_write_node(node)
        listeners[:on_constant_path_operator_write_node_enter]&.each { |listener| listener.on_constant_path_operator_write_node_enter(node) }
        listeners[:on_constant_path_operator_write_node_leave]&.each { |listener| listener.on_constant_path_operator_write_node_leave(node) }
      end

      # Dispatch enter and leave events for ConstantPathOrWriteNode nodes.
      #--
      #: (ConstantPathOrWriteNode node) -> void
      def visit_constant_path_or_write_node(node)
        listeners[:on_constant_path_or_write_node_enter]&.each { |listener| listener.on_constant_path_or_write_node_enter(node) }
        listeners[:on_constant_path_or_write_node_leave]&.each { |listener| listener.on_constant_path_or_write_node_leave(node) }
      end

      # Dispatch enter and leave events for ConstantPathTargetNode nodes.
      #--
      #: (ConstantPathTargetNode node) -> void
      def visit_constant_path_target_node(node)
        listeners[:on_constant_path_target_node_enter]&.each { |listener| listener.on_constant_path_target_node_enter(node) }
        listeners[:on_constant_path_target_node_leave]&.each { |listener| listener.on_constant_path_target_node_leave(node) }
      end

      # Dispatch enter and leave events for ConstantPathWriteNode nodes.
      #--
      #: (ConstantPathWriteNode node) -> void
      def visit_constant_path_write_node(node)
        listeners[:on_constant_path_write_node_enter]&.each { |listener| listener.on_constant_path_write_node_enter(node) }
        listeners[:on_constant_path_write_node_leave]&.each { |listener| listener.on_constant_path_write_node_leave(node) }
      end

      # Dispatch enter and leave events for ConstantReadNode nodes.
      #--
      #: (ConstantReadNode node) -> void
      def visit_constant_read_node(node)
        listeners[:on_constant_read_node_enter]&.each { |listener| listener.on_constant_read_node_enter(node) }
        listeners[:on_constant_read_node_leave]&.each { |listener| listener.on_constant_read_node_leave(node) }
      end

      # Dispatch enter and leave events for ConstantTargetNode nodes.
      #--
      #: (ConstantTargetNode node) -> void
      def visit_constant_target_node(node)
        listeners[:on_constant_target_node_enter]&.each { |listener| listener.on_constant_target_node_enter(node) }
        listeners[:on_constant_target_node_leave]&.each { |listener| listener.on_constant_target_node_leave(node) }
      end

      # Dispatch enter and leave events for ConstantWriteNode nodes.
      #--
      #: (ConstantWriteNode node) -> void
      def visit_constant_write_node(node)
        listeners[:on_constant_write_node_enter]&.each { |listener| listener.on_constant_write_node_enter(node) }
        listeners[:on_constant_write_node_leave]&.each { |listener| listener.on_constant_write_node_leave(node) }
      end

      # Dispatch enter and leave events for DefNode nodes.
      #--
      #: (DefNode node) -> void
      def visit_def_node(node)
        listeners[:on_def_node_enter]&.each { |listener| listener.on_def_node_enter(node) }
        listeners[:on_def_node_leave]&.each { |listener| listener.on_def_node_leave(node) }
      end

      # Dispatch enter and leave events for DefinedNode nodes.
      #--
      #: (DefinedNode node) -> void
      def visit_defined_node(node)
        listeners[:on_defined_node_enter]&.each { |listener| listener.on_defined_node_enter(node) }
        listeners[:on_defined_node_leave]&.each { |listener| listener.on_defined_node_leave(node) }
      end

      # Dispatch enter and leave events for ElseNode nodes.
      #--
      #: (ElseNode node) -> void
      def visit_else_node(node)
        listeners[:on_else_node_enter]&.each { |listener| listener.on_else_node_enter(node) }
        listeners[:on_else_node_leave]&.each { |listener| listener.on_else_node_leave(node) }
      end

      # Dispatch enter and leave events for EmbeddedStatementsNode nodes.
      #--
      #: (EmbeddedStatementsNode node) -> void
      def visit_embedded_statements_node(node)
        listeners[:on_embedded_statements_node_enter]&.each { |listener| listener.on_embedded_statements_node_enter(node) }
        listeners[:on_embedded_statements_node_leave]&.each { |listener| listener.on_embedded_statements_node_leave(node) }
      end

      # Dispatch enter and leave events for EmbeddedVariableNode nodes.
      #--
      #: (EmbeddedVariableNode node) -> void
      def visit_embedded_variable_node(node)
        listeners[:on_embedded_variable_node_enter]&.each { |listener| listener.on_embedded_variable_node_enter(node) }
        listeners[:on_embedded_variable_node_leave]&.each { |listener| listener.on_embedded_variable_node_leave(node) }
      end

      # Dispatch enter and leave events for EnsureNode nodes.
      #--
      #: (EnsureNode node) -> void
      def visit_ensure_node(node)
        listeners[:on_ensure_node_enter]&.each { |listener| listener.on_ensure_node_enter(node) }
        listeners[:on_ensure_node_leave]&.each { |listener| listener.on_ensure_node_leave(node) }
      end

      # Dispatch enter and leave events for ErrorRecoveryNode nodes.
      #--
      #: (ErrorRecoveryNode node) -> void
      def visit_error_recovery_node(node)
        listeners[:on_error_recovery_node_enter]&.each { |listener| listener.on_error_recovery_node_enter(node) }
        listeners[:on_error_recovery_node_leave]&.each { |listener| listener.on_error_recovery_node_leave(node) }
      end

      # Dispatch enter and leave events for FalseNode nodes.
      #--
      #: (FalseNode node) -> void
      def visit_false_node(node)
        listeners[:on_false_node_enter]&.each { |listener| listener.on_false_node_enter(node) }
        listeners[:on_false_node_leave]&.each { |listener| listener.on_false_node_leave(node) }
      end

      # Dispatch enter and leave events for FindPatternNode nodes.
      #--
      #: (FindPatternNode node) -> void
      def visit_find_pattern_node(node)
        listeners[:on_find_pattern_node_enter]&.each { |listener| listener.on_find_pattern_node_enter(node) }
        listeners[:on_find_pattern_node_leave]&.each { |listener| listener.on_find_pattern_node_leave(node) }
      end

      # Dispatch enter and leave events for FlipFlopNode nodes.
      #--
      #: (FlipFlopNode node) -> void
      def visit_flip_flop_node(node)
        listeners[:on_flip_flop_node_enter]&.each { |listener| listener.on_flip_flop_node_enter(node) }
        listeners[:on_flip_flop_node_leave]&.each { |listener| listener.on_flip_flop_node_leave(node) }
      end

      # Dispatch enter and leave events for FloatNode nodes.
      #--
      #: (FloatNode node) -> void
      def visit_float_node(node)
        listeners[:on_float_node_enter]&.each { |listener| listener.on_float_node_enter(node) }
        listeners[:on_float_node_leave]&.each { |listener| listener.on_float_node_leave(node) }
      end

      # Dispatch enter and leave events for ForNode nodes.
      #--
      #: (ForNode node) -> void
      def visit_for_node(node)
        listeners[:on_for_node_enter]&.each { |listener| listener.on_for_node_enter(node) }
        listeners[:on_for_node_leave]&.each { |listener| listener.on_for_node_leave(node) }
      end

      # Dispatch enter and leave events for ForwardingArgumentsNode nodes.
      #--
      #: (ForwardingArgumentsNode node) -> void
      def visit_forwarding_arguments_node(node)
        listeners[:on_forwarding_arguments_node_enter]&.each { |listener| listener.on_forwarding_arguments_node_enter(node) }
        listeners[:on_forwarding_arguments_node_leave]&.each { |listener| listener.on_forwarding_arguments_node_leave(node) }
      end

      # Dispatch enter and leave events for ForwardingParameterNode nodes.
      #--
      #: (ForwardingParameterNode node) -> void
      def visit_forwarding_parameter_node(node)
        listeners[:on_forwarding_parameter_node_enter]&.each { |listener| listener.on_forwarding_parameter_node_enter(node) }
        listeners[:on_forwarding_parameter_node_leave]&.each { |listener| listener.on_forwarding_parameter_node_leave(node) }
      end

      # Dispatch enter and leave events for ForwardingSuperNode nodes.
      #--
      #: (ForwardingSuperNode node) -> void
      def visit_forwarding_super_node(node)
        listeners[:on_forwarding_super_node_enter]&.each { |listener| listener.on_forwarding_super_node_enter(node) }
        listeners[:on_forwarding_super_node_leave]&.each { |listener| listener.on_forwarding_super_node_leave(node) }
      end

      # Dispatch enter and leave events for GlobalVariableAndWriteNode nodes.
      #--
      #: (GlobalVariableAndWriteNode node) -> void
      def visit_global_variable_and_write_node(node)
        listeners[:on_global_variable_and_write_node_enter]&.each { |listener| listener.on_global_variable_and_write_node_enter(node) }
        listeners[:on_global_variable_and_write_node_leave]&.each { |listener| listener.on_global_variable_and_write_node_leave(node) }
      end

      # Dispatch enter and leave events for GlobalVariableOperatorWriteNode nodes.
      #--
      #: (GlobalVariableOperatorWriteNode node) -> void
      def visit_global_variable_operator_write_node(node)
        listeners[:on_global_variable_operator_write_node_enter]&.each { |listener| listener.on_global_variable_operator_write_node_enter(node) }
        listeners[:on_global_variable_operator_write_node_leave]&.each { |listener| listener.on_global_variable_operator_write_node_leave(node) }
      end

      # Dispatch enter and leave events for GlobalVariableOrWriteNode nodes.
      #--
      #: (GlobalVariableOrWriteNode node) -> void
      def visit_global_variable_or_write_node(node)
        listeners[:on_global_variable_or_write_node_enter]&.each { |listener| listener.on_global_variable_or_write_node_enter(node) }
        listeners[:on_global_variable_or_write_node_leave]&.each { |listener| listener.on_global_variable_or_write_node_leave(node) }
      end

      # Dispatch enter and leave events for GlobalVariableReadNode nodes.
      #--
      #: (GlobalVariableReadNode node) -> void
      def visit_global_variable_read_node(node)
        listeners[:on_global_variable_read_node_enter]&.each { |listener| listener.on_global_variable_read_node_enter(node) }
        listeners[:on_global_variable_read_node_leave]&.each { |listener| listener.on_global_variable_read_node_leave(node) }
      end

      # Dispatch enter and leave events for GlobalVariableTargetNode nodes.
      #--
      #: (GlobalVariableTargetNode node) -> void
      def visit_global_variable_target_node(node)
        listeners[:on_global_variable_target_node_enter]&.each { |listener| listener.on_global_variable_target_node_enter(node) }
        listeners[:on_global_variable_target_node_leave]&.each { |listener| listener.on_global_variable_target_node_leave(node) }
      end

      # Dispatch enter and leave events for GlobalVariableWriteNode nodes.
      #--
      #: (GlobalVariableWriteNode node) -> void
      def visit_global_variable_write_node(node)
        listeners[:on_global_variable_write_node_enter]&.each { |listener| listener.on_global_variable_write_node_enter(node) }
        listeners[:on_global_variable_write_node_leave]&.each { |listener| listener.on_global_variable_write_node_leave(node) }
      end

      # Dispatch enter and leave events for HashNode nodes.
      #--
      #: (HashNode node) -> void
      def visit_hash_node(node)
        listeners[:on_hash_node_enter]&.each { |listener| listener.on_hash_node_enter(node) }
        listeners[:on_hash_node_leave]&.each { |listener| listener.on_hash_node_leave(node) }
      end

      # Dispatch enter and leave events for HashPatternNode nodes.
      #--
      #: (HashPatternNode node) -> void
      def visit_hash_pattern_node(node)
        listeners[:on_hash_pattern_node_enter]&.each { |listener| listener.on_hash_pattern_node_enter(node) }
        listeners[:on_hash_pattern_node_leave]&.each { |listener| listener.on_hash_pattern_node_leave(node) }
      end

      # Dispatch enter and leave events for IfNode nodes.
      #--
      #: (IfNode node) -> void
      def visit_if_node(node)
        listeners[:on_if_node_enter]&.each { |listener| listener.on_if_node_enter(node) }
        listeners[:on_if_node_leave]&.each { |listener| listener.on_if_node_leave(node) }
      end

      # Dispatch enter and leave events for ImaginaryNode nodes.
      #--
      #: (ImaginaryNode node) -> void
      def visit_imaginary_node(node)
        listeners[:on_imaginary_node_enter]&.each { |listener| listener.on_imaginary_node_enter(node) }
        listeners[:on_imaginary_node_leave]&.each { |listener| listener.on_imaginary_node_leave(node) }
      end

      # Dispatch enter and leave events for ImplicitNode nodes.
      #--
      #: (ImplicitNode node) -> void
      def visit_implicit_node(node)
        listeners[:on_implicit_node_enter]&.each { |listener| listener.on_implicit_node_enter(node) }
        listeners[:on_implicit_node_leave]&.each { |listener| listener.on_implicit_node_leave(node) }
      end

      # Dispatch enter and leave events for ImplicitRestNode nodes.
      #--
      #: (ImplicitRestNode node) -> void
      def visit_implicit_rest_node(node)
        listeners[:on_implicit_rest_node_enter]&.each { |listener| listener.on_implicit_rest_node_enter(node) }
        listeners[:on_implicit_rest_node_leave]&.each { |listener| listener.on_implicit_rest_node_leave(node) }
      end

      # Dispatch enter and leave events for InNode nodes.
      #--
      #: (InNode node) -> void
      def visit_in_node(node)
        listeners[:on_in_node_enter]&.each { |listener| listener.on_in_node_enter(node) }
        listeners[:on_in_node_leave]&.each { |listener| listener.on_in_node_leave(node) }
      end

      # Dispatch enter and leave events for IndexAndWriteNode nodes.
      #--
      #: (IndexAndWriteNode node) -> void
      def visit_index_and_write_node(node)
        listeners[:on_index_and_write_node_enter]&.each { |listener| listener.on_index_and_write_node_enter(node) }
        listeners[:on_index_and_write_node_leave]&.each { |listener| listener.on_index_and_write_node_leave(node) }
      end

      # Dispatch enter and leave events for IndexOperatorWriteNode nodes.
      #--
      #: (IndexOperatorWriteNode node) -> void
      def visit_index_operator_write_node(node)
        listeners[:on_index_operator_write_node_enter]&.each { |listener| listener.on_index_operator_write_node_enter(node) }
        listeners[:on_index_operator_write_node_leave]&.each { |listener| listener.on_index_operator_write_node_leave(node) }
      end

      # Dispatch enter and leave events for IndexOrWriteNode nodes.
      #--
      #: (IndexOrWriteNode node) -> void
      def visit_index_or_write_node(node)
        listeners[:on_index_or_write_node_enter]&.each { |listener| listener.on_index_or_write_node_enter(node) }
        listeners[:on_index_or_write_node_leave]&.each { |listener| listener.on_index_or_write_node_leave(node) }
      end

      # Dispatch enter and leave events for IndexTargetNode nodes.
      #--
      #: (IndexTargetNode node) -> void
      def visit_index_target_node(node)
        listeners[:on_index_target_node_enter]&.each { |listener| listener.on_index_target_node_enter(node) }
        listeners[:on_index_target_node_leave]&.each { |listener| listener.on_index_target_node_leave(node) }
      end

      # Dispatch enter and leave events for InstanceVariableAndWriteNode nodes.
      #--
      #: (InstanceVariableAndWriteNode node) -> void
      def visit_instance_variable_and_write_node(node)
        listeners[:on_instance_variable_and_write_node_enter]&.each { |listener| listener.on_instance_variable_and_write_node_enter(node) }
        listeners[:on_instance_variable_and_write_node_leave]&.each { |listener| listener.on_instance_variable_and_write_node_leave(node) }
      end

      # Dispatch enter and leave events for InstanceVariableOperatorWriteNode nodes.
      #--
      #: (InstanceVariableOperatorWriteNode node) -> void
      def visit_instance_variable_operator_write_node(node)
        listeners[:on_instance_variable_operator_write_node_enter]&.each { |listener| listener.on_instance_variable_operator_write_node_enter(node) }
        listeners[:on_instance_variable_operator_write_node_leave]&.each { |listener| listener.on_instance_variable_operator_write_node_leave(node) }
      end

      # Dispatch enter and leave events for InstanceVariableOrWriteNode nodes.
      #--
      #: (InstanceVariableOrWriteNode node) -> void
      def visit_instance_variable_or_write_node(node)
        listeners[:on_instance_variable_or_write_node_enter]&.each { |listener| listener.on_instance_variable_or_write_node_enter(node) }
        listeners[:on_instance_variable_or_write_node_leave]&.each { |listener| listener.on_instance_variable_or_write_node_leave(node) }
      end

      # Dispatch enter and leave events for InstanceVariableReadNode nodes.
      #--
      #: (InstanceVariableReadNode node) -> void
      def visit_instance_variable_read_node(node)
        listeners[:on_instance_variable_read_node_enter]&.each { |listener| listener.on_instance_variable_read_node_enter(node) }
        listeners[:on_instance_variable_read_node_leave]&.each { |listener| listener.on_instance_variable_read_node_leave(node) }
      end

      # Dispatch enter and leave events for InstanceVariableTargetNode nodes.
      #--
      #: (InstanceVariableTargetNode node) -> void
      def visit_instance_variable_target_node(node)
        listeners[:on_instance_variable_target_node_enter]&.each { |listener| listener.on_instance_variable_target_node_enter(node) }
        listeners[:on_instance_variable_target_node_leave]&.each { |listener| listener.on_instance_variable_target_node_leave(node) }
      end

      # Dispatch enter and leave events for InstanceVariableWriteNode nodes.
      #--
      #: (InstanceVariableWriteNode node) -> void
      def visit_instance_variable_write_node(node)
        listeners[:on_instance_variable_write_node_enter]&.each { |listener| listener.on_instance_variable_write_node_enter(node) }
        listeners[:on_instance_variable_write_node_leave]&.each { |listener| listener.on_instance_variable_write_node_leave(node) }
      end

      # Dispatch enter and leave events for IntegerNode nodes.
      #--
      #: (IntegerNode node) -> void
      def visit_integer_node(node)
        listeners[:on_integer_node_enter]&.each { |listener| listener.on_integer_node_enter(node) }
        listeners[:on_integer_node_leave]&.each { |listener| listener.on_integer_node_leave(node) }
      end

      # Dispatch enter and leave events for InterpolatedMatchLastLineNode nodes.
      #--
      #: (InterpolatedMatchLastLineNode node) -> void
      def visit_interpolated_match_last_line_node(node)
        listeners[:on_interpolated_match_last_line_node_enter]&.each { |listener| listener.on_interpolated_match_last_line_node_enter(node) }
        listeners[:on_interpolated_match_last_line_node_leave]&.each { |listener| listener.on_interpolated_match_last_line_node_leave(node) }
      end

      # Dispatch enter and leave events for InterpolatedRegularExpressionNode nodes.
      #--
      #: (InterpolatedRegularExpressionNode node) -> void
      def visit_interpolated_regular_expression_node(node)
        listeners[:on_interpolated_regular_expression_node_enter]&.each { |listener| listener.on_interpolated_regular_expression_node_enter(node) }
        listeners[:on_interpolated_regular_expression_node_leave]&.each { |listener| listener.on_interpolated_regular_expression_node_leave(node) }
      end

      # Dispatch enter and leave events for InterpolatedStringNode nodes.
      #--
      #: (InterpolatedStringNode node) -> void
      def visit_interpolated_string_node(node)
        listeners[:on_interpolated_string_node_enter]&.each { |listener| listener.on_interpolated_string_node_enter(node) }
        listeners[:on_interpolated_string_node_leave]&.each { |listener| listener.on_interpolated_string_node_leave(node) }
      end

      # Dispatch enter and leave events for InterpolatedSymbolNode nodes.
      #--
      #: (InterpolatedSymbolNode node) -> void
      def visit_interpolated_symbol_node(node)
        listeners[:on_interpolated_symbol_node_enter]&.each { |listener| listener.on_interpolated_symbol_node_enter(node) }
        listeners[:on_interpolated_symbol_node_leave]&.each { |listener| listener.on_interpolated_symbol_node_leave(node) }
      end

      # Dispatch enter and leave events for InterpolatedXStringNode nodes.
      #--
      #: (InterpolatedXStringNode node) -> void
      def visit_interpolated_x_string_node(node)
        listeners[:on_interpolated_x_string_node_enter]&.each { |listener| listener.on_interpolated_x_string_node_enter(node) }
        listeners[:on_interpolated_x_string_node_leave]&.each { |listener| listener.on_interpolated_x_string_node_leave(node) }
      end

      # Dispatch enter and leave events for ItLocalVariableReadNode nodes.
      #--
      #: (ItLocalVariableReadNode node) -> void
      def visit_it_local_variable_read_node(node)
        listeners[:on_it_local_variable_read_node_enter]&.each { |listener| listener.on_it_local_variable_read_node_enter(node) }
        listeners[:on_it_local_variable_read_node_leave]&.each { |listener| listener.on_it_local_variable_read_node_leave(node) }
      end

      # Dispatch enter and leave events for ItParametersNode nodes.
      #--
      #: (ItParametersNode node) -> void
      def visit_it_parameters_node(node)
        listeners[:on_it_parameters_node_enter]&.each { |listener| listener.on_it_parameters_node_enter(node) }
        listeners[:on_it_parameters_node_leave]&.each { |listener| listener.on_it_parameters_node_leave(node) }
      end

      # Dispatch enter and leave events for KeywordHashNode nodes.
      #--
      #: (KeywordHashNode node) -> void
      def visit_keyword_hash_node(node)
        listeners[:on_keyword_hash_node_enter]&.each { |listener| listener.on_keyword_hash_node_enter(node) }
        listeners[:on_keyword_hash_node_leave]&.each { |listener| listener.on_keyword_hash_node_leave(node) }
      end

      # Dispatch enter and leave events for KeywordRestParameterNode nodes.
      #--
      #: (KeywordRestParameterNode node) -> void
      def visit_keyword_rest_parameter_node(node)
        listeners[:on_keyword_rest_parameter_node_enter]&.each { |listener| listener.on_keyword_rest_parameter_node_enter(node) }
        listeners[:on_keyword_rest_parameter_node_leave]&.each { |listener| listener.on_keyword_rest_parameter_node_leave(node) }
      end

      # Dispatch enter and leave events for LambdaNode nodes.
      #--
      #: (LambdaNode node) -> void
      def visit_lambda_node(node)
        listeners[:on_lambda_node_enter]&.each { |listener| listener.on_lambda_node_enter(node) }
        listeners[:on_lambda_node_leave]&.each { |listener| listener.on_lambda_node_leave(node) }
      end

      # Dispatch enter and leave events for LocalVariableAndWriteNode nodes.
      #--
      #: (LocalVariableAndWriteNode node) -> void
      def visit_local_variable_and_write_node(node)
        listeners[:on_local_variable_and_write_node_enter]&.each { |listener| listener.on_local_variable_and_write_node_enter(node) }
        listeners[:on_local_variable_and_write_node_leave]&.each { |listener| listener.on_local_variable_and_write_node_leave(node) }
      end

      # Dispatch enter and leave events for LocalVariableOperatorWriteNode nodes.
      #--
      #: (LocalVariableOperatorWriteNode node) -> void
      def visit_local_variable_operator_write_node(node)
        listeners[:on_local_variable_operator_write_node_enter]&.each { |listener| listener.on_local_variable_operator_write_node_enter(node) }
        listeners[:on_local_variable_operator_write_node_leave]&.each { |listener| listener.on_local_variable_operator_write_node_leave(node) }
      end

      # Dispatch enter and leave events for LocalVariableOrWriteNode nodes.
      #--
      #: (LocalVariableOrWriteNode node) -> void
      def visit_local_variable_or_write_node(node)
        listeners[:on_local_variable_or_write_node_enter]&.each { |listener| listener.on_local_variable_or_write_node_enter(node) }
        listeners[:on_local_variable_or_write_node_leave]&.each { |listener| listener.on_local_variable_or_write_node_leave(node) }
      end

      # Dispatch enter and leave events for LocalVariableReadNode nodes.
      #--
      #: (LocalVariableReadNode node) -> void
      def visit_local_variable_read_node(node)
        listeners[:on_local_variable_read_node_enter]&.each { |listener| listener.on_local_variable_read_node_enter(node) }
        listeners[:on_local_variable_read_node_leave]&.each { |listener| listener.on_local_variable_read_node_leave(node) }
      end

      # Dispatch enter and leave events for LocalVariableTargetNode nodes.
      #--
      #: (LocalVariableTargetNode node) -> void
      def visit_local_variable_target_node(node)
        listeners[:on_local_variable_target_node_enter]&.each { |listener| listener.on_local_variable_target_node_enter(node) }
        listeners[:on_local_variable_target_node_leave]&.each { |listener| listener.on_local_variable_target_node_leave(node) }
      end

      # Dispatch enter and leave events for LocalVariableWriteNode nodes.
      #--
      #: (LocalVariableWriteNode node) -> void
      def visit_local_variable_write_node(node)
        listeners[:on_local_variable_write_node_enter]&.each { |listener| listener.on_local_variable_write_node_enter(node) }
        listeners[:on_local_variable_write_node_leave]&.each { |listener| listener.on_local_variable_write_node_leave(node) }
      end

      # Dispatch enter and leave events for MatchLastLineNode nodes.
      #--
      #: (MatchLastLineNode node) -> void
      def visit_match_last_line_node(node)
        listeners[:on_match_last_line_node_enter]&.each { |listener| listener.on_match_last_line_node_enter(node) }
        listeners[:on_match_last_line_node_leave]&.each { |listener| listener.on_match_last_line_node_leave(node) }
      end

      # Dispatch enter and leave events for MatchPredicateNode nodes.
      #--
      #: (MatchPredicateNode node) -> void
      def visit_match_predicate_node(node)
        listeners[:on_match_predicate_node_enter]&.each { |listener| listener.on_match_predicate_node_enter(node) }
        listeners[:on_match_predicate_node_leave]&.each { |listener| listener.on_match_predicate_node_leave(node) }
      end

      # Dispatch enter and leave events for MatchRequiredNode nodes.
      #--
      #: (MatchRequiredNode node) -> void
      def visit_match_required_node(node)
        listeners[:on_match_required_node_enter]&.each { |listener| listener.on_match_required_node_enter(node) }
        listeners[:on_match_required_node_leave]&.each { |listener| listener.on_match_required_node_leave(node) }
      end

      # Dispatch enter and leave events for MatchWriteNode nodes.
      #--
      #: (MatchWriteNode node) -> void
      def visit_match_write_node(node)
        listeners[:on_match_write_node_enter]&.each { |listener| listener.on_match_write_node_enter(node) }
        listeners[:on_match_write_node_leave]&.each { |listener| listener.on_match_write_node_leave(node) }
      end

      # Dispatch enter and leave events for ModuleNode nodes.
      #--
      #: (ModuleNode node) -> void
      def visit_module_node(node)
        listeners[:on_module_node_enter]&.each { |listener| listener.on_module_node_enter(node) }
        listeners[:on_module_node_leave]&.each { |listener| listener.on_module_node_leave(node) }
      end

      # Dispatch enter and leave events for MultiTargetNode nodes.
      #--
      #: (MultiTargetNode node) -> void
      def visit_multi_target_node(node)
        listeners[:on_multi_target_node_enter]&.each { |listener| listener.on_multi_target_node_enter(node) }
        listeners[:on_multi_target_node_leave]&.each { |listener| listener.on_multi_target_node_leave(node) }
      end

      # Dispatch enter and leave events for MultiWriteNode nodes.
      #--
      #: (MultiWriteNode node) -> void
      def visit_multi_write_node(node)
        listeners[:on_multi_write_node_enter]&.each { |listener| listener.on_multi_write_node_enter(node) }
        listeners[:on_multi_write_node_leave]&.each { |listener| listener.on_multi_write_node_leave(node) }
      end

      # Dispatch enter and leave events for NextNode nodes.
      #--
      #: (NextNode node) -> void
      def visit_next_node(node)
        listeners[:on_next_node_enter]&.each { |listener| listener.on_next_node_enter(node) }
        listeners[:on_next_node_leave]&.each { |listener| listener.on_next_node_leave(node) }
      end

      # Dispatch enter and leave events for NilNode nodes.
      #--
      #: (NilNode node) -> void
      def visit_nil_node(node)
        listeners[:on_nil_node_enter]&.each { |listener| listener.on_nil_node_enter(node) }
        listeners[:on_nil_node_leave]&.each { |listener| listener.on_nil_node_leave(node) }
      end

      # Dispatch enter and leave events for NoBlockParameterNode nodes.
      #--
      #: (NoBlockParameterNode node) -> void
      def visit_no_block_parameter_node(node)
        listeners[:on_no_block_parameter_node_enter]&.each { |listener| listener.on_no_block_parameter_node_enter(node) }
        listeners[:on_no_block_parameter_node_leave]&.each { |listener| listener.on_no_block_parameter_node_leave(node) }
      end

      # Dispatch enter and leave events for NoKeywordsParameterNode nodes.
      #--
      #: (NoKeywordsParameterNode node) -> void
      def visit_no_keywords_parameter_node(node)
        listeners[:on_no_keywords_parameter_node_enter]&.each { |listener| listener.on_no_keywords_parameter_node_enter(node) }
        listeners[:on_no_keywords_parameter_node_leave]&.each { |listener| listener.on_no_keywords_parameter_node_leave(node) }
      end

      # Dispatch enter and leave events for NumberedParametersNode nodes.
      #--
      #: (NumberedParametersNode node) -> void
      def visit_numbered_parameters_node(node)
        listeners[:on_numbered_parameters_node_enter]&.each { |listener| listener.on_numbered_parameters_node_enter(node) }
        listeners[:on_numbered_parameters_node_leave]&.each { |listener| listener.on_numbered_parameters_node_leave(node) }
      end

      # Dispatch enter and leave events for NumberedReferenceReadNode nodes.
      #--
      #: (NumberedReferenceReadNode node) -> void
      def visit_numbered_reference_read_node(node)
        listeners[:on_numbered_reference_read_node_enter]&.each { |listener| listener.on_numbered_reference_read_node_enter(node) }
        listeners[:on_numbered_reference_read_node_leave]&.each { |listener| listener.on_numbered_reference_read_node_leave(node) }
      end

      # Dispatch enter and leave events for OptionalKeywordParameterNode nodes.
      #--
      #: (OptionalKeywordParameterNode node) -> void
      def visit_optional_keyword_parameter_node(node)
        listeners[:on_optional_keyword_parameter_node_enter]&.each { |listener| listener.on_optional_keyword_parameter_node_enter(node) }
        listeners[:on_optional_keyword_parameter_node_leave]&.each { |listener| listener.on_optional_keyword_parameter_node_leave(node) }
      end

      # Dispatch enter and leave events for OptionalParameterNode nodes.
      #--
      #: (OptionalParameterNode node) -> void
      def visit_optional_parameter_node(node)
        listeners[:on_optional_parameter_node_enter]&.each { |listener| listener.on_optional_parameter_node_enter(node) }
        listeners[:on_optional_parameter_node_leave]&.each { |listener| listener.on_optional_parameter_node_leave(node) }
      end

      # Dispatch enter and leave events for OrNode nodes.
      #--
      #: (OrNode node) -> void
      def visit_or_node(node)
        listeners[:on_or_node_enter]&.each { |listener| listener.on_or_node_enter(node) }
        listeners[:on_or_node_leave]&.each { |listener| listener.on_or_node_leave(node) }
      end

      # Dispatch enter and leave events for ParametersNode nodes.
      #--
      #: (ParametersNode node) -> void
      def visit_parameters_node(node)
        listeners[:on_parameters_node_enter]&.each { |listener| listener.on_parameters_node_enter(node) }
        listeners[:on_parameters_node_leave]&.each { |listener| listener.on_parameters_node_leave(node) }
      end

      # Dispatch enter and leave events for ParenthesesNode nodes.
      #--
      #: (ParenthesesNode node) -> void
      def visit_parentheses_node(node)
        listeners[:on_parentheses_node_enter]&.each { |listener| listener.on_parentheses_node_enter(node) }
        listeners[:on_parentheses_node_leave]&.each { |listener| listener.on_parentheses_node_leave(node) }
      end

      # Dispatch enter and leave events for PinnedExpressionNode nodes.
      #--
      #: (PinnedExpressionNode node) -> void
      def visit_pinned_expression_node(node)
        listeners[:on_pinned_expression_node_enter]&.each { |listener| listener.on_pinned_expression_node_enter(node) }
        listeners[:on_pinned_expression_node_leave]&.each { |listener| listener.on_pinned_expression_node_leave(node) }
      end

      # Dispatch enter and leave events for PinnedVariableNode nodes.
      #--
      #: (PinnedVariableNode node) -> void
      def visit_pinned_variable_node(node)
        listeners[:on_pinned_variable_node_enter]&.each { |listener| listener.on_pinned_variable_node_enter(node) }
        listeners[:on_pinned_variable_node_leave]&.each { |listener| listener.on_pinned_variable_node_leave(node) }
      end

      # Dispatch enter and leave events for PostExecutionNode nodes.
      #--
      #: (PostExecutionNode node) -> void
      def visit_post_execution_node(node)
        listeners[:on_post_execution_node_enter]&.each { |listener| listener.on_post_execution_node_enter(node) }
        listeners[:on_post_execution_node_leave]&.each { |listener| listener.on_post_execution_node_leave(node) }
      end

      # Dispatch enter and leave events for PreExecutionNode nodes.
      #--
      #: (PreExecutionNode node) -> void
      def visit_pre_execution_node(node)
        listeners[:on_pre_execution_node_enter]&.each { |listener| listener.on_pre_execution_node_enter(node) }
        listeners[:on_pre_execution_node_leave]&.each { |listener| listener.on_pre_execution_node_leave(node) }
      end

      # Dispatch enter and leave events for ProgramNode nodes.
      #--
      #: (ProgramNode node) -> void
      def visit_program_node(node)
        listeners[:on_program_node_enter]&.each { |listener| listener.on_program_node_enter(node) }
        listeners[:on_program_node_leave]&.each { |listener| listener.on_program_node_leave(node) }
      end

      # Dispatch enter and leave events for RangeNode nodes.
      #--
      #: (RangeNode node) -> void
      def visit_range_node(node)
        listeners[:on_range_node_enter]&.each { |listener| listener.on_range_node_enter(node) }
        listeners[:on_range_node_leave]&.each { |listener| listener.on_range_node_leave(node) }
      end

      # Dispatch enter and leave events for RationalNode nodes.
      #--
      #: (RationalNode node) -> void
      def visit_rational_node(node)
        listeners[:on_rational_node_enter]&.each { |listener| listener.on_rational_node_enter(node) }
        listeners[:on_rational_node_leave]&.each { |listener| listener.on_rational_node_leave(node) }
      end

      # Dispatch enter and leave events for RedoNode nodes.
      #--
      #: (RedoNode node) -> void
      def visit_redo_node(node)
        listeners[:on_redo_node_enter]&.each { |listener| listener.on_redo_node_enter(node) }
        listeners[:on_redo_node_leave]&.each { |listener| listener.on_redo_node_leave(node) }
      end

      # Dispatch enter and leave events for RegularExpressionNode nodes.
      #--
      #: (RegularExpressionNode node) -> void
      def visit_regular_expression_node(node)
        listeners[:on_regular_expression_node_enter]&.each { |listener| listener.on_regular_expression_node_enter(node) }
        listeners[:on_regular_expression_node_leave]&.each { |listener| listener.on_regular_expression_node_leave(node) }
      end

      # Dispatch enter and leave events for RequiredKeywordParameterNode nodes.
      #--
      #: (RequiredKeywordParameterNode node) -> void
      def visit_required_keyword_parameter_node(node)
        listeners[:on_required_keyword_parameter_node_enter]&.each { |listener| listener.on_required_keyword_parameter_node_enter(node) }
        listeners[:on_required_keyword_parameter_node_leave]&.each { |listener| listener.on_required_keyword_parameter_node_leave(node) }
      end

      # Dispatch enter and leave events for RequiredParameterNode nodes.
      #--
      #: (RequiredParameterNode node) -> void
      def visit_required_parameter_node(node)
        listeners[:on_required_parameter_node_enter]&.each { |listener| listener.on_required_parameter_node_enter(node) }
        listeners[:on_required_parameter_node_leave]&.each { |listener| listener.on_required_parameter_node_leave(node) }
      end

      # Dispatch enter and leave events for RescueModifierNode nodes.
      #--
      #: (RescueModifierNode node) -> void
      def visit_rescue_modifier_node(node)
        listeners[:on_rescue_modifier_node_enter]&.each { |listener| listener.on_rescue_modifier_node_enter(node) }
        listeners[:on_rescue_modifier_node_leave]&.each { |listener| listener.on_rescue_modifier_node_leave(node) }
      end

      # Dispatch enter and leave events for RescueNode nodes.
      #--
      #: (RescueNode node) -> void
      def visit_rescue_node(node)
        listeners[:on_rescue_node_enter]&.each { |listener| listener.on_rescue_node_enter(node) }
        listeners[:on_rescue_node_leave]&.each { |listener| listener.on_rescue_node_leave(node) }
      end

      # Dispatch enter and leave events for RestParameterNode nodes.
      #--
      #: (RestParameterNode node) -> void
      def visit_rest_parameter_node(node)
        listeners[:on_rest_parameter_node_enter]&.each { |listener| listener.on_rest_parameter_node_enter(node) }
        listeners[:on_rest_parameter_node_leave]&.each { |listener| listener.on_rest_parameter_node_leave(node) }
      end

      # Dispatch enter and leave events for RetryNode nodes.
      #--
      #: (RetryNode node) -> void
      def visit_retry_node(node)
        listeners[:on_retry_node_enter]&.each { |listener| listener.on_retry_node_enter(node) }
        listeners[:on_retry_node_leave]&.each { |listener| listener.on_retry_node_leave(node) }
      end

      # Dispatch enter and leave events for ReturnNode nodes.
      #--
      #: (ReturnNode node) -> void
      def visit_return_node(node)
        listeners[:on_return_node_enter]&.each { |listener| listener.on_return_node_enter(node) }
        listeners[:on_return_node_leave]&.each { |listener| listener.on_return_node_leave(node) }
      end

      # Dispatch enter and leave events for SelfNode nodes.
      #--
      #: (SelfNode node) -> void
      def visit_self_node(node)
        listeners[:on_self_node_enter]&.each { |listener| listener.on_self_node_enter(node) }
        listeners[:on_self_node_leave]&.each { |listener| listener.on_self_node_leave(node) }
      end

      # Dispatch enter and leave events for ShareableConstantNode nodes.
      #--
      #: (ShareableConstantNode node) -> void
      def visit_shareable_constant_node(node)
        listeners[:on_shareable_constant_node_enter]&.each { |listener| listener.on_shareable_constant_node_enter(node) }
        listeners[:on_shareable_constant_node_leave]&.each { |listener| listener.on_shareable_constant_node_leave(node) }
      end

      # Dispatch enter and leave events for SingletonClassNode nodes.
      #--
      #: (SingletonClassNode node) -> void
      def visit_singleton_class_node(node)
        listeners[:on_singleton_class_node_enter]&.each { |listener| listener.on_singleton_class_node_enter(node) }
        listeners[:on_singleton_class_node_leave]&.each { |listener| listener.on_singleton_class_node_leave(node) }
      end

      # Dispatch enter and leave events for SourceEncodingNode nodes.
      #--
      #: (SourceEncodingNode node) -> void
      def visit_source_encoding_node(node)
        listeners[:on_source_encoding_node_enter]&.each { |listener| listener.on_source_encoding_node_enter(node) }
        listeners[:on_source_encoding_node_leave]&.each { |listener| listener.on_source_encoding_node_leave(node) }
      end

      # Dispatch enter and leave events for SourceFileNode nodes.
      #--
      #: (SourceFileNode node) -> void
      def visit_source_file_node(node)
        listeners[:on_source_file_node_enter]&.each { |listener| listener.on_source_file_node_enter(node) }
        listeners[:on_source_file_node_leave]&.each { |listener| listener.on_source_file_node_leave(node) }
      end

      # Dispatch enter and leave events for SourceLineNode nodes.
      #--
      #: (SourceLineNode node) -> void
      def visit_source_line_node(node)
        listeners[:on_source_line_node_enter]&.each { |listener| listener.on_source_line_node_enter(node) }
        listeners[:on_source_line_node_leave]&.each { |listener| listener.on_source_line_node_leave(node) }
      end

      # Dispatch enter and leave events for SplatNode nodes.
      #--
      #: (SplatNode node) -> void
      def visit_splat_node(node)
        listeners[:on_splat_node_enter]&.each { |listener| listener.on_splat_node_enter(node) }
        listeners[:on_splat_node_leave]&.each { |listener| listener.on_splat_node_leave(node) }
      end

      # Dispatch enter and leave events for StatementsNode nodes.
      #--
      #: (StatementsNode node) -> void
      def visit_statements_node(node)
        listeners[:on_statements_node_enter]&.each { |listener| listener.on_statements_node_enter(node) }
        listeners[:on_statements_node_leave]&.each { |listener| listener.on_statements_node_leave(node) }
      end

      # Dispatch enter and leave events for StringNode nodes.
      #--
      #: (StringNode node) -> void
      def visit_string_node(node)
        listeners[:on_string_node_enter]&.each { |listener| listener.on_string_node_enter(node) }
        listeners[:on_string_node_leave]&.each { |listener| listener.on_string_node_leave(node) }
      end

      # Dispatch enter and leave events for SuperNode nodes.
      #--
      #: (SuperNode node) -> void
      def visit_super_node(node)
        listeners[:on_super_node_enter]&.each { |listener| listener.on_super_node_enter(node) }
        listeners[:on_super_node_leave]&.each { |listener| listener.on_super_node_leave(node) }
      end

      # Dispatch enter and leave events for SymbolNode nodes.
      #--
      #: (SymbolNode node) -> void
      def visit_symbol_node(node)
        listeners[:on_symbol_node_enter]&.each { |listener| listener.on_symbol_node_enter(node) }
        listeners[:on_symbol_node_leave]&.each { |listener| listener.on_symbol_node_leave(node) }
      end

      # Dispatch enter and leave events for TrueNode nodes.
      #--
      #: (TrueNode node) -> void
      def visit_true_node(node)
        listeners[:on_true_node_enter]&.each { |listener| listener.on_true_node_enter(node) }
        listeners[:on_true_node_leave]&.each { |listener| listener.on_true_node_leave(node) }
      end

      # Dispatch enter and leave events for UndefNode nodes.
      #--
      #: (UndefNode node) -> void
      def visit_undef_node(node)
        listeners[:on_undef_node_enter]&.each { |listener| listener.on_undef_node_enter(node) }
        listeners[:on_undef_node_leave]&.each { |listener| listener.on_undef_node_leave(node) }
      end

      # Dispatch enter and leave events for UnlessNode nodes.
      #--
      #: (UnlessNode node) -> void
      def visit_unless_node(node)
        listeners[:on_unless_node_enter]&.each { |listener| listener.on_unless_node_enter(node) }
        listeners[:on_unless_node_leave]&.each { |listener| listener.on_unless_node_leave(node) }
      end

      # Dispatch enter and leave events for UntilNode nodes.
      #--
      #: (UntilNode node) -> void
      def visit_until_node(node)
        listeners[:on_until_node_enter]&.each { |listener| listener.on_until_node_enter(node) }
        listeners[:on_until_node_leave]&.each { |listener| listener.on_until_node_leave(node) }
      end

      # Dispatch enter and leave events for WhenNode nodes.
      #--
      #: (WhenNode node) -> void
      def visit_when_node(node)
        listeners[:on_when_node_enter]&.each { |listener| listener.on_when_node_enter(node) }
        listeners[:on_when_node_leave]&.each { |listener| listener.on_when_node_leave(node) }
      end

      # Dispatch enter and leave events for WhileNode nodes.
      #--
      #: (WhileNode node) -> void
      def visit_while_node(node)
        listeners[:on_while_node_enter]&.each { |listener| listener.on_while_node_enter(node) }
        listeners[:on_while_node_leave]&.each { |listener| listener.on_while_node_leave(node) }
      end

      # Dispatch enter and leave events for XStringNode nodes.
      #--
      #: (XStringNode node) -> void
      def visit_x_string_node(node)
        listeners[:on_x_string_node_enter]&.each { |listener| listener.on_x_string_node_enter(node) }
        listeners[:on_x_string_node_leave]&.each { |listener| listener.on_x_string_node_leave(node) }
      end

      # Dispatch enter and leave events for YieldNode nodes.
      #--
      #: (YieldNode node) -> void
      def visit_yield_node(node)
        listeners[:on_yield_node_enter]&.each { |listener| listener.on_yield_node_enter(node) }
        listeners[:on_yield_node_leave]&.each { |listener| listener.on_yield_node_leave(node) }
      end
    end

    private_constant :DispatchOnce
  end
end
