syntax_tree 4.3.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,924 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SyntaxTree
4
+ class Visitor
5
+ # This visitor walks through the tree and copies each node as it is being
6
+ # visited. This is useful for mutating the tree before it is formatted.
7
+ class MutationVisitor < BasicVisitor
8
+ attr_reader :mutations
9
+
10
+ def initialize
11
+ @mutations = []
12
+ end
13
+
14
+ # Create a new mutation based on the given query that will mutate the node
15
+ # using the given block. The block should return a new node that will take
16
+ # the place of the given node in the tree. These blocks frequently make
17
+ # use of the `copy` method on nodes to create a new node with the same
18
+ # properties as the original node.
19
+ def mutate(query, &block)
20
+ mutations << [Pattern.new(query).compile, block]
21
+ end
22
+
23
+ # This is the base visit method for each node in the tree. It first
24
+ # creates a copy of the node using the visit_* methods defined below. Then
25
+ # it checks each mutation in sequence and calls it if it finds a match.
26
+ def visit(node)
27
+ return unless node
28
+ result = node.accept(self)
29
+
30
+ mutations.each do |(pattern, mutation)|
31
+ result = mutation.call(result) if pattern.call(result)
32
+ end
33
+
34
+ result
35
+ end
36
+
37
+ # Visit a BEGINBlock node.
38
+ def visit_BEGIN(node)
39
+ node.copy(
40
+ lbrace: visit(node.lbrace),
41
+ statements: visit(node.statements)
42
+ )
43
+ end
44
+
45
+ # Visit a CHAR node.
46
+ def visit_CHAR(node)
47
+ node.copy
48
+ end
49
+
50
+ # Visit a ENDBlock node.
51
+ def visit_END(node)
52
+ node.copy(
53
+ lbrace: visit(node.lbrace),
54
+ statements: visit(node.statements)
55
+ )
56
+ end
57
+
58
+ # Visit a EndContent node.
59
+ def visit___end__(node)
60
+ node.copy
61
+ end
62
+
63
+ # Visit a AliasNode node.
64
+ def visit_alias(node)
65
+ node.copy(left: visit(node.left), right: visit(node.right))
66
+ end
67
+
68
+ # Visit a ARef node.
69
+ def visit_aref(node)
70
+ node.copy(index: visit(node.index))
71
+ end
72
+
73
+ # Visit a ARefField node.
74
+ def visit_aref_field(node)
75
+ node.copy(index: visit(node.index))
76
+ end
77
+
78
+ # Visit a ArgParen node.
79
+ def visit_arg_paren(node)
80
+ node.copy(arguments: visit(node.arguments))
81
+ end
82
+
83
+ # Visit a Args node.
84
+ def visit_args(node)
85
+ node.copy(parts: visit_all(node.parts))
86
+ end
87
+
88
+ # Visit a ArgBlock node.
89
+ def visit_arg_block(node)
90
+ node.copy(value: visit(node.value))
91
+ end
92
+
93
+ # Visit a ArgStar node.
94
+ def visit_arg_star(node)
95
+ node.copy(value: visit(node.value))
96
+ end
97
+
98
+ # Visit a ArgsForward node.
99
+ def visit_args_forward(node)
100
+ node.copy
101
+ end
102
+
103
+ # Visit a ArrayLiteral node.
104
+ def visit_array(node)
105
+ node.copy(
106
+ lbracket: visit(node.lbracket),
107
+ contents: visit(node.contents)
108
+ )
109
+ end
110
+
111
+ # Visit a AryPtn node.
112
+ def visit_aryptn(node)
113
+ node.copy(
114
+ constant: visit(node.constant),
115
+ requireds: visit_all(node.requireds),
116
+ rest: visit(node.rest),
117
+ posts: visit_all(node.posts)
118
+ )
119
+ end
120
+
121
+ # Visit a Assign node.
122
+ def visit_assign(node)
123
+ node.copy(target: visit(node.target))
124
+ end
125
+
126
+ # Visit a Assoc node.
127
+ def visit_assoc(node)
128
+ node.copy
129
+ end
130
+
131
+ # Visit a AssocSplat node.
132
+ def visit_assoc_splat(node)
133
+ node.copy
134
+ end
135
+
136
+ # Visit a Backref node.
137
+ def visit_backref(node)
138
+ node.copy
139
+ end
140
+
141
+ # Visit a Backtick node.
142
+ def visit_backtick(node)
143
+ node.copy
144
+ end
145
+
146
+ # Visit a BareAssocHash node.
147
+ def visit_bare_assoc_hash(node)
148
+ node.copy(assocs: visit_all(node.assocs))
149
+ end
150
+
151
+ # Visit a Begin node.
152
+ def visit_begin(node)
153
+ node.copy(bodystmt: visit(node.bodystmt))
154
+ end
155
+
156
+ # Visit a PinnedBegin node.
157
+ def visit_pinned_begin(node)
158
+ node.copy
159
+ end
160
+
161
+ # Visit a Binary node.
162
+ def visit_binary(node)
163
+ node.copy
164
+ end
165
+
166
+ # Visit a BlockVar node.
167
+ def visit_block_var(node)
168
+ node.copy(params: visit(node.params), locals: visit_all(node.locals))
169
+ end
170
+
171
+ # Visit a BlockArg node.
172
+ def visit_blockarg(node)
173
+ node.copy(name: visit(node.name))
174
+ end
175
+
176
+ # Visit a BodyStmt node.
177
+ def visit_bodystmt(node)
178
+ node.copy(
179
+ statements: visit(node.statements),
180
+ rescue_clause: visit(node.rescue_clause),
181
+ else_clause: visit(node.else_clause),
182
+ ensure_clause: visit(node.ensure_clause)
183
+ )
184
+ end
185
+
186
+ # Visit a Break node.
187
+ def visit_break(node)
188
+ node.copy(arguments: visit(node.arguments))
189
+ end
190
+
191
+ # Visit a Call node.
192
+ def visit_call(node)
193
+ node.copy(
194
+ receiver: visit(node.receiver),
195
+ operator: node.operator == :"::" ? :"::" : visit(node.operator),
196
+ message: node.message == :call ? :call : visit(node.message),
197
+ arguments: visit(node.arguments)
198
+ )
199
+ end
200
+
201
+ # Visit a Case node.
202
+ def visit_case(node)
203
+ node.copy(
204
+ keyword: visit(node.keyword),
205
+ value: visit(node.value),
206
+ consequent: visit(node.consequent)
207
+ )
208
+ end
209
+
210
+ # Visit a RAssign node.
211
+ def visit_rassign(node)
212
+ node.copy(operator: visit(node.operator))
213
+ end
214
+
215
+ # Visit a ClassDeclaration node.
216
+ def visit_class(node)
217
+ node.copy(
218
+ constant: visit(node.constant),
219
+ superclass: visit(node.superclass),
220
+ bodystmt: visit(node.bodystmt)
221
+ )
222
+ end
223
+
224
+ # Visit a Comma node.
225
+ def visit_comma(node)
226
+ node.copy
227
+ end
228
+
229
+ # Visit a Command node.
230
+ def visit_command(node)
231
+ node.copy(
232
+ message: visit(node.message),
233
+ arguments: visit(node.arguments),
234
+ block: visit(node.block)
235
+ )
236
+ end
237
+
238
+ # Visit a CommandCall node.
239
+ def visit_command_call(node)
240
+ node.copy(
241
+ operator: node.operator == :"::" ? :"::" : visit(node.operator),
242
+ message: visit(node.message),
243
+ arguments: visit(node.arguments),
244
+ block: visit(node.block)
245
+ )
246
+ end
247
+
248
+ # Visit a Comment node.
249
+ def visit_comment(node)
250
+ node.copy
251
+ end
252
+
253
+ # Visit a Const node.
254
+ def visit_const(node)
255
+ node.copy
256
+ end
257
+
258
+ # Visit a ConstPathField node.
259
+ def visit_const_path_field(node)
260
+ node.copy(constant: visit(node.constant))
261
+ end
262
+
263
+ # Visit a ConstPathRef node.
264
+ def visit_const_path_ref(node)
265
+ node.copy(constant: visit(node.constant))
266
+ end
267
+
268
+ # Visit a ConstRef node.
269
+ def visit_const_ref(node)
270
+ node.copy(constant: visit(node.constant))
271
+ end
272
+
273
+ # Visit a CVar node.
274
+ def visit_cvar(node)
275
+ node.copy
276
+ end
277
+
278
+ # Visit a Def node.
279
+ def visit_def(node)
280
+ node.copy(
281
+ target: visit(node.target),
282
+ operator: visit(node.operator),
283
+ name: visit(node.name),
284
+ params: visit(node.params),
285
+ bodystmt: visit(node.bodystmt)
286
+ )
287
+ end
288
+
289
+ # Visit a Defined node.
290
+ def visit_defined(node)
291
+ node.copy
292
+ end
293
+
294
+ # Visit a Block node.
295
+ def visit_block(node)
296
+ node.copy(
297
+ opening: visit(node.opening),
298
+ block_var: visit(node.block_var),
299
+ bodystmt: visit(node.bodystmt)
300
+ )
301
+ end
302
+
303
+ # Visit a RangeNode node.
304
+ def visit_range(node)
305
+ node.copy(
306
+ left: visit(node.left),
307
+ operator: visit(node.operator),
308
+ right: visit(node.right)
309
+ )
310
+ end
311
+
312
+ # Visit a DynaSymbol node.
313
+ def visit_dyna_symbol(node)
314
+ node.copy(parts: visit_all(node.parts))
315
+ end
316
+
317
+ # Visit a Else node.
318
+ def visit_else(node)
319
+ node.copy(
320
+ keyword: visit(node.keyword),
321
+ statements: visit(node.statements)
322
+ )
323
+ end
324
+
325
+ # Visit a Elsif node.
326
+ def visit_elsif(node)
327
+ node.copy(
328
+ statements: visit(node.statements),
329
+ consequent: visit(node.consequent)
330
+ )
331
+ end
332
+
333
+ # Visit a EmbDoc node.
334
+ def visit_embdoc(node)
335
+ node.copy
336
+ end
337
+
338
+ # Visit a EmbExprBeg node.
339
+ def visit_embexpr_beg(node)
340
+ node.copy
341
+ end
342
+
343
+ # Visit a EmbExprEnd node.
344
+ def visit_embexpr_end(node)
345
+ node.copy
346
+ end
347
+
348
+ # Visit a EmbVar node.
349
+ def visit_embvar(node)
350
+ node.copy
351
+ end
352
+
353
+ # Visit a Ensure node.
354
+ def visit_ensure(node)
355
+ node.copy(
356
+ keyword: visit(node.keyword),
357
+ statements: visit(node.statements)
358
+ )
359
+ end
360
+
361
+ # Visit a ExcessedComma node.
362
+ def visit_excessed_comma(node)
363
+ node.copy
364
+ end
365
+
366
+ # Visit a Field node.
367
+ def visit_field(node)
368
+ node.copy(
369
+ operator: node.operator == :"::" ? :"::" : visit(node.operator),
370
+ name: visit(node.name)
371
+ )
372
+ end
373
+
374
+ # Visit a FloatLiteral node.
375
+ def visit_float(node)
376
+ node.copy
377
+ end
378
+
379
+ # Visit a FndPtn node.
380
+ def visit_fndptn(node)
381
+ node.copy(
382
+ constant: visit(node.constant),
383
+ left: visit(node.left),
384
+ values: visit_all(node.values),
385
+ right: visit(node.right)
386
+ )
387
+ end
388
+
389
+ # Visit a For node.
390
+ def visit_for(node)
391
+ node.copy(index: visit(node.index), statements: visit(node.statements))
392
+ end
393
+
394
+ # Visit a GVar node.
395
+ def visit_gvar(node)
396
+ node.copy
397
+ end
398
+
399
+ # Visit a HashLiteral node.
400
+ def visit_hash(node)
401
+ node.copy(lbrace: visit(node.lbrace), assocs: visit_all(node.assocs))
402
+ end
403
+
404
+ # Visit a Heredoc node.
405
+ def visit_heredoc(node)
406
+ node.copy(
407
+ beginning: visit(node.beginning),
408
+ ending: visit(node.ending),
409
+ parts: visit_all(node.parts)
410
+ )
411
+ end
412
+
413
+ # Visit a HeredocBeg node.
414
+ def visit_heredoc_beg(node)
415
+ node.copy
416
+ end
417
+
418
+ # Visit a HeredocEnd node.
419
+ def visit_heredoc_end(node)
420
+ node.copy
421
+ end
422
+
423
+ # Visit a HshPtn node.
424
+ def visit_hshptn(node)
425
+ node.copy(
426
+ constant: visit(node.constant),
427
+ keywords:
428
+ node.keywords.map { |label, value| [visit(label), visit(value)] },
429
+ keyword_rest: visit(node.keyword_rest)
430
+ )
431
+ end
432
+
433
+ # Visit a Ident node.
434
+ def visit_ident(node)
435
+ node.copy
436
+ end
437
+
438
+ # Visit a IfNode node.
439
+ def visit_if(node)
440
+ node.copy(
441
+ predicate: visit(node.predicate),
442
+ statements: visit(node.statements),
443
+ consequent: visit(node.consequent)
444
+ )
445
+ end
446
+
447
+ # Visit a IfOp node.
448
+ def visit_if_op(node)
449
+ node.copy
450
+ end
451
+
452
+ # Visit a Imaginary node.
453
+ def visit_imaginary(node)
454
+ node.copy
455
+ end
456
+
457
+ # Visit a In node.
458
+ def visit_in(node)
459
+ node.copy(
460
+ statements: visit(node.statements),
461
+ consequent: visit(node.consequent)
462
+ )
463
+ end
464
+
465
+ # Visit a Int node.
466
+ def visit_int(node)
467
+ node.copy
468
+ end
469
+
470
+ # Visit a IVar node.
471
+ def visit_ivar(node)
472
+ node.copy
473
+ end
474
+
475
+ # Visit a Kw node.
476
+ def visit_kw(node)
477
+ node.copy
478
+ end
479
+
480
+ # Visit a KwRestParam node.
481
+ def visit_kwrest_param(node)
482
+ node.copy(name: visit(node.name))
483
+ end
484
+
485
+ # Visit a Label node.
486
+ def visit_label(node)
487
+ node.copy
488
+ end
489
+
490
+ # Visit a LabelEnd node.
491
+ def visit_label_end(node)
492
+ node.copy
493
+ end
494
+
495
+ # Visit a Lambda node.
496
+ def visit_lambda(node)
497
+ node.copy(
498
+ params: visit(node.params),
499
+ statements: visit(node.statements)
500
+ )
501
+ end
502
+
503
+ # Visit a LambdaVar node.
504
+ def visit_lambda_var(node)
505
+ node.copy(params: visit(node.params), locals: visit_all(node.locals))
506
+ end
507
+
508
+ # Visit a LBrace node.
509
+ def visit_lbrace(node)
510
+ node.copy
511
+ end
512
+
513
+ # Visit a LBracket node.
514
+ def visit_lbracket(node)
515
+ node.copy
516
+ end
517
+
518
+ # Visit a LParen node.
519
+ def visit_lparen(node)
520
+ node.copy
521
+ end
522
+
523
+ # Visit a MAssign node.
524
+ def visit_massign(node)
525
+ node.copy(target: visit(node.target))
526
+ end
527
+
528
+ # Visit a MethodAddBlock node.
529
+ def visit_method_add_block(node)
530
+ node.copy(call: visit(node.call), block: visit(node.block))
531
+ end
532
+
533
+ # Visit a MLHS node.
534
+ def visit_mlhs(node)
535
+ node.copy(parts: visit_all(node.parts))
536
+ end
537
+
538
+ # Visit a MLHSParen node.
539
+ def visit_mlhs_paren(node)
540
+ node.copy(contents: visit(node.contents))
541
+ end
542
+
543
+ # Visit a ModuleDeclaration node.
544
+ def visit_module(node)
545
+ node.copy(
546
+ constant: visit(node.constant),
547
+ bodystmt: visit(node.bodystmt)
548
+ )
549
+ end
550
+
551
+ # Visit a MRHS node.
552
+ def visit_mrhs(node)
553
+ node.copy(parts: visit_all(node.parts))
554
+ end
555
+
556
+ # Visit a Next node.
557
+ def visit_next(node)
558
+ node.copy(arguments: visit(node.arguments))
559
+ end
560
+
561
+ # Visit a Op node.
562
+ def visit_op(node)
563
+ node.copy
564
+ end
565
+
566
+ # Visit a OpAssign node.
567
+ def visit_opassign(node)
568
+ node.copy(target: visit(node.target), operator: visit(node.operator))
569
+ end
570
+
571
+ # Visit a Params node.
572
+ def visit_params(node)
573
+ node.copy(
574
+ requireds: visit_all(node.requireds),
575
+ optionals:
576
+ node.optionals.map { |ident, value| [visit(ident), visit(value)] },
577
+ rest: visit(node.rest),
578
+ posts: visit_all(node.posts),
579
+ keywords:
580
+ node.keywords.map { |ident, value| [visit(ident), visit(value)] },
581
+ keyword_rest:
582
+ node.keyword_rest == :nil ? :nil : visit(node.keyword_rest),
583
+ block: visit(node.block)
584
+ )
585
+ end
586
+
587
+ # Visit a Paren node.
588
+ def visit_paren(node)
589
+ node.copy(lparen: visit(node.lparen), contents: visit(node.contents))
590
+ end
591
+
592
+ # Visit a Period node.
593
+ def visit_period(node)
594
+ node.copy
595
+ end
596
+
597
+ # Visit a Program node.
598
+ def visit_program(node)
599
+ node.copy(statements: visit(node.statements))
600
+ end
601
+
602
+ # Visit a QSymbols node.
603
+ def visit_qsymbols(node)
604
+ node.copy(
605
+ beginning: visit(node.beginning),
606
+ elements: visit_all(node.elements)
607
+ )
608
+ end
609
+
610
+ # Visit a QSymbolsBeg node.
611
+ def visit_qsymbols_beg(node)
612
+ node.copy
613
+ end
614
+
615
+ # Visit a QWords node.
616
+ def visit_qwords(node)
617
+ node.copy(
618
+ beginning: visit(node.beginning),
619
+ elements: visit_all(node.elements)
620
+ )
621
+ end
622
+
623
+ # Visit a QWordsBeg node.
624
+ def visit_qwords_beg(node)
625
+ node.copy
626
+ end
627
+
628
+ # Visit a RationalLiteral node.
629
+ def visit_rational(node)
630
+ node.copy
631
+ end
632
+
633
+ # Visit a RBrace node.
634
+ def visit_rbrace(node)
635
+ node.copy
636
+ end
637
+
638
+ # Visit a RBracket node.
639
+ def visit_rbracket(node)
640
+ node.copy
641
+ end
642
+
643
+ # Visit a Redo node.
644
+ def visit_redo(node)
645
+ node.copy
646
+ end
647
+
648
+ # Visit a RegexpContent node.
649
+ def visit_regexp_content(node)
650
+ node.copy(parts: visit_all(node.parts))
651
+ end
652
+
653
+ # Visit a RegexpBeg node.
654
+ def visit_regexp_beg(node)
655
+ node.copy
656
+ end
657
+
658
+ # Visit a RegexpEnd node.
659
+ def visit_regexp_end(node)
660
+ node.copy
661
+ end
662
+
663
+ # Visit a RegexpLiteral node.
664
+ def visit_regexp_literal(node)
665
+ node.copy(parts: visit_all(node.parts))
666
+ end
667
+
668
+ # Visit a RescueEx node.
669
+ def visit_rescue_ex(node)
670
+ node.copy(variable: visit(node.variable))
671
+ end
672
+
673
+ # Visit a Rescue node.
674
+ def visit_rescue(node)
675
+ node.copy(
676
+ keyword: visit(node.keyword),
677
+ exception: visit(node.exception),
678
+ statements: visit(node.statements),
679
+ consequent: visit(node.consequent)
680
+ )
681
+ end
682
+
683
+ # Visit a RescueMod node.
684
+ def visit_rescue_mod(node)
685
+ node.copy
686
+ end
687
+
688
+ # Visit a RestParam node.
689
+ def visit_rest_param(node)
690
+ node.copy(name: visit(node.name))
691
+ end
692
+
693
+ # Visit a Retry node.
694
+ def visit_retry(node)
695
+ node.copy
696
+ end
697
+
698
+ # Visit a Return node.
699
+ def visit_return(node)
700
+ node.copy(arguments: visit(node.arguments))
701
+ end
702
+
703
+ # Visit a RParen node.
704
+ def visit_rparen(node)
705
+ node.copy
706
+ end
707
+
708
+ # Visit a SClass node.
709
+ def visit_sclass(node)
710
+ node.copy(bodystmt: visit(node.bodystmt))
711
+ end
712
+
713
+ # Visit a Statements node.
714
+ def visit_statements(node)
715
+ node.copy(body: visit_all(node.body))
716
+ end
717
+
718
+ # Visit a StringContent node.
719
+ def visit_string_content(node)
720
+ node.copy(parts: visit_all(node.parts))
721
+ end
722
+
723
+ # Visit a StringConcat node.
724
+ def visit_string_concat(node)
725
+ node.copy(left: visit(node.left), right: visit(node.right))
726
+ end
727
+
728
+ # Visit a StringDVar node.
729
+ def visit_string_dvar(node)
730
+ node.copy(variable: visit(node.variable))
731
+ end
732
+
733
+ # Visit a StringEmbExpr node.
734
+ def visit_string_embexpr(node)
735
+ node.copy(statements: visit(node.statements))
736
+ end
737
+
738
+ # Visit a StringLiteral node.
739
+ def visit_string_literal(node)
740
+ node.copy(parts: visit_all(node.parts))
741
+ end
742
+
743
+ # Visit a Super node.
744
+ def visit_super(node)
745
+ node.copy(arguments: visit(node.arguments))
746
+ end
747
+
748
+ # Visit a SymBeg node.
749
+ def visit_symbeg(node)
750
+ node.copy
751
+ end
752
+
753
+ # Visit a SymbolContent node.
754
+ def visit_symbol_content(node)
755
+ node.copy(value: visit(node.value))
756
+ end
757
+
758
+ # Visit a SymbolLiteral node.
759
+ def visit_symbol_literal(node)
760
+ node.copy(value: visit(node.value))
761
+ end
762
+
763
+ # Visit a Symbols node.
764
+ def visit_symbols(node)
765
+ node.copy(
766
+ beginning: visit(node.beginning),
767
+ elements: visit_all(node.elements)
768
+ )
769
+ end
770
+
771
+ # Visit a SymbolsBeg node.
772
+ def visit_symbols_beg(node)
773
+ node.copy
774
+ end
775
+
776
+ # Visit a TLambda node.
777
+ def visit_tlambda(node)
778
+ node.copy
779
+ end
780
+
781
+ # Visit a TLamBeg node.
782
+ def visit_tlambeg(node)
783
+ node.copy
784
+ end
785
+
786
+ # Visit a TopConstField node.
787
+ def visit_top_const_field(node)
788
+ node.copy(constant: visit(node.constant))
789
+ end
790
+
791
+ # Visit a TopConstRef node.
792
+ def visit_top_const_ref(node)
793
+ node.copy(constant: visit(node.constant))
794
+ end
795
+
796
+ # Visit a TStringBeg node.
797
+ def visit_tstring_beg(node)
798
+ node.copy
799
+ end
800
+
801
+ # Visit a TStringContent node.
802
+ def visit_tstring_content(node)
803
+ node.copy
804
+ end
805
+
806
+ # Visit a TStringEnd node.
807
+ def visit_tstring_end(node)
808
+ node.copy
809
+ end
810
+
811
+ # Visit a Not node.
812
+ def visit_not(node)
813
+ node.copy(statement: visit(node.statement))
814
+ end
815
+
816
+ # Visit a Unary node.
817
+ def visit_unary(node)
818
+ node.copy
819
+ end
820
+
821
+ # Visit a Undef node.
822
+ def visit_undef(node)
823
+ node.copy(symbols: visit_all(node.symbols))
824
+ end
825
+
826
+ # Visit a UnlessNode node.
827
+ def visit_unless(node)
828
+ node.copy(
829
+ predicate: visit(node.predicate),
830
+ statements: visit(node.statements),
831
+ consequent: visit(node.consequent)
832
+ )
833
+ end
834
+
835
+ # Visit a UntilNode node.
836
+ def visit_until(node)
837
+ node.copy(
838
+ predicate: visit(node.predicate),
839
+ statements: visit(node.statements)
840
+ )
841
+ end
842
+
843
+ # Visit a VarField node.
844
+ def visit_var_field(node)
845
+ node.copy(value: visit(node.value))
846
+ end
847
+
848
+ # Visit a VarRef node.
849
+ def visit_var_ref(node)
850
+ node.copy(value: visit(node.value))
851
+ end
852
+
853
+ # Visit a PinnedVarRef node.
854
+ def visit_pinned_var_ref(node)
855
+ node.copy(value: visit(node.value))
856
+ end
857
+
858
+ # Visit a VCall node.
859
+ def visit_vcall(node)
860
+ node.copy(value: visit(node.value))
861
+ end
862
+
863
+ # Visit a VoidStmt node.
864
+ def visit_void_stmt(node)
865
+ node.copy
866
+ end
867
+
868
+ # Visit a When node.
869
+ def visit_when(node)
870
+ node.copy(
871
+ arguments: visit(node.arguments),
872
+ statements: visit(node.statements),
873
+ consequent: visit(node.consequent)
874
+ )
875
+ end
876
+
877
+ # Visit a WhileNode node.
878
+ def visit_while(node)
879
+ node.copy(
880
+ predicate: visit(node.predicate),
881
+ statements: visit(node.statements)
882
+ )
883
+ end
884
+
885
+ # Visit a Word node.
886
+ def visit_word(node)
887
+ node.copy(parts: visit_all(node.parts))
888
+ end
889
+
890
+ # Visit a Words node.
891
+ def visit_words(node)
892
+ node.copy(
893
+ beginning: visit(node.beginning),
894
+ elements: visit_all(node.elements)
895
+ )
896
+ end
897
+
898
+ # Visit a WordsBeg node.
899
+ def visit_words_beg(node)
900
+ node.copy
901
+ end
902
+
903
+ # Visit a XString node.
904
+ def visit_xstring(node)
905
+ node.copy(parts: visit_all(node.parts))
906
+ end
907
+
908
+ # Visit a XStringLiteral node.
909
+ def visit_xstring_literal(node)
910
+ node.copy(parts: visit_all(node.parts))
911
+ end
912
+
913
+ # Visit a YieldNode node.
914
+ def visit_yield(node)
915
+ node.copy(arguments: visit(node.arguments))
916
+ end
917
+
918
+ # Visit a ZSuper node.
919
+ def visit_zsuper(node)
920
+ node.copy
921
+ end
922
+ end
923
+ end
924
+ end