prism 0.27.0 → 0.28.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -1
  3. data/config.yml +39 -27
  4. data/docs/configuration.md +1 -0
  5. data/ext/prism/api_node.c +814 -807
  6. data/ext/prism/extension.c +5 -3
  7. data/ext/prism/extension.h +1 -1
  8. data/include/prism/ast.h +38 -16
  9. data/include/prism/diagnostic.h +12 -5
  10. data/include/prism/options.h +2 -2
  11. data/include/prism/parser.h +10 -0
  12. data/include/prism/static_literals.h +8 -6
  13. data/include/prism/version.h +2 -2
  14. data/lib/prism/dot_visitor.rb +22 -6
  15. data/lib/prism/dsl.rb +8 -8
  16. data/lib/prism/ffi.rb +3 -3
  17. data/lib/prism/inspect_visitor.rb +2156 -0
  18. data/lib/prism/lex_compat.rb +1 -1
  19. data/lib/prism/mutation_compiler.rb +2 -2
  20. data/lib/prism/node.rb +589 -1715
  21. data/lib/prism/node_ext.rb +34 -5
  22. data/lib/prism/parse_result.rb +78 -0
  23. data/lib/prism/pattern.rb +12 -6
  24. data/lib/prism/polyfill/byteindex.rb +13 -0
  25. data/lib/prism/polyfill/unpack1.rb +14 -0
  26. data/lib/prism/reflection.rb +13 -13
  27. data/lib/prism/serialize.rb +21 -14
  28. data/lib/prism/translation/parser/compiler.rb +2 -2
  29. data/lib/prism/translation/parser.rb +6 -6
  30. data/lib/prism/translation/ripper.rb +13 -9
  31. data/lib/prism/translation/ruby_parser.rb +4 -4
  32. data/lib/prism.rb +2 -1
  33. data/prism.gemspec +36 -38
  34. data/rbi/prism/compiler.rbi +3 -5
  35. data/rbi/prism/inspect_visitor.rbi +12 -0
  36. data/rbi/prism/node.rbi +354 -319
  37. data/rbi/prism/parse_result.rbi +23 -0
  38. data/rbi/prism/translation/ripper.rbi +1 -11
  39. data/sig/prism/dsl.rbs +3 -3
  40. data/sig/prism/inspect_visitor.rbs +22 -0
  41. data/sig/prism/node.rbs +64 -47
  42. data/sig/prism/parse_result.rbs +12 -0
  43. data/src/diagnostic.c +38 -24
  44. data/src/node.c +41 -16
  45. data/src/options.c +2 -2
  46. data/src/prettyprint.c +61 -18
  47. data/src/prism.c +607 -185
  48. data/src/serialize.c +5 -2
  49. data/src/static_literals.c +120 -34
  50. data/src/token_type.c +4 -4
  51. metadata +7 -9
  52. data/lib/prism/node_inspector.rb +0 -68
  53. data/lib/prism/polyfill/string.rb +0 -12
  54. data/rbi/prism/desugar_compiler.rbi +0 -5
  55. data/rbi/prism/mutation_compiler.rbi +0 -5
  56. data/rbi/prism/translation/parser/compiler.rbi +0 -13
  57. data/rbi/prism/translation/ripper/ripper_compiler.rbi +0 -5
  58. data/rbi/prism/translation/ruby_parser.rbi +0 -11
data/lib/prism/node.rb CHANGED
@@ -48,11 +48,27 @@ module Prism
48
48
  end
49
49
  end
50
50
 
51
+ # Returns all of the lines of the source code associated with this node.
52
+ def source_lines
53
+ location.source_lines
54
+ end
55
+
56
+ # An alias for source_lines, used to mimic the API from
57
+ # RubyVM::AbstractSyntaxTree to make it easier to migrate.
58
+ alias script_lines source_lines
59
+
51
60
  # Slice the location of the node from the source.
52
61
  def slice
53
62
  location.slice
54
63
  end
55
64
 
65
+ # Slice the location of the node from the source, starting at the beginning
66
+ # of the line that the location starts on, ending at the end of the line
67
+ # that the location ends on.
68
+ def slice_lines
69
+ location.slice_lines
70
+ end
71
+
56
72
  # Similar to inspect, but respects the current level of indentation given by
57
73
  # the pretty print object.
58
74
  def pretty_print(q)
@@ -68,6 +84,43 @@ module Prism
68
84
  DotVisitor.new.tap { |visitor| accept(visitor) }.to_dot
69
85
  end
70
86
 
87
+ # Returns a list of nodes that are descendants of this node that contain the
88
+ # given line and column. This is useful for locating a node that is selected
89
+ # based on the line and column of the source code.
90
+ #
91
+ # Important to note is that the column given to this method should be in
92
+ # bytes, as opposed to characters or code units.
93
+ def tunnel(line, column)
94
+ queue = [self] #: Array[Prism::node]
95
+ result = []
96
+
97
+ while (node = queue.shift)
98
+ result << node
99
+
100
+ node.compact_child_nodes.each do |child_node|
101
+ child_location = child_node.location
102
+
103
+ start_line = child_location.start_line
104
+ end_line = child_location.end_line
105
+
106
+ if start_line == end_line
107
+ if line == start_line && column >= child_location.start_column && column < child_location.end_column
108
+ queue << child_node
109
+ break
110
+ end
111
+ elsif (line == start_line && column >= child_location.start_column) || (line == end_line && column < child_location.end_column)
112
+ queue << child_node
113
+ break
114
+ elsif line > start_line && line < end_line
115
+ queue << child_node
116
+ break
117
+ end
118
+ end
119
+ end
120
+
121
+ result
122
+ end
123
+
71
124
  # Returns a list of the fields that exist for this node class. Fields
72
125
  # describe the structure of the node. This kind of reflection is useful for
73
126
  # things like recursively visiting each node _and_ field in the tree.
@@ -118,7 +171,7 @@ module Prism
118
171
  end
119
172
 
120
173
  # Returns a string representation of the node.
121
- def inspect(inspector = NodeInspector.new)
174
+ def inspect
122
175
  raise NoMethodError, "undefined method `inspect' for #{inspect}"
123
176
  end
124
177
 
@@ -203,15 +256,9 @@ module Prism
203
256
  keyword_loc.slice
204
257
  end
205
258
 
206
- # def inspect(NodeInspector inspector) -> String
207
- def inspect(inspector = NodeInspector.new)
208
- inspector << inspector.header(self)
209
- inspector << "├── new_name:\n"
210
- inspector << inspector.child_node(new_name, "│ ")
211
- inspector << "├── old_name:\n"
212
- inspector << inspector.child_node(old_name, "│ ")
213
- inspector << "└── keyword_loc: #{inspector.location(keyword_loc)}\n"
214
- inspector.to_str
259
+ # def inspect -> String
260
+ def inspect
261
+ InspectVisitor.compose(self)
215
262
  end
216
263
 
217
264
  # Sometimes you want to check an instance of a node against a list of
@@ -318,15 +365,9 @@ module Prism
318
365
  keyword_loc.slice
319
366
  end
320
367
 
321
- # def inspect(NodeInspector inspector) -> String
322
- def inspect(inspector = NodeInspector.new)
323
- inspector << inspector.header(self)
324
- inspector << "├── new_name:\n"
325
- inspector << inspector.child_node(new_name, "│ ")
326
- inspector << "├── old_name:\n"
327
- inspector << inspector.child_node(old_name, "│ ")
328
- inspector << "└── keyword_loc: #{inspector.location(keyword_loc)}\n"
329
- inspector.to_str
368
+ # def inspect -> String
369
+ def inspect
370
+ InspectVisitor.compose(self)
330
371
  end
331
372
 
332
373
  # Sometimes you want to check an instance of a node against a list of
@@ -433,15 +474,9 @@ module Prism
433
474
  operator_loc.slice
434
475
  end
435
476
 
436
- # def inspect(NodeInspector inspector) -> String
437
- def inspect(inspector = NodeInspector.new)
438
- inspector << inspector.header(self)
439
- inspector << "├── left:\n"
440
- inspector << inspector.child_node(left, "│ ")
441
- inspector << "├── right:\n"
442
- inspector << inspector.child_node(right, "│ ")
443
- inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
444
- inspector.to_str
477
+ # def inspect -> String
478
+ def inspect
479
+ InspectVisitor.compose(self)
445
480
  end
446
481
 
447
482
  # Sometimes you want to check an instance of a node against a list of
@@ -563,15 +598,9 @@ module Prism
563
598
  operator_loc.slice
564
599
  end
565
600
 
566
- # def inspect(NodeInspector inspector) -> String
567
- def inspect(inspector = NodeInspector.new)
568
- inspector << inspector.header(self)
569
- inspector << "├── left:\n"
570
- inspector << inspector.child_node(left, "│ ")
571
- inspector << "├── right:\n"
572
- inspector << inspector.child_node(right, "│ ")
573
- inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
574
- inspector.to_str
601
+ # def inspect -> String
602
+ def inspect
603
+ InspectVisitor.compose(self)
575
604
  end
576
605
 
577
606
  # Sometimes you want to check an instance of a node against a list of
@@ -666,18 +695,19 @@ module Prism
666
695
  # attr_reader arguments: Array[Prism::node]
667
696
  attr_reader :arguments
668
697
 
698
+ # def contains_keywords?: () -> bool
699
+ def contains_keywords?
700
+ flags.anybits?(ArgumentsNodeFlags::CONTAINS_KEYWORDS)
701
+ end
702
+
669
703
  # def contains_keyword_splat?: () -> bool
670
704
  def contains_keyword_splat?
671
705
  flags.anybits?(ArgumentsNodeFlags::CONTAINS_KEYWORD_SPLAT)
672
706
  end
673
707
 
674
- # def inspect(NodeInspector inspector) -> String
675
- def inspect(inspector = NodeInspector.new)
676
- inspector << inspector.header(self)
677
- flags = [("contains_keyword_splat" if contains_keyword_splat?)].compact
678
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
679
- inspector << "└── arguments: #{inspector.list("#{inspector.prefix} ", arguments)}"
680
- inspector.to_str
708
+ # def inspect -> String
709
+ def inspect
710
+ InspectVisitor.compose(self)
681
711
  end
682
712
 
683
713
  # Sometimes you want to check an instance of a node against a list of
@@ -825,15 +855,9 @@ module Prism
825
855
  closing_loc&.slice
826
856
  end
827
857
 
828
- # def inspect(NodeInspector inspector) -> String
829
- def inspect(inspector = NodeInspector.new)
830
- inspector << inspector.header(self)
831
- flags = [("contains_splat" if contains_splat?)].compact
832
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
833
- inspector << "├── elements: #{inspector.list("#{inspector.prefix}│ ", elements)}"
834
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
835
- inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n"
836
- inspector.to_str
858
+ # def inspect -> String
859
+ def inspect
860
+ InspectVisitor.compose(self)
837
861
  end
838
862
 
839
863
  # Sometimes you want to check an instance of a node against a list of
@@ -992,26 +1016,9 @@ module Prism
992
1016
  closing_loc&.slice
993
1017
  end
994
1018
 
995
- # def inspect(NodeInspector inspector) -> String
996
- def inspect(inspector = NodeInspector.new)
997
- inspector << inspector.header(self)
998
- if (constant = self.constant).nil?
999
- inspector << "├── constant: ∅\n"
1000
- else
1001
- inspector << "├── constant:\n"
1002
- inspector << constant.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
1003
- end
1004
- inspector << "├── requireds: #{inspector.list("#{inspector.prefix}│ ", requireds)}"
1005
- if (rest = self.rest).nil?
1006
- inspector << "├── rest: ∅\n"
1007
- else
1008
- inspector << "├── rest:\n"
1009
- inspector << rest.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
1010
- end
1011
- inspector << "├── posts: #{inspector.list("#{inspector.prefix}│ ", posts)}"
1012
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
1013
- inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n"
1014
- inspector.to_str
1019
+ # def inspect -> String
1020
+ def inspect
1021
+ InspectVisitor.compose(self)
1015
1022
  end
1016
1023
 
1017
1024
  # Sometimes you want to check an instance of a node against a list of
@@ -1147,15 +1154,9 @@ module Prism
1147
1154
  operator_loc&.slice
1148
1155
  end
1149
1156
 
1150
- # def inspect(NodeInspector inspector) -> String
1151
- def inspect(inspector = NodeInspector.new)
1152
- inspector << inspector.header(self)
1153
- inspector << "├── key:\n"
1154
- inspector << inspector.child_node(key, "│ ")
1155
- inspector << "├── value:\n"
1156
- inspector << inspector.child_node(value, "│ ")
1157
- inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
1158
- inspector.to_str
1157
+ # def inspect -> String
1158
+ def inspect
1159
+ InspectVisitor.compose(self)
1159
1160
  end
1160
1161
 
1161
1162
  # Sometimes you want to check an instance of a node against a list of
@@ -1266,17 +1267,9 @@ module Prism
1266
1267
  operator_loc.slice
1267
1268
  end
1268
1269
 
1269
- # def inspect(NodeInspector inspector) -> String
1270
- def inspect(inspector = NodeInspector.new)
1271
- inspector << inspector.header(self)
1272
- if (value = self.value).nil?
1273
- inspector << "├── value: ∅\n"
1274
- else
1275
- inspector << "├── value:\n"
1276
- inspector << value.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
1277
- end
1278
- inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
1279
- inspector.to_str
1270
+ # def inspect -> String
1271
+ def inspect
1272
+ InspectVisitor.compose(self)
1280
1273
  end
1281
1274
 
1282
1275
  # Sometimes you want to check an instance of a node against a list of
@@ -1369,11 +1362,9 @@ module Prism
1369
1362
  # $+ # name `:$+`
1370
1363
  attr_reader :name
1371
1364
 
1372
- # def inspect(NodeInspector inspector) -> String
1373
- def inspect(inspector = NodeInspector.new)
1374
- inspector << inspector.header(self)
1375
- inspector << "└── name: #{name.inspect}\n"
1376
- inspector.to_str
1365
+ # def inspect -> String
1366
+ def inspect
1367
+ InspectVisitor.compose(self)
1377
1368
  end
1378
1369
 
1379
1370
  # Sometimes you want to check an instance of a node against a list of
@@ -1522,36 +1513,9 @@ module Prism
1522
1513
  end_keyword_loc&.slice
1523
1514
  end
1524
1515
 
1525
- # def inspect(NodeInspector inspector) -> String
1526
- def inspect(inspector = NodeInspector.new)
1527
- inspector << inspector.header(self)
1528
- inspector << "├── begin_keyword_loc: #{inspector.location(begin_keyword_loc)}\n"
1529
- if (statements = self.statements).nil?
1530
- inspector << "├── statements: ∅\n"
1531
- else
1532
- inspector << "├── statements:\n"
1533
- inspector << statements.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
1534
- end
1535
- if (rescue_clause = self.rescue_clause).nil?
1536
- inspector << "├── rescue_clause: ∅\n"
1537
- else
1538
- inspector << "├── rescue_clause:\n"
1539
- inspector << rescue_clause.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
1540
- end
1541
- if (else_clause = self.else_clause).nil?
1542
- inspector << "├── else_clause: ∅\n"
1543
- else
1544
- inspector << "├── else_clause:\n"
1545
- inspector << else_clause.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
1546
- end
1547
- if (ensure_clause = self.ensure_clause).nil?
1548
- inspector << "├── ensure_clause: ∅\n"
1549
- else
1550
- inspector << "├── ensure_clause:\n"
1551
- inspector << ensure_clause.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
1552
- end
1553
- inspector << "└── end_keyword_loc: #{inspector.location(end_keyword_loc)}\n"
1554
- inspector.to_str
1516
+ # def inspect -> String
1517
+ def inspect
1518
+ InspectVisitor.compose(self)
1555
1519
  end
1556
1520
 
1557
1521
  # Sometimes you want to check an instance of a node against a list of
@@ -1659,17 +1623,9 @@ module Prism
1659
1623
  operator_loc.slice
1660
1624
  end
1661
1625
 
1662
- # def inspect(NodeInspector inspector) -> String
1663
- def inspect(inspector = NodeInspector.new)
1664
- inspector << inspector.header(self)
1665
- if (expression = self.expression).nil?
1666
- inspector << "├── expression: ∅\n"
1667
- else
1668
- inspector << "├── expression:\n"
1669
- inspector << expression.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
1670
- end
1671
- inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
1672
- inspector.to_str
1626
+ # def inspect -> String
1627
+ def inspect
1628
+ InspectVisitor.compose(self)
1673
1629
  end
1674
1630
 
1675
1631
  # Sometimes you want to check an instance of a node against a list of
@@ -1768,13 +1724,9 @@ module Prism
1768
1724
  flags.anybits?(ParameterFlags::REPEATED_PARAMETER)
1769
1725
  end
1770
1726
 
1771
- # def inspect(NodeInspector inspector) -> String
1772
- def inspect(inspector = NodeInspector.new)
1773
- inspector << inspector.header(self)
1774
- flags = [("repeated_parameter" if repeated_parameter?)].compact
1775
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
1776
- inspector << "└── name: #{name.inspect}\n"
1777
- inspector.to_str
1727
+ # def inspect -> String
1728
+ def inspect
1729
+ InspectVisitor.compose(self)
1778
1730
  end
1779
1731
 
1780
1732
  # Sometimes you want to check an instance of a node against a list of
@@ -1900,25 +1852,9 @@ module Prism
1900
1852
  closing_loc.slice
1901
1853
  end
1902
1854
 
1903
- # def inspect(NodeInspector inspector) -> String
1904
- def inspect(inspector = NodeInspector.new)
1905
- inspector << inspector.header(self)
1906
- inspector << "├── locals: #{locals.inspect}\n"
1907
- if (parameters = self.parameters).nil?
1908
- inspector << "├── parameters: ∅\n"
1909
- else
1910
- inspector << "├── parameters:\n"
1911
- inspector << parameters.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
1912
- end
1913
- if (body = self.body).nil?
1914
- inspector << "├── body: ∅\n"
1915
- else
1916
- inspector << "├── body:\n"
1917
- inspector << body.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
1918
- end
1919
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
1920
- inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n"
1921
- inspector.to_str
1855
+ # def inspect -> String
1856
+ def inspect
1857
+ InspectVisitor.compose(self)
1922
1858
  end
1923
1859
 
1924
1860
  # Sometimes you want to check an instance of a node against a list of
@@ -2049,19 +1985,9 @@ module Prism
2049
1985
  operator_loc.slice
2050
1986
  end
2051
1987
 
2052
- # def inspect(NodeInspector inspector) -> String
2053
- def inspect(inspector = NodeInspector.new)
2054
- inspector << inspector.header(self)
2055
- flags = [("repeated_parameter" if repeated_parameter?)].compact
2056
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
2057
- if (name = self.name).nil?
2058
- inspector << "├── name: ∅\n"
2059
- else
2060
- inspector << "├── name: #{name.inspect}\n"
2061
- end
2062
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
2063
- inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
2064
- inspector.to_str
1988
+ # def inspect -> String
1989
+ def inspect
1990
+ InspectVisitor.compose(self)
2065
1991
  end
2066
1992
 
2067
1993
  # Sometimes you want to check an instance of a node against a list of
@@ -2201,19 +2127,9 @@ module Prism
2201
2127
  closing_loc&.slice
2202
2128
  end
2203
2129
 
2204
- # def inspect(NodeInspector inspector) -> String
2205
- def inspect(inspector = NodeInspector.new)
2206
- inspector << inspector.header(self)
2207
- if (parameters = self.parameters).nil?
2208
- inspector << "├── parameters: ∅\n"
2209
- else
2210
- inspector << "├── parameters:\n"
2211
- inspector << parameters.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
2212
- end
2213
- inspector << "├── locals: #{inspector.list("#{inspector.prefix}│ ", locals)}"
2214
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
2215
- inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n"
2216
- inspector.to_str
2130
+ # def inspect -> String
2131
+ def inspect
2132
+ InspectVisitor.compose(self)
2217
2133
  end
2218
2134
 
2219
2135
  # Sometimes you want to check an instance of a node against a list of
@@ -2326,17 +2242,9 @@ module Prism
2326
2242
  keyword_loc.slice
2327
2243
  end
2328
2244
 
2329
- # def inspect(NodeInspector inspector) -> String
2330
- def inspect(inspector = NodeInspector.new)
2331
- inspector << inspector.header(self)
2332
- if (arguments = self.arguments).nil?
2333
- inspector << "├── arguments: ∅\n"
2334
- else
2335
- inspector << "├── arguments:\n"
2336
- inspector << arguments.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
2337
- end
2338
- inspector << "└── keyword_loc: #{inspector.location(keyword_loc)}\n"
2339
- inspector.to_str
2245
+ # def inspect -> String
2246
+ def inspect
2247
+ InspectVisitor.compose(self)
2340
2248
  end
2341
2249
 
2342
2250
  # Sometimes you want to check an instance of a node against a list of
@@ -2516,25 +2424,9 @@ module Prism
2516
2424
  operator_loc.slice
2517
2425
  end
2518
2426
 
2519
- # def inspect(NodeInspector inspector) -> String
2520
- def inspect(inspector = NodeInspector.new)
2521
- inspector << inspector.header(self)
2522
- flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?), ("attribute_write" if attribute_write?), ("ignore_visibility" if ignore_visibility?)].compact
2523
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
2524
- if (receiver = self.receiver).nil?
2525
- inspector << "├── receiver: ∅\n"
2526
- else
2527
- inspector << "├── receiver:\n"
2528
- inspector << receiver.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
2529
- end
2530
- inspector << "├── call_operator_loc: #{inspector.location(call_operator_loc)}\n"
2531
- inspector << "├── message_loc: #{inspector.location(message_loc)}\n"
2532
- inspector << "├── read_name: #{read_name.inspect}\n"
2533
- inspector << "├── write_name: #{write_name.inspect}\n"
2534
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
2535
- inspector << "└── value:\n"
2536
- inspector << inspector.child_node(value, " ")
2537
- inspector.to_str
2427
+ # def inspect -> String
2428
+ def inspect
2429
+ InspectVisitor.compose(self)
2538
2430
  end
2539
2431
 
2540
2432
  # Sometimes you want to check an instance of a node against a list of
@@ -2770,35 +2662,9 @@ module Prism
2770
2662
  closing_loc&.slice
2771
2663
  end
2772
2664
 
2773
- # def inspect(NodeInspector inspector) -> String
2774
- def inspect(inspector = NodeInspector.new)
2775
- inspector << inspector.header(self)
2776
- flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?), ("attribute_write" if attribute_write?), ("ignore_visibility" if ignore_visibility?)].compact
2777
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
2778
- if (receiver = self.receiver).nil?
2779
- inspector << "├── receiver: ∅\n"
2780
- else
2781
- inspector << "├── receiver:\n"
2782
- inspector << receiver.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
2783
- end
2784
- inspector << "├── call_operator_loc: #{inspector.location(call_operator_loc)}\n"
2785
- inspector << "├── name: #{name.inspect}\n"
2786
- inspector << "├── message_loc: #{inspector.location(message_loc)}\n"
2787
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
2788
- if (arguments = self.arguments).nil?
2789
- inspector << "├── arguments: ∅\n"
2790
- else
2791
- inspector << "├── arguments:\n"
2792
- inspector << arguments.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
2793
- end
2794
- inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
2795
- if (block = self.block).nil?
2796
- inspector << "└── block: ∅\n"
2797
- else
2798
- inspector << "└── block:\n"
2799
- inspector << block.inspect(inspector.child_inspector(" ")).delete_prefix(inspector.prefix)
2800
- end
2801
- inspector.to_str
2665
+ # def inspect -> String
2666
+ def inspect
2667
+ InspectVisitor.compose(self)
2802
2668
  end
2803
2669
 
2804
2670
  # Sometimes you want to check an instance of a node against a list of
@@ -2984,26 +2850,9 @@ module Prism
2984
2850
  message_loc&.slice
2985
2851
  end
2986
2852
 
2987
- # def inspect(NodeInspector inspector) -> String
2988
- def inspect(inspector = NodeInspector.new)
2989
- inspector << inspector.header(self)
2990
- flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?), ("attribute_write" if attribute_write?), ("ignore_visibility" if ignore_visibility?)].compact
2991
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
2992
- if (receiver = self.receiver).nil?
2993
- inspector << "├── receiver: ∅\n"
2994
- else
2995
- inspector << "├── receiver:\n"
2996
- inspector << receiver.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
2997
- end
2998
- inspector << "├── call_operator_loc: #{inspector.location(call_operator_loc)}\n"
2999
- inspector << "├── message_loc: #{inspector.location(message_loc)}\n"
3000
- inspector << "├── read_name: #{read_name.inspect}\n"
3001
- inspector << "├── write_name: #{write_name.inspect}\n"
3002
- inspector << "├── operator: #{operator.inspect}\n"
3003
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
3004
- inspector << "└── value:\n"
3005
- inspector << inspector.child_node(value, " ")
3006
- inspector.to_str
2853
+ # def inspect -> String
2854
+ def inspect
2855
+ InspectVisitor.compose(self)
3007
2856
  end
3008
2857
 
3009
2858
  # Sometimes you want to check an instance of a node against a list of
@@ -3190,25 +3039,9 @@ module Prism
3190
3039
  operator_loc.slice
3191
3040
  end
3192
3041
 
3193
- # def inspect(NodeInspector inspector) -> String
3194
- def inspect(inspector = NodeInspector.new)
3195
- inspector << inspector.header(self)
3196
- flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?), ("attribute_write" if attribute_write?), ("ignore_visibility" if ignore_visibility?)].compact
3197
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
3198
- if (receiver = self.receiver).nil?
3199
- inspector << "├── receiver: ∅\n"
3200
- else
3201
- inspector << "├── receiver:\n"
3202
- inspector << receiver.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
3203
- end
3204
- inspector << "├── call_operator_loc: #{inspector.location(call_operator_loc)}\n"
3205
- inspector << "├── message_loc: #{inspector.location(message_loc)}\n"
3206
- inspector << "├── read_name: #{read_name.inspect}\n"
3207
- inspector << "├── write_name: #{write_name.inspect}\n"
3208
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
3209
- inspector << "└── value:\n"
3210
- inspector << inspector.child_node(value, " ")
3211
- inspector.to_str
3042
+ # def inspect -> String
3043
+ def inspect
3044
+ InspectVisitor.compose(self)
3212
3045
  end
3213
3046
 
3214
3047
  # Sometimes you want to check an instance of a node against a list of
@@ -3366,17 +3199,9 @@ module Prism
3366
3199
  message_loc.slice
3367
3200
  end
3368
3201
 
3369
- # def inspect(NodeInspector inspector) -> String
3370
- def inspect(inspector = NodeInspector.new)
3371
- inspector << inspector.header(self)
3372
- flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?), ("attribute_write" if attribute_write?), ("ignore_visibility" if ignore_visibility?)].compact
3373
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
3374
- inspector << "├── receiver:\n"
3375
- inspector << inspector.child_node(receiver, "│ ")
3376
- inspector << "├── call_operator_loc: #{inspector.location(call_operator_loc)}\n"
3377
- inspector << "├── name: #{name.inspect}\n"
3378
- inspector << "└── message_loc: #{inspector.location(message_loc)}\n"
3379
- inspector.to_str
3202
+ # def inspect -> String
3203
+ def inspect
3204
+ InspectVisitor.compose(self)
3380
3205
  end
3381
3206
 
3382
3207
  # Sometimes you want to check an instance of a node against a list of
@@ -3485,15 +3310,9 @@ module Prism
3485
3310
  operator_loc.slice
3486
3311
  end
3487
3312
 
3488
- # def inspect(NodeInspector inspector) -> String
3489
- def inspect(inspector = NodeInspector.new)
3490
- inspector << inspector.header(self)
3491
- inspector << "├── value:\n"
3492
- inspector << inspector.child_node(value, "│ ")
3493
- inspector << "├── target:\n"
3494
- inspector << inspector.child_node(target, "│ ")
3495
- inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
3496
- inspector.to_str
3313
+ # def inspect -> String
3314
+ def inspect
3315
+ InspectVisitor.compose(self)
3497
3316
  end
3498
3317
 
3499
3318
  # Sometimes you want to check an instance of a node against a list of
@@ -3623,25 +3442,9 @@ module Prism
3623
3442
  end_keyword_loc.slice
3624
3443
  end
3625
3444
 
3626
- # def inspect(NodeInspector inspector) -> String
3627
- def inspect(inspector = NodeInspector.new)
3628
- inspector << inspector.header(self)
3629
- if (predicate = self.predicate).nil?
3630
- inspector << "├── predicate: ∅\n"
3631
- else
3632
- inspector << "├── predicate:\n"
3633
- inspector << predicate.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
3634
- end
3635
- inspector << "├── conditions: #{inspector.list("#{inspector.prefix}│ ", conditions)}"
3636
- if (consequent = self.consequent).nil?
3637
- inspector << "├── consequent: ∅\n"
3638
- else
3639
- inspector << "├── consequent:\n"
3640
- inspector << consequent.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
3641
- end
3642
- inspector << "├── case_keyword_loc: #{inspector.location(case_keyword_loc)}\n"
3643
- inspector << "└── end_keyword_loc: #{inspector.location(end_keyword_loc)}\n"
3644
- inspector.to_str
3445
+ # def inspect -> String
3446
+ def inspect
3447
+ InspectVisitor.compose(self)
3645
3448
  end
3646
3449
 
3647
3450
  # Sometimes you want to check an instance of a node against a list of
@@ -3774,25 +3577,9 @@ module Prism
3774
3577
  end_keyword_loc.slice
3775
3578
  end
3776
3579
 
3777
- # def inspect(NodeInspector inspector) -> String
3778
- def inspect(inspector = NodeInspector.new)
3779
- inspector << inspector.header(self)
3780
- if (predicate = self.predicate).nil?
3781
- inspector << "├── predicate: ∅\n"
3782
- else
3783
- inspector << "├── predicate:\n"
3784
- inspector << predicate.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
3785
- end
3786
- inspector << "├── conditions: #{inspector.list("#{inspector.prefix}│ ", conditions)}"
3787
- if (consequent = self.consequent).nil?
3788
- inspector << "├── consequent: ∅\n"
3789
- else
3790
- inspector << "├── consequent:\n"
3791
- inspector << consequent.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
3792
- end
3793
- inspector << "├── case_keyword_loc: #{inspector.location(case_keyword_loc)}\n"
3794
- inspector << "└── end_keyword_loc: #{inspector.location(end_keyword_loc)}\n"
3795
- inspector.to_str
3580
+ # def inspect -> String
3581
+ def inspect
3582
+ InspectVisitor.compose(self)
3796
3583
  end
3797
3584
 
3798
3585
  # Sometimes you want to check an instance of a node against a list of
@@ -3950,29 +3737,9 @@ module Prism
3950
3737
  end_keyword_loc.slice
3951
3738
  end
3952
3739
 
3953
- # def inspect(NodeInspector inspector) -> String
3954
- def inspect(inspector = NodeInspector.new)
3955
- inspector << inspector.header(self)
3956
- inspector << "├── locals: #{locals.inspect}\n"
3957
- inspector << "├── class_keyword_loc: #{inspector.location(class_keyword_loc)}\n"
3958
- inspector << "├── constant_path:\n"
3959
- inspector << inspector.child_node(constant_path, "│ ")
3960
- inspector << "├── inheritance_operator_loc: #{inspector.location(inheritance_operator_loc)}\n"
3961
- if (superclass = self.superclass).nil?
3962
- inspector << "├── superclass: ∅\n"
3963
- else
3964
- inspector << "├── superclass:\n"
3965
- inspector << superclass.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
3966
- end
3967
- if (body = self.body).nil?
3968
- inspector << "├── body: ∅\n"
3969
- else
3970
- inspector << "├── body:\n"
3971
- inspector << body.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
3972
- end
3973
- inspector << "├── end_keyword_loc: #{inspector.location(end_keyword_loc)}\n"
3974
- inspector << "└── name: #{name.inspect}\n"
3975
- inspector.to_str
3740
+ # def inspect -> String
3741
+ def inspect
3742
+ InspectVisitor.compose(self)
3976
3743
  end
3977
3744
 
3978
3745
  # Sometimes you want to check an instance of a node against a list of
@@ -4093,15 +3860,9 @@ module Prism
4093
3860
  operator_loc.slice
4094
3861
  end
4095
3862
 
4096
- # def inspect(NodeInspector inspector) -> String
4097
- def inspect(inspector = NodeInspector.new)
4098
- inspector << inspector.header(self)
4099
- inspector << "├── name: #{name.inspect}\n"
4100
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
4101
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
4102
- inspector << "└── value:\n"
4103
- inspector << inspector.child_node(value, " ")
4104
- inspector.to_str
3863
+ # def inspect -> String
3864
+ def inspect
3865
+ InspectVisitor.compose(self)
4105
3866
  end
4106
3867
 
4107
3868
  # Sometimes you want to check an instance of a node against a list of
@@ -4216,16 +3977,9 @@ module Prism
4216
3977
  # attr_reader operator: Symbol
4217
3978
  attr_reader :operator
4218
3979
 
4219
- # def inspect(NodeInspector inspector) -> String
4220
- def inspect(inspector = NodeInspector.new)
4221
- inspector << inspector.header(self)
4222
- inspector << "├── name: #{name.inspect}\n"
4223
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
4224
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
4225
- inspector << "├── value:\n"
4226
- inspector << inspector.child_node(value, "│ ")
4227
- inspector << "└── operator: #{operator.inspect}\n"
4228
- inspector.to_str
3980
+ # def inspect -> String
3981
+ def inspect
3982
+ InspectVisitor.compose(self)
4229
3983
  end
4230
3984
 
4231
3985
  # Sometimes you want to check an instance of a node against a list of
@@ -4342,15 +4096,9 @@ module Prism
4342
4096
  operator_loc.slice
4343
4097
  end
4344
4098
 
4345
- # def inspect(NodeInspector inspector) -> String
4346
- def inspect(inspector = NodeInspector.new)
4347
- inspector << inspector.header(self)
4348
- inspector << "├── name: #{name.inspect}\n"
4349
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
4350
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
4351
- inspector << "└── value:\n"
4352
- inspector << inspector.child_node(value, " ")
4353
- inspector.to_str
4099
+ # def inspect -> String
4100
+ def inspect
4101
+ InspectVisitor.compose(self)
4354
4102
  end
4355
4103
 
4356
4104
  # Sometimes you want to check an instance of a node against a list of
@@ -4445,11 +4193,9 @@ module Prism
4445
4193
  # @@_test # name `:@@_test`
4446
4194
  attr_reader :name
4447
4195
 
4448
- # def inspect(NodeInspector inspector) -> String
4449
- def inspect(inspector = NodeInspector.new)
4450
- inspector << inspector.header(self)
4451
- inspector << "└── name: #{name.inspect}\n"
4452
- inspector.to_str
4196
+ # def inspect -> String
4197
+ def inspect
4198
+ InspectVisitor.compose(self)
4453
4199
  end
4454
4200
 
4455
4201
  # Sometimes you want to check an instance of a node against a list of
@@ -4537,11 +4283,9 @@ module Prism
4537
4283
  # attr_reader name: Symbol
4538
4284
  attr_reader :name
4539
4285
 
4540
- # def inspect(NodeInspector inspector) -> String
4541
- def inspect(inspector = NodeInspector.new)
4542
- inspector << inspector.header(self)
4543
- inspector << "└── name: #{name.inspect}\n"
4544
- inspector.to_str
4286
+ # def inspect -> String
4287
+ def inspect
4288
+ InspectVisitor.compose(self)
4545
4289
  end
4546
4290
 
4547
4291
  # Sometimes you want to check an instance of a node against a list of
@@ -4670,15 +4414,9 @@ module Prism
4670
4414
  operator_loc.slice
4671
4415
  end
4672
4416
 
4673
- # def inspect(NodeInspector inspector) -> String
4674
- def inspect(inspector = NodeInspector.new)
4675
- inspector << inspector.header(self)
4676
- inspector << "├── name: #{name.inspect}\n"
4677
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
4678
- inspector << "├── value:\n"
4679
- inspector << inspector.child_node(value, "│ ")
4680
- inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
4681
- inspector.to_str
4417
+ # def inspect -> String
4418
+ def inspect
4419
+ InspectVisitor.compose(self)
4682
4420
  end
4683
4421
 
4684
4422
  # Sometimes you want to check an instance of a node against a list of
@@ -4794,15 +4532,9 @@ module Prism
4794
4532
  operator_loc.slice
4795
4533
  end
4796
4534
 
4797
- # def inspect(NodeInspector inspector) -> String
4798
- def inspect(inspector = NodeInspector.new)
4799
- inspector << inspector.header(self)
4800
- inspector << "├── name: #{name.inspect}\n"
4801
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
4802
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
4803
- inspector << "└── value:\n"
4804
- inspector << inspector.child_node(value, " ")
4805
- inspector.to_str
4535
+ # def inspect -> String
4536
+ def inspect
4537
+ InspectVisitor.compose(self)
4806
4538
  end
4807
4539
 
4808
4540
  # Sometimes you want to check an instance of a node against a list of
@@ -4917,16 +4649,9 @@ module Prism
4917
4649
  # attr_reader operator: Symbol
4918
4650
  attr_reader :operator
4919
4651
 
4920
- # def inspect(NodeInspector inspector) -> String
4921
- def inspect(inspector = NodeInspector.new)
4922
- inspector << inspector.header(self)
4923
- inspector << "├── name: #{name.inspect}\n"
4924
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
4925
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
4926
- inspector << "├── value:\n"
4927
- inspector << inspector.child_node(value, "│ ")
4928
- inspector << "└── operator: #{operator.inspect}\n"
4929
- inspector.to_str
4652
+ # def inspect -> String
4653
+ def inspect
4654
+ InspectVisitor.compose(self)
4930
4655
  end
4931
4656
 
4932
4657
  # Sometimes you want to check an instance of a node against a list of
@@ -5043,15 +4768,9 @@ module Prism
5043
4768
  operator_loc.slice
5044
4769
  end
5045
4770
 
5046
- # def inspect(NodeInspector inspector) -> String
5047
- def inspect(inspector = NodeInspector.new)
5048
- inspector << inspector.header(self)
5049
- inspector << "├── name: #{name.inspect}\n"
5050
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
5051
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
5052
- inspector << "└── value:\n"
5053
- inspector << inspector.child_node(value, " ")
5054
- inspector.to_str
4771
+ # def inspect -> String
4772
+ def inspect
4773
+ InspectVisitor.compose(self)
5055
4774
  end
5056
4775
 
5057
4776
  # Sometimes you want to check an instance of a node against a list of
@@ -5159,15 +4878,9 @@ module Prism
5159
4878
  operator_loc.slice
5160
4879
  end
5161
4880
 
5162
- # def inspect(NodeInspector inspector) -> String
5163
- def inspect(inspector = NodeInspector.new)
5164
- inspector << inspector.header(self)
5165
- inspector << "├── target:\n"
5166
- inspector << inspector.child_node(target, "│ ")
5167
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
5168
- inspector << "└── value:\n"
5169
- inspector << inspector.child_node(value, " ")
5170
- inspector.to_str
4881
+ # def inspect -> String
4882
+ def inspect
4883
+ InspectVisitor.compose(self)
5171
4884
  end
5172
4885
 
5173
4886
  # Sometimes you want to check an instance of a node against a list of
@@ -5213,14 +4926,15 @@ module Prism
5213
4926
  # Foo::Bar
5214
4927
  # ^^^^^^^^
5215
4928
  class ConstantPathNode < Node
5216
- # def initialize: (Prism::node? parent, ConstantReadNode | MissingNode child, Location delimiter_loc, Location location) -> void
5217
- def initialize(source, parent, child, delimiter_loc, location)
4929
+ # def initialize: (Prism::node? parent, Symbol? name, Location delimiter_loc, Location name_loc, Location location) -> void
4930
+ def initialize(source, parent, name, delimiter_loc, name_loc, location)
5218
4931
  @source = source
5219
4932
  @newline = false
5220
4933
  @location = location
5221
4934
  @parent = parent
5222
- @child = child
4935
+ @name = name
5223
4936
  @delimiter_loc = delimiter_loc
4937
+ @name_loc = name_loc
5224
4938
  end
5225
4939
 
5226
4940
  # def accept: (Visitor visitor) -> void
@@ -5230,33 +4944,32 @@ module Prism
5230
4944
 
5231
4945
  # def child_nodes: () -> Array[nil | Node]
5232
4946
  def child_nodes
5233
- [parent, child]
4947
+ [parent]
5234
4948
  end
5235
4949
 
5236
4950
  # def compact_child_nodes: () -> Array[Node]
5237
4951
  def compact_child_nodes
5238
4952
  compact = [] #: Array[Prism::node]
5239
4953
  compact << parent if parent
5240
- compact << child
5241
4954
  compact
5242
4955
  end
5243
4956
 
5244
4957
  # def comment_targets: () -> Array[Node | Location]
5245
4958
  def comment_targets
5246
- [*parent, child, delimiter_loc] #: Array[Prism::node | Location]
4959
+ [*parent, delimiter_loc, name_loc] #: Array[Prism::node | Location]
5247
4960
  end
5248
4961
 
5249
- # def copy: (?parent: Prism::node?, ?child: ConstantReadNode | MissingNode, ?delimiter_loc: Location, ?location: Location) -> ConstantPathNode
5250
- def copy(parent: self.parent, child: self.child, delimiter_loc: self.delimiter_loc, location: self.location)
5251
- ConstantPathNode.new(source, parent, child, delimiter_loc, location)
4962
+ # def copy: (?parent: Prism::node?, ?name: Symbol?, ?delimiter_loc: Location, ?name_loc: Location, ?location: Location) -> ConstantPathNode
4963
+ def copy(parent: self.parent, name: self.name, delimiter_loc: self.delimiter_loc, name_loc: self.name_loc, location: self.location)
4964
+ ConstantPathNode.new(source, parent, name, delimiter_loc, name_loc, location)
5252
4965
  end
5253
4966
 
5254
4967
  # def deconstruct: () -> Array[nil | Node]
5255
4968
  alias deconstruct child_nodes
5256
4969
 
5257
- # def deconstruct_keys: (Array[Symbol] keys) -> { parent: Prism::node?, child: ConstantReadNode | MissingNode, delimiter_loc: Location, location: Location }
4970
+ # def deconstruct_keys: (Array[Symbol] keys) -> { parent: Prism::node?, name: Symbol?, delimiter_loc: Location, name_loc: Location, location: Location }
5258
4971
  def deconstruct_keys(keys)
5259
- { parent: parent, child: child, delimiter_loc: delimiter_loc, location: location }
4972
+ { parent: parent, name: name, delimiter_loc: delimiter_loc, name_loc: name_loc, location: location }
5260
4973
  end
5261
4974
 
5262
4975
  # The left-hand node of the path, if present. It can be `nil` or any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). It will be `nil` when the constant lookup is at the root of the module tree.
@@ -5271,18 +4984,8 @@ module Prism
5271
4984
  # ^^^
5272
4985
  attr_reader :parent
5273
4986
 
5274
- # The right-hand node of the path. Always a `ConstantReadNode` in a
5275
- # valid Ruby syntax tree.
5276
- #
5277
- # ::Foo
5278
- # ^^^
5279
- #
5280
- # self::Test
5281
- # ^^^^
5282
- #
5283
- # a.b::C
5284
- # ^
5285
- attr_reader :child
4987
+ # The name of the constant being accessed. This could be `nil` in the event of a syntax error.
4988
+ attr_reader :name
5286
4989
 
5287
4990
  # The location of the `::` delimiter.
5288
4991
  #
@@ -5297,24 +5000,27 @@ module Prism
5297
5000
  @delimiter_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
5298
5001
  end
5299
5002
 
5003
+ # The location of the name of the constant.
5004
+ #
5005
+ # ::Foo
5006
+ # ^^^
5007
+ #
5008
+ # One::Two
5009
+ # ^^^
5010
+ def name_loc
5011
+ location = @name_loc
5012
+ return location if location.is_a?(Location)
5013
+ @name_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
5014
+ end
5015
+
5300
5016
  # def delimiter: () -> String
5301
5017
  def delimiter
5302
5018
  delimiter_loc.slice
5303
5019
  end
5304
5020
 
5305
- # def inspect(NodeInspector inspector) -> String
5306
- def inspect(inspector = NodeInspector.new)
5307
- inspector << inspector.header(self)
5308
- if (parent = self.parent).nil?
5309
- inspector << "├── parent: ∅\n"
5310
- else
5311
- inspector << "├── parent:\n"
5312
- inspector << parent.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
5313
- end
5314
- inspector << "├── child:\n"
5315
- inspector << inspector.child_node(child, "│ ")
5316
- inspector << "└── delimiter_loc: #{inspector.location(delimiter_loc)}\n"
5317
- inspector.to_str
5021
+ # def inspect -> String
5022
+ def inspect
5023
+ InspectVisitor.compose(self)
5318
5024
  end
5319
5025
 
5320
5026
  # Sometimes you want to check an instance of a node against a list of
@@ -5350,8 +5056,9 @@ module Prism
5350
5056
  def ===(other)
5351
5057
  other.is_a?(ConstantPathNode) &&
5352
5058
  (parent === other.parent) &&
5353
- (child === other.child) &&
5354
- (delimiter_loc.nil? == other.delimiter_loc.nil?)
5059
+ (name === other.name) &&
5060
+ (delimiter_loc.nil? == other.delimiter_loc.nil?) &&
5061
+ (name_loc.nil? == other.name_loc.nil?)
5355
5062
  end
5356
5063
  end
5357
5064
 
@@ -5420,16 +5127,9 @@ module Prism
5420
5127
  # attr_reader operator: Symbol
5421
5128
  attr_reader :operator
5422
5129
 
5423
- # def inspect(NodeInspector inspector) -> String
5424
- def inspect(inspector = NodeInspector.new)
5425
- inspector << inspector.header(self)
5426
- inspector << "├── target:\n"
5427
- inspector << inspector.child_node(target, "│ ")
5428
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
5429
- inspector << "├── value:\n"
5430
- inspector << inspector.child_node(value, "│ ")
5431
- inspector << "└── operator: #{operator.inspect}\n"
5432
- inspector.to_str
5130
+ # def inspect -> String
5131
+ def inspect
5132
+ InspectVisitor.compose(self)
5433
5133
  end
5434
5134
 
5435
5135
  # Sometimes you want to check an instance of a node against a list of
@@ -5537,15 +5237,9 @@ module Prism
5537
5237
  operator_loc.slice
5538
5238
  end
5539
5239
 
5540
- # def inspect(NodeInspector inspector) -> String
5541
- def inspect(inspector = NodeInspector.new)
5542
- inspector << inspector.header(self)
5543
- inspector << "├── target:\n"
5544
- inspector << inspector.child_node(target, "│ ")
5545
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
5546
- inspector << "└── value:\n"
5547
- inspector << inspector.child_node(value, " ")
5548
- inspector.to_str
5240
+ # def inspect -> String
5241
+ def inspect
5242
+ InspectVisitor.compose(self)
5549
5243
  end
5550
5244
 
5551
5245
  # Sometimes you want to check an instance of a node against a list of
@@ -5591,14 +5285,15 @@ module Prism
5591
5285
  # Foo::Foo, Bar::Bar = baz
5592
5286
  # ^^^^^^^^ ^^^^^^^^
5593
5287
  class ConstantPathTargetNode < Node
5594
- # def initialize: (Prism::node? parent, ConstantReadNode | MissingNode child, Location delimiter_loc, Location location) -> void
5595
- def initialize(source, parent, child, delimiter_loc, location)
5288
+ # def initialize: (Prism::node? parent, Symbol? name, Location delimiter_loc, Location name_loc, Location location) -> void
5289
+ def initialize(source, parent, name, delimiter_loc, name_loc, location)
5596
5290
  @source = source
5597
5291
  @newline = false
5598
5292
  @location = location
5599
5293
  @parent = parent
5600
- @child = child
5294
+ @name = name
5601
5295
  @delimiter_loc = delimiter_loc
5296
+ @name_loc = name_loc
5602
5297
  end
5603
5298
 
5604
5299
  # def accept: (Visitor visitor) -> void
@@ -5608,40 +5303,39 @@ module Prism
5608
5303
 
5609
5304
  # def child_nodes: () -> Array[nil | Node]
5610
5305
  def child_nodes
5611
- [parent, child]
5306
+ [parent]
5612
5307
  end
5613
5308
 
5614
5309
  # def compact_child_nodes: () -> Array[Node]
5615
5310
  def compact_child_nodes
5616
5311
  compact = [] #: Array[Prism::node]
5617
5312
  compact << parent if parent
5618
- compact << child
5619
5313
  compact
5620
5314
  end
5621
5315
 
5622
5316
  # def comment_targets: () -> Array[Node | Location]
5623
5317
  def comment_targets
5624
- [*parent, child, delimiter_loc] #: Array[Prism::node | Location]
5318
+ [*parent, delimiter_loc, name_loc] #: Array[Prism::node | Location]
5625
5319
  end
5626
5320
 
5627
- # def copy: (?parent: Prism::node?, ?child: ConstantReadNode | MissingNode, ?delimiter_loc: Location, ?location: Location) -> ConstantPathTargetNode
5628
- def copy(parent: self.parent, child: self.child, delimiter_loc: self.delimiter_loc, location: self.location)
5629
- ConstantPathTargetNode.new(source, parent, child, delimiter_loc, location)
5321
+ # def copy: (?parent: Prism::node?, ?name: Symbol?, ?delimiter_loc: Location, ?name_loc: Location, ?location: Location) -> ConstantPathTargetNode
5322
+ def copy(parent: self.parent, name: self.name, delimiter_loc: self.delimiter_loc, name_loc: self.name_loc, location: self.location)
5323
+ ConstantPathTargetNode.new(source, parent, name, delimiter_loc, name_loc, location)
5630
5324
  end
5631
5325
 
5632
5326
  # def deconstruct: () -> Array[nil | Node]
5633
5327
  alias deconstruct child_nodes
5634
5328
 
5635
- # def deconstruct_keys: (Array[Symbol] keys) -> { parent: Prism::node?, child: ConstantReadNode | MissingNode, delimiter_loc: Location, location: Location }
5329
+ # def deconstruct_keys: (Array[Symbol] keys) -> { parent: Prism::node?, name: Symbol?, delimiter_loc: Location, name_loc: Location, location: Location }
5636
5330
  def deconstruct_keys(keys)
5637
- { parent: parent, child: child, delimiter_loc: delimiter_loc, location: location }
5331
+ { parent: parent, name: name, delimiter_loc: delimiter_loc, name_loc: name_loc, location: location }
5638
5332
  end
5639
5333
 
5640
5334
  # attr_reader parent: Prism::node?
5641
5335
  attr_reader :parent
5642
5336
 
5643
- # attr_reader child: ConstantReadNode | MissingNode
5644
- attr_reader :child
5337
+ # attr_reader name: Symbol?
5338
+ attr_reader :name
5645
5339
 
5646
5340
  # attr_reader delimiter_loc: Location
5647
5341
  def delimiter_loc
@@ -5650,24 +5344,21 @@ module Prism
5650
5344
  @delimiter_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
5651
5345
  end
5652
5346
 
5347
+ # attr_reader name_loc: Location
5348
+ def name_loc
5349
+ location = @name_loc
5350
+ return location if location.is_a?(Location)
5351
+ @name_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
5352
+ end
5353
+
5653
5354
  # def delimiter: () -> String
5654
5355
  def delimiter
5655
5356
  delimiter_loc.slice
5656
5357
  end
5657
5358
 
5658
- # def inspect(NodeInspector inspector) -> String
5659
- def inspect(inspector = NodeInspector.new)
5660
- inspector << inspector.header(self)
5661
- if (parent = self.parent).nil?
5662
- inspector << "├── parent: ∅\n"
5663
- else
5664
- inspector << "├── parent:\n"
5665
- inspector << parent.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
5666
- end
5667
- inspector << "├── child:\n"
5668
- inspector << inspector.child_node(child, "│ ")
5669
- inspector << "└── delimiter_loc: #{inspector.location(delimiter_loc)}\n"
5670
- inspector.to_str
5359
+ # def inspect -> String
5360
+ def inspect
5361
+ InspectVisitor.compose(self)
5671
5362
  end
5672
5363
 
5673
5364
  # Sometimes you want to check an instance of a node against a list of
@@ -5703,8 +5394,9 @@ module Prism
5703
5394
  def ===(other)
5704
5395
  other.is_a?(ConstantPathTargetNode) &&
5705
5396
  (parent === other.parent) &&
5706
- (child === other.child) &&
5707
- (delimiter_loc.nil? == other.delimiter_loc.nil?)
5397
+ (name === other.name) &&
5398
+ (delimiter_loc.nil? == other.delimiter_loc.nil?) &&
5399
+ (name_loc.nil? == other.name_loc.nil?)
5708
5400
  end
5709
5401
  end
5710
5402
 
@@ -5792,15 +5484,9 @@ module Prism
5792
5484
  operator_loc.slice
5793
5485
  end
5794
5486
 
5795
- # def inspect(NodeInspector inspector) -> String
5796
- def inspect(inspector = NodeInspector.new)
5797
- inspector << inspector.header(self)
5798
- inspector << "├── target:\n"
5799
- inspector << inspector.child_node(target, "│ ")
5800
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
5801
- inspector << "└── value:\n"
5802
- inspector << inspector.child_node(value, " ")
5803
- inspector.to_str
5487
+ # def inspect -> String
5488
+ def inspect
5489
+ InspectVisitor.compose(self)
5804
5490
  end
5805
5491
 
5806
5492
  # Sometimes you want to check an instance of a node against a list of
@@ -5894,11 +5580,9 @@ module Prism
5894
5580
  # SOME_CONSTANT # name `:SOME_CONSTANT`
5895
5581
  attr_reader :name
5896
5582
 
5897
- # def inspect(NodeInspector inspector) -> String
5898
- def inspect(inspector = NodeInspector.new)
5899
- inspector << inspector.header(self)
5900
- inspector << "└── name: #{name.inspect}\n"
5901
- inspector.to_str
5583
+ # def inspect -> String
5584
+ def inspect
5585
+ InspectVisitor.compose(self)
5902
5586
  end
5903
5587
 
5904
5588
  # Sometimes you want to check an instance of a node against a list of
@@ -5986,11 +5670,9 @@ module Prism
5986
5670
  # attr_reader name: Symbol
5987
5671
  attr_reader :name
5988
5672
 
5989
- # def inspect(NodeInspector inspector) -> String
5990
- def inspect(inspector = NodeInspector.new)
5991
- inspector << inspector.header(self)
5992
- inspector << "└── name: #{name.inspect}\n"
5993
- inspector.to_str
5673
+ # def inspect -> String
5674
+ def inspect
5675
+ InspectVisitor.compose(self)
5994
5676
  end
5995
5677
 
5996
5678
  # Sometimes you want to check an instance of a node against a list of
@@ -6119,15 +5801,9 @@ module Prism
6119
5801
  operator_loc.slice
6120
5802
  end
6121
5803
 
6122
- # def inspect(NodeInspector inspector) -> String
6123
- def inspect(inspector = NodeInspector.new)
6124
- inspector << inspector.header(self)
6125
- inspector << "├── name: #{name.inspect}\n"
6126
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
6127
- inspector << "├── value:\n"
6128
- inspector << inspector.child_node(value, "│ ")
6129
- inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
6130
- inspector.to_str
5804
+ # def inspect -> String
5805
+ def inspect
5806
+ InspectVisitor.compose(self)
6131
5807
  end
6132
5808
 
6133
5809
  # Sometimes you want to check an instance of a node against a list of
@@ -6355,37 +6031,9 @@ module Prism
6355
6031
  end_keyword_loc&.slice
6356
6032
  end
6357
6033
 
6358
- # def inspect(NodeInspector inspector) -> String
6359
- def inspect(inspector = NodeInspector.new)
6360
- inspector << inspector.header(self)
6361
- inspector << "├── name: #{name.inspect}\n"
6362
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
6363
- if (receiver = self.receiver).nil?
6364
- inspector << "├── receiver: ∅\n"
6365
- else
6366
- inspector << "├── receiver:\n"
6367
- inspector << receiver.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
6368
- end
6369
- if (parameters = self.parameters).nil?
6370
- inspector << "├── parameters: ∅\n"
6371
- else
6372
- inspector << "├── parameters:\n"
6373
- inspector << parameters.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
6374
- end
6375
- if (body = self.body).nil?
6376
- inspector << "├── body: ∅\n"
6377
- else
6378
- inspector << "├── body:\n"
6379
- inspector << body.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
6380
- end
6381
- inspector << "├── locals: #{locals.inspect}\n"
6382
- inspector << "├── def_keyword_loc: #{inspector.location(def_keyword_loc)}\n"
6383
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
6384
- inspector << "├── lparen_loc: #{inspector.location(lparen_loc)}\n"
6385
- inspector << "├── rparen_loc: #{inspector.location(rparen_loc)}\n"
6386
- inspector << "├── equal_loc: #{inspector.location(equal_loc)}\n"
6387
- inspector << "└── end_keyword_loc: #{inspector.location(end_keyword_loc)}\n"
6388
- inspector.to_str
6034
+ # def inspect -> String
6035
+ def inspect
6036
+ InspectVisitor.compose(self)
6389
6037
  end
6390
6038
 
6391
6039
  # Sometimes you want to check an instance of a node against a list of
@@ -6536,15 +6184,9 @@ module Prism
6536
6184
  keyword_loc.slice
6537
6185
  end
6538
6186
 
6539
- # def inspect(NodeInspector inspector) -> String
6540
- def inspect(inspector = NodeInspector.new)
6541
- inspector << inspector.header(self)
6542
- inspector << "├── lparen_loc: #{inspector.location(lparen_loc)}\n"
6543
- inspector << "├── value:\n"
6544
- inspector << inspector.child_node(value, "│ ")
6545
- inspector << "├── rparen_loc: #{inspector.location(rparen_loc)}\n"
6546
- inspector << "└── keyword_loc: #{inspector.location(keyword_loc)}\n"
6547
- inspector.to_str
6187
+ # def inspect -> String
6188
+ def inspect
6189
+ InspectVisitor.compose(self)
6548
6190
  end
6549
6191
 
6550
6192
  # Sometimes you want to check an instance of a node against a list of
@@ -6669,18 +6311,9 @@ module Prism
6669
6311
  end_keyword_loc&.slice
6670
6312
  end
6671
6313
 
6672
- # def inspect(NodeInspector inspector) -> String
6673
- def inspect(inspector = NodeInspector.new)
6674
- inspector << inspector.header(self)
6675
- inspector << "├── else_keyword_loc: #{inspector.location(else_keyword_loc)}\n"
6676
- if (statements = self.statements).nil?
6677
- inspector << "├── statements: ∅\n"
6678
- else
6679
- inspector << "├── statements:\n"
6680
- inspector << statements.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
6681
- end
6682
- inspector << "└── end_keyword_loc: #{inspector.location(end_keyword_loc)}\n"
6683
- inspector.to_str
6314
+ # def inspect -> String
6315
+ def inspect
6316
+ InspectVisitor.compose(self)
6684
6317
  end
6685
6318
 
6686
6319
  # Sometimes you want to check an instance of a node against a list of
@@ -6798,18 +6431,9 @@ module Prism
6798
6431
  closing_loc.slice
6799
6432
  end
6800
6433
 
6801
- # def inspect(NodeInspector inspector) -> String
6802
- def inspect(inspector = NodeInspector.new)
6803
- inspector << inspector.header(self)
6804
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
6805
- if (statements = self.statements).nil?
6806
- inspector << "├── statements: ∅\n"
6807
- else
6808
- inspector << "├── statements:\n"
6809
- inspector << statements.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
6810
- end
6811
- inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n"
6812
- inspector.to_str
6434
+ # def inspect -> String
6435
+ def inspect
6436
+ InspectVisitor.compose(self)
6813
6437
  end
6814
6438
 
6815
6439
  # Sometimes you want to check an instance of a node against a list of
@@ -6912,13 +6536,9 @@ module Prism
6912
6536
  operator_loc.slice
6913
6537
  end
6914
6538
 
6915
- # def inspect(NodeInspector inspector) -> String
6916
- def inspect(inspector = NodeInspector.new)
6917
- inspector << inspector.header(self)
6918
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
6919
- inspector << "└── variable:\n"
6920
- inspector << inspector.child_node(variable, " ")
6921
- inspector.to_str
6539
+ # def inspect -> String
6540
+ def inspect
6541
+ InspectVisitor.compose(self)
6922
6542
  end
6923
6543
 
6924
6544
  # Sometimes you want to check an instance of a node against a list of
@@ -7039,18 +6659,9 @@ module Prism
7039
6659
  end_keyword_loc.slice
7040
6660
  end
7041
6661
 
7042
- # def inspect(NodeInspector inspector) -> String
7043
- def inspect(inspector = NodeInspector.new)
7044
- inspector << inspector.header(self)
7045
- inspector << "├── ensure_keyword_loc: #{inspector.location(ensure_keyword_loc)}\n"
7046
- if (statements = self.statements).nil?
7047
- inspector << "├── statements: ∅\n"
7048
- else
7049
- inspector << "├── statements:\n"
7050
- inspector << statements.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
7051
- end
7052
- inspector << "└── end_keyword_loc: #{inspector.location(end_keyword_loc)}\n"
7053
- inspector.to_str
6662
+ # def inspect -> String
6663
+ def inspect
6664
+ InspectVisitor.compose(self)
7054
6665
  end
7055
6666
 
7056
6667
  # Sometimes you want to check an instance of a node against a list of
@@ -7136,10 +6747,9 @@ module Prism
7136
6747
  { location: location }
7137
6748
  end
7138
6749
 
7139
- # def inspect(NodeInspector inspector) -> String
7140
- def inspect(inspector = NodeInspector.new)
7141
- inspector << inspector.header(self)
7142
- inspector.to_str
6750
+ # def inspect -> String
6751
+ def inspect
6752
+ InspectVisitor.compose(self)
7143
6753
  end
7144
6754
 
7145
6755
  # Sometimes you want to check an instance of a node against a list of
@@ -7287,23 +6897,9 @@ module Prism
7287
6897
  closing_loc&.slice
7288
6898
  end
7289
6899
 
7290
- # def inspect(NodeInspector inspector) -> String
7291
- def inspect(inspector = NodeInspector.new)
7292
- inspector << inspector.header(self)
7293
- if (constant = self.constant).nil?
7294
- inspector << "├── constant: ∅\n"
7295
- else
7296
- inspector << "├── constant:\n"
7297
- inspector << constant.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
7298
- end
7299
- inspector << "├── left:\n"
7300
- inspector << inspector.child_node(left, "│ ")
7301
- inspector << "├── requireds: #{inspector.list("#{inspector.prefix}│ ", requireds)}"
7302
- inspector << "├── right:\n"
7303
- inspector << inspector.child_node(right, "│ ")
7304
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
7305
- inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n"
7306
- inspector.to_str
6900
+ # def inspect -> String
6901
+ def inspect
6902
+ InspectVisitor.compose(self)
7307
6903
  end
7308
6904
 
7309
6905
  # Sometimes you want to check an instance of a node against a list of
@@ -7427,25 +7023,9 @@ module Prism
7427
7023
  operator_loc.slice
7428
7024
  end
7429
7025
 
7430
- # def inspect(NodeInspector inspector) -> String
7431
- def inspect(inspector = NodeInspector.new)
7432
- inspector << inspector.header(self)
7433
- flags = [("exclude_end" if exclude_end?)].compact
7434
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
7435
- if (left = self.left).nil?
7436
- inspector << "├── left: ∅\n"
7437
- else
7438
- inspector << "├── left:\n"
7439
- inspector << left.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
7440
- end
7441
- if (right = self.right).nil?
7442
- inspector << "├── right: ∅\n"
7443
- else
7444
- inspector << "├── right:\n"
7445
- inspector << right.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
7446
- end
7447
- inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
7448
- inspector.to_str
7026
+ # def inspect -> String
7027
+ def inspect
7028
+ InspectVisitor.compose(self)
7449
7029
  end
7450
7030
 
7451
7031
  # Sometimes you want to check an instance of a node against a list of
@@ -7536,11 +7116,9 @@ module Prism
7536
7116
  # The value of the floating point number as a Float.
7537
7117
  attr_reader :value
7538
7118
 
7539
- # def inspect(NodeInspector inspector) -> String
7540
- def inspect(inspector = NodeInspector.new)
7541
- inspector << inspector.header(self)
7542
- inspector << "└── value: #{value.inspect}\n"
7543
- inspector.to_str
7119
+ # def inspect -> String
7120
+ def inspect
7121
+ InspectVisitor.compose(self)
7544
7122
  end
7545
7123
 
7546
7124
  # Sometimes you want to check an instance of a node against a list of
@@ -7698,24 +7276,9 @@ module Prism
7698
7276
  end_keyword_loc.slice
7699
7277
  end
7700
7278
 
7701
- # def inspect(NodeInspector inspector) -> String
7702
- def inspect(inspector = NodeInspector.new)
7703
- inspector << inspector.header(self)
7704
- inspector << "├── index:\n"
7705
- inspector << inspector.child_node(index, "│ ")
7706
- inspector << "├── collection:\n"
7707
- inspector << inspector.child_node(collection, "│ ")
7708
- if (statements = self.statements).nil?
7709
- inspector << "├── statements: ∅\n"
7710
- else
7711
- inspector << "├── statements:\n"
7712
- inspector << statements.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
7713
- end
7714
- inspector << "├── for_keyword_loc: #{inspector.location(for_keyword_loc)}\n"
7715
- inspector << "├── in_keyword_loc: #{inspector.location(in_keyword_loc)}\n"
7716
- inspector << "├── do_keyword_loc: #{inspector.location(do_keyword_loc)}\n"
7717
- inspector << "└── end_keyword_loc: #{inspector.location(end_keyword_loc)}\n"
7718
- inspector.to_str
7279
+ # def inspect -> String
7280
+ def inspect
7281
+ InspectVisitor.compose(self)
7719
7282
  end
7720
7283
 
7721
7284
  # Sometimes you want to check an instance of a node against a list of
@@ -7807,10 +7370,9 @@ module Prism
7807
7370
  { location: location }
7808
7371
  end
7809
7372
 
7810
- # def inspect(NodeInspector inspector) -> String
7811
- def inspect(inspector = NodeInspector.new)
7812
- inspector << inspector.header(self)
7813
- inspector.to_str
7373
+ # def inspect -> String
7374
+ def inspect
7375
+ InspectVisitor.compose(self)
7814
7376
  end
7815
7377
 
7816
7378
  # Sometimes you want to check an instance of a node against a list of
@@ -7894,10 +7456,9 @@ module Prism
7894
7456
  { location: location }
7895
7457
  end
7896
7458
 
7897
- # def inspect(NodeInspector inspector) -> String
7898
- def inspect(inspector = NodeInspector.new)
7899
- inspector << inspector.header(self)
7900
- inspector.to_str
7459
+ # def inspect -> String
7460
+ def inspect
7461
+ InspectVisitor.compose(self)
7901
7462
  end
7902
7463
 
7903
7464
  # Sometimes you want to check an instance of a node against a list of
@@ -7986,16 +7547,9 @@ module Prism
7986
7547
  # attr_reader block: BlockNode?
7987
7548
  attr_reader :block
7988
7549
 
7989
- # def inspect(NodeInspector inspector) -> String
7990
- def inspect(inspector = NodeInspector.new)
7991
- inspector << inspector.header(self)
7992
- if (block = self.block).nil?
7993
- inspector << "└── block: ∅\n"
7994
- else
7995
- inspector << "└── block:\n"
7996
- inspector << block.inspect(inspector.child_inspector(" ")).delete_prefix(inspector.prefix)
7997
- end
7998
- inspector.to_str
7550
+ # def inspect -> String
7551
+ def inspect
7552
+ InspectVisitor.compose(self)
7999
7553
  end
8000
7554
 
8001
7555
  # Sometimes you want to check an instance of a node against a list of
@@ -8108,15 +7662,9 @@ module Prism
8108
7662
  operator_loc.slice
8109
7663
  end
8110
7664
 
8111
- # def inspect(NodeInspector inspector) -> String
8112
- def inspect(inspector = NodeInspector.new)
8113
- inspector << inspector.header(self)
8114
- inspector << "├── name: #{name.inspect}\n"
8115
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
8116
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
8117
- inspector << "└── value:\n"
8118
- inspector << inspector.child_node(value, " ")
8119
- inspector.to_str
7665
+ # def inspect -> String
7666
+ def inspect
7667
+ InspectVisitor.compose(self)
8120
7668
  end
8121
7669
 
8122
7670
  # Sometimes you want to check an instance of a node against a list of
@@ -8231,16 +7779,9 @@ module Prism
8231
7779
  # attr_reader operator: Symbol
8232
7780
  attr_reader :operator
8233
7781
 
8234
- # def inspect(NodeInspector inspector) -> String
8235
- def inspect(inspector = NodeInspector.new)
8236
- inspector << inspector.header(self)
8237
- inspector << "├── name: #{name.inspect}\n"
8238
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
8239
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
8240
- inspector << "├── value:\n"
8241
- inspector << inspector.child_node(value, "│ ")
8242
- inspector << "└── operator: #{operator.inspect}\n"
8243
- inspector.to_str
7782
+ # def inspect -> String
7783
+ def inspect
7784
+ InspectVisitor.compose(self)
8244
7785
  end
8245
7786
 
8246
7787
  # Sometimes you want to check an instance of a node against a list of
@@ -8357,15 +7898,9 @@ module Prism
8357
7898
  operator_loc.slice
8358
7899
  end
8359
7900
 
8360
- # def inspect(NodeInspector inspector) -> String
8361
- def inspect(inspector = NodeInspector.new)
8362
- inspector << inspector.header(self)
8363
- inspector << "├── name: #{name.inspect}\n"
8364
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
8365
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
8366
- inspector << "└── value:\n"
8367
- inspector << inspector.child_node(value, " ")
8368
- inspector.to_str
7901
+ # def inspect -> String
7902
+ def inspect
7903
+ InspectVisitor.compose(self)
8369
7904
  end
8370
7905
 
8371
7906
  # Sometimes you want to check an instance of a node against a list of
@@ -8460,11 +7995,9 @@ module Prism
8460
7995
  # $_Test # name `:$_Test`
8461
7996
  attr_reader :name
8462
7997
 
8463
- # def inspect(NodeInspector inspector) -> String
8464
- def inspect(inspector = NodeInspector.new)
8465
- inspector << inspector.header(self)
8466
- inspector << "└── name: #{name.inspect}\n"
8467
- inspector.to_str
7998
+ # def inspect -> String
7999
+ def inspect
8000
+ InspectVisitor.compose(self)
8468
8001
  end
8469
8002
 
8470
8003
  # Sometimes you want to check an instance of a node against a list of
@@ -8552,11 +8085,9 @@ module Prism
8552
8085
  # attr_reader name: Symbol
8553
8086
  attr_reader :name
8554
8087
 
8555
- # def inspect(NodeInspector inspector) -> String
8556
- def inspect(inspector = NodeInspector.new)
8557
- inspector << inspector.header(self)
8558
- inspector << "└── name: #{name.inspect}\n"
8559
- inspector.to_str
8088
+ # def inspect -> String
8089
+ def inspect
8090
+ InspectVisitor.compose(self)
8560
8091
  end
8561
8092
 
8562
8093
  # Sometimes you want to check an instance of a node against a list of
@@ -8685,15 +8216,9 @@ module Prism
8685
8216
  operator_loc.slice
8686
8217
  end
8687
8218
 
8688
- # def inspect(NodeInspector inspector) -> String
8689
- def inspect(inspector = NodeInspector.new)
8690
- inspector << inspector.header(self)
8691
- inspector << "├── name: #{name.inspect}\n"
8692
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
8693
- inspector << "├── value:\n"
8694
- inspector << inspector.child_node(value, "│ ")
8695
- inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
8696
- inspector.to_str
8219
+ # def inspect -> String
8220
+ def inspect
8221
+ InspectVisitor.compose(self)
8697
8222
  end
8698
8223
 
8699
8224
  # Sometimes you want to check an instance of a node against a list of
@@ -8822,13 +8347,9 @@ module Prism
8822
8347
  closing_loc.slice
8823
8348
  end
8824
8349
 
8825
- # def inspect(NodeInspector inspector) -> String
8826
- def inspect(inspector = NodeInspector.new)
8827
- inspector << inspector.header(self)
8828
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
8829
- inspector << "├── elements: #{inspector.list("#{inspector.prefix}│ ", elements)}"
8830
- inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n"
8831
- inspector.to_str
8350
+ # def inspect -> String
8351
+ def inspect
8352
+ InspectVisitor.compose(self)
8832
8353
  end
8833
8354
 
8834
8355
  # Sometimes you want to check an instance of a node against a list of
@@ -8972,25 +8493,9 @@ module Prism
8972
8493
  closing_loc&.slice
8973
8494
  end
8974
8495
 
8975
- # def inspect(NodeInspector inspector) -> String
8976
- def inspect(inspector = NodeInspector.new)
8977
- inspector << inspector.header(self)
8978
- if (constant = self.constant).nil?
8979
- inspector << "├── constant: ∅\n"
8980
- else
8981
- inspector << "├── constant:\n"
8982
- inspector << constant.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
8983
- end
8984
- inspector << "├── elements: #{inspector.list("#{inspector.prefix}│ ", elements)}"
8985
- if (rest = self.rest).nil?
8986
- inspector << "├── rest: ∅\n"
8987
- else
8988
- inspector << "├── rest:\n"
8989
- inspector << rest.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
8990
- end
8991
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
8992
- inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n"
8993
- inspector.to_str
8496
+ # def inspect -> String
8497
+ def inspect
8498
+ InspectVisitor.compose(self)
8994
8499
  end
8995
8500
 
8996
8501
  # Sometimes you want to check an instance of a node against a list of
@@ -9208,27 +8713,9 @@ module Prism
9208
8713
  end_keyword_loc&.slice
9209
8714
  end
9210
8715
 
9211
- # def inspect(NodeInspector inspector) -> String
9212
- def inspect(inspector = NodeInspector.new)
9213
- inspector << inspector.header(self)
9214
- inspector << "├── if_keyword_loc: #{inspector.location(if_keyword_loc)}\n"
9215
- inspector << "├── predicate:\n"
9216
- inspector << inspector.child_node(predicate, "│ ")
9217
- inspector << "├── then_keyword_loc: #{inspector.location(then_keyword_loc)}\n"
9218
- if (statements = self.statements).nil?
9219
- inspector << "├── statements: ∅\n"
9220
- else
9221
- inspector << "├── statements:\n"
9222
- inspector << statements.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
9223
- end
9224
- if (consequent = self.consequent).nil?
9225
- inspector << "├── consequent: ∅\n"
9226
- else
9227
- inspector << "├── consequent:\n"
9228
- inspector << consequent.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
9229
- end
9230
- inspector << "└── end_keyword_loc: #{inspector.location(end_keyword_loc)}\n"
9231
- inspector.to_str
8716
+ # def inspect -> String
8717
+ def inspect
8718
+ InspectVisitor.compose(self)
9232
8719
  end
9233
8720
 
9234
8721
  # Sometimes you want to check an instance of a node against a list of
@@ -9321,12 +8808,9 @@ module Prism
9321
8808
  # attr_reader numeric: FloatNode | IntegerNode | RationalNode
9322
8809
  attr_reader :numeric
9323
8810
 
9324
- # def inspect(NodeInspector inspector) -> String
9325
- def inspect(inspector = NodeInspector.new)
9326
- inspector << inspector.header(self)
9327
- inspector << "└── numeric:\n"
9328
- inspector << inspector.child_node(numeric, " ")
9329
- inspector.to_str
8811
+ # def inspect -> String
8812
+ def inspect
8813
+ InspectVisitor.compose(self)
9330
8814
  end
9331
8815
 
9332
8816
  # Sometimes you want to check an instance of a node against a list of
@@ -9420,12 +8904,9 @@ module Prism
9420
8904
  # attr_reader value: Prism::node
9421
8905
  attr_reader :value
9422
8906
 
9423
- # def inspect(NodeInspector inspector) -> String
9424
- def inspect(inspector = NodeInspector.new)
9425
- inspector << inspector.header(self)
9426
- inspector << "└── value:\n"
9427
- inspector << inspector.child_node(value, " ")
9428
- inspector.to_str
8907
+ # def inspect -> String
8908
+ def inspect
8909
+ InspectVisitor.compose(self)
9429
8910
  end
9430
8911
 
9431
8912
  # Sometimes you want to check an instance of a node against a list of
@@ -9518,10 +8999,9 @@ module Prism
9518
8999
  { location: location }
9519
9000
  end
9520
9001
 
9521
- # def inspect(NodeInspector inspector) -> String
9522
- def inspect(inspector = NodeInspector.new)
9523
- inspector << inspector.header(self)
9524
- inspector.to_str
9002
+ # def inspect -> String
9003
+ def inspect
9004
+ InspectVisitor.compose(self)
9525
9005
  end
9526
9006
 
9527
9007
  # Sometimes you want to check an instance of a node against a list of
@@ -9647,20 +9127,9 @@ module Prism
9647
9127
  then_loc&.slice
9648
9128
  end
9649
9129
 
9650
- # def inspect(NodeInspector inspector) -> String
9651
- def inspect(inspector = NodeInspector.new)
9652
- inspector << inspector.header(self)
9653
- inspector << "├── pattern:\n"
9654
- inspector << inspector.child_node(pattern, "│ ")
9655
- if (statements = self.statements).nil?
9656
- inspector << "├── statements: ∅\n"
9657
- else
9658
- inspector << "├── statements:\n"
9659
- inspector << statements.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
9660
- end
9661
- inspector << "├── in_loc: #{inspector.location(in_loc)}\n"
9662
- inspector << "└── then_loc: #{inspector.location(then_loc)}\n"
9663
- inspector.to_str
9130
+ # def inspect -> String
9131
+ def inspect
9132
+ InspectVisitor.compose(self)
9664
9133
  end
9665
9134
 
9666
9135
  # Sometimes you want to check an instance of a node against a list of
@@ -9851,36 +9320,9 @@ module Prism
9851
9320
  operator_loc.slice
9852
9321
  end
9853
9322
 
9854
- # def inspect(NodeInspector inspector) -> String
9855
- def inspect(inspector = NodeInspector.new)
9856
- inspector << inspector.header(self)
9857
- flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?), ("attribute_write" if attribute_write?), ("ignore_visibility" if ignore_visibility?)].compact
9858
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
9859
- if (receiver = self.receiver).nil?
9860
- inspector << "├── receiver: ∅\n"
9861
- else
9862
- inspector << "├── receiver:\n"
9863
- inspector << receiver.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
9864
- end
9865
- inspector << "├── call_operator_loc: #{inspector.location(call_operator_loc)}\n"
9866
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
9867
- if (arguments = self.arguments).nil?
9868
- inspector << "├── arguments: ∅\n"
9869
- else
9870
- inspector << "├── arguments:\n"
9871
- inspector << arguments.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
9872
- end
9873
- inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
9874
- if (block = self.block).nil?
9875
- inspector << "├── block: ∅\n"
9876
- else
9877
- inspector << "├── block:\n"
9878
- inspector << block.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
9879
- end
9880
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
9881
- inspector << "└── value:\n"
9882
- inspector << inspector.child_node(value, " ")
9883
- inspector.to_str
9323
+ # def inspect -> String
9324
+ def inspect
9325
+ InspectVisitor.compose(self)
9884
9326
  end
9885
9327
 
9886
9328
  # Sometimes you want to check an instance of a node against a list of
@@ -10075,37 +9517,9 @@ module Prism
10075
9517
  closing_loc.slice
10076
9518
  end
10077
9519
 
10078
- # def inspect(NodeInspector inspector) -> String
10079
- def inspect(inspector = NodeInspector.new)
10080
- inspector << inspector.header(self)
10081
- flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?), ("attribute_write" if attribute_write?), ("ignore_visibility" if ignore_visibility?)].compact
10082
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
10083
- if (receiver = self.receiver).nil?
10084
- inspector << "├── receiver: ∅\n"
10085
- else
10086
- inspector << "├── receiver:\n"
10087
- inspector << receiver.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
10088
- end
10089
- inspector << "├── call_operator_loc: #{inspector.location(call_operator_loc)}\n"
10090
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
10091
- if (arguments = self.arguments).nil?
10092
- inspector << "├── arguments: ∅\n"
10093
- else
10094
- inspector << "├── arguments:\n"
10095
- inspector << arguments.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
10096
- end
10097
- inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
10098
- if (block = self.block).nil?
10099
- inspector << "├── block: ∅\n"
10100
- else
10101
- inspector << "├── block:\n"
10102
- inspector << block.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
10103
- end
10104
- inspector << "├── operator: #{operator.inspect}\n"
10105
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
10106
- inspector << "└── value:\n"
10107
- inspector << inspector.child_node(value, " ")
10108
- inspector.to_str
9520
+ # def inspect -> String
9521
+ def inspect
9522
+ InspectVisitor.compose(self)
10109
9523
  end
10110
9524
 
10111
9525
  # Sometimes you want to check an instance of a node against a list of
@@ -10302,36 +9716,9 @@ module Prism
10302
9716
  operator_loc.slice
10303
9717
  end
10304
9718
 
10305
- # def inspect(NodeInspector inspector) -> String
10306
- def inspect(inspector = NodeInspector.new)
10307
- inspector << inspector.header(self)
10308
- flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?), ("attribute_write" if attribute_write?), ("ignore_visibility" if ignore_visibility?)].compact
10309
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
10310
- if (receiver = self.receiver).nil?
10311
- inspector << "├── receiver: ∅\n"
10312
- else
10313
- inspector << "├── receiver:\n"
10314
- inspector << receiver.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
10315
- end
10316
- inspector << "├── call_operator_loc: #{inspector.location(call_operator_loc)}\n"
10317
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
10318
- if (arguments = self.arguments).nil?
10319
- inspector << "├── arguments: ∅\n"
10320
- else
10321
- inspector << "├── arguments:\n"
10322
- inspector << arguments.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
10323
- end
10324
- inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
10325
- if (block = self.block).nil?
10326
- inspector << "├── block: ∅\n"
10327
- else
10328
- inspector << "├── block:\n"
10329
- inspector << block.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
10330
- end
10331
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
10332
- inspector << "└── value:\n"
10333
- inspector << inspector.child_node(value, " ")
10334
- inspector.to_str
9719
+ # def inspect -> String
9720
+ def inspect
9721
+ InspectVisitor.compose(self)
10335
9722
  end
10336
9723
 
10337
9724
  # Sometimes you want to check an instance of a node against a list of
@@ -10498,28 +9885,9 @@ module Prism
10498
9885
  closing_loc.slice
10499
9886
  end
10500
9887
 
10501
- # def inspect(NodeInspector inspector) -> String
10502
- def inspect(inspector = NodeInspector.new)
10503
- inspector << inspector.header(self)
10504
- flags = [("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?), ("attribute_write" if attribute_write?), ("ignore_visibility" if ignore_visibility?)].compact
10505
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
10506
- inspector << "├── receiver:\n"
10507
- inspector << inspector.child_node(receiver, "│ ")
10508
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
10509
- if (arguments = self.arguments).nil?
10510
- inspector << "├── arguments: ∅\n"
10511
- else
10512
- inspector << "├── arguments:\n"
10513
- inspector << arguments.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
10514
- end
10515
- inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
10516
- if (block = self.block).nil?
10517
- inspector << "└── block: ∅\n"
10518
- else
10519
- inspector << "└── block:\n"
10520
- inspector << block.inspect(inspector.child_inspector(" ")).delete_prefix(inspector.prefix)
10521
- end
10522
- inspector.to_str
9888
+ # def inspect -> String
9889
+ def inspect
9890
+ InspectVisitor.compose(self)
10523
9891
  end
10524
9892
 
10525
9893
  # Sometimes you want to check an instance of a node against a list of
@@ -10637,15 +10005,9 @@ module Prism
10637
10005
  operator_loc.slice
10638
10006
  end
10639
10007
 
10640
- # def inspect(NodeInspector inspector) -> String
10641
- def inspect(inspector = NodeInspector.new)
10642
- inspector << inspector.header(self)
10643
- inspector << "├── name: #{name.inspect}\n"
10644
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
10645
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
10646
- inspector << "└── value:\n"
10647
- inspector << inspector.child_node(value, " ")
10648
- inspector.to_str
10008
+ # def inspect -> String
10009
+ def inspect
10010
+ InspectVisitor.compose(self)
10649
10011
  end
10650
10012
 
10651
10013
  # Sometimes you want to check an instance of a node against a list of
@@ -10760,16 +10122,9 @@ module Prism
10760
10122
  # attr_reader operator: Symbol
10761
10123
  attr_reader :operator
10762
10124
 
10763
- # def inspect(NodeInspector inspector) -> String
10764
- def inspect(inspector = NodeInspector.new)
10765
- inspector << inspector.header(self)
10766
- inspector << "├── name: #{name.inspect}\n"
10767
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
10768
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
10769
- inspector << "├── value:\n"
10770
- inspector << inspector.child_node(value, "│ ")
10771
- inspector << "└── operator: #{operator.inspect}\n"
10772
- inspector.to_str
10125
+ # def inspect -> String
10126
+ def inspect
10127
+ InspectVisitor.compose(self)
10773
10128
  end
10774
10129
 
10775
10130
  # Sometimes you want to check an instance of a node against a list of
@@ -10886,15 +10241,9 @@ module Prism
10886
10241
  operator_loc.slice
10887
10242
  end
10888
10243
 
10889
- # def inspect(NodeInspector inspector) -> String
10890
- def inspect(inspector = NodeInspector.new)
10891
- inspector << inspector.header(self)
10892
- inspector << "├── name: #{name.inspect}\n"
10893
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
10894
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
10895
- inspector << "└── value:\n"
10896
- inspector << inspector.child_node(value, " ")
10897
- inspector.to_str
10244
+ # def inspect -> String
10245
+ def inspect
10246
+ InspectVisitor.compose(self)
10898
10247
  end
10899
10248
 
10900
10249
  # Sometimes you want to check an instance of a node against a list of
@@ -10989,11 +10338,9 @@ module Prism
10989
10338
  # @_test # name `:@_test`
10990
10339
  attr_reader :name
10991
10340
 
10992
- # def inspect(NodeInspector inspector) -> String
10993
- def inspect(inspector = NodeInspector.new)
10994
- inspector << inspector.header(self)
10995
- inspector << "└── name: #{name.inspect}\n"
10996
- inspector.to_str
10341
+ # def inspect -> String
10342
+ def inspect
10343
+ InspectVisitor.compose(self)
10997
10344
  end
10998
10345
 
10999
10346
  # Sometimes you want to check an instance of a node against a list of
@@ -11081,11 +10428,9 @@ module Prism
11081
10428
  # attr_reader name: Symbol
11082
10429
  attr_reader :name
11083
10430
 
11084
- # def inspect(NodeInspector inspector) -> String
11085
- def inspect(inspector = NodeInspector.new)
11086
- inspector << inspector.header(self)
11087
- inspector << "└── name: #{name.inspect}\n"
11088
- inspector.to_str
10431
+ # def inspect -> String
10432
+ def inspect
10433
+ InspectVisitor.compose(self)
11089
10434
  end
11090
10435
 
11091
10436
  # Sometimes you want to check an instance of a node against a list of
@@ -11214,15 +10559,9 @@ module Prism
11214
10559
  operator_loc.slice
11215
10560
  end
11216
10561
 
11217
- # def inspect(NodeInspector inspector) -> String
11218
- def inspect(inspector = NodeInspector.new)
11219
- inspector << inspector.header(self)
11220
- inspector << "├── name: #{name.inspect}\n"
11221
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
11222
- inspector << "├── value:\n"
11223
- inspector << inspector.child_node(value, "│ ")
11224
- inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
11225
- inspector.to_str
10562
+ # def inspect -> String
10563
+ def inspect
10564
+ InspectVisitor.compose(self)
11226
10565
  end
11227
10566
 
11228
10567
  # Sometimes you want to check an instance of a node against a list of
@@ -11338,13 +10677,9 @@ module Prism
11338
10677
  flags.anybits?(IntegerBaseFlags::HEXADECIMAL)
11339
10678
  end
11340
10679
 
11341
- # def inspect(NodeInspector inspector) -> String
11342
- def inspect(inspector = NodeInspector.new)
11343
- inspector << inspector.header(self)
11344
- flags = [("binary" if binary?), ("decimal" if decimal?), ("octal" if octal?), ("hexadecimal" if hexadecimal?)].compact
11345
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
11346
- inspector << "└── value: #{value.inspect}\n"
11347
- inspector.to_str
10680
+ # def inspect -> String
10681
+ def inspect
10682
+ InspectVisitor.compose(self)
11348
10683
  end
11349
10684
 
11350
10685
  # Sometimes you want to check an instance of a node against a list of
@@ -11524,15 +10859,9 @@ module Prism
11524
10859
  closing_loc.slice
11525
10860
  end
11526
10861
 
11527
- # def inspect(NodeInspector inspector) -> String
11528
- def inspect(inspector = NodeInspector.new)
11529
- inspector << inspector.header(self)
11530
- flags = [("ignore_case" if ignore_case?), ("extended" if extended?), ("multi_line" if multi_line?), ("once" if once?), ("euc_jp" if euc_jp?), ("ascii_8bit" if ascii_8bit?), ("windows_31j" if windows_31j?), ("utf_8" if utf_8?), ("forced_utf8_encoding" if forced_utf8_encoding?), ("forced_binary_encoding" if forced_binary_encoding?), ("forced_us_ascii_encoding" if forced_us_ascii_encoding?)].compact
11531
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
11532
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
11533
- inspector << "├── parts: #{inspector.list("#{inspector.prefix}│ ", parts)}"
11534
- inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n"
11535
- inspector.to_str
10862
+ # def inspect -> String
10863
+ def inspect
10864
+ InspectVisitor.compose(self)
11536
10865
  end
11537
10866
 
11538
10867
  # Sometimes you want to check an instance of a node against a list of
@@ -11715,15 +11044,9 @@ module Prism
11715
11044
  closing_loc.slice
11716
11045
  end
11717
11046
 
11718
- # def inspect(NodeInspector inspector) -> String
11719
- def inspect(inspector = NodeInspector.new)
11720
- inspector << inspector.header(self)
11721
- flags = [("ignore_case" if ignore_case?), ("extended" if extended?), ("multi_line" if multi_line?), ("once" if once?), ("euc_jp" if euc_jp?), ("ascii_8bit" if ascii_8bit?), ("windows_31j" if windows_31j?), ("utf_8" if utf_8?), ("forced_utf8_encoding" if forced_utf8_encoding?), ("forced_binary_encoding" if forced_binary_encoding?), ("forced_us_ascii_encoding" if forced_us_ascii_encoding?)].compact
11722
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
11723
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
11724
- inspector << "├── parts: #{inspector.list("#{inspector.prefix}│ ", parts)}"
11725
- inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n"
11726
- inspector.to_str
11047
+ # def inspect -> String
11048
+ def inspect
11049
+ InspectVisitor.compose(self)
11727
11050
  end
11728
11051
 
11729
11052
  # Sometimes you want to check an instance of a node against a list of
@@ -11873,15 +11196,9 @@ module Prism
11873
11196
  closing_loc&.slice
11874
11197
  end
11875
11198
 
11876
- # def inspect(NodeInspector inspector) -> String
11877
- def inspect(inspector = NodeInspector.new)
11878
- inspector << inspector.header(self)
11879
- flags = [("frozen" if frozen?), ("mutable" if mutable?)].compact
11880
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
11881
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
11882
- inspector << "├── parts: #{inspector.list("#{inspector.prefix}│ ", parts)}"
11883
- inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n"
11884
- inspector.to_str
11199
+ # def inspect -> String
11200
+ def inspect
11201
+ InspectVisitor.compose(self)
11885
11202
  end
11886
11203
 
11887
11204
  # Sometimes you want to check an instance of a node against a list of
@@ -12016,13 +11333,9 @@ module Prism
12016
11333
  closing_loc&.slice
12017
11334
  end
12018
11335
 
12019
- # def inspect(NodeInspector inspector) -> String
12020
- def inspect(inspector = NodeInspector.new)
12021
- inspector << inspector.header(self)
12022
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
12023
- inspector << "├── parts: #{inspector.list("#{inspector.prefix}│ ", parts)}"
12024
- inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n"
12025
- inspector.to_str
11336
+ # def inspect -> String
11337
+ def inspect
11338
+ InspectVisitor.compose(self)
12026
11339
  end
12027
11340
 
12028
11341
  # Sometimes you want to check an instance of a node against a list of
@@ -12144,13 +11457,9 @@ module Prism
12144
11457
  closing_loc.slice
12145
11458
  end
12146
11459
 
12147
- # def inspect(NodeInspector inspector) -> String
12148
- def inspect(inspector = NodeInspector.new)
12149
- inspector << inspector.header(self)
12150
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
12151
- inspector << "├── parts: #{inspector.list("#{inspector.prefix}│ ", parts)}"
12152
- inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n"
12153
- inspector.to_str
11460
+ # def inspect -> String
11461
+ def inspect
11462
+ InspectVisitor.compose(self)
12154
11463
  end
12155
11464
 
12156
11465
  # Sometimes you want to check an instance of a node against a list of
@@ -12237,10 +11546,9 @@ module Prism
12237
11546
  { location: location }
12238
11547
  end
12239
11548
 
12240
- # def inspect(NodeInspector inspector) -> String
12241
- def inspect(inspector = NodeInspector.new)
12242
- inspector << inspector.header(self)
12243
- inspector.to_str
11549
+ # def inspect -> String
11550
+ def inspect
11551
+ InspectVisitor.compose(self)
12244
11552
  end
12245
11553
 
12246
11554
  # Sometimes you want to check an instance of a node against a list of
@@ -12337,13 +11645,9 @@ module Prism
12337
11645
  flags.anybits?(KeywordHashNodeFlags::SYMBOL_KEYS)
12338
11646
  end
12339
11647
 
12340
- # def inspect(NodeInspector inspector) -> String
12341
- def inspect(inspector = NodeInspector.new)
12342
- inspector << inspector.header(self)
12343
- flags = [("symbol_keys" if symbol_keys?)].compact
12344
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
12345
- inspector << "└── elements: #{inspector.list("#{inspector.prefix} ", elements)}"
12346
- inspector.to_str
11648
+ # def inspect -> String
11649
+ def inspect
11650
+ InspectVisitor.compose(self)
12347
11651
  end
12348
11652
 
12349
11653
  # Sometimes you want to check an instance of a node against a list of
@@ -12471,19 +11775,9 @@ module Prism
12471
11775
  operator_loc.slice
12472
11776
  end
12473
11777
 
12474
- # def inspect(NodeInspector inspector) -> String
12475
- def inspect(inspector = NodeInspector.new)
12476
- inspector << inspector.header(self)
12477
- flags = [("repeated_parameter" if repeated_parameter?)].compact
12478
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
12479
- if (name = self.name).nil?
12480
- inspector << "├── name: ∅\n"
12481
- else
12482
- inspector << "├── name: #{name.inspect}\n"
12483
- end
12484
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
12485
- inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
12486
- inspector.to_str
11778
+ # def inspect -> String
11779
+ def inspect
11780
+ InspectVisitor.compose(self)
12487
11781
  end
12488
11782
 
12489
11783
  # Sometimes you want to check an instance of a node against a list of
@@ -12624,26 +11918,9 @@ module Prism
12624
11918
  closing_loc.slice
12625
11919
  end
12626
11920
 
12627
- # def inspect(NodeInspector inspector) -> String
12628
- def inspect(inspector = NodeInspector.new)
12629
- inspector << inspector.header(self)
12630
- inspector << "├── locals: #{locals.inspect}\n"
12631
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
12632
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
12633
- inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
12634
- if (parameters = self.parameters).nil?
12635
- inspector << "├── parameters: ∅\n"
12636
- else
12637
- inspector << "├── parameters:\n"
12638
- inspector << parameters.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
12639
- end
12640
- if (body = self.body).nil?
12641
- inspector << "└── body: ∅\n"
12642
- else
12643
- inspector << "└── body:\n"
12644
- inspector << body.inspect(inspector.child_inspector(" ")).delete_prefix(inspector.prefix)
12645
- end
12646
- inspector.to_str
11921
+ # def inspect -> String
11922
+ def inspect
11923
+ InspectVisitor.compose(self)
12647
11924
  end
12648
11925
 
12649
11926
  # Sometimes you want to check an instance of a node against a list of
@@ -12766,16 +12043,9 @@ module Prism
12766
12043
  operator_loc.slice
12767
12044
  end
12768
12045
 
12769
- # def inspect(NodeInspector inspector) -> String
12770
- def inspect(inspector = NodeInspector.new)
12771
- inspector << inspector.header(self)
12772
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
12773
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
12774
- inspector << "├── value:\n"
12775
- inspector << inspector.child_node(value, "│ ")
12776
- inspector << "├── name: #{name.inspect}\n"
12777
- inspector << "└── depth: #{depth.inspect}\n"
12778
- inspector.to_str
12046
+ # def inspect -> String
12047
+ def inspect
12048
+ InspectVisitor.compose(self)
12779
12049
  end
12780
12050
 
12781
12051
  # Sometimes you want to check an instance of a node against a list of
@@ -12895,17 +12165,9 @@ module Prism
12895
12165
  # attr_reader depth: Integer
12896
12166
  attr_reader :depth
12897
12167
 
12898
- # def inspect(NodeInspector inspector) -> String
12899
- def inspect(inspector = NodeInspector.new)
12900
- inspector << inspector.header(self)
12901
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
12902
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
12903
- inspector << "├── value:\n"
12904
- inspector << inspector.child_node(value, "│ ")
12905
- inspector << "├── name: #{name.inspect}\n"
12906
- inspector << "├── operator: #{operator.inspect}\n"
12907
- inspector << "└── depth: #{depth.inspect}\n"
12908
- inspector.to_str
12168
+ # def inspect -> String
12169
+ def inspect
12170
+ InspectVisitor.compose(self)
12909
12171
  end
12910
12172
 
12911
12173
  # Sometimes you want to check an instance of a node against a list of
@@ -13027,16 +12289,9 @@ module Prism
13027
12289
  operator_loc.slice
13028
12290
  end
13029
12291
 
13030
- # def inspect(NodeInspector inspector) -> String
13031
- def inspect(inspector = NodeInspector.new)
13032
- inspector << inspector.header(self)
13033
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
13034
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
13035
- inspector << "├── value:\n"
13036
- inspector << inspector.child_node(value, "│ ")
13037
- inspector << "├── name: #{name.inspect}\n"
13038
- inspector << "└── depth: #{depth.inspect}\n"
13039
- inspector.to_str
12292
+ # def inspect -> String
12293
+ def inspect
12294
+ InspectVisitor.compose(self)
13040
12295
  end
13041
12296
 
13042
12297
  # Sometimes you want to check an instance of a node against a list of
@@ -13150,12 +12405,9 @@ module Prism
13150
12405
  # The specific rules for calculating the depth may differ from individual Ruby implementations, as they are not specified by the language. For more information, see [the Prism documentation](https://github.com/ruby/prism/blob/main/docs/local_variable_depth.md).
13151
12406
  attr_reader :depth
13152
12407
 
13153
- # def inspect(NodeInspector inspector) -> String
13154
- def inspect(inspector = NodeInspector.new)
13155
- inspector << inspector.header(self)
13156
- inspector << "├── name: #{name.inspect}\n"
13157
- inspector << "└── depth: #{depth.inspect}\n"
13158
- inspector.to_str
12408
+ # def inspect -> String
12409
+ def inspect
12410
+ InspectVisitor.compose(self)
13159
12411
  end
13160
12412
 
13161
12413
  # Sometimes you want to check an instance of a node against a list of
@@ -13248,12 +12500,9 @@ module Prism
13248
12500
  # attr_reader depth: Integer
13249
12501
  attr_reader :depth
13250
12502
 
13251
- # def inspect(NodeInspector inspector) -> String
13252
- def inspect(inspector = NodeInspector.new)
13253
- inspector << inspector.header(self)
13254
- inspector << "├── name: #{name.inspect}\n"
13255
- inspector << "└── depth: #{depth.inspect}\n"
13256
- inspector.to_str
12503
+ # def inspect -> String
12504
+ def inspect
12505
+ InspectVisitor.compose(self)
13257
12506
  end
13258
12507
 
13259
12508
  # Sometimes you want to check an instance of a node against a list of
@@ -13397,16 +12646,9 @@ module Prism
13397
12646
  operator_loc.slice
13398
12647
  end
13399
12648
 
13400
- # def inspect(NodeInspector inspector) -> String
13401
- def inspect(inspector = NodeInspector.new)
13402
- inspector << inspector.header(self)
13403
- inspector << "├── name: #{name.inspect}\n"
13404
- inspector << "├── depth: #{depth.inspect}\n"
13405
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
13406
- inspector << "├── value:\n"
13407
- inspector << inspector.child_node(value, "│ ")
13408
- inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
13409
- inspector.to_str
12649
+ # def inspect -> String
12650
+ def inspect
12651
+ InspectVisitor.compose(self)
13410
12652
  end
13411
12653
 
13412
12654
  # Sometimes you want to check an instance of a node against a list of
@@ -13597,16 +12839,9 @@ module Prism
13597
12839
  closing_loc.slice
13598
12840
  end
13599
12841
 
13600
- # def inspect(NodeInspector inspector) -> String
13601
- def inspect(inspector = NodeInspector.new)
13602
- inspector << inspector.header(self)
13603
- flags = [("ignore_case" if ignore_case?), ("extended" if extended?), ("multi_line" if multi_line?), ("once" if once?), ("euc_jp" if euc_jp?), ("ascii_8bit" if ascii_8bit?), ("windows_31j" if windows_31j?), ("utf_8" if utf_8?), ("forced_utf8_encoding" if forced_utf8_encoding?), ("forced_binary_encoding" if forced_binary_encoding?), ("forced_us_ascii_encoding" if forced_us_ascii_encoding?)].compact
13604
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
13605
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
13606
- inspector << "├── content_loc: #{inspector.location(content_loc)}\n"
13607
- inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
13608
- inspector << "└── unescaped: #{unescaped.inspect}\n"
13609
- inspector.to_str
12842
+ # def inspect -> String
12843
+ def inspect
12844
+ InspectVisitor.compose(self)
13610
12845
  end
13611
12846
 
13612
12847
  # Sometimes you want to check an instance of a node against a list of
@@ -13715,15 +12950,9 @@ module Prism
13715
12950
  operator_loc.slice
13716
12951
  end
13717
12952
 
13718
- # def inspect(NodeInspector inspector) -> String
13719
- def inspect(inspector = NodeInspector.new)
13720
- inspector << inspector.header(self)
13721
- inspector << "├── value:\n"
13722
- inspector << inspector.child_node(value, "│ ")
13723
- inspector << "├── pattern:\n"
13724
- inspector << inspector.child_node(pattern, "│ ")
13725
- inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
13726
- inspector.to_