class SyntaxTree::MutationVisitor

This visitor walks through the tree and copies each node as it is being visited. This is useful for mutating the tree before it is formatted.

Attributes

mutations[R]

Public Class Methods

new() click to toggle source
# File lib/syntax_tree/mutation_visitor.rb, line 9
def initialize
  @mutations = []
end

Public Instance Methods

mutate(query, &block) click to toggle source

Create a new mutation based on the given query that will mutate the node using the given block. The block should return a new node that will take the place of the given node in the tree. These blocks frequently make use of the ‘copy` method on nodes to create a new node with the same properties as the original node.

# File lib/syntax_tree/mutation_visitor.rb, line 18
def mutate(query, &block)
  mutations << [Pattern.new(query).compile, block]
end
visit(node) click to toggle source

This is the base visit method for each node in the tree. It first creates a copy of the node using the visit_* methods defined below. Then it checks each mutation in sequence and calls it if it finds a match.

# File lib/syntax_tree/mutation_visitor.rb, line 25
def visit(node)
  return unless node
  result = node.accept(self)

  mutations.each do |(pattern, mutation)|
    result = mutation.call(result) if pattern.call(result)
  end

  result
end
visit_BEGIN(node) click to toggle source

Visit a BEGINBlock node.

# File lib/syntax_tree/mutation_visitor.rb, line 38
def visit_BEGIN(node)
  node.copy(
    lbrace: visit(node.lbrace),
    statements: visit(node.statements)
  )
end
visit_CHAR(node) click to toggle source

Visit a CHAR node.

# File lib/syntax_tree/mutation_visitor.rb, line 46
def visit_CHAR(node)
  node.copy
end
visit_END(node) click to toggle source

Visit a ENDBlock node.

# File lib/syntax_tree/mutation_visitor.rb, line 51
def visit_END(node)
  node.copy(
    lbrace: visit(node.lbrace),
    statements: visit(node.statements)
  )
end
visit___end__(node) click to toggle source

Visit a EndContent node.

# File lib/syntax_tree/mutation_visitor.rb, line 59
def visit___end__(node)
  node.copy
end
visit_alias(node) click to toggle source

Visit a AliasNode node.

# File lib/syntax_tree/mutation_visitor.rb, line 64
def visit_alias(node)
  node.copy(left: visit(node.left), right: visit(node.right))
end
visit_aref(node) click to toggle source

Visit a ARef node.

# File lib/syntax_tree/mutation_visitor.rb, line 69
def visit_aref(node)
  node.copy(index: visit(node.index))
end
visit_aref_field(node) click to toggle source

Visit a ARefField node.

# File lib/syntax_tree/mutation_visitor.rb, line 74
def visit_aref_field(node)
  node.copy(index: visit(node.index))
end
visit_arg_block(node) click to toggle source

Visit a ArgBlock node.

# File lib/syntax_tree/mutation_visitor.rb, line 89
def visit_arg_block(node)
  node.copy(value: visit(node.value))
end
visit_arg_paren(node) click to toggle source

Visit a ArgParen node.

# File lib/syntax_tree/mutation_visitor.rb, line 79
def visit_arg_paren(node)
  node.copy(arguments: visit(node.arguments))
end
visit_arg_star(node) click to toggle source

Visit a ArgStar node.

# File lib/syntax_tree/mutation_visitor.rb, line 94
def visit_arg_star(node)
  node.copy(value: visit(node.value))
end
visit_args(node) click to toggle source

Visit a Args node.

# File lib/syntax_tree/mutation_visitor.rb, line 84
def visit_args(node)
  node.copy(parts: visit_all(node.parts))
end
visit_args_forward(node) click to toggle source

Visit a ArgsForward node.

# File lib/syntax_tree/mutation_visitor.rb, line 99
def visit_args_forward(node)
  node.copy
end
visit_array(node) click to toggle source

Visit a ArrayLiteral node.

# File lib/syntax_tree/mutation_visitor.rb, line 104
def visit_array(node)
  node.copy(
    lbracket: visit(node.lbracket),
    contents: visit(node.contents)
  )
end
visit_aryptn(node) click to toggle source

Visit a AryPtn node.

# File lib/syntax_tree/mutation_visitor.rb, line 112
def visit_aryptn(node)
  node.copy(
    constant: visit(node.constant),
    requireds: visit_all(node.requireds),
    rest: visit(node.rest),
    posts: visit_all(node.posts)
  )
end
visit_assign(node) click to toggle source

Visit a Assign node.

# File lib/syntax_tree/mutation_visitor.rb, line 122
def visit_assign(node)
  node.copy(target: visit(node.target))
end
visit_assoc(node) click to toggle source

Visit a Assoc node.

# File lib/syntax_tree/mutation_visitor.rb, line 127
def visit_assoc(node)
  node.copy
end
visit_assoc_splat(node) click to toggle source

Visit a AssocSplat node.

# File lib/syntax_tree/mutation_visitor.rb, line 132
def visit_assoc_splat(node)
  node.copy
end
visit_backref(node) click to toggle source

Visit a Backref node.

# File lib/syntax_tree/mutation_visitor.rb, line 137
def visit_backref(node)
  node.copy
end
visit_backtick(node) click to toggle source

Visit a Backtick node.

# File lib/syntax_tree/mutation_visitor.rb, line 142
def visit_backtick(node)
  node.copy
end
visit_bare_assoc_hash(node) click to toggle source

Visit a BareAssocHash node.

# File lib/syntax_tree/mutation_visitor.rb, line 147
def visit_bare_assoc_hash(node)
  node.copy(assocs: visit_all(node.assocs))
end
visit_begin(node) click to toggle source

Visit a Begin node.

# File lib/syntax_tree/mutation_visitor.rb, line 152
def visit_begin(node)
  node.copy(bodystmt: visit(node.bodystmt))
end
visit_binary(node) click to toggle source

Visit a Binary node.

# File lib/syntax_tree/mutation_visitor.rb, line 162
def visit_binary(node)
  node.copy
end
visit_block(node) click to toggle source

Visit a Block node.

# File lib/syntax_tree/mutation_visitor.rb, line 295
def visit_block(node)
  node.copy(
    opening: visit(node.opening),
    block_var: visit(node.block_var),
    bodystmt: visit(node.bodystmt)
  )
end
visit_block_var(node) click to toggle source

Visit a BlockVar node.

# File lib/syntax_tree/mutation_visitor.rb, line 167
def visit_block_var(node)
  node.copy(params: visit(node.params), locals: visit_all(node.locals))
end
visit_blockarg(node) click to toggle source

Visit a BlockArg node.

# File lib/syntax_tree/mutation_visitor.rb, line 172
def visit_blockarg(node)
  node.copy(name: visit(node.name))
end
visit_bodystmt(node) click to toggle source

Visit a BodyStmt node.

# File lib/syntax_tree/mutation_visitor.rb, line 177
def visit_bodystmt(node)
  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
visit_break(node) click to toggle source

Visit a Break node.

# File lib/syntax_tree/mutation_visitor.rb, line 187
def visit_break(node)
  node.copy(arguments: visit(node.arguments))
end
visit_call(node) click to toggle source

Visit a Call node.

# File lib/syntax_tree/mutation_visitor.rb, line 192
def visit_call(node)
  node.copy(
    receiver: visit(node.receiver),
    operator: node.operator == :"::" ? :"::" : visit(node.operator),
    message: node.message == :call ? :call : visit(node.message),
    arguments: visit(node.arguments)
  )
end
visit_case(node) click to toggle source

Visit a Case node.

# File lib/syntax_tree/mutation_visitor.rb, line 202
def visit_case(node)
  node.copy(
    keyword: visit(node.keyword),
    value: visit(node.value),
    consequent: visit(node.consequent)
  )
end
visit_class(node) click to toggle source

Visit a ClassDeclaration node.

# File lib/syntax_tree/mutation_visitor.rb, line 216
def visit_class(node)
  node.copy(
    constant: visit(node.constant),
    superclass: visit(node.superclass),
    bodystmt: visit(node.bodystmt)
  )
end
visit_comma(node) click to toggle source

Visit a Comma node.

# File lib/syntax_tree/mutation_visitor.rb, line 225
def visit_comma(node)
  node.copy
end
visit_command(node) click to toggle source

Visit a Command node.

# File lib/syntax_tree/mutation_visitor.rb, line 230
def visit_command(node)
  node.copy(
    message: visit(node.message),
    arguments: visit(node.arguments),
    block: visit(node.block)
  )
end
visit_command_call(node) click to toggle source

Visit a CommandCall node.

# File lib/syntax_tree/mutation_visitor.rb, line 239
def visit_command_call(node)
  node.copy(
    operator: node.operator == :"::" ? :"::" : visit(node.operator),
    message: visit(node.message),
    arguments: visit(node.arguments),
    block: visit(node.block)
  )
end
visit_comment(node) click to toggle source

Visit a Comment node.

# File lib/syntax_tree/mutation_visitor.rb, line 249
def visit_comment(node)
  node.copy
end
visit_const(node) click to toggle source

Visit a Const node.

# File lib/syntax_tree/mutation_visitor.rb, line 254
def visit_const(node)
  node.copy
end
visit_const_path_field(node) click to toggle source

Visit a ConstPathField node.

# File lib/syntax_tree/mutation_visitor.rb, line 259
def visit_const_path_field(node)
  node.copy(constant: visit(node.constant))
end
visit_const_path_ref(node) click to toggle source

Visit a ConstPathRef node.

# File lib/syntax_tree/mutation_visitor.rb, line 264
def visit_const_path_ref(node)
  node.copy(constant: visit(node.constant))
end
visit_const_ref(node) click to toggle source

Visit a ConstRef node.

# File lib/syntax_tree/mutation_visitor.rb, line 269
def visit_const_ref(node)
  node.copy(constant: visit(node.constant))
end
visit_cvar(node) click to toggle source

Visit a CVar node.

# File lib/syntax_tree/mutation_visitor.rb, line 274
def visit_cvar(node)
  node.copy
end
visit_def(node) click to toggle source

Visit a Def node.

# File lib/syntax_tree/mutation_visitor.rb, line 279
def visit_def(node)
  node.copy(
    target: visit(node.target),
    operator: visit(node.operator),
    name: visit(node.name),
    params: visit(node.params),
    bodystmt: visit(node.bodystmt)
  )
end
visit_defined(node) click to toggle source

Visit a Defined node.

# File lib/syntax_tree/mutation_visitor.rb, line 290
def visit_defined(node)
  node.copy
end
visit_dyna_symbol(node) click to toggle source

Visit a DynaSymbol node.

# File lib/syntax_tree/mutation_visitor.rb, line 313
def visit_dyna_symbol(node)
  node.copy(parts: visit_all(node.parts))
end
visit_else(node) click to toggle source

Visit a Else node.

# File lib/syntax_tree/mutation_visitor.rb, line 318
def visit_else(node)
  node.copy(
    keyword: visit(node.keyword),
    statements: visit(node.statements)
  )
end
visit_elsif(node) click to toggle source

Visit a Elsif node.

# File lib/syntax_tree/mutation_visitor.rb, line 326
def visit_elsif(node)
  node.copy(
    statements: visit(node.statements),
    consequent: visit(node.consequent)
  )
end
visit_embdoc(node) click to toggle source

Visit a EmbDoc node.

# File lib/syntax_tree/mutation_visitor.rb, line 334
def visit_embdoc(node)
  node.copy
end
visit_embexpr_beg(node) click to toggle source

Visit a EmbExprBeg node.

# File lib/syntax_tree/mutation_visitor.rb, line 339
def visit_embexpr_beg(node)
  node.copy
end
visit_embexpr_end(node) click to toggle source

Visit a EmbExprEnd node.

# File lib/syntax_tree/mutation_visitor.rb, line 344
def visit_embexpr_end(node)
  node.copy
end
visit_embvar(node) click to toggle source

Visit a EmbVar node.

# File lib/syntax_tree/mutation_visitor.rb, line 349
def visit_embvar(node)
  node.copy
end
visit_ensure(node) click to toggle source

Visit a Ensure node.

# File lib/syntax_tree/mutation_visitor.rb, line 354
def visit_ensure(node)
  node.copy(
    keyword: visit(node.keyword),
    statements: visit(node.statements)
  )
end
visit_excessed_comma(node) click to toggle source

Visit a ExcessedComma node.

# File lib/syntax_tree/mutation_visitor.rb, line 362
def visit_excessed_comma(node)
  node.copy
end
visit_field(node) click to toggle source

Visit a Field node.

# File lib/syntax_tree/mutation_visitor.rb, line 367
def visit_field(node)
  node.copy(
    operator: node.operator == :"::" ? :"::" : visit(node.operator),
    name: visit(node.name)
  )
end
visit_float(node) click to toggle source

Visit a FloatLiteral node.

# File lib/syntax_tree/mutation_visitor.rb, line 375
def visit_float(node)
  node.copy
end
visit_fndptn(node) click to toggle source

Visit a FndPtn node.

# File lib/syntax_tree/mutation_visitor.rb, line 380
def visit_fndptn(node)
  node.copy(
    constant: visit(node.constant),
    left: visit(node.left),
    values: visit_all(node.values),
    right: visit(node.right)
  )
end
visit_for(node) click to toggle source

Visit a For node.

# File lib/syntax_tree/mutation_visitor.rb, line 390
def visit_for(node)
  node.copy(index: visit(node.index), statements: visit(node.statements))
end
visit_gvar(node) click to toggle source

Visit a GVar node.

# File lib/syntax_tree/mutation_visitor.rb, line 395
def visit_gvar(node)
  node.copy
end
visit_hash(node) click to toggle source

Visit a HashLiteral node.

# File lib/syntax_tree/mutation_visitor.rb, line 400
def visit_hash(node)
  node.copy(lbrace: visit(node.lbrace), assocs: visit_all(node.assocs))
end
visit_heredoc(node) click to toggle source

Visit a Heredoc node.

# File lib/syntax_tree/mutation_visitor.rb, line 405
def visit_heredoc(node)
  node.copy(
    beginning: visit(node.beginning),
    ending: visit(node.ending),
    parts: visit_all(node.parts)
  )
end
visit_heredoc_beg(node) click to toggle source

Visit a HeredocBeg node.

# File lib/syntax_tree/mutation_visitor.rb, line 414
def visit_heredoc_beg(node)
  node.copy
end
visit_heredoc_end(node) click to toggle source

Visit a HeredocEnd node.

# File lib/syntax_tree/mutation_visitor.rb, line 419
def visit_heredoc_end(node)
  node.copy
end
visit_hshptn(node) click to toggle source

Visit a HshPtn node.

# File lib/syntax_tree/mutation_visitor.rb, line 424
def visit_hshptn(node)
  node.copy(
    constant: visit(node.constant),
    keywords:
      node.keywords.map { |label, value| [visit(label), visit(value)] },
    keyword_rest: visit(node.keyword_rest)
  )
end
visit_ident(node) click to toggle source

Visit a Ident node.

# File lib/syntax_tree/mutation_visitor.rb, line 434
def visit_ident(node)
  node.copy
end
visit_if(node) click to toggle source

Visit a IfNode node.

# File lib/syntax_tree/mutation_visitor.rb, line 439
def visit_if(node)
  node.copy(
    predicate: visit(node.predicate),
    statements: visit(node.statements),
    consequent: visit(node.consequent)
  )
end
visit_if_op(node) click to toggle source

Visit a IfOp node.

# File lib/syntax_tree/mutation_visitor.rb, line 448
def visit_if_op(node)
  node.copy
end
visit_imaginary(node) click to toggle source

Visit a Imaginary node.

# File lib/syntax_tree/mutation_visitor.rb, line 453
def visit_imaginary(node)
  node.copy
end
visit_in(node) click to toggle source

Visit a In node.

# File lib/syntax_tree/mutation_visitor.rb, line 458
def visit_in(node)
  node.copy(
    statements: visit(node.statements),
    consequent: visit(node.consequent)
  )
end
visit_int(node) click to toggle source

Visit a Int node.

# File lib/syntax_tree/mutation_visitor.rb, line 466
def visit_int(node)
  node.copy
end
visit_ivar(node) click to toggle source

Visit a IVar node.

# File lib/syntax_tree/mutation_visitor.rb, line 471
def visit_ivar(node)
  node.copy
end
visit_kw(node) click to toggle source

Visit a Kw node.

# File lib/syntax_tree/mutation_visitor.rb, line 476
def visit_kw(node)
  node.copy
end
visit_kwrest_param(node) click to toggle source

Visit a KwRestParam node.

# File lib/syntax_tree/mutation_visitor.rb, line 481
def visit_kwrest_param(node)
  node.copy(name: visit(node.name))
end
visit_label(node) click to toggle source

Visit a Label node.

# File lib/syntax_tree/mutation_visitor.rb, line 486
def visit_label(node)
  node.copy
end
visit_label_end(node) click to toggle source

Visit a LabelEnd node.

# File lib/syntax_tree/mutation_visitor.rb, line 491
def visit_label_end(node)
  node.copy
end
visit_lambda(node) click to toggle source

Visit a Lambda node.

# File lib/syntax_tree/mutation_visitor.rb, line 496
def visit_lambda(node)
  node.copy(
    params: visit(node.params),
    statements: visit(node.statements)
  )
end
visit_lambda_var(node) click to toggle source

Visit a LambdaVar node.

# File lib/syntax_tree/mutation_visitor.rb, line 504
def visit_lambda_var(node)
  node.copy(params: visit(node.params), locals: visit_all(node.locals))
end
visit_lbrace(node) click to toggle source

Visit a LBrace node.

# File lib/syntax_tree/mutation_visitor.rb, line 509
def visit_lbrace(node)
  node.copy
end
visit_lbracket(node) click to toggle source

Visit a LBracket node.

# File lib/syntax_tree/mutation_visitor.rb, line 514
def visit_lbracket(node)
  node.copy
end
visit_lparen(node) click to toggle source

Visit a LParen node.

# File lib/syntax_tree/mutation_visitor.rb, line 519
def visit_lparen(node)
  node.copy
end
visit_massign(node) click to toggle source

Visit a MAssign node.

# File lib/syntax_tree/mutation_visitor.rb, line 524
def visit_massign(node)
  node.copy(target: visit(node.target))
end
visit_method_add_block(node) click to toggle source

Visit a MethodAddBlock node.

# File lib/syntax_tree/mutation_visitor.rb, line 529
def visit_method_add_block(node)
  node.copy(call: visit(node.call), block: visit(node.block))
end
visit_mlhs(node) click to toggle source

Visit a MLHS node.

# File lib/syntax_tree/mutation_visitor.rb, line 534
def visit_mlhs(node)
  node.copy(parts: visit_all(node.parts))
end
visit_mlhs_paren(node) click to toggle source

Visit a MLHSParen node.

# File lib/syntax_tree/mutation_visitor.rb, line 539
def visit_mlhs_paren(node)
  node.copy(contents: visit(node.contents))
end
visit_module(node) click to toggle source

Visit a ModuleDeclaration node.

# File lib/syntax_tree/mutation_visitor.rb, line 544
def visit_module(node)
  node.copy(
    constant: visit(node.constant),
    bodystmt: visit(node.bodystmt)
  )
end
visit_mrhs(node) click to toggle source

Visit a MRHS node.

# File lib/syntax_tree/mutation_visitor.rb, line 552
def visit_mrhs(node)
  node.copy(parts: visit_all(node.parts))
end
visit_next(node) click to toggle source

Visit a Next node.

# File lib/syntax_tree/mutation_visitor.rb, line 557
def visit_next(node)
  node.copy(arguments: visit(node.arguments))
end
visit_not(node) click to toggle source

Visit a Not node.

# File lib/syntax_tree/mutation_visitor.rb, line 812
def visit_not(node)
  node.copy(statement: visit(node.statement))
end
visit_op(node) click to toggle source

Visit a Op node.

# File lib/syntax_tree/mutation_visitor.rb, line 562
def visit_op(node)
  node.copy
end
visit_opassign(node) click to toggle source

Visit a OpAssign node.

# File lib/syntax_tree/mutation_visitor.rb, line 567
def visit_opassign(node)
  node.copy(target: visit(node.target), operator: visit(node.operator))
end
visit_params(node) click to toggle source

Visit a Params node.

# File lib/syntax_tree/mutation_visitor.rb, line 572
def visit_params(node)
  node.copy(
    requireds: visit_all(node.requireds),
    optionals:
      node.optionals.map { |ident, value| [visit(ident), visit(value)] },
    rest: visit(node.rest),
    posts: visit_all(node.posts),
    keywords:
      node.keywords.map { |ident, value| [visit(ident), visit(value)] },
    keyword_rest:
      node.keyword_rest == :nil ? :nil : visit(node.keyword_rest),
    block: visit(node.block)
  )
end
visit_paren(node) click to toggle source

Visit a Paren node.

# File lib/syntax_tree/mutation_visitor.rb, line 588
def visit_paren(node)
  node.copy(lparen: visit(node.lparen), contents: visit(node.contents))
end
visit_period(node) click to toggle source

Visit a Period node.

# File lib/syntax_tree/mutation_visitor.rb, line 593
def visit_period(node)
  node.copy
end
visit_pinned_begin(node) click to toggle source

Visit a PinnedBegin node.

# File lib/syntax_tree/mutation_visitor.rb, line 157
def visit_pinned_begin(node)
  node.copy
end
visit_pinned_var_ref(node) click to toggle source

Visit a PinnedVarRef node.

# File lib/syntax_tree/mutation_visitor.rb, line 854
def visit_pinned_var_ref(node)
  node.copy(value: visit(node.value))
end
visit_program(node) click to toggle source

Visit a Program node.

# File lib/syntax_tree/mutation_visitor.rb, line 598
def visit_program(node)
  node.copy(statements: visit(node.statements))
end
visit_qsymbols(node) click to toggle source

Visit a QSymbols node.

# File lib/syntax_tree/mutation_visitor.rb, line 603
def visit_qsymbols(node)
  node.copy(
    beginning: visit(node.beginning),
    elements: visit_all(node.elements)
  )
end
visit_qsymbols_beg(node) click to toggle source

Visit a QSymbolsBeg node.

# File lib/syntax_tree/mutation_visitor.rb, line 611
def visit_qsymbols_beg(node)
  node.copy
end
visit_qwords(node) click to toggle source

Visit a QWords node.

# File lib/syntax_tree/mutation_visitor.rb, line 616
def visit_qwords(node)
  node.copy(
    beginning: visit(node.beginning),
    elements: visit_all(node.elements)
  )
end
visit_qwords_beg(node) click to toggle source

Visit a QWordsBeg node.

# File lib/syntax_tree/mutation_visitor.rb, line 624
def visit_qwords_beg(node)
  node.copy
end
visit_range(node) click to toggle source

Visit a RangeNode node.

# File lib/syntax_tree/mutation_visitor.rb, line 304
def visit_range(node)
  node.copy(
    left: visit(node.left),
    operator: visit(node.operator),
    right: visit(node.right)
  )
end
visit_rassign(node) click to toggle source

Visit a RAssign node.

# File lib/syntax_tree/mutation_visitor.rb, line 211
def visit_rassign(node)
  node.copy(operator: visit(node.operator))
end
visit_rational(node) click to toggle source

Visit a RationalLiteral node.

# File lib/syntax_tree/mutation_visitor.rb, line 629
def visit_rational(node)
  node.copy
end
visit_rbrace(node) click to toggle source

Visit a RBrace node.

# File lib/syntax_tree/mutation_visitor.rb, line 634
def visit_rbrace(node)
  node.copy
end
visit_rbracket(node) click to toggle source

Visit a RBracket node.

# File lib/syntax_tree/mutation_visitor.rb, line 639
def visit_rbracket(node)
  node.copy
end
visit_redo(node) click to toggle source

Visit a Redo node.

# File lib/syntax_tree/mutation_visitor.rb, line 644
def visit_redo(node)
  node.copy
end
visit_regexp_beg(node) click to toggle source

Visit a RegexpBeg node.

# File lib/syntax_tree/mutation_visitor.rb, line 654
def visit_regexp_beg(node)
  node.copy
end
visit_regexp_content(node) click to toggle source

Visit a RegexpContent node.

# File lib/syntax_tree/mutation_visitor.rb, line 649
def visit_regexp_content(node)
  node.copy(parts: visit_all(node.parts))
end
visit_regexp_end(node) click to toggle source

Visit a RegexpEnd node.

# File lib/syntax_tree/mutation_visitor.rb, line 659
def visit_regexp_end(node)
  node.copy
end
visit_regexp_literal(node) click to toggle source

Visit a RegexpLiteral node.

# File lib/syntax_tree/mutation_visitor.rb, line 664
def visit_regexp_literal(node)
  node.copy(parts: visit_all(node.parts))
end
visit_rescue(node) click to toggle source

Visit a Rescue node.

# File lib/syntax_tree/mutation_visitor.rb, line 674
def visit_rescue(node)
  node.copy(
    keyword: visit(node.keyword),
    exception: visit(node.exception),
    statements: visit(node.statements),
    consequent: visit(node.consequent)
  )
end
visit_rescue_ex(node) click to toggle source

Visit a RescueEx node.

# File lib/syntax_tree/mutation_visitor.rb, line 669
def visit_rescue_ex(node)
  node.copy(variable: visit(node.variable))
end
visit_rescue_mod(node) click to toggle source

Visit a RescueMod node.

# File lib/syntax_tree/mutation_visitor.rb, line 684
def visit_rescue_mod(node)
  node.copy
end
visit_rest_param(node) click to toggle source

Visit a RestParam node.

# File lib/syntax_tree/mutation_visitor.rb, line 689
def visit_rest_param(node)
  node.copy(name: visit(node.name))
end
visit_retry(node) click to toggle source

Visit a Retry node.

# File lib/syntax_tree/mutation_visitor.rb, line 694
def visit_retry(node)
  node.copy
end
visit_return(node) click to toggle source

Visit a Return node.

# File lib/syntax_tree/mutation_visitor.rb, line 699
def visit_return(node)
  node.copy(arguments: visit(node.arguments))
end
visit_rparen(node) click to toggle source

Visit a RParen node.

# File lib/syntax_tree/mutation_visitor.rb, line 704
def visit_rparen(node)
  node.copy
end
visit_sclass(node) click to toggle source

Visit a SClass node.

# File lib/syntax_tree/mutation_visitor.rb, line 709
def visit_sclass(node)
  node.copy(bodystmt: visit(node.bodystmt))
end
visit_statements(node) click to toggle source

Visit a Statements node.

# File lib/syntax_tree/mutation_visitor.rb, line 714
def visit_statements(node)
  node.copy(body: visit_all(node.body))
end
visit_string_concat(node) click to toggle source

Visit a StringConcat node.

# File lib/syntax_tree/mutation_visitor.rb, line 724
def visit_string_concat(node)
  node.copy(left: visit(node.left), right: visit(node.right))
end
visit_string_content(node) click to toggle source

Visit a StringContent node.

# File lib/syntax_tree/mutation_visitor.rb, line 719
def visit_string_content(node)
  node.copy(parts: visit_all(node.parts))
end
visit_string_dvar(node) click to toggle source

Visit a StringDVar node.

# File lib/syntax_tree/mutation_visitor.rb, line 729
def visit_string_dvar(node)
  node.copy(variable: visit(node.variable))
end
visit_string_embexpr(node) click to toggle source

Visit a StringEmbExpr node.

# File lib/syntax_tree/mutation_visitor.rb, line 734
def visit_string_embexpr(node)
  node.copy(statements: visit(node.statements))
end
visit_string_literal(node) click to toggle source

Visit a StringLiteral node.

# File lib/syntax_tree/mutation_visitor.rb, line 739
def visit_string_literal(node)
  node.copy(parts: visit_all(node.parts))
end
visit_super(node) click to toggle source

Visit a Super node.

# File lib/syntax_tree/mutation_visitor.rb, line 744
def visit_super(node)
  node.copy(arguments: visit(node.arguments))
end
visit_symbeg(node) click to toggle source

Visit a SymBeg node.

# File lib/syntax_tree/mutation_visitor.rb, line 749
def visit_symbeg(node)
  node.copy
end
visit_symbol_content(node) click to toggle source

Visit a SymbolContent node.

# File lib/syntax_tree/mutation_visitor.rb, line 754
def visit_symbol_content(node)
  node.copy(value: visit(node.value))
end
visit_symbol_literal(node) click to toggle source

Visit a SymbolLiteral node.

# File lib/syntax_tree/mutation_visitor.rb, line 759
def visit_symbol_literal(node)
  node.copy(value: visit(node.value))
end
visit_symbols(node) click to toggle source

Visit a Symbols node.

# File lib/syntax_tree/mutation_visitor.rb, line 764
def visit_symbols(node)
  node.copy(
    beginning: visit(node.beginning),
    elements: visit_all(node.elements)
  )
end
visit_symbols_beg(node) click to toggle source

Visit a SymbolsBeg node.

# File lib/syntax_tree/mutation_visitor.rb, line 772
def visit_symbols_beg(node)
  node.copy
end
visit_tlambda(node) click to toggle source

Visit a TLambda node.

# File lib/syntax_tree/mutation_visitor.rb, line 777
def visit_tlambda(node)
  node.copy
end
visit_tlambeg(node) click to toggle source

Visit a TLamBeg node.

# File lib/syntax_tree/mutation_visitor.rb, line 782
def visit_tlambeg(node)
  node.copy
end
visit_top_const_field(node) click to toggle source

Visit a TopConstField node.

# File lib/syntax_tree/mutation_visitor.rb, line 787
def visit_top_const_field(node)
  node.copy(constant: visit(node.constant))
end
visit_top_const_ref(node) click to toggle source

Visit a TopConstRef node.

# File lib/syntax_tree/mutation_visitor.rb, line 792
def visit_top_const_ref(node)
  node.copy(constant: visit(node.constant))
end
visit_tstring_beg(node) click to toggle source

Visit a TStringBeg node.

# File lib/syntax_tree/mutation_visitor.rb, line 797
def visit_tstring_beg(node)
  node.copy
end
visit_tstring_content(node) click to toggle source

Visit a TStringContent node.

# File lib/syntax_tree/mutation_visitor.rb, line 802
def visit_tstring_content(node)
  node.copy
end
visit_tstring_end(node) click to toggle source

Visit a TStringEnd node.

# File lib/syntax_tree/mutation_visitor.rb, line 807
def visit_tstring_end(node)
  node.copy
end
visit_unary(node) click to toggle source

Visit a Unary node.

# File lib/syntax_tree/mutation_visitor.rb, line 817
def visit_unary(node)
  node.copy
end
visit_undef(node) click to toggle source

Visit a Undef node.

# File lib/syntax_tree/mutation_visitor.rb, line 822
def visit_undef(node)
  node.copy(symbols: visit_all(node.symbols))
end
visit_unless(node) click to toggle source

Visit a UnlessNode node.

# File lib/syntax_tree/mutation_visitor.rb, line 827
def visit_unless(node)
  node.copy(
    predicate: visit(node.predicate),
    statements: visit(node.statements),
    consequent: visit(node.consequent)
  )
end
visit_until(node) click to toggle source

Visit a UntilNode node.

# File lib/syntax_tree/mutation_visitor.rb, line 836
def visit_until(node)
  node.copy(
    predicate: visit(node.predicate),
    statements: visit(node.statements)
  )
end
visit_var_field(node) click to toggle source

Visit a VarField node.

# File lib/syntax_tree/mutation_visitor.rb, line 844
def visit_var_field(node)
  node.copy(value: visit(node.value))
end
visit_var_ref(node) click to toggle source

Visit a VarRef node.

# File lib/syntax_tree/mutation_visitor.rb, line 849
def visit_var_ref(node)
  node.copy(value: visit(node.value))
end
visit_vcall(node) click to toggle source

Visit a VCall node.

# File lib/syntax_tree/mutation_visitor.rb, line 859
def visit_vcall(node)
  node.copy(value: visit(node.value))
end
visit_void_stmt(node) click to toggle source

Visit a VoidStmt node.

# File lib/syntax_tree/mutation_visitor.rb, line 864
def visit_void_stmt(node)
  node.copy
end
visit_when(node) click to toggle source

Visit a When node.

# File lib/syntax_tree/mutation_visitor.rb, line 869
def visit_when(node)
  node.copy(
    arguments: visit(node.arguments),
    statements: visit(node.statements),
    consequent: visit(node.consequent)
  )
end
visit_while(node) click to toggle source

Visit a WhileNode node.

# File lib/syntax_tree/mutation_visitor.rb, line 878
def visit_while(node)
  node.copy(
    predicate: visit(node.predicate),
    statements: visit(node.statements)
  )
end
visit_word(node) click to toggle source

Visit a Word node.

# File lib/syntax_tree/mutation_visitor.rb, line 886
def visit_word(node)
  node.copy(parts: visit_all(node.parts))
end
visit_words(node) click to toggle source

Visit a Words node.

# File lib/syntax_tree/mutation_visitor.rb, line 891
def visit_words(node)
  node.copy(
    beginning: visit(node.beginning),
    elements: visit_all(node.elements)
  )
end
visit_words_beg(node) click to toggle source

Visit a WordsBeg node.

# File lib/syntax_tree/mutation_visitor.rb, line 899
def visit_words_beg(node)
  node.copy
end
visit_xstring(node) click to toggle source

Visit a XString node.

# File lib/syntax_tree/mutation_visitor.rb, line 904
def visit_xstring(node)
  node.copy(parts: visit_all(node.parts))
end
visit_xstring_literal(node) click to toggle source

Visit a XStringLiteral node.

# File lib/syntax_tree/mutation_visitor.rb, line 909
def visit_xstring_literal(node)
  node.copy(parts: visit_all(node.parts))
end
visit_yield(node) click to toggle source

Visit a YieldNode node.

# File lib/syntax_tree/mutation_visitor.rb, line 914
def visit_yield(node)
  node.copy(arguments: visit(node.arguments))
end
visit_zsuper(node) click to toggle source

Visit a ZSuper node.

# File lib/syntax_tree/mutation_visitor.rb, line 919
def visit_zsuper(node)
  node.copy
end