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
Public Class Methods
# File lib/syntax_tree/mutation_visitor.rb, line 9 def initialize @mutations = [] end
Public Instance Methods
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
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 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 a CHAR
node.
# File lib/syntax_tree/mutation_visitor.rb, line 46 def visit_CHAR(node) node.copy end
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 a EndContent
node.
# File lib/syntax_tree/mutation_visitor.rb, line 59 def visit___end__(node) node.copy end
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 a ARef
node.
# File lib/syntax_tree/mutation_visitor.rb, line 69 def visit_aref(node) node.copy(index: visit(node.index)) end
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 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 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 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 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 a ArgsForward
node.
# File lib/syntax_tree/mutation_visitor.rb, line 99 def visit_args_forward(node) node.copy end
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 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 a Assign
node.
# File lib/syntax_tree/mutation_visitor.rb, line 122 def visit_assign(node) node.copy(target: visit(node.target)) end
Visit a Assoc
node.
# File lib/syntax_tree/mutation_visitor.rb, line 127 def visit_assoc(node) node.copy end
Visit a AssocSplat
node.
# File lib/syntax_tree/mutation_visitor.rb, line 132 def visit_assoc_splat(node) node.copy end
Visit a Backref
node.
# File lib/syntax_tree/mutation_visitor.rb, line 137 def visit_backref(node) node.copy end
Visit a Backtick
node.
# File lib/syntax_tree/mutation_visitor.rb, line 142 def visit_backtick(node) node.copy end
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 a Begin
node.
# File lib/syntax_tree/mutation_visitor.rb, line 152 def visit_begin(node) node.copy(bodystmt: visit(node.bodystmt)) end
Visit a Binary
node.
# File lib/syntax_tree/mutation_visitor.rb, line 162 def visit_binary(node) node.copy end
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 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 a BlockArg
node.
# File lib/syntax_tree/mutation_visitor.rb, line 172 def visit_blockarg(node) node.copy(name: visit(node.name)) end
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 a Break
node.
# File lib/syntax_tree/mutation_visitor.rb, line 187 def visit_break(node) node.copy(arguments: visit(node.arguments)) end
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 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 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 a Comma
node.
# File lib/syntax_tree/mutation_visitor.rb, line 225 def visit_comma(node) node.copy end
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 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 a Comment
node.
# File lib/syntax_tree/mutation_visitor.rb, line 249 def visit_comment(node) node.copy end
Visit a Const
node.
# File lib/syntax_tree/mutation_visitor.rb, line 254 def visit_const(node) node.copy end
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 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 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 a CVar
node.
# File lib/syntax_tree/mutation_visitor.rb, line 274 def visit_cvar(node) node.copy end
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 a Defined
node.
# File lib/syntax_tree/mutation_visitor.rb, line 290 def visit_defined(node) node.copy end
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 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 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 a EmbDoc
node.
# File lib/syntax_tree/mutation_visitor.rb, line 334 def visit_embdoc(node) node.copy end
Visit a EmbExprBeg
node.
# File lib/syntax_tree/mutation_visitor.rb, line 339 def visit_embexpr_beg(node) node.copy end
Visit a EmbExprEnd
node.
# File lib/syntax_tree/mutation_visitor.rb, line 344 def visit_embexpr_end(node) node.copy end
Visit a EmbVar
node.
# File lib/syntax_tree/mutation_visitor.rb, line 349 def visit_embvar(node) node.copy end
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 a ExcessedComma
node.
# File lib/syntax_tree/mutation_visitor.rb, line 362 def visit_excessed_comma(node) node.copy end
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 a FloatLiteral
node.
# File lib/syntax_tree/mutation_visitor.rb, line 375 def visit_float(node) node.copy end
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 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 a GVar
node.
# File lib/syntax_tree/mutation_visitor.rb, line 395 def visit_gvar(node) node.copy end
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 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 a HeredocBeg
node.
# File lib/syntax_tree/mutation_visitor.rb, line 414 def visit_heredoc_beg(node) node.copy end
Visit a HeredocEnd
node.
# File lib/syntax_tree/mutation_visitor.rb, line 419 def visit_heredoc_end(node) node.copy end
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 a Ident
node.
# File lib/syntax_tree/mutation_visitor.rb, line 434 def visit_ident(node) node.copy end
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 a IfOp
node.
# File lib/syntax_tree/mutation_visitor.rb, line 448 def visit_if_op(node) node.copy end
Visit a Imaginary
node.
# File lib/syntax_tree/mutation_visitor.rb, line 453 def visit_imaginary(node) node.copy end
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 a Int
node.
# File lib/syntax_tree/mutation_visitor.rb, line 466 def visit_int(node) node.copy end
Visit a IVar
node.
# File lib/syntax_tree/mutation_visitor.rb, line 471 def visit_ivar(node) node.copy end
Visit a Kw
node.
# File lib/syntax_tree/mutation_visitor.rb, line 476 def visit_kw(node) node.copy end
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 a Label
node.
# File lib/syntax_tree/mutation_visitor.rb, line 486 def visit_label(node) node.copy end
Visit a LabelEnd
node.
# File lib/syntax_tree/mutation_visitor.rb, line 491 def visit_label_end(node) node.copy end
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 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 a LBrace
node.
# File lib/syntax_tree/mutation_visitor.rb, line 509 def visit_lbrace(node) node.copy end
Visit a LBracket
node.
# File lib/syntax_tree/mutation_visitor.rb, line 514 def visit_lbracket(node) node.copy end
Visit a LParen
node.
# File lib/syntax_tree/mutation_visitor.rb, line 519 def visit_lparen(node) node.copy end
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 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 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 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 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 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 a Next
node.
# File lib/syntax_tree/mutation_visitor.rb, line 557 def visit_next(node) node.copy(arguments: visit(node.arguments)) end
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 a Op
node.
# File lib/syntax_tree/mutation_visitor.rb, line 562 def visit_op(node) node.copy end
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 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 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 a Period
node.
# File lib/syntax_tree/mutation_visitor.rb, line 593 def visit_period(node) node.copy end
Visit a PinnedBegin
node.
# File lib/syntax_tree/mutation_visitor.rb, line 157 def visit_pinned_begin(node) node.copy end
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 a Program
node.
# File lib/syntax_tree/mutation_visitor.rb, line 598 def visit_program(node) node.copy(statements: visit(node.statements)) end
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 a QSymbolsBeg
node.
# File lib/syntax_tree/mutation_visitor.rb, line 611 def visit_qsymbols_beg(node) node.copy end
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 a QWordsBeg
node.
# File lib/syntax_tree/mutation_visitor.rb, line 624 def visit_qwords_beg(node) node.copy end
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 a RAssign
node.
# File lib/syntax_tree/mutation_visitor.rb, line 211 def visit_rassign(node) node.copy(operator: visit(node.operator)) end
Visit a RationalLiteral
node.
# File lib/syntax_tree/mutation_visitor.rb, line 629 def visit_rational(node) node.copy end
Visit a RBrace
node.
# File lib/syntax_tree/mutation_visitor.rb, line 634 def visit_rbrace(node) node.copy end
Visit a RBracket
node.
# File lib/syntax_tree/mutation_visitor.rb, line 639 def visit_rbracket(node) node.copy end
Visit a Redo
node.
# File lib/syntax_tree/mutation_visitor.rb, line 644 def visit_redo(node) node.copy end
Visit a RegexpBeg
node.
# File lib/syntax_tree/mutation_visitor.rb, line 654 def visit_regexp_beg(node) node.copy end
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 a RegexpEnd
node.
# File lib/syntax_tree/mutation_visitor.rb, line 659 def visit_regexp_end(node) node.copy end
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 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 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 a RescueMod
node.
# File lib/syntax_tree/mutation_visitor.rb, line 684 def visit_rescue_mod(node) node.copy end
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 a Retry
node.
# File lib/syntax_tree/mutation_visitor.rb, line 694 def visit_retry(node) node.copy end
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 a RParen
node.
# File lib/syntax_tree/mutation_visitor.rb, line 704 def visit_rparen(node) node.copy end
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 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 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 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 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 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 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 a Super
node.
# File lib/syntax_tree/mutation_visitor.rb, line 744 def visit_super(node) node.copy(arguments: visit(node.arguments)) end
Visit a SymBeg
node.
# File lib/syntax_tree/mutation_visitor.rb, line 749 def visit_symbeg(node) node.copy end
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 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 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 a SymbolsBeg
node.
# File lib/syntax_tree/mutation_visitor.rb, line 772 def visit_symbols_beg(node) node.copy end
Visit a TLambda
node.
# File lib/syntax_tree/mutation_visitor.rb, line 777 def visit_tlambda(node) node.copy end
Visit a TLamBeg
node.
# File lib/syntax_tree/mutation_visitor.rb, line 782 def visit_tlambeg(node) node.copy end
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 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 a TStringBeg
node.
# File lib/syntax_tree/mutation_visitor.rb, line 797 def visit_tstring_beg(node) node.copy end
Visit a TStringContent
node.
# File lib/syntax_tree/mutation_visitor.rb, line 802 def visit_tstring_content(node) node.copy end
Visit a TStringEnd
node.
# File lib/syntax_tree/mutation_visitor.rb, line 807 def visit_tstring_end(node) node.copy end
Visit a Unary
node.
# File lib/syntax_tree/mutation_visitor.rb, line 817 def visit_unary(node) node.copy end
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 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 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 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 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 a VCall
node.
# File lib/syntax_tree/mutation_visitor.rb, line 859 def visit_vcall(node) node.copy(value: visit(node.value)) end
Visit a VoidStmt
node.
# File lib/syntax_tree/mutation_visitor.rb, line 864 def visit_void_stmt(node) node.copy end
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 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 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 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 a WordsBeg
node.
# File lib/syntax_tree/mutation_visitor.rb, line 899 def visit_words_beg(node) node.copy end
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 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 a YieldNode
node.
# File lib/syntax_tree/mutation_visitor.rb, line 914 def visit_yield(node) node.copy(arguments: visit(node.arguments)) end
Visit a ZSuper
node.
# File lib/syntax_tree/mutation_visitor.rb, line 919 def visit_zsuper(node) node.copy end