mutant 0.11.10 → 0.11.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,890 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mutant
4
+ module AST
5
+ # AST Structure metadata
6
+ # rubocop:disable Metrics/ModuleLength
7
+ module Structure
8
+ class Node
9
+ include Adamantium, Anima.new(:type, :fixed, :variable)
10
+
11
+ class Fixed
12
+ include Adamantium, Anima.new(:index, :name)
13
+
14
+ class Descendant < self
15
+ end
16
+
17
+ class Attribute < self
18
+ end
19
+
20
+ def attribute?
21
+ instance_of?(Attribute)
22
+ end
23
+
24
+ def descendant?
25
+ instance_of?(Descendant)
26
+ end
27
+
28
+ def value(node)
29
+ node.children.fetch(index)
30
+ end
31
+ end
32
+
33
+ class Variable
34
+ include Adamantium, Anima.new(:name, :range)
35
+
36
+ class Descendants < self
37
+ def nodes(node)
38
+ node.children[range]
39
+ end
40
+ end
41
+
42
+ class Attributes < self
43
+ def nodes(_node)
44
+ EMPTY_ARRAY
45
+ end
46
+ end
47
+ end
48
+
49
+ def each_descendant_deep(node, &block)
50
+ each_descendant(node) do |descendant|
51
+ block.call(descendant)
52
+ Structure.for(descendant.type).each_descendant_deep(descendant, &block)
53
+ end
54
+ end
55
+
56
+ def each_node(node, &block)
57
+ block.call(node)
58
+ each_descendant_deep(node, &block)
59
+ end
60
+
61
+ def each_descendant(node, &block)
62
+ descendants.each_value do |descendant|
63
+ value = descendant.value(node)
64
+
65
+ block.call(value) if value
66
+ end
67
+
68
+ variable_descendants(node).each do |value|
69
+ block.call(value) if value
70
+ end
71
+
72
+ self
73
+ end
74
+
75
+ def descendants
76
+ fixed.select(&:descendant?).to_h { |child| [child.name, child] }
77
+ end
78
+
79
+ def attributes
80
+ fixed.select(&:attribute?).to_h { |child| [child.name, child] }
81
+ end
82
+
83
+ def descendant(name)
84
+ maybe_descendant(name) or fail "Node #{type} does not have fixed descendant #{name}"
85
+ end
86
+
87
+ def attribute(name)
88
+ maybe_attribute(name) or fail "Node #{type} does not have fixed attribute #{name}"
89
+ end
90
+
91
+ def maybe_attribute(name)
92
+ attributes[name]
93
+ end
94
+
95
+ def maybe_descendant(name)
96
+ descendants[name]
97
+ end
98
+
99
+ def self.fixed(values)
100
+ values.each_with_index.map do |(klass, name), index|
101
+ klass.new(index: index, name: name)
102
+ end
103
+ end
104
+
105
+ private
106
+
107
+ def variable_descendants(node)
108
+ return EMPTY_ARRAY unless variable
109
+
110
+ variable.nodes(node)
111
+ end
112
+ end
113
+
114
+ ALL = [
115
+ Node.new(
116
+ type: :__ENCODING__,
117
+ fixed: EMPTY_ARRAY,
118
+ variable: nil
119
+ ),
120
+ Node.new(
121
+ type: :__FILE__,
122
+ fixed: EMPTY_ARRAY,
123
+ variable: nil
124
+ ),
125
+ Node.new(
126
+ type: :__LINE__,
127
+ fixed: EMPTY_ARRAY,
128
+ variable: nil
129
+ ),
130
+ Node.new(
131
+ type: :alias,
132
+ fixed: Node.fixed(
133
+ [
134
+ [Node::Fixed::Descendant, :source],
135
+ [Node::Fixed::Descendant, :target]
136
+ ]
137
+ ),
138
+ variable: nil
139
+ ),
140
+ Node.new(
141
+ type: :and,
142
+ fixed: Node.fixed(
143
+ [
144
+ [Node::Fixed::Descendant, :left],
145
+ [Node::Fixed::Descendant, :right]
146
+ ]
147
+ ),
148
+ variable: nil
149
+ ),
150
+ Node.new(
151
+ type: :and_asgn,
152
+ fixed: Node.fixed(
153
+ [
154
+ [Node::Fixed::Descendant, :target],
155
+ [Node::Fixed::Descendant, :value]
156
+ ]
157
+ ),
158
+ variable: nil
159
+ ),
160
+ Node.new(
161
+ type: :arg,
162
+ fixed: Node.fixed([[Node::Fixed::Attribute, :name]]),
163
+ variable: nil
164
+ ),
165
+ Node.new(
166
+ type: :args,
167
+ fixed: EMPTY_ARRAY,
168
+ variable: Node::Variable::Descendants.new(name: :arguments, range: 0..)
169
+ ),
170
+ Node.new(
171
+ type: :array,
172
+ fixed: EMPTY_ARRAY,
173
+ variable: Node::Variable::Descendants.new(name: :members, range: 0..)
174
+ ),
175
+ Node.new(
176
+ type: :array_pattern,
177
+ fixed: EMPTY_ARRAY,
178
+ variable: Node::Variable::Descendants.new(name: :members, range: 0..)
179
+ ),
180
+ Node.new(
181
+ type: :back_ref,
182
+ fixed: Node.fixed([[Node::Fixed::Attribute, :name]]),
183
+ variable: nil
184
+ ),
185
+ Node.new(
186
+ type: :begin,
187
+ fixed: EMPTY_ARRAY,
188
+ variable: Node::Variable::Descendants.new(name: :members, range: 0..)
189
+ ),
190
+ Node.new(
191
+ type: :block,
192
+ fixed: Node.fixed(
193
+ [
194
+ [Node::Fixed::Descendant, :receiver],
195
+ [Node::Fixed::Descendant, :arguments],
196
+ [Node::Fixed::Descendant, :body]
197
+ ]
198
+ ),
199
+ variable: nil
200
+ ),
201
+ Node.new(
202
+ type: :blockarg,
203
+ fixed: Node.fixed([[Node::Fixed::Attribute, :name]]),
204
+ variable: nil
205
+ ),
206
+ Node.new(
207
+ type: :block_pass,
208
+ fixed: Node.fixed([[Node::Fixed::Descendant, :value]]),
209
+ variable: nil
210
+ ),
211
+ Node.new(
212
+ type: :break,
213
+ fixed: EMPTY_ARRAY,
214
+ variable: Node::Variable::Descendants.new(name: :values, range: 0..)
215
+ ),
216
+ Node.new(
217
+ type: :case,
218
+ fixed: Node.fixed([[Node::Fixed::Descendant, :value]]),
219
+ variable: Node::Variable::Descendants.new(name: :members, range: 1..)
220
+ ),
221
+ Node.new(
222
+ type: :case_match,
223
+ fixed: [
224
+ Node::Fixed::Descendant.new(index: 0, name: :target),
225
+ Node::Fixed::Descendant.new(index: -1, name: :else_branch)
226
+ ],
227
+ variable: Node::Variable::Descendants.new(name: :patterns, range: 1..-2)
228
+ ),
229
+ Node.new(
230
+ type: :casgn,
231
+ fixed: Node.fixed(
232
+ [
233
+ [Node::Fixed::Descendant, :base],
234
+ [Node::Fixed::Attribute, :name],
235
+ [Node::Fixed::Descendant, :value]
236
+ ]
237
+ ),
238
+ variable: nil
239
+ ),
240
+ Node.new(
241
+ type: :cbase,
242
+ fixed: EMPTY_ARRAY,
243
+ variable: nil
244
+ ),
245
+ Node.new(
246
+ type: :class,
247
+ fixed: Node.fixed(
248
+ [
249
+ [Node::Fixed::Descendant, :name],
250
+ [Node::Fixed::Descendant, :superclass],
251
+ [Node::Fixed::Descendant, :body]
252
+ ]
253
+ ),
254
+ variable: nil
255
+ ),
256
+ Node.new(
257
+ type: :complex,
258
+ fixed: Node.fixed([[Node::Fixed::Attribute, :name]]),
259
+ variable: nil
260
+ ),
261
+ Node.new(
262
+ type: :const,
263
+ fixed: Node.fixed(
264
+ [
265
+ [Node::Fixed::Descendant, :base],
266
+ [Node::Fixed::Attribute, :name]
267
+ ]
268
+ ),
269
+ variable: nil
270
+ ),
271
+ Node.new(
272
+ type: :const_pattern,
273
+ fixed: Node.fixed(
274
+ [
275
+ [Node::Fixed::Descendant, :target],
276
+ [Node::Fixed::Descendant, :pattern]
277
+ ]
278
+ ),
279
+ variable: nil
280
+ ),
281
+ Node.new(
282
+ type: :csend,
283
+ fixed: Node.fixed(
284
+ [
285
+ [Node::Fixed::Descendant, :receiver],
286
+ [Node::Fixed::Attribute, :selector]
287
+ ]
288
+ ),
289
+ variable: Node::Variable::Descendants.new(name: :arguments, range: 2..)
290
+ ),
291
+ Node.new(
292
+ type: :cvar,
293
+ fixed: Node.fixed([[Node::Fixed::Attribute, :name]]),
294
+ variable: nil
295
+ ),
296
+ Node.new(
297
+ type: :cvasgn,
298
+ fixed: Node.fixed(
299
+ [
300
+ [Node::Fixed::Attribute, :name],
301
+ [Node::Fixed::Descendant, :value]
302
+ ]
303
+ ),
304
+ variable: nil
305
+ ),
306
+ Node.new(
307
+ type: :defined?,
308
+ fixed: Node.fixed([[Node::Fixed::Descendant, :value]]),
309
+ variable: nil
310
+ ),
311
+ Node.new(
312
+ type: :dstr,
313
+ fixed: EMPTY_ARRAY,
314
+ variable: Node::Variable::Descendants.new(name: :members, range: 0..)
315
+ ),
316
+ Node.new(
317
+ type: :dsym,
318
+ fixed: EMPTY_ARRAY,
319
+ variable: Node::Variable::Descendants.new(name: :members, range: 0..)
320
+ ),
321
+ Node.new(
322
+ type: :def,
323
+ fixed: Node.fixed(
324
+ [
325
+ [Node::Fixed::Attribute, :name],
326
+ [Node::Fixed::Descendant, :arguments],
327
+ [Node::Fixed::Descendant, :body]
328
+ ]
329
+ ),
330
+ variable: nil
331
+ ),
332
+ Node.new(
333
+ type: :defs,
334
+ fixed: Node.fixed(
335
+ [
336
+ [Node::Fixed::Descendant, :singleton],
337
+ [Node::Fixed::Attribute, :name],
338
+ [Node::Fixed::Descendant, :arguments],
339
+ [Node::Fixed::Descendant, :body]
340
+ ]
341
+ ),
342
+ variable: nil
343
+ ),
344
+ Node.new(
345
+ type: :empty_else,
346
+ fixed: EMPTY_ARRAY,
347
+ variable: nil
348
+ ),
349
+ Node.new(
350
+ type: :ensure,
351
+ fixed: Node.fixed(
352
+ [
353
+ [Node::Fixed::Descendant, :target],
354
+ [Node::Fixed::Descendant, :ensure_body]
355
+ ]
356
+ ),
357
+ variable: nil
358
+ ),
359
+ Node.new(
360
+ type: :eflipflop,
361
+ fixed: Node.fixed(
362
+ [
363
+ [Node::Fixed::Descendant, :start],
364
+ [Node::Fixed::Descendant, :end]
365
+ ]
366
+ ),
367
+ variable: nil
368
+ ),
369
+ Node.new(
370
+ type: :erange,
371
+ fixed: Node.fixed(
372
+ [
373
+ [Node::Fixed::Descendant, :begin],
374
+ [Node::Fixed::Descendant, :end]
375
+ ]
376
+ ),
377
+ variable: nil
378
+ ),
379
+ Node.new(
380
+ type: :false,
381
+ fixed: EMPTY_ARRAY,
382
+ variable: nil
383
+ ),
384
+ Node.new(
385
+ type: :float,
386
+ fixed: Node.fixed([[Node::Fixed::Attribute, :value]]),
387
+ variable: nil
388
+ ),
389
+ Node.new(
390
+ type: :for,
391
+ fixed: Node.fixed(
392
+ [
393
+ [Node::Fixed::Descendant, :target],
394
+ [Node::Fixed::Descendant, :source],
395
+ [Node::Fixed::Descendant, :body]
396
+ ]
397
+ ),
398
+ variable: nil
399
+ ),
400
+ Node.new(
401
+ type: :gvar,
402
+ fixed: Node.fixed([[Node::Fixed::Attribute, :name]]),
403
+ variable: nil
404
+ ),
405
+ Node.new(
406
+ type: :gvasgn,
407
+ fixed: Node.fixed(
408
+ [
409
+ [Node::Fixed::Attribute, :name],
410
+ [Node::Fixed::Descendant, :value]
411
+ ]
412
+ ),
413
+ variable: nil
414
+ ),
415
+ Node.new(
416
+ type: :hash,
417
+ fixed: EMPTY_ARRAY,
418
+ variable: Node::Variable::Descendants.new(name: :members, range: 0..)
419
+ ),
420
+ Node.new(
421
+ type: :index,
422
+ fixed: Node.fixed([[Node::Fixed::Descendant, :receiver]]),
423
+ variable: Node::Variable::Descendants.new(name: :members, range: 1..)
424
+ ),
425
+ Node.new(
426
+ type: :indexasgn,
427
+ fixed: Node.fixed([[Node::Fixed::Descendant, :receiver]]),
428
+ variable: Node::Variable::Descendants.new(name: :members, range: 1..)
429
+ ),
430
+ Node.new(
431
+ type: :if,
432
+ fixed: Node.fixed(
433
+ [
434
+ [Node::Fixed::Descendant, :condition],
435
+ [Node::Fixed::Descendant, :true_branch],
436
+ [Node::Fixed::Descendant, :false_branch]
437
+ ]
438
+ ),
439
+ variable: nil
440
+ ),
441
+ Node.new(
442
+ type: :iflipflop,
443
+ fixed: Node.fixed(
444
+ [
445
+ [Node::Fixed::Descendant, :start],
446
+ [Node::Fixed::Descendant, :end]
447
+ ]
448
+ ),
449
+ variable: nil
450
+ ),
451
+ Node.new(
452
+ type: :in_pattern,
453
+ fixed: Node.fixed(
454
+ [
455
+ [Node::Fixed::Descendant, :target],
456
+ [Node::Fixed::Descendant, :unless_guard],
457
+ [Node::Fixed::Descendant, :branch],
458
+ [Node::Fixed::Descendant, :else_branch]
459
+ ]
460
+ ),
461
+ variable: nil
462
+ ),
463
+ Node.new(
464
+ type: :int,
465
+ fixed: Node.fixed([[Node::Fixed::Attribute, :value]]),
466
+ variable: nil
467
+ ),
468
+ Node.new(
469
+ type: :irange,
470
+ fixed: Node.fixed(
471
+ [
472
+ [Node::Fixed::Descendant, :begin],
473
+ [Node::Fixed::Descendant, :end]
474
+ ]
475
+ ),
476
+ variable: nil
477
+ ),
478
+ Node.new(
479
+ type: :ivar,
480
+ fixed: Node.fixed([[Node::Fixed::Attribute, :name]]),
481
+ variable: nil
482
+ ),
483
+ Node.new(
484
+ type: :ivasgn,
485
+ fixed: Node.fixed(
486
+ [
487
+ [Node::Fixed::Attribute, :name],
488
+ [Node::Fixed::Descendant, :value]
489
+ ]
490
+ ),
491
+ variable: nil
492
+ ),
493
+ Node.new(
494
+ type: :kwarg,
495
+ fixed: Node.fixed([[Node::Fixed::Attribute, :name]]),
496
+ variable: nil
497
+ ),
498
+ Node.new(
499
+ type: :kwargs,
500
+ fixed: EMPTY_ARRAY,
501
+ variable: Node::Variable::Descendants.new(name: :members, range: 0..)
502
+ ),
503
+ Node.new(
504
+ type: :kwbegin,
505
+ fixed: EMPTY_ARRAY,
506
+ variable: Node::Variable::Descendants.new(name: :members, range: 0..)
507
+ ),
508
+ Node.new(
509
+ type: :kwoptarg,
510
+ fixed: Node.fixed(
511
+ [
512
+ [Node::Fixed::Attribute, :name],
513
+ [Node::Fixed::Descendant, :value]
514
+ ]
515
+ ),
516
+ variable: nil
517
+ ),
518
+ Node.new(
519
+ type: :kwrestarg,
520
+ fixed: Node.fixed([[Node::Fixed::Attribute, :name]]),
521
+ variable: nil
522
+ ),
523
+ Node.new(
524
+ type: :kwsplat,
525
+ fixed: Node.fixed([[Node::Fixed::Descendant, :value]]),
526
+ variable: nil
527
+ ),
528
+ Node.new(
529
+ type: :lambda,
530
+ fixed: EMPTY_ARRAY,
531
+ variable: nil
532
+ ),
533
+ Node.new(
534
+ type: :lvar,
535
+ fixed: Node.fixed([[Node::Fixed::Attribute, :value]]),
536
+ variable: nil
537
+ ),
538
+ Node.new(
539
+ type: :lvasgn,
540
+ fixed: Node.fixed(
541
+ [
542
+ [Node::Fixed::Attribute, :name],
543
+ [Node::Fixed::Descendant, :value]
544
+ ]
545
+ ),
546
+ variable: nil
547
+ ),
548
+ Node.new(
549
+ type: :match_current_line,
550
+ fixed: Node.fixed([[Node::Fixed::Descendant, :pattern]]),
551
+ variable: nil
552
+ ),
553
+ Node.new(
554
+ type: :match_pattern,
555
+ fixed: Node.fixed(
556
+ [
557
+ [Node::Fixed::Descendant, :target],
558
+ [Node::Fixed::Descendant, :pattern]
559
+ ]
560
+ ),
561
+ variable: nil
562
+ ),
563
+ Node.new(
564
+ type: :match_rest,
565
+ fixed: Node.fixed([[Node::Fixed::Descendant, :value]]),
566
+ variable: nil
567
+ ),
568
+ Node.new(
569
+ type: :match_var,
570
+ fixed: Node.fixed([[Node::Fixed::Attribute, :name]]),
571
+ variable: nil
572
+ ),
573
+ Node.new(
574
+ type: :match_with_lvasgn,
575
+ fixed: Node.fixed(
576
+ [
577
+ [Node::Fixed::Descendant, :pattern],
578
+ [Node::Fixed::Descendant, :target]
579
+ ]
580
+ ),
581
+ variable: nil
582
+ ),
583
+ Node.new(
584
+ type: :masgn,
585
+ fixed: Node.fixed(
586
+ [
587
+ [Node::Fixed::Descendant, :targets],
588
+ [Node::Fixed::Descendant, :values]
589
+ ]
590
+ ),
591
+ variable: nil
592
+ ),
593
+ Node.new(
594
+ type: :mlhs,
595
+ fixed: EMPTY_ARRAY,
596
+ variable: Node::Variable::Descendants.new(name: :members, range: 0..)
597
+ ),
598
+ Node.new(
599
+ type: :module,
600
+ fixed: Node.fixed(
601
+ [
602
+ [Node::Fixed::Descendant, :name],
603
+ [Node::Fixed::Descendant, :body]
604
+ ]
605
+ ),
606
+ variable: Node::Variable::Descendants.new(name: :members, range: 2..)
607
+ ),
608
+ Node.new(
609
+ type: :next,
610
+ fixed: EMPTY_ARRAY,
611
+ variable: Node::Variable::Descendants.new(name: :values, range: 0..)
612
+ ),
613
+ Node.new(
614
+ type: :nth_ref,
615
+ fixed: Node.fixed([[Node::Fixed::Attribute, :value]]),
616
+ variable: nil
617
+ ),
618
+ Node.new(
619
+ type: :numblock,
620
+ fixed: Node.fixed(
621
+ [
622
+ [Node::Fixed::Descendant, :receiver],
623
+ [Node::Fixed::Attribute, :parameters],
624
+ [Node::Fixed::Descendant, :body]
625
+ ]
626
+ ),
627
+ variable: nil
628
+ ),
629
+ Node.new(
630
+ type: :op_asgn,
631
+ fixed: Node.fixed(
632
+ [
633
+ [Node::Fixed::Descendant, :target],
634
+ [Node::Fixed::Attribute, :operator],
635
+ [Node::Fixed::Descendant, :value]
636
+ ]
637
+ ),
638
+ variable: nil
639
+ ),
640
+ Node.new(
641
+ type: :optarg,
642
+ fixed: Node.fixed(
643
+ [
644
+ [Node::Fixed::Attribute, :name],
645
+ [Node::Fixed::Descendant, :value]
646
+ ]
647
+ ),
648
+ variable: nil
649
+ ),
650
+ Node.new(
651
+ type: :or,
652
+ fixed: Node.fixed(
653
+ [
654
+ [Node::Fixed::Descendant, :left],
655
+ [Node::Fixed::Descendant, :right]
656
+ ]
657
+ ),
658
+ variable: nil
659
+ ),
660
+ Node.new(
661
+ type: :or_asgn,
662
+ fixed: Node.fixed(
663
+ [
664
+ [Node::Fixed::Descendant, :target],
665
+ [Node::Fixed::Descendant, :value]
666
+ ]
667
+ ),
668
+ variable: nil
669
+ ),
670
+ Node.new(
671
+ type: :rational,
672
+ fixed: Node.fixed([[Node::Fixed::Attribute, :name]]),
673
+ variable: nil
674
+ ),
675
+ Node.new(
676
+ type: :redo,
677
+ fixed: EMPTY_ARRAY,
678
+ variable: nil
679
+ ),
680
+ Node.new(
681
+ type: :regexp,
682
+ fixed: [
683
+ Node::Fixed::Descendant.new(index: -1, name: :options)
684
+ ],
685
+ variable: Node::Variable::Descendants.new(name: :members, range: 0..-2)
686
+ ),
687
+ Node.new(
688
+ type: :regopt,
689
+ fixed: EMPTY_ARRAY,
690
+ variable: Node::Variable::Attributes.new(name: :options, range: 0..)
691
+ ),
692
+ Node.new(
693
+ type: :rescue,
694
+ fixed: [
695
+ Node::Fixed::Descendant.new(index: 0, name: :body),
696
+ Node::Fixed::Descendant.new(index: 1, name: :resbody),
697
+ Node::Fixed::Descendant.new(index: -1, name: :else_body)
698
+ ],
699
+ variable: Node::Variable::Descendants.new(name: :resbodies, range: 2..-2)
700
+ ),
701
+ Node.new(
702
+ type: :resbody,
703
+ fixed: Node.fixed(
704
+ [
705
+ [Node::Fixed::Descendant, :captures],
706
+ [Node::Fixed::Descendant, :assignment],
707
+ [Node::Fixed::Descendant, :body]
708
+ ]
709
+ ),
710
+ variable: nil
711
+ ),
712
+ Node.new(
713
+ type: :restarg,
714
+ fixed: Node.fixed([[Node::Fixed::Attribute, :name]]),
715
+ variable: nil
716
+ ),
717
+ Node.new(
718
+ type: :retry,
719
+ fixed: EMPTY_ARRAY,
720
+ variable: nil
721
+ ),
722
+ Node.new(
723
+ type: :return,
724
+ fixed: EMPTY_ARRAY,
725
+ variable: Node::Variable::Descendants.new(name: :values, range: 0..)
726
+ ),
727
+ Node.new(
728
+ type: :self,
729
+ fixed: EMPTY_ARRAY,
730
+ variable: nil
731
+ ),
732
+ Node.new(
733
+ type: :send,
734
+ fixed: Node.fixed(
735
+ [
736
+ [Node::Fixed::Descendant, :receiver],
737
+ [Node::Fixed::Attribute, :selector]
738
+ ]
739
+ ),
740
+ variable: Node::Variable::Descendants.new(name: :arguments, range: 2..)
741
+ ),
742
+ Node.new(
743
+ type: :shadowarg,
744
+ fixed: Node.fixed([[Node::Fixed::Attribute, :name]]),
745
+ variable: nil
746
+ ),
747
+ Node.new(
748
+ type: :nil,
749
+ fixed: EMPTY_ARRAY,
750
+ variable: nil
751
+ ),
752
+ Node.new(
753
+ type: :preexe,
754
+ fixed: Node.fixed([[Node::Fixed::Descendant, :body]]),
755
+ variable: nil
756
+ ),
757
+ Node.new(
758
+ type: :pair,
759
+ fixed: Node.fixed(
760
+ [
761
+ [Node::Fixed::Descendant, :name],
762
+ [Node::Fixed::Descendant, :value]
763
+ ]
764
+ ),
765
+ variable: nil
766
+ ),
767
+ Node.new(
768
+ type: :postexe,
769
+ fixed: Node.fixed([[Node::Fixed::Descendant, :body]]),
770
+ variable: nil
771
+ ),
772
+ Node.new(
773
+ type: :procarg0,
774
+ fixed: EMPTY_ARRAY,
775
+ variable: Node::Variable::Descendants.new(name: :arguments, range: 0..)
776
+ ),
777
+ Node.new(
778
+ type: :sclass,
779
+ fixed: Node.fixed(
780
+ [
781
+ [Node::Fixed::Descendant, :singleton],
782
+ [Node::Fixed::Descendant, :body]
783
+ ]
784
+ ),
785
+ variable: nil
786
+ ),
787
+ Node.new(
788
+ type: :splat,
789
+ fixed: Node.fixed([[Node::Fixed::Descendant, :value]]),
790
+ variable: nil
791
+ ),
792
+ Node.new(
793
+ type: :str,
794
+ fixed: Node.fixed([[Node::Fixed::Attribute, :value]]),
795
+ variable: nil
796
+ ),
797
+ Node.new(
798
+ type: :super,
799
+ fixed: EMPTY_ARRAY,
800
+ variable: Node::Variable::Descendants.new(name: :arguments, range: 0..)
801
+ ),
802
+ Node.new(
803
+ type: :sym,
804
+ fixed: Node.fixed([[Node::Fixed::Attribute, :value]]),
805
+ variable: nil
806
+ ),
807
+ Node.new(
808
+ type: :true,
809
+ fixed: EMPTY_ARRAY,
810
+ variable: nil
811
+ ),
812
+ Node.new(
813
+ type: :undef,
814
+ fixed: EMPTY_ARRAY,
815
+ variable: Node::Variable::Descendants.new(name: :members, range: 0..)
816
+ ),
817
+ Node.new(
818
+ type: :until,
819
+ fixed: Node.fixed(
820
+ [
821
+ [Node::Fixed::Descendant, :condition],
822
+ [Node::Fixed::Descendant, :body]
823
+ ]
824
+ ),
825
+ variable: nil
826
+ ),
827
+ Node.new(
828
+ type: :until_post,
829
+ fixed: Node.fixed(
830
+ [
831
+ [Node::Fixed::Descendant, :condition],
832
+ [Node::Fixed::Descendant, :body]
833
+ ]
834
+ ),
835
+ variable: nil
836
+ ),
837
+ Node.new(
838
+ type: :when,
839
+ fixed: [Node::Fixed::Descendant.new(index: -1, name: :body)],
840
+ variable: Node::Variable::Descendants.new(name: :conditions, range: 0..-2)
841
+ ),
842
+ Node.new(
843
+ type: :while_post,
844
+ fixed: Node.fixed(
845
+ [
846
+ [Node::Fixed::Descendant, :condition],
847
+ [Node::Fixed::Descendant, :body]
848
+ ]
849
+ ),
850
+ variable: nil
851
+ ),
852
+ Node.new(
853
+ type: :while,
854
+ fixed: Node.fixed(
855
+ [
856
+ [Node::Fixed::Descendant, :condition],
857
+ [Node::Fixed::Descendant, :body]
858
+ ]
859
+ ),
860
+ variable: nil
861
+ ),
862
+ Node.new(
863
+ type: :xstr,
864
+ fixed: EMPTY_ARRAY,
865
+ variable: Node::Variable::Descendants.new(name: :members, range: 0..)
866
+ ),
867
+ Node.new(
868
+ type: :yield,
869
+ fixed: EMPTY_ARRAY,
870
+ variable: Node::Variable::Descendants.new(name: :values, range: 0..)
871
+ ),
872
+ Node.new(
873
+ type: :zsuper,
874
+ fixed: EMPTY_ARRAY,
875
+ variable: nil
876
+ )
877
+ ].to_h { |node| [node.type, node] }.freeze
878
+
879
+ # Lookup AST structure for a specific type
880
+ #
881
+ # @param [Symbol] type
882
+ #
883
+ # @return [Structure]
884
+ def self.for(type)
885
+ ALL.fetch(type)
886
+ end
887
+ end # Structure
888
+ # rubocop:enable Metrics/ModuleLength
889
+ end # AST
890
+ end # Mutant