# 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/mutation_compiler.rb.erb
if you are looking to modify the template
++
=end

#--
# rbs_inline: enabled

module Prism
  # This visitor walks through the tree and copies each node as it is being
  # visited. This is useful for consumers that want to mutate the tree, as you
  # can change subtrees in place without effecting the rest of the tree.
  class MutationCompiler < Compiler
    #: (AliasGlobalVariableNode) -> node?
    def visit_alias_global_variable_node(node) # :nodoc:
      node.copy(new_name: visit(node.new_name), old_name: visit(node.old_name))
    end

    #: (AliasMethodNode) -> node?
    def visit_alias_method_node(node) # :nodoc:
      node.copy(new_name: visit(node.new_name), old_name: visit(node.old_name))
    end

    #: (AlternationPatternNode) -> node?
    def visit_alternation_pattern_node(node) # :nodoc:
      node.copy(left: visit(node.left), right: visit(node.right))
    end

    #: (AndNode) -> node?
    def visit_and_node(node) # :nodoc:
      node.copy(left: visit(node.left), right: visit(node.right))
    end

    #: (ArgumentsNode) -> node?
    def visit_arguments_node(node) # :nodoc:
      node.copy(arguments: visit_all(node.arguments))
    end

    #: (ArrayNode) -> node?
    def visit_array_node(node) # :nodoc:
      node.copy(elements: visit_all(node.elements))
    end

    #: (ArrayPatternNode) -> node?
    def visit_array_pattern_node(node) # :nodoc:
      node.copy(constant: visit(node.constant), requireds: visit_all(node.requireds), rest: visit(node.rest), posts: visit_all(node.posts))
    end

    #: (AssocNode) -> node?
    def visit_assoc_node(node) # :nodoc:
      node.copy(key: visit(node.key), value: visit(node.value))
    end

    #: (AssocSplatNode) -> node?
    def visit_assoc_splat_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (BackReferenceReadNode) -> node?
    def visit_back_reference_read_node(node) # :nodoc:
      node.copy
    end

    #: (BeginNode) -> node?
    def visit_begin_node(node) # :nodoc:
      node.copy(statements: visit(node.statements), rescue_clause: visit(node.rescue_clause), else_clause: visit(node.else_clause), ensure_clause: visit(node.ensure_clause))
    end

    #: (BlockArgumentNode) -> node?
    def visit_block_argument_node(node) # :nodoc:
      node.copy(expression: visit(node.expression))
    end

    #: (BlockLocalVariableNode) -> node?
    def visit_block_local_variable_node(node) # :nodoc:
      node.copy
    end

    #: (BlockNode) -> node?
    def visit_block_node(node) # :nodoc:
      node.copy(parameters: visit(node.parameters), body: visit(node.body))
    end

    #: (BlockParameterNode) -> node?
    def visit_block_parameter_node(node) # :nodoc:
      node.copy
    end

    #: (BlockParametersNode) -> node?
    def visit_block_parameters_node(node) # :nodoc:
      node.copy(parameters: visit(node.parameters), locals: visit_all(node.locals))
    end

    #: (BreakNode) -> node?
    def visit_break_node(node) # :nodoc:
      node.copy(arguments: visit(node.arguments))
    end

    #: (CallAndWriteNode) -> node?
    def visit_call_and_write_node(node) # :nodoc:
      node.copy(receiver: visit(node.receiver), value: visit(node.value))
    end

    #: (CallNode) -> node?
    def visit_call_node(node) # :nodoc:
      node.copy(receiver: visit(node.receiver), arguments: visit(node.arguments), block: visit(node.block))
    end

    #: (CallOperatorWriteNode) -> node?
    def visit_call_operator_write_node(node) # :nodoc:
      node.copy(receiver: visit(node.receiver), value: visit(node.value))
    end

    #: (CallOrWriteNode) -> node?
    def visit_call_or_write_node(node) # :nodoc:
      node.copy(receiver: visit(node.receiver), value: visit(node.value))
    end

    #: (CallTargetNode) -> node?
    def visit_call_target_node(node) # :nodoc:
      node.copy(receiver: visit(node.receiver))
    end

    #: (CapturePatternNode) -> node?
    def visit_capture_pattern_node(node) # :nodoc:
      node.copy(value: visit(node.value), target: visit(node.target))
    end

    #: (CaseMatchNode) -> node?
    def visit_case_match_node(node) # :nodoc:
      node.copy(predicate: visit(node.predicate), conditions: visit_all(node.conditions), else_clause: visit(node.else_clause))
    end

    #: (CaseNode) -> node?
    def visit_case_node(node) # :nodoc:
      node.copy(predicate: visit(node.predicate), conditions: visit_all(node.conditions), else_clause: visit(node.else_clause))
    end

    #: (ClassNode) -> node?
    def visit_class_node(node) # :nodoc:
      node.copy(constant_path: visit(node.constant_path), superclass: visit(node.superclass), body: visit(node.body))
    end

    #: (ClassVariableAndWriteNode) -> node?
    def visit_class_variable_and_write_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (ClassVariableOperatorWriteNode) -> node?
    def visit_class_variable_operator_write_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (ClassVariableOrWriteNode) -> node?
    def visit_class_variable_or_write_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (ClassVariableReadNode) -> node?
    def visit_class_variable_read_node(node) # :nodoc:
      node.copy
    end

    #: (ClassVariableTargetNode) -> node?
    def visit_class_variable_target_node(node) # :nodoc:
      node.copy
    end

    #: (ClassVariableWriteNode) -> node?
    def visit_class_variable_write_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (ConstantAndWriteNode) -> node?
    def visit_constant_and_write_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (ConstantOperatorWriteNode) -> node?
    def visit_constant_operator_write_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (ConstantOrWriteNode) -> node?
    def visit_constant_or_write_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (ConstantPathAndWriteNode) -> node?
    def visit_constant_path_and_write_node(node) # :nodoc:
      node.copy(target: visit(node.target), value: visit(node.value))
    end

    #: (ConstantPathNode) -> node?
    def visit_constant_path_node(node) # :nodoc:
      node.copy(parent: visit(node.parent))
    end

    #: (ConstantPathOperatorWriteNode) -> node?
    def visit_constant_path_operator_write_node(node) # :nodoc:
      node.copy(target: visit(node.target), value: visit(node.value))
    end

    #: (ConstantPathOrWriteNode) -> node?
    def visit_constant_path_or_write_node(node) # :nodoc:
      node.copy(target: visit(node.target), value: visit(node.value))
    end

    #: (ConstantPathTargetNode) -> node?
    def visit_constant_path_target_node(node) # :nodoc:
      node.copy(parent: visit(node.parent))
    end

    #: (ConstantPathWriteNode) -> node?
    def visit_constant_path_write_node(node) # :nodoc:
      node.copy(target: visit(node.target), value: visit(node.value))
    end

    #: (ConstantReadNode) -> node?
    def visit_constant_read_node(node) # :nodoc:
      node.copy
    end

    #: (ConstantTargetNode) -> node?
    def visit_constant_target_node(node) # :nodoc:
      node.copy
    end

    #: (ConstantWriteNode) -> node?
    def visit_constant_write_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (DefNode) -> node?
    def visit_def_node(node) # :nodoc:
      node.copy(receiver: visit(node.receiver), parameters: visit(node.parameters), body: visit(node.body))
    end

    #: (DefinedNode) -> node?
    def visit_defined_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (ElseNode) -> node?
    def visit_else_node(node) # :nodoc:
      node.copy(statements: visit(node.statements))
    end

    #: (EmbeddedStatementsNode) -> node?
    def visit_embedded_statements_node(node) # :nodoc:
      node.copy(statements: visit(node.statements))
    end

    #: (EmbeddedVariableNode) -> node?
    def visit_embedded_variable_node(node) # :nodoc:
      node.copy(variable: visit(node.variable))
    end

    #: (EnsureNode) -> node?
    def visit_ensure_node(node) # :nodoc:
      node.copy(statements: visit(node.statements))
    end

    #: (ErrorRecoveryNode) -> node?
    def visit_error_recovery_node(node) # :nodoc:
      node.copy(unexpected: visit(node.unexpected))
    end

    #: (FalseNode) -> node?
    def visit_false_node(node) # :nodoc:
      node.copy
    end

    #: (FindPatternNode) -> node?
    def visit_find_pattern_node(node) # :nodoc:
      node.copy(constant: visit(node.constant), left: visit(node.left), requireds: visit_all(node.requireds), right: visit(node.right))
    end

    #: (FlipFlopNode) -> node?
    def visit_flip_flop_node(node) # :nodoc:
      node.copy(left: visit(node.left), right: visit(node.right))
    end

    #: (FloatNode) -> node?
    def visit_float_node(node) # :nodoc:
      node.copy
    end

    #: (ForNode) -> node?
    def visit_for_node(node) # :nodoc:
      node.copy(index: visit(node.index), collection: visit(node.collection), statements: visit(node.statements))
    end

    #: (ForwardingArgumentsNode) -> node?
    def visit_forwarding_arguments_node(node) # :nodoc:
      node.copy
    end

    #: (ForwardingParameterNode) -> node?
    def visit_forwarding_parameter_node(node) # :nodoc:
      node.copy
    end

    #: (ForwardingSuperNode) -> node?
    def visit_forwarding_super_node(node) # :nodoc:
      node.copy(block: visit(node.block))
    end

    #: (GlobalVariableAndWriteNode) -> node?
    def visit_global_variable_and_write_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (GlobalVariableOperatorWriteNode) -> node?
    def visit_global_variable_operator_write_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (GlobalVariableOrWriteNode) -> node?
    def visit_global_variable_or_write_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (GlobalVariableReadNode) -> node?
    def visit_global_variable_read_node(node) # :nodoc:
      node.copy
    end

    #: (GlobalVariableTargetNode) -> node?
    def visit_global_variable_target_node(node) # :nodoc:
      node.copy
    end

    #: (GlobalVariableWriteNode) -> node?
    def visit_global_variable_write_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (HashNode) -> node?
    def visit_hash_node(node) # :nodoc:
      node.copy(elements: visit_all(node.elements))
    end

    #: (HashPatternNode) -> node?
    def visit_hash_pattern_node(node) # :nodoc:
      node.copy(constant: visit(node.constant), elements: visit_all(node.elements), rest: visit(node.rest))
    end

    #: (IfNode) -> node?
    def visit_if_node(node) # :nodoc:
      node.copy(predicate: visit(node.predicate), statements: visit(node.statements), subsequent: visit(node.subsequent))
    end

    #: (ImaginaryNode) -> node?
    def visit_imaginary_node(node) # :nodoc:
      node.copy(numeric: visit(node.numeric))
    end

    #: (ImplicitNode) -> node?
    def visit_implicit_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (ImplicitRestNode) -> node?
    def visit_implicit_rest_node(node) # :nodoc:
      node.copy
    end

    #: (InNode) -> node?
    def visit_in_node(node) # :nodoc:
      node.copy(pattern: visit(node.pattern), statements: visit(node.statements))
    end

    #: (IndexAndWriteNode) -> node?
    def visit_index_and_write_node(node) # :nodoc:
      node.copy(receiver: visit(node.receiver), arguments: visit(node.arguments), block: visit(node.block), value: visit(node.value))
    end

    #: (IndexOperatorWriteNode) -> node?
    def visit_index_operator_write_node(node) # :nodoc:
      node.copy(receiver: visit(node.receiver), arguments: visit(node.arguments), block: visit(node.block), value: visit(node.value))
    end

    #: (IndexOrWriteNode) -> node?
    def visit_index_or_write_node(node) # :nodoc:
      node.copy(receiver: visit(node.receiver), arguments: visit(node.arguments), block: visit(node.block), value: visit(node.value))
    end

    #: (IndexTargetNode) -> node?
    def visit_index_target_node(node) # :nodoc:
      node.copy(receiver: visit(node.receiver), arguments: visit(node.arguments), block: visit(node.block))
    end

    #: (InstanceVariableAndWriteNode) -> node?
    def visit_instance_variable_and_write_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (InstanceVariableOperatorWriteNode) -> node?
    def visit_instance_variable_operator_write_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (InstanceVariableOrWriteNode) -> node?
    def visit_instance_variable_or_write_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (InstanceVariableReadNode) -> node?
    def visit_instance_variable_read_node(node) # :nodoc:
      node.copy
    end

    #: (InstanceVariableTargetNode) -> node?
    def visit_instance_variable_target_node(node) # :nodoc:
      node.copy
    end

    #: (InstanceVariableWriteNode) -> node?
    def visit_instance_variable_write_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (IntegerNode) -> node?
    def visit_integer_node(node) # :nodoc:
      node.copy
    end

    #: (InterpolatedMatchLastLineNode) -> node?
    def visit_interpolated_match_last_line_node(node) # :nodoc:
      node.copy(parts: visit_all(node.parts))
    end

    #: (InterpolatedRegularExpressionNode) -> node?
    def visit_interpolated_regular_expression_node(node) # :nodoc:
      node.copy(parts: visit_all(node.parts))
    end

    #: (InterpolatedStringNode) -> node?
    def visit_interpolated_string_node(node) # :nodoc:
      node.copy(parts: visit_all(node.parts))
    end

    #: (InterpolatedSymbolNode) -> node?
    def visit_interpolated_symbol_node(node) # :nodoc:
      node.copy(parts: visit_all(node.parts))
    end

    #: (InterpolatedXStringNode) -> node?
    def visit_interpolated_x_string_node(node) # :nodoc:
      node.copy(parts: visit_all(node.parts))
    end

    #: (ItLocalVariableReadNode) -> node?
    def visit_it_local_variable_read_node(node) # :nodoc:
      node.copy
    end

    #: (ItParametersNode) -> node?
    def visit_it_parameters_node(node) # :nodoc:
      node.copy
    end

    #: (KeywordHashNode) -> node?
    def visit_keyword_hash_node(node) # :nodoc:
      node.copy(elements: visit_all(node.elements))
    end

    #: (KeywordRestParameterNode) -> node?
    def visit_keyword_rest_parameter_node(node) # :nodoc:
      node.copy
    end

    #: (LambdaNode) -> node?
    def visit_lambda_node(node) # :nodoc:
      node.copy(parameters: visit(node.parameters), body: visit(node.body))
    end

    #: (LocalVariableAndWriteNode) -> node?
    def visit_local_variable_and_write_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (LocalVariableOperatorWriteNode) -> node?
    def visit_local_variable_operator_write_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (LocalVariableOrWriteNode) -> node?
    def visit_local_variable_or_write_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (LocalVariableReadNode) -> node?
    def visit_local_variable_read_node(node) # :nodoc:
      node.copy
    end

    #: (LocalVariableTargetNode) -> node?
    def visit_local_variable_target_node(node) # :nodoc:
      node.copy
    end

    #: (LocalVariableWriteNode) -> node?
    def visit_local_variable_write_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (MatchLastLineNode) -> node?
    def visit_match_last_line_node(node) # :nodoc:
      node.copy
    end

    #: (MatchPredicateNode) -> node?
    def visit_match_predicate_node(node) # :nodoc:
      node.copy(value: visit(node.value), pattern: visit(node.pattern))
    end

    #: (MatchRequiredNode) -> node?
    def visit_match_required_node(node) # :nodoc:
      node.copy(value: visit(node.value), pattern: visit(node.pattern))
    end

    #: (MatchWriteNode) -> node?
    def visit_match_write_node(node) # :nodoc:
      node.copy(call: visit(node.call), targets: visit_all(node.targets))
    end

    #: (ModuleNode) -> node?
    def visit_module_node(node) # :nodoc:
      node.copy(constant_path: visit(node.constant_path), body: visit(node.body))
    end

    #: (MultiTargetNode) -> node?
    def visit_multi_target_node(node) # :nodoc:
      node.copy(lefts: visit_all(node.lefts), rest: visit(node.rest), rights: visit_all(node.rights))
    end

    #: (MultiWriteNode) -> node?
    def visit_multi_write_node(node) # :nodoc:
      node.copy(lefts: visit_all(node.lefts), rest: visit(node.rest), rights: visit_all(node.rights), value: visit(node.value))
    end

    #: (NextNode) -> node?
    def visit_next_node(node) # :nodoc:
      node.copy(arguments: visit(node.arguments))
    end

    #: (NilNode) -> node?
    def visit_nil_node(node) # :nodoc:
      node.copy
    end

    #: (NoBlockParameterNode) -> node?
    def visit_no_block_parameter_node(node) # :nodoc:
      node.copy
    end

    #: (NoKeywordsParameterNode) -> node?
    def visit_no_keywords_parameter_node(node) # :nodoc:
      node.copy
    end

    #: (NumberedParametersNode) -> node?
    def visit_numbered_parameters_node(node) # :nodoc:
      node.copy
    end

    #: (NumberedReferenceReadNode) -> node?
    def visit_numbered_reference_read_node(node) # :nodoc:
      node.copy
    end

    #: (OptionalKeywordParameterNode) -> node?
    def visit_optional_keyword_parameter_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (OptionalParameterNode) -> node?
    def visit_optional_parameter_node(node) # :nodoc:
      node.copy(value: visit(node.value))
    end

    #: (OrNode) -> node?
    def visit_or_node(node) # :nodoc:
      node.copy(left: visit(node.left), right: visit(node.right))
    end

    #: (ParametersNode) -> node?
    def visit_parameters_node(node) # :nodoc:
      node.copy(requireds: visit_all(node.requireds), optionals: visit_all(node.optionals), rest: visit(node.rest), posts: visit_all(node.posts), keywords: visit_all(node.keywords), keyword_rest: visit(node.keyword_rest), block: visit(node.block))
    end

    #: (ParenthesesNode) -> node?
    def visit_parentheses_node(node) # :nodoc:
      node.copy(body: visit(node.body))
    end

    #: (PinnedExpressionNode) -> node?
    def visit_pinned_expression_node(node) # :nodoc:
      node.copy(expression: visit(node.expression))
    end

    #: (PinnedVariableNode) -> node?
    def visit_pinned_variable_node(node) # :nodoc:
      node.copy(variable: visit(node.variable))
    end

    #: (PostExecutionNode) -> node?
    def visit_post_execution_node(node) # :nodoc:
      node.copy(statements: visit(node.statements))
    end

    #: (PreExecutionNode) -> node?
    def visit_pre_execution_node(node) # :nodoc:
      node.copy(statements: visit(node.statements))
    end

    #: (ProgramNode) -> node?
    def visit_program_node(node) # :nodoc:
      node.copy(statements: visit(node.statements))
    end

    #: (RangeNode) -> node?
    def visit_range_node(node) # :nodoc:
      node.copy(left: visit(node.left), right: visit(node.right))
    end

    #: (RationalNode) -> node?
    def visit_rational_node(node) # :nodoc:
      node.copy
    end

    #: (RedoNode) -> node?
    def visit_redo_node(node) # :nodoc:
      node.copy
    end

    #: (RegularExpressionNode) -> node?
    def visit_regular_expression_node(node) # :nodoc:
      node.copy
    end

    #: (RequiredKeywordParameterNode) -> node?
    def visit_required_keyword_parameter_node(node) # :nodoc:
      node.copy
    end

    #: (RequiredParameterNode) -> node?
    def visit_required_parameter_node(node) # :nodoc:
      node.copy
    end

    #: (RescueModifierNode) -> node?
    def visit_rescue_modifier_node(node) # :nodoc:
      node.copy(expression: visit(node.expression), rescue_expression: visit(node.rescue_expression))
    end

    #: (RescueNode) -> node?
    def visit_rescue_node(node) # :nodoc:
      node.copy(exceptions: visit_all(node.exceptions), reference: visit(node.reference), statements: visit(node.statements), subsequent: visit(node.subsequent))
    end

    #: (RestParameterNode) -> node?
    def visit_rest_parameter_node(node) # :nodoc:
      node.copy
    end

    #: (RetryNode) -> node?
    def visit_retry_node(node) # :nodoc:
      node.copy
    end

    #: (ReturnNode) -> node?
    def visit_return_node(node) # :nodoc:
      node.copy(arguments: visit(node.arguments))
    end

    #: (SelfNode) -> node?
    def visit_self_node(node) # :nodoc:
      node.copy
    end

    #: (ShareableConstantNode) -> node?
    def visit_shareable_constant_node(node) # :nodoc:
      node.copy(write: visit(node.write))
    end

    #: (SingletonClassNode) -> node?
    def visit_singleton_class_node(node) # :nodoc:
      node.copy(expression: visit(node.expression), body: visit(node.body))
    end

    #: (SourceEncodingNode) -> node?
    def visit_source_encoding_node(node) # :nodoc:
      node.copy
    end

    #: (SourceFileNode) -> node?
    def visit_source_file_node(node) # :nodoc:
      node.copy
    end

    #: (SourceLineNode) -> node?
    def visit_source_line_node(node) # :nodoc:
      node.copy
    end

    #: (SplatNode) -> node?
    def visit_splat_node(node) # :nodoc:
      node.copy(expression: visit(node.expression))
    end

    #: (StatementsNode) -> node?
    def visit_statements_node(node) # :nodoc:
      node.copy(body: visit_all(node.body))
    end

    #: (StringNode) -> node?
    def visit_string_node(node) # :nodoc:
      node.copy
    end

    #: (SuperNode) -> node?
    def visit_super_node(node) # :nodoc:
      node.copy(arguments: visit(node.arguments), block: visit(node.block))
    end

    #: (SymbolNode) -> node?
    def visit_symbol_node(node) # :nodoc:
      node.copy
    end

    #: (TrueNode) -> node?
    def visit_true_node(node) # :nodoc:
      node.copy
    end

    #: (UndefNode) -> node?
    def visit_undef_node(node) # :nodoc:
      node.copy(names: visit_all(node.names))
    end

    #: (UnlessNode) -> node?
    def visit_unless_node(node) # :nodoc:
      node.copy(predicate: visit(node.predicate), statements: visit(node.statements), else_clause: visit(node.else_clause))
    end

    #: (UntilNode) -> node?
    def visit_until_node(node) # :nodoc:
      node.copy(predicate: visit(node.predicate), statements: visit(node.statements))
    end

    #: (WhenNode) -> node?
    def visit_when_node(node) # :nodoc:
      node.copy(conditions: visit_all(node.conditions), statements: visit(node.statements))
    end

    #: (WhileNode) -> node?
    def visit_while_node(node) # :nodoc:
      node.copy(predicate: visit(node.predicate), statements: visit(node.statements))
    end

    #: (XStringNode) -> node?
    def visit_x_string_node(node) # :nodoc:
      node.copy
    end

    #: (YieldNode) -> node?
    def visit_yield_node(node) # :nodoc:
      node.copy(arguments: visit(node.arguments))
    end
  end
end
