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_str
12953
+ # def inspect -> String
12954
+ def inspect
12955
+ InspectVisitor.compose(self)
13727
12956
  end
13728
12957
 
13729
12958
  # Sometimes you want to check an instance of a node against a list of
@@ -13830,15 +13059,9 @@ module Prism
13830
13059
  operator_loc.slice
13831
13060
  end
13832
13061
 
13833
- # def inspect(NodeInspector inspector) -> String
13834
- def inspect(inspector = NodeInspector.new)
13835
- inspector << inspector.header(self)
13836
- inspector << "├── value:\n"
13837
- inspector << inspector.child_node(value, "│ ")
13838
- inspector << "├── pattern:\n"
13839
- inspector << inspector.child_node(pattern, "│ ")
13840
- inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
13841
- inspector.to_str
13062
+ # def inspect -> String
13063
+ def inspect
13064
+ InspectVisitor.compose(self)
13842
13065
  end
13843
13066
 
13844
13067
  # Sometimes you want to check an instance of a node against a list of
@@ -13932,13 +13155,9 @@ module Prism
13932
13155
  # attr_reader targets: Array[LocalVariableTargetNode]
13933
13156
  attr_reader :targets
13934
13157
 
13935
- # def inspect(NodeInspector inspector) -> String
13936
- def inspect(inspector = NodeInspector.new)
13937
- inspector << inspector.header(self)
13938
- inspector << "├── call:\n"
13939
- inspector << inspector.child_node(call, "│ ")
13940
- inspector << "└── targets: #{inspector.list("#{inspector.prefix} ", targets)}"
13941
- inspector.to_str
13158
+ # def inspect -> String
13159
+ def inspect
13160
+ InspectVisitor.compose(self)
13942
13161
  end
13943
13162
 
13944
13163
  # Sometimes you want to check an instance of a node against a list of
@@ -14021,10 +13240,9 @@ module Prism
14021
13240
  { location: location }
14022
13241
  end
14023
13242
 
14024
- # def inspect(NodeInspector inspector) -> String
14025
- def inspect(inspector = NodeInspector.new)
14026
- inspector << inspector.header(self)
14027
- inspector.to_str
13243
+ # def inspect -> String
13244
+ def inspect
13245
+ InspectVisitor.compose(self)
14028
13246
  end
14029
13247
 
14030
13248
  # Sometimes you want to check an instance of a node against a list of
@@ -14152,22 +13370,9 @@ module Prism
14152
13370
  end_keyword_loc.slice
14153
13371
  end
14154
13372
 
14155
- # def inspect(NodeInspector inspector) -> String
14156
- def inspect(inspector = NodeInspector.new)
14157
- inspector << inspector.header(self)
14158
- inspector << "├── locals: #{locals.inspect}\n"
14159
- inspector << "├── module_keyword_loc: #{inspector.location(module_keyword_loc)}\n"
14160
- inspector << "├── constant_path:\n"
14161
- inspector << inspector.child_node(constant_path, "│ ")
14162
- if (body = self.body).nil?
14163
- inspector << "├── body: ∅\n"
14164
- else
14165
- inspector << "├── body:\n"
14166
- inspector << body.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
14167
- end
14168
- inspector << "├── end_keyword_loc: #{inspector.location(end_keyword_loc)}\n"
14169
- inspector << "└── name: #{name.inspect}\n"
14170
- inspector.to_str
13373
+ # def inspect -> String
13374
+ def inspect
13375
+ InspectVisitor.compose(self)
14171
13376
  end
14172
13377
 
14173
13378
  # Sometimes you want to check an instance of a node against a list of
@@ -14311,20 +13516,9 @@ module Prism
14311
13516
  rparen_loc&.slice
14312
13517
  end
14313
13518
 
14314
- # def inspect(NodeInspector inspector) -> String
14315
- def inspect(inspector = NodeInspector.new)
14316
- inspector << inspector.header(self)
14317
- inspector << "├── lefts: #{inspector.list("#{inspector.prefix}│ ", lefts)}"
14318
- if (rest = self.rest).nil?
14319
- inspector << "├── rest: ∅\n"
14320
- else
14321
- inspector << "├── rest:\n"
14322
- inspector << rest.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
14323
- end
14324
- inspector << "├── rights: #{inspector.list("#{inspector.prefix}│ ", rights)}"
14325
- inspector << "├── lparen_loc: #{inspector.location(lparen_loc)}\n"
14326
- inspector << "└── rparen_loc: #{inspector.location(rparen_loc)}\n"
14327
- inspector.to_str
13519
+ # def inspect -> String
13520
+ def inspect
13521
+ InspectVisitor.compose(self)
14328
13522
  end
14329
13523
 
14330
13524
  # Sometimes you want to check an instance of a node against a list of
@@ -14486,23 +13680,9 @@ module Prism
14486
13680
  operator_loc.slice
14487
13681
  end
14488
13682
 
14489
- # def inspect(NodeInspector inspector) -> String
14490
- def inspect(inspector = NodeInspector.new)
14491
- inspector << inspector.header(self)
14492
- inspector << "├── lefts: #{inspector.list("#{inspector.prefix}│ ", lefts)}"
14493
- if (rest = self.rest).nil?
14494
- inspector << "├── rest: ∅\n"
14495
- else
14496
- inspector << "├── rest:\n"
14497
- inspector << rest.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
14498
- end
14499
- inspector << "├── rights: #{inspector.list("#{inspector.prefix}│ ", rights)}"
14500
- inspector << "├── lparen_loc: #{inspector.location(lparen_loc)}\n"
14501
- inspector << "├── rparen_loc: #{inspector.location(rparen_loc)}\n"
14502
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
14503
- inspector << "└── value:\n"
14504
- inspector << inspector.child_node(value, " ")
14505
- inspector.to_str
13683
+ # def inspect -> String
13684
+ def inspect
13685
+ InspectVisitor.compose(self)
14506
13686
  end
14507
13687
 
14508
13688
  # Sometimes you want to check an instance of a node against a list of
@@ -14613,17 +13793,9 @@ module Prism
14613
13793
  keyword_loc.slice
14614
13794
  end
14615
13795
 
14616
- # def inspect(NodeInspector inspector) -> String
14617
- def inspect(inspector = NodeInspector.new)
14618
- inspector << inspector.header(self)
14619
- if (arguments = self.arguments).nil?
14620
- inspector << "├── arguments: ∅\n"
14621
- else
14622
- inspector << "├── arguments:\n"
14623
- inspector << arguments.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
14624
- end
14625
- inspector << "└── keyword_loc: #{inspector.location(keyword_loc)}\n"
14626
- inspector.to_str
13796
+ # def inspect -> String
13797
+ def inspect
13798
+ InspectVisitor.compose(self)
14627
13799
  end
14628
13800
 
14629
13801
  # Sometimes you want to check an instance of a node against a list of
@@ -14708,10 +13880,9 @@ module Prism
14708
13880
  { location: location }
14709
13881
  end
14710
13882
 
14711
- # def inspect(NodeInspector inspector) -> String
14712
- def inspect(inspector = NodeInspector.new)
14713
- inspector << inspector.header(self)
14714
- inspector.to_str
13883
+ # def inspect -> String
13884
+ def inspect
13885
+ InspectVisitor.compose(self)
14715
13886
  end
14716
13887
 
14717
13888
  # Sometimes you want to check an instance of a node against a list of
@@ -14821,12 +13992,9 @@ module Prism
14821
13992
  keyword_loc.slice
14822
13993
  end
14823
13994
 
14824
- # def inspect(NodeInspector inspector) -> String
14825
- def inspect(inspector = NodeInspector.new)
14826
- inspector << inspector.header(self)
14827
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
14828
- inspector << "└── keyword_loc: #{inspector.location(keyword_loc)}\n"
14829
- inspector.to_str
13995
+ # def inspect -> String
13996
+ def inspect
13997
+ InspectVisitor.compose(self)
14830
13998
  end
14831
13999
 
14832
14000
  # Sometimes you want to check an instance of a node against a list of
@@ -14915,11 +14083,9 @@ module Prism
14915
14083
  # attr_reader maximum: Integer
14916
14084
  attr_reader :maximum
14917
14085
 
14918
- # def inspect(NodeInspector inspector) -> String
14919
- def inspect(inspector = NodeInspector.new)
14920
- inspector << inspector.header(self)
14921
- inspector << "└── maximum: #{maximum.inspect}\n"
14922
- inspector.to_str
14086
+ # def inspect -> String
14087
+ def inspect
14088
+ InspectVisitor.compose(self)
14923
14089
  end
14924
14090
 
14925
14091
  # Sometimes you want to check an instance of a node against a list of
@@ -15013,11 +14179,9 @@ module Prism
15013
14179
  # $4294967296 # number `0`
15014
14180
  attr_reader :number
15015
14181
 
15016
- # def inspect(NodeInspector inspector) -> String
15017
- def inspect(inspector = NodeInspector.new)
15018
- inspector << inspector.header(self)
15019
- inspector << "└── number: #{number.inspect}\n"
15020
- inspector.to_str
14182
+ # def inspect -> String
14183
+ def inspect
14184
+ InspectVisitor.compose(self)
15021
14185
  end
15022
14186
 
15023
14187
  # Sometimes you want to check an instance of a node against a list of
@@ -15128,16 +14292,9 @@ module Prism
15128
14292
  flags.anybits?(ParameterFlags::REPEATED_PARAMETER)
15129
14293
  end
15130
14294
 
15131
- # def inspect(NodeInspector inspector) -> String
15132
- def inspect(inspector = NodeInspector.new)
15133
- inspector << inspector.header(self)
15134
- flags = [("repeated_parameter" if repeated_parameter?)].compact
15135
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
15136
- inspector << "├── name: #{name.inspect}\n"
15137
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
15138
- inspector << "└── value:\n"
15139
- inspector << inspector.child_node(value, " ")
15140
- inspector.to_str
14295
+ # def inspect -> String
14296
+ def inspect
14297
+ InspectVisitor.compose(self)
15141
14298
  end
15142
14299
 
15143
14300
  # Sometimes you want to check an instance of a node against a list of
@@ -15264,17 +14421,9 @@ module Prism
15264
14421
  operator_loc.slice
15265
14422
  end
15266
14423
 
15267
- # def inspect(NodeInspector inspector) -> String
15268
- def inspect(inspector = NodeInspector.new)
15269
- inspector << inspector.header(self)
15270
- flags = [("repeated_parameter" if repeated_parameter?)].compact
15271
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
15272
- inspector << "├── name: #{name.inspect}\n"
15273
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
15274
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
15275
- inspector << "└── value:\n"
15276
- inspector << inspector.child_node(value, " ")
15277
- inspector.to_str
14424
+ # def inspect -> String
14425
+ def inspect
14426
+ InspectVisitor.compose(self)
15278
14427
  end
15279
14428
 
15280
14429
  # Sometimes you want to check an instance of a node against a list of
@@ -15398,15 +14547,9 @@ module Prism
15398
14547
  operator_loc.slice
15399
14548
  end
15400
14549
 
15401
- # def inspect(NodeInspector inspector) -> String
15402
- def inspect(inspector = NodeInspector.new)
15403
- inspector << inspector.header(self)
15404
- inspector << "├── left:\n"
15405
- inspector << inspector.child_node(left, "│ ")
15406
- inspector << "├── right:\n"
15407
- inspector << inspector.child_node(right, "│ ")
15408
- inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
15409
- inspector.to_str
14550
+ # def inspect -> String
14551
+ def inspect
14552
+ InspectVisitor.compose(self)
15410
14553
  end
15411
14554
 
15412
14555
  # Sometimes you want to check an instance of a node against a list of
@@ -15529,32 +14672,9 @@ module Prism
15529
14672
  # attr_reader block: BlockParameterNode?
15530
14673
  attr_reader :block
15531
14674
 
15532
- # def inspect(NodeInspector inspector) -> String
15533
- def inspect(inspector = NodeInspector.new)
15534
- inspector << inspector.header(self)
15535
- inspector << "├── requireds: #{inspector.list("#{inspector.prefix}│ ", requireds)}"
15536
- inspector << "├── optionals: #{inspector.list("#{inspector.prefix}│ ", optionals)}"
15537
- if (rest = self.rest).nil?
15538
- inspector << "├── rest: ∅\n"
15539
- else
15540
- inspector << "├── rest:\n"
15541
- inspector << rest.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
15542
- end
15543
- inspector << "├── posts: #{inspector.list("#{inspector.prefix}│ ", posts)}"
15544
- inspector << "├── keywords: #{inspector.list("#{inspector.prefix}│ ", keywords)}"
15545
- if (keyword_rest = self.keyword_rest).nil?
15546
- inspector << "├── keyword_rest: ∅\n"
15547
- else
15548
- inspector << "├── keyword_rest:\n"
15549
- inspector << keyword_rest.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
15550
- end
15551
- if (block = self.block).nil?
15552
- inspector << "└── block: ∅\n"
15553
- else
15554
- inspector << "└── block:\n"
15555
- inspector << block.inspect(inspector.child_inspector(" ")).delete_prefix(inspector.prefix)
15556
- end
15557
- inspector.to_str
14675
+ # def inspect -> String
14676
+ def inspect
14677
+ InspectVisitor.compose(self)
15558
14678
  end
15559
14679
 
15560
14680
  # Sometimes you want to check an instance of a node against a list of
@@ -15684,18 +14804,9 @@ module Prism
15684
14804
  closing_loc.slice
15685
14805
  end
15686
14806
 
15687
- # def inspect(NodeInspector inspector) -> String
15688
- def inspect(inspector = NodeInspector.new)
15689
- inspector << inspector.header(self)
15690
- if (body = self.body).nil?
15691
- inspector << "├── body: ∅\n"
15692
- else
15693
- inspector << "├── body:\n"
15694
- inspector << body.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
15695
- end
15696
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
15697
- inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n"
15698
- inspector.to_str
14807
+ # def inspect -> String
14808
+ def inspect
14809
+ InspectVisitor.compose(self)
15699
14810
  end
15700
14811
 
15701
14812
  # Sometimes you want to check an instance of a node against a list of
@@ -15824,15 +14935,9 @@ module Prism
15824
14935
  rparen_loc.slice
15825
14936
  end
15826
14937
 
15827
- # def inspect(NodeInspector inspector) -> String
15828
- def inspect(inspector = NodeInspector.new)
15829
- inspector << inspector.header(self)
15830
- inspector << "├── expression:\n"
15831
- inspector << inspector.child_node(expression, "│ ")
15832
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
15833
- inspector << "├── lparen_loc: #{inspector.location(lparen_loc)}\n"
15834
- inspector << "└── rparen_loc: #{inspector.location(rparen_loc)}\n"
15835
- inspector.to_str
14938
+ # def inspect -> String
14939
+ def inspect
14940
+ InspectVisitor.compose(self)
15836
14941
  end
15837
14942
 
15838
14943
  # Sometimes you want to check an instance of a node against a list of
@@ -15936,13 +15041,9 @@ module Prism
15936
15041
  operator_loc.slice
15937
15042
  end
15938
15043
 
15939
- # def inspect(NodeInspector inspector) -> String
15940
- def inspect(inspector = NodeInspector.new)
15941
- inspector << inspector.header(self)
15942
- inspector << "├── variable:\n"
15943
- inspector << inspector.child_node(variable, "│ ")
15944
- inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
15945
- inspector.to_str
15044
+ # def inspect -> String
15045
+ def inspect
15046
+ InspectVisitor.compose(self)
15946
15047
  end
15947
15048
 
15948
15049
  # Sometimes you want to check an instance of a node against a list of
@@ -16072,19 +15173,9 @@ module Prism
16072
15173
  closing_loc.slice
16073
15174
  end
16074
15175
 
16075
- # def inspect(NodeInspector inspector) -> String
16076
- def inspect(inspector = NodeInspector.new)
16077
- inspector << inspector.header(self)
16078
- if (statements = self.statements).nil?
16079
- inspector << "├── statements: ∅\n"
16080
- else
16081
- inspector << "├── statements:\n"
16082
- inspector << statements.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
16083
- end
16084
- inspector << "├── keyword_loc: #{inspector.location(keyword_loc)}\n"
16085
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
16086
- inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n"
16087
- inspector.to_str
15176
+ # def inspect -> String
15177
+ def inspect
15178
+ InspectVisitor.compose(self)
16088
15179
  end
16089
15180
 
16090
15181
  # Sometimes you want to check an instance of a node against a list of
@@ -16216,19 +15307,9 @@ module Prism
16216
15307
  closing_loc.slice
16217
15308
  end
16218
15309
 
16219
- # def inspect(NodeInspector inspector) -> String
16220
- def inspect(inspector = NodeInspector.new)
16221
- inspector << inspector.header(self)
16222
- if (statements = self.statements).nil?
16223
- inspector << "├── statements: ∅\n"
16224
- else
16225
- inspector << "├── statements:\n"
16226
- inspector << statements.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
16227
- end
16228
- inspector << "├── keyword_loc: #{inspector.location(keyword_loc)}\n"
16229
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
16230
- inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n"
16231
- inspector.to_str
15310
+ # def inspect -> String
15311
+ def inspect
15312
+ InspectVisitor.compose(self)
16232
15313
  end
16233
15314
 
16234
15315
  # Sometimes you want to check an instance of a node against a list of
@@ -16320,13 +15401,9 @@ module Prism
16320
15401
  # attr_reader statements: StatementsNode
16321
15402
  attr_reader :statements
16322
15403
 
16323
- # def inspect(NodeInspector inspector) -> String
16324
- def inspect(inspector = NodeInspector.new)
16325
- inspector << inspector.header(self)
16326
- inspector << "├── locals: #{locals.inspect}\n"
16327
- inspector << "└── statements:\n"
16328
- inspector << inspector.child_node(statements, " ")
16329
- inspector.to_str
15404
+ # def inspect -> String
15405
+ def inspect
15406
+ InspectVisitor.compose(self)
16330
15407
  end
16331
15408
 
16332
15409
  # Sometimes you want to check an instance of a node against a list of
@@ -16462,25 +15539,9 @@ module Prism
16462
15539
  operator_loc.slice
16463
15540
  end
16464
15541
 
16465
- # def inspect(NodeInspector inspector) -> String
16466
- def inspect(inspector = NodeInspector.new)
16467
- inspector << inspector.header(self)
16468
- flags = [("exclude_end" if exclude_end?)].compact
16469
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
16470
- if (left = self.left).nil?
16471
- inspector << "├── left: ∅\n"
16472
- else
16473
- inspector << "├── left:\n"
16474
- inspector << left.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
16475
- end
16476
- if (right = self.right).nil?
16477
- inspector << "├── right: ∅\n"
16478
- else
16479
- inspector << "├── right:\n"
16480
- inspector << right.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
16481
- end
16482
- inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
16483
- inspector.to_str
15542
+ # def inspect -> String
15543
+ def inspect
15544
+ InspectVisitor.compose(self)
16484
15545
  end
16485
15546
 
16486
15547
  # Sometimes you want to check an instance of a node against a list of
@@ -16571,12 +15632,9 @@ module Prism
16571
15632
  # attr_reader numeric: Prism::node
16572
15633
  attr_reader :numeric
16573
15634
 
16574
- # def inspect(NodeInspector inspector) -> String
16575
- def inspect(inspector = NodeInspector.new)
16576
- inspector << inspector.header(self)
16577
- inspector << "└── numeric:\n"
16578
- inspector << inspector.child_node(numeric, " ")
16579
- inspector.to_str
15635
+ # def inspect -> String
15636
+ def inspect
15637
+ InspectVisitor.compose(self)
16580
15638
  end
16581
15639
 
16582
15640
  # Sometimes you want to check an instance of a node against a list of
@@ -16660,10 +15718,9 @@ module Prism
16660
15718
  { location: location }
16661
15719
  end
16662
15720
 
16663
- # def inspect(NodeInspector inspector) -> String
16664
- def inspect(inspector = NodeInspector.new)
16665
- inspector << inspector.header(self)
16666
- inspector.to_str
15721
+ # def inspect -> String
15722
+ def inspect
15723
+ InspectVisitor.compose(self)
16667
15724
  end
16668
15725
 
16669
15726
  # Sometimes you want to check an instance of a node against a list of
@@ -16849,16 +15906,9 @@ module Prism
16849
15906
  closing_loc.slice
16850
15907
  end
16851
15908
 
16852
- # def inspect(NodeInspector inspector) -> String
16853
- def inspect(inspector = NodeInspector.new)
16854
- inspector << inspector.header(self)
16855
- 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
16856
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
16857
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
16858
- inspector << "├── content_loc: #{inspector.location(content_loc)}\n"
16859
- inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
16860
- inspector << "└── unescaped: #{unescaped.inspect}\n"
16861
- inspector.to_str
15909
+ # def inspect -> String
15910
+ def inspect
15911
+ InspectVisitor.compose(self)
16862
15912
  end
16863
15913
 
16864
15914
  # Sometimes you want to check an instance of a node against a list of
@@ -16969,14 +16019,9 @@ module Prism
16969
16019
  flags.anybits?(ParameterFlags::REPEATED_PARAMETER)
16970
16020
  end
16971
16021
 
16972
- # def inspect(NodeInspector inspector) -> String
16973
- def inspect(inspector = NodeInspector.new)
16974
- inspector << inspector.header(self)
16975
- flags = [("repeated_parameter" if repeated_parameter?)].compact
16976
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
16977
- inspector << "├── name: #{name.inspect}\n"
16978
- inspector << "└── name_loc: #{inspector.location(name_loc)}\n"
16979
- inspector.to_str
16022
+ # def inspect -> String
16023
+ def inspect
16024
+ InspectVisitor.compose(self)
16980
16025
  end
16981
16026
 
16982
16027
  # Sometimes you want to check an instance of a node against a list of
@@ -17077,13 +16122,9 @@ module Prism
17077
16122
  flags.anybits?(ParameterFlags::REPEATED_PARAMETER)
17078
16123
  end
17079
16124
 
17080
- # def inspect(NodeInspector inspector) -> String
17081
- def inspect(inspector = NodeInspector.new)
17082
- inspector << inspector.header(self)
17083
- flags = [("repeated_parameter" if repeated_parameter?)].compact
17084
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
17085
- inspector << "└── name: #{name.inspect}\n"
17086
- inspector.to_str
16125
+ # def inspect -> String
16126
+ def inspect
16127
+ InspectVisitor.compose(self)
17087
16128
  end
17088
16129
 
17089
16130
  # Sometimes you want to check an instance of a node against a list of
@@ -17193,15 +16234,9 @@ module Prism
17193
16234
  keyword_loc.slice
17194
16235
  end
17195
16236
 
17196
- # def inspect(NodeInspector inspector) -> String
17197
- def inspect(inspector = NodeInspector.new)
17198
- inspector << inspector.header(self)
17199
- inspector << "├── expression:\n"
17200
- inspector << inspector.child_node(expression, "│ ")
17201
- inspector << "├── keyword_loc: #{inspector.location(keyword_loc)}\n"
17202
- inspector << "└── rescue_expression:\n"
17203
- inspector << inspector.child_node(rescue_expression, " ")
17204
- inspector.to_str
16237
+ # def inspect -> String
16238
+ def inspect
16239
+ InspectVisitor.compose(self)
17205
16240
  end
17206
16241
 
17207
16242
  # Sometimes you want to check an instance of a node against a list of
@@ -17345,31 +16380,9 @@ module Prism
17345
16380
  operator_loc&.slice
17346
16381
  end
17347
16382
 
17348
- # def inspect(NodeInspector inspector) -> String
17349
- def inspect(inspector = NodeInspector.new)
17350
- inspector << inspector.header(self)
17351
- inspector << "├── keyword_loc: #{inspector.location(keyword_loc)}\n"
17352
- inspector << "├── exceptions: #{inspector.list("#{inspector.prefix}│ ", exceptions)}"
17353
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
17354
- if (reference = self.reference).nil?
17355
- inspector << "├── reference: ∅\n"
17356
- else
17357
- inspector << "├── reference:\n"
17358
- inspector << reference.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
17359
- end
17360
- if (statements = self.statements).nil?
17361
- inspector << "├── statements: ∅\n"
17362
- else
17363
- inspector << "├── statements:\n"
17364
- inspector << statements.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
17365
- end
17366
- if (consequent = self.consequent).nil?
17367
- inspector << "└── consequent: ∅\n"
17368
- else
17369
- inspector << "└── consequent:\n"
17370
- inspector << consequent.inspect(inspector.child_inspector(" ")).delete_prefix(inspector.prefix)
17371
- end
17372
- inspector.to_str
16383
+ # def inspect -> String
16384
+ def inspect
16385
+ InspectVisitor.compose(self)
17373
16386
  end
17374
16387
 
17375
16388
  # Sometimes you want to check an instance of a node against a list of
@@ -17501,19 +16514,9 @@ module Prism
17501
16514
  operator_loc.slice
17502
16515
  end
17503
16516
 
17504
- # def inspect(NodeInspector inspector) -> String
17505
- def inspect(inspector = NodeInspector.new)
17506
- inspector << inspector.header(self)
17507
- flags = [("repeated_parameter" if repeated_parameter?)].compact
17508
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
17509
- if (name = self.name).nil?
17510
- inspector << "├── name: ∅\n"
17511
- else
17512
- inspector << "├── name: #{name.inspect}\n"
17513
- end
17514
- inspector << "├── name_loc: #{inspector.location(name_loc)}\n"
17515
- inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n"
17516
- inspector.to_str
16517
+ # def inspect -> String
16518
+ def inspect
16519
+ InspectVisitor.compose(self)
17517
16520
  end
17518
16521
 
17519
16522
  # Sometimes you want to check an instance of a node against a list of
@@ -17600,10 +16603,9 @@ module Prism
17600
16603
  { location: location }
17601
16604
  end
17602
16605
 
17603
- # def inspect(NodeInspector inspector) -> String
17604
- def inspect(inspector = NodeInspector.new)
17605
- inspector << inspector.header(self)
17606
- inspector.to_str
16606
+ # def inspect -> String
16607
+ def inspect
16608
+ InspectVisitor.compose(self)
17607
16609
  end
17608
16610
 
17609
16611
  # Sometimes you want to check an instance of a node against a list of
@@ -17646,11 +16648,12 @@ module Prism
17646
16648
  # return 1
17647
16649
  # ^^^^^^^^
17648
16650
  class ReturnNode < Node
17649
- # def initialize: (Location keyword_loc, ArgumentsNode? arguments, Location location) -> void
17650
- def initialize(source, keyword_loc, arguments, location)
16651
+ # def initialize: (Integer flags, Location keyword_loc, ArgumentsNode? arguments, Location location) -> void
16652
+ def initialize(source, flags, keyword_loc, arguments, location)
17651
16653
  @source = source
17652
16654
  @newline = false
17653
16655
  @location = location
16656
+ @flags = flags
17654
16657
  @keyword_loc = keyword_loc
17655
16658
  @arguments = arguments
17656
16659
  end
@@ -17677,19 +16680,23 @@ module Prism
17677
16680
  [keyword_loc, *arguments] #: Array[Prism::node | Location]
17678
16681
  end
17679
16682
 
17680
- # def copy: (?keyword_loc: Location, ?arguments: ArgumentsNode?, ?location: Location) -> ReturnNode
17681
- def copy(keyword_loc: self.keyword_loc, arguments: self.arguments, location: self.location)
17682
- ReturnNode.new(source, keyword_loc, arguments, location)
16683
+ # def copy: (?flags: Integer, ?keyword_loc: Location, ?arguments: ArgumentsNode?, ?location: Location) -> ReturnNode
16684
+ def copy(flags: self.flags, keyword_loc: self.keyword_loc, arguments: self.arguments, location: self.location)
16685
+ ReturnNode.new(source, flags, keyword_loc, arguments, location)
17683
16686
  end
17684
16687
 
17685
16688
  # def deconstruct: () -> Array[nil | Node]
17686
16689
  alias deconstruct child_nodes
17687
16690
 
17688
- # def deconstruct_keys: (Array[Symbol] keys) -> { keyword_loc: Location, arguments: ArgumentsNode?, location: Location }
16691
+ # def deconstruct_keys: (Array[Symbol] keys) -> { flags: Integer, keyword_loc: Location, arguments: ArgumentsNode?, location: Location }
17689
16692
  def deconstruct_keys(keys)
17690
- { keyword_loc: keyword_loc, arguments: arguments, location: location }
16693
+ { flags: flags, keyword_loc: keyword_loc, arguments: arguments, location: location }
17691
16694
  end
17692
16695
 
16696
+ # protected attr_reader flags: Integer
16697
+ attr_reader :flags
16698
+ protected :flags
16699
+
17693
16700
  # attr_reader keyword_loc: Location
17694
16701
  def keyword_loc
17695
16702
  location = @keyword_loc
@@ -17700,22 +16707,19 @@ module Prism
17700
16707
  # attr_reader arguments: ArgumentsNode?
17701
16708
  attr_reader :arguments
17702
16709
 
16710
+ # def redundant?: () -> bool
16711
+ def redundant?
16712
+ flags.anybits?(ReturnNodeFlags::REDUNDANT)
16713
+ end
16714
+
17703
16715
  # def keyword: () -> String
17704
16716
  def keyword
17705
16717
  keyword_loc.slice
17706
16718
  end
17707
16719
 
17708
- # def inspect(NodeInspector inspector) -> String
17709
- def inspect(inspector = NodeInspector.new)
17710
- inspector << inspector.header(self)
17711
- inspector << "├── keyword_loc: #{inspector.location(keyword_loc)}\n"
17712
- if (arguments = self.arguments).nil?
17713
- inspector << "└── arguments: ∅\n"
17714
- else
17715
- inspector << "└── arguments:\n"
17716
- inspector << arguments.inspect(inspector.child_inspector(" ")).delete_prefix(inspector.prefix)
17717
- end
17718
- inspector.to_str
16720
+ # def inspect -> String
16721
+ def inspect
16722
+ InspectVisitor.compose(self)
17719
16723
  end
17720
16724
 
17721
16725
  # Sometimes you want to check an instance of a node against a list of
@@ -17750,6 +16754,7 @@ module Prism
17750
16754
  # comparing the value of locations. Locations are checked only for presence.
17751
16755
  def ===(other)
17752
16756
  other.is_a?(ReturnNode) &&
16757
+ (flags === other.flags) &&
17753
16758
  (keyword_loc.nil? == other.keyword_loc.nil?) &&
17754
16759
  (arguments === other.arguments)
17755
16760
  end
@@ -17800,10 +16805,9 @@ module Prism
17800
16805
  { location: location }
17801
16806
  end
17802
16807
 
17803
- # def inspect(NodeInspector inspector) -> String
17804
- def inspect(inspector = NodeInspector.new)
17805
- inspector << inspector.header(self)
17806
- inspector.to_str
16808
+ # def inspect -> String
16809
+ def inspect
16810
+ InspectVisitor.compose(self)
17807
16811
  end
17808
16812
 
17809
16813
  # Sometimes you want to check an instance of a node against a list of
@@ -17911,14 +16915,9 @@ module Prism
17911
16915
  flags.anybits?(ShareableConstantNodeFlags::EXPERIMENTAL_COPY)
17912
16916
  end
17913
16917
 
17914
- # def inspect(NodeInspector inspector) -> String
17915
- def inspect(inspector = NodeInspector.new)
17916
- inspector << inspector.header(self)
17917
- flags = [("literal" if literal?), ("experimental_everything" if experimental_everything?), ("experimental_copy" if experimental_copy?)].compact
17918
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
17919
- inspector << "└── write:\n"
17920
- inspector << inspector.child_node(write, " ")
17921
- inspector.to_str
16918
+ # def inspect -> String
16919
+ def inspect
16920
+ InspectVisitor.compose(self)
17922
16921
  end
17923
16922
 
17924
16923
  # Sometimes you want to check an instance of a node against a list of
@@ -18057,22 +17056,9 @@ module Prism
18057
17056
  end_keyword_loc.slice
18058
17057
  end
18059
17058
 
18060
- # def inspect(NodeInspector inspector) -> String
18061
- def inspect(inspector = NodeInspector.new)
18062
- inspector << inspector.header(self)
18063
- inspector << "├── locals: #{locals.inspect}\n"
18064
- inspector << "├── class_keyword_loc: #{inspector.location(class_keyword_loc)}\n"
18065
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
18066
- inspector << "├── expression:\n"
18067
- inspector << inspector.child_node(expression, "│ ")
18068
- if (body = self.body).nil?
18069
- inspector << "├── body: ∅\n"
18070
- else
18071
- inspector << "├── body:\n"
18072
- inspector << body.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
18073
- end
18074
- inspector << "└── end_keyword_loc: #{inspector.location(end_keyword_loc)}\n"
18075
- inspector.to_str
17059
+ # def inspect -> String
17060
+ def inspect
17061
+ InspectVisitor.compose(self)
18076
17062
  end
18077
17063
 
18078
17064
  # Sometimes you want to check an instance of a node against a list of
@@ -18162,10 +17148,9 @@ module Prism
18162
17148
  { location: location }
18163
17149
  end
18164
17150
 
18165
- # def inspect(NodeInspector inspector) -> String
18166
- def inspect(inspector = NodeInspector.new)
18167
- inspector << inspector.header(self)
18168
- inspector.to_str
17151
+ # def inspect -> String
17152
+ def inspect
17153
+ InspectVisitor.compose(self)
18169
17154
  end
18170
17155
 
18171
17156
  # Sometimes you want to check an instance of a node against a list of
@@ -18277,13 +17262,9 @@ module Prism
18277
17262
  flags.anybits?(StringFlags::MUTABLE)
18278
17263
  end
18279
17264
 
18280
- # def inspect(NodeInspector inspector) -> String
18281
- def inspect(inspector = NodeInspector.new)
18282
- inspector << inspector.header(self)
18283
- flags = [("forced_utf8_encoding" if forced_utf8_encoding?), ("forced_binary_encoding" if forced_binary_encoding?), ("frozen" if frozen?), ("mutable" if mutable?)].compact
18284
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
18285
- inspector << "└── filepath: #{filepath.inspect}\n"
18286
- inspector.to_str
17265
+ # def inspect -> String
17266
+ def inspect
17267
+ InspectVisitor.compose(self)
18287
17268
  end
18288
17269
 
18289
17270
  # Sometimes you want to check an instance of a node against a list of
@@ -18368,10 +17349,9 @@ module Prism
18368
17349
  { location: location }
18369
17350
  end
18370
17351
 
18371
- # def inspect(NodeInspector inspector) -> String
18372
- def inspect(inspector = NodeInspector.new)
18373
- inspector << inspector.header(self)
18374
- inspector.to_str
17352
+ # def inspect -> String
17353
+ def inspect
17354
+ InspectVisitor.compose(self)
18375
17355
  end
18376
17356
 
18377
17357
  # Sometimes you want to check an instance of a node against a list of
@@ -18473,17 +17453,9 @@ module Prism
18473
17453
  operator_loc.slice
18474
17454
  end
18475
17455
 
18476
- # def inspect(NodeInspector inspector) -> String
18477
- def inspect(inspector = NodeInspector.new)
18478
- inspector << inspector.header(self)
18479
- inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
18480
- if (expression = self.expression).nil?
18481
- inspector << "└── expression: ∅\n"
18482
- else
18483
- inspector << "└── expression:\n"
18484
- inspector << expression.inspect(inspector.child_inspector(" ")).delete_prefix(inspector.prefix)
18485
- end
18486
- inspector.to_str
17456
+ # def inspect -> String
17457
+ def inspect
17458
+ InspectVisitor.compose(self)
18487
17459
  end
18488
17460
 
18489
17461
  # Sometimes you want to check an instance of a node against a list of
@@ -18572,11 +17544,9 @@ module Prism
18572
17544
  # attr_reader body: Array[Prism::node]
18573
17545
  attr_reader :body
18574
17546
 
18575
- # def inspect(NodeInspector inspector) -> String
18576
- def inspect(inspector = NodeInspector.new)
18577
- inspector << inspector.header(self)
18578
- inspector << "└── body: #{inspector.list("#{inspector.prefix} ", body)}"
18579
- inspector.to_str
17547
+ # def inspect -> String
17548
+ def inspect
17549
+ InspectVisitor.compose(self)
18580
17550
  end
18581
17551
 
18582
17552
  # Sometimes you want to check an instance of a node against a list of
@@ -18747,16 +17717,9 @@ module Prism
18747
17717
  closing_loc&.slice
18748
17718
  end
18749
17719
 
18750
- # def inspect(NodeInspector inspector) -> String
18751
- def inspect(inspector = NodeInspector.new)
18752
- inspector << inspector.header(self)
18753
- flags = [("forced_utf8_encoding" if forced_utf8_encoding?), ("forced_binary_encoding" if forced_binary_encoding?), ("frozen" if frozen?), ("mutable" if mutable?)].compact
18754
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
18755
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
18756
- inspector << "├── content_loc: #{inspector.location(content_loc)}\n"
18757
- inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
18758
- inspector << "└── unescaped: #{unescaped.inspect}\n"
18759
- inspector.to_str
17720
+ # def inspect -> String
17721
+ def inspect
17722
+ InspectVisitor.compose(self)
18760
17723
  end
18761
17724
 
18762
17725
  # Sometimes you want to check an instance of a node against a list of
@@ -18909,25 +17872,9 @@ module Prism
18909
17872
  rparen_loc&.slice
18910
17873
  end
18911
17874
 
18912
- # def inspect(NodeInspector inspector) -> String
18913
- def inspect(inspector = NodeInspector.new)
18914
- inspector << inspector.header(self)
18915
- inspector << "├── keyword_loc: #{inspector.location(keyword_loc)}\n"
18916
- inspector << "├── lparen_loc: #{inspector.location(lparen_loc)}\n"
18917
- if (arguments = self.arguments).nil?
18918
- inspector << "├── arguments: ∅\n"
18919
- else
18920
- inspector << "├── arguments:\n"
18921
- inspector << arguments.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
18922
- end
18923
- inspector << "├── rparen_loc: #{inspector.location(rparen_loc)}\n"
18924
- if (block = self.block).nil?
18925
- inspector << "└── block: ∅\n"
18926
- else
18927
- inspector << "└── block:\n"
18928
- inspector << block.inspect(inspector.child_inspector(" ")).delete_prefix(inspector.prefix)
18929
- end
18930
- inspector.to_str
17875
+ # def inspect -> String
17876
+ def inspect
17877
+ InspectVisitor.compose(self)
18931
17878
  end
18932
17879
 
18933
17880
  # Sometimes you want to check an instance of a node against a list of
@@ -19099,16 +18046,9 @@ module Prism
19099
18046
  closing_loc&.slice
19100
18047
  end
19101
18048
 
19102
- # def inspect(NodeInspector inspector) -> String
19103
- def inspect(inspector = NodeInspector.new)
19104
- inspector << inspector.header(self)
19105
- flags = [("forced_utf8_encoding" if forced_utf8_encoding?), ("forced_binary_encoding" if forced_binary_encoding?), ("forced_us_ascii_encoding" if forced_us_ascii_encoding?)].compact
19106
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
19107
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
19108
- inspector << "├── value_loc: #{inspector.location(value_loc)}\n"
19109
- inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
19110
- inspector << "└── unescaped: #{unescaped.inspect}\n"
19111
- inspector.to_str
18049
+ # def inspect -> String
18050
+ def inspect
18051
+ InspectVisitor.compose(self)
19112
18052
  end
19113
18053
 
19114
18054
  # Sometimes you want to check an instance of a node against a list of
@@ -19196,10 +18136,9 @@ module Prism
19196
18136
  { location: location }
19197
18137
  end
19198
18138
 
19199
- # def inspect(NodeInspector inspector) -> String
19200
- def inspect(inspector = NodeInspector.new)
19201
- inspector << inspector.header(self)
19202
- inspector.to_str
18139
+ # def inspect -> String
18140
+ def inspect
18141
+ InspectVisitor.compose(self)
19203
18142
  end
19204
18143
 
19205
18144
  # Sometimes you want to check an instance of a node against a list of
@@ -19299,12 +18238,9 @@ module Prism
19299
18238
  keyword_loc.slice
19300
18239
  end
19301
18240
 
19302
- # def inspect(NodeInspector inspector) -> String
19303
- def inspect(inspector = NodeInspector.new)
19304
- inspector << inspector.header(self)
19305
- inspector << "├── names: #{inspector.list("#{inspector.prefix}│ ", names)}"
19306
- inspector << "└── keyword_loc: #{inspector.location(keyword_loc)}\n"
19307
- inspector.to_str
18241
+ # def inspect -> String
18242
+ def inspect
18243
+ InspectVisitor.compose(self)
19308
18244
  end
19309
18245
 
19310
18246
  # Sometimes you want to check an instance of a node against a list of
@@ -19487,27 +18423,9 @@ module Prism
19487
18423
  end_keyword_loc&.slice
19488
18424
  end
19489
18425
 
19490
- # def inspect(NodeInspector inspector) -> String
19491
- def inspect(inspector = NodeInspector.new)
19492
- inspector << inspector.header(self)
19493
- inspector << "├── keyword_loc: #{inspector.location(keyword_loc)}\n"
19494
- inspector << "├── predicate:\n"
19495
- inspector << inspector.child_node(predicate, "│ ")
19496
- inspector << "├── then_keyword_loc: #{inspector.location(then_keyword_loc)}\n"
19497
- if (statements = self.statements).nil?
19498
- inspector << "├── statements: ∅\n"
19499
- else
19500
- inspector << "├── statements:\n"
19501
- inspector << statements.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
19502
- end
19503
- if (consequent = self.consequent).nil?
19504
- inspector << "├── consequent: ∅\n"
19505
- else
19506
- inspector << "├── consequent:\n"
19507
- inspector << consequent.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
19508
- end
19509
- inspector << "└── end_keyword_loc: #{inspector.location(end_keyword_loc)}\n"
19510
- inspector.to_str
18426
+ # def inspect -> String
18427
+ def inspect
18428
+ InspectVisitor.compose(self)
19511
18429
  end
19512
18430
 
19513
18431
  # Sometimes you want to check an instance of a node against a list of
@@ -19656,22 +18574,9 @@ module Prism
19656
18574
  closing_loc&.slice
19657
18575
  end
19658
18576
 
19659
- # def inspect(NodeInspector inspector) -> String
19660
- def inspect(inspector = NodeInspector.new)
19661
- inspector << inspector.header(self)
19662
- flags = [("begin_modifier" if begin_modifier?)].compact
19663
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
19664
- inspector << "├── keyword_loc: #{inspector.location(keyword_loc)}\n"
19665
- inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
19666
- inspector << "├── predicate:\n"
19667
- inspector << inspector.child_node(predicate, "│ ")
19668
- if (statements = self.statements).nil?
19669
- inspector << "└── statements: ∅\n"
19670
- else
19671
- inspector << "└── statements:\n"
19672
- inspector << statements.inspect(inspector.child_inspector(" ")).delete_prefix(inspector.prefix)
19673
- end
19674
- inspector.to_str
18577
+ # def inspect -> String
18578
+ def inspect
18579
+ InspectVisitor.compose(self)
19675
18580
  end
19676
18581
 
19677
18582
  # Sometimes you want to check an instance of a node against a list of
@@ -19804,19 +18709,9 @@ module Prism
19804
18709
  then_keyword_loc&.slice
19805
18710
  end
19806
18711
 
19807
- # def inspect(NodeInspector inspector) -> String
19808
- def inspect(inspector = NodeInspector.new)
19809
- inspector << inspector.header(self)
19810
- inspector << "├── keyword_loc: #{inspector.location(keyword_loc)}\n"
19811
- inspector << "├── conditions: #{inspector.list("#{inspector.prefix}│ ", conditions)}"
19812
- inspector << "├── then_keyword_loc: #{inspector.location(then_keyword_loc)}\n"
19813
- if (statements = self.statements).nil?
19814
- inspector << "└── statements: ∅\n"
19815
- else
19816
- inspector << "└── statements:\n"
19817
- inspector << statements.inspect(inspector.child_inspector(" ")).delete_prefix(inspector.prefix)
19818
- end
19819
- inspector.to_str
18712
+ # def inspect -> String
18713
+ def inspect
18714
+ InspectVisitor.compose(self)
19820
18715
  end
19821
18716
 
19822
18717
  # Sometimes you want to check an instance of a node against a list of
@@ -19964,22 +18859,9 @@ module Prism
19964
18859
  closing_loc&.slice
19965
18860
  end
19966
18861
 
19967
- # def inspect(NodeInspector inspector) -> String
19968
- def inspect(inspector = NodeInspector.new)
19969
- inspector << inspector.header(self)
19970
- flags = [("begin_modifier" if begin_modifier?)].compact
19971
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
19972
- inspector << "├── keyword_loc: #{inspector.location(keyword_loc)}\n"
19973
- inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
19974
- inspector << "├── predicate:\n"
19975
- inspector << inspector.child_node(predicate, "│ ")
19976
- if (statements = self.statements).nil?
19977
- inspector << "└── statements: ∅\n"
19978
- else
19979
- inspector << "└── statements:\n"
19980
- inspector << statements.inspect(inspector.child_inspector(" ")).delete_prefix(inspector.prefix)
19981
- end
19982
- inspector.to_str
18862
+ # def inspect -> String
18863
+ def inspect
18864
+ InspectVisitor.compose(self)
19983
18865
  end
19984
18866
 
19985
18867
  # Sometimes you want to check an instance of a node against a list of
@@ -20125,16 +19007,9 @@ module Prism
20125
19007
  closing_loc.slice
20126
19008
  end
20127
19009
 
20128
- # def inspect(NodeInspector inspector) -> String
20129
- def inspect(inspector = NodeInspector.new)
20130
- inspector << inspector.header(self)
20131
- flags = [("forced_utf8_encoding" if forced_utf8_encoding?), ("forced_binary_encoding" if forced_binary_encoding?)].compact
20132
- inspector << "├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n"
20133
- inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n"
20134
- inspector << "├── content_loc: #{inspector.location(content_loc)}\n"
20135
- inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n"
20136
- inspector << "└── unescaped: #{unescaped.inspect}\n"
20137
- inspector.to_str
19010
+ # def inspect -> String
19011
+ def inspect
19012
+ InspectVisitor.compose(self)
20138
19013
  end
20139
19014
 
20140
19015
  # Sometimes you want to check an instance of a node against a list of
@@ -20279,19 +19154,9 @@ module Prism
20279
19154
  rparen_loc&.slice
20280
19155
  end
20281
19156
 
20282
- # def inspect(NodeInspector inspector) -> String
20283
- def inspect(inspector = NodeInspector.new)
20284
- inspector << inspector.header(self)
20285
- inspector << "├── keyword_loc: #{inspector.location(keyword_loc)}\n"
20286
- inspector << "├── lparen_loc: #{inspector.location(lparen_loc)}\n"
20287
- if (arguments = self.arguments).nil?
20288
- inspector << "├── arguments: ∅\n"
20289
- else
20290
- inspector << "├── arguments:\n"
20291
- inspector << arguments.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix)
20292
- end
20293
- inspector << "└── rparen_loc: #{inspector.location(rparen_loc)}\n"
20294
- inspector.to_str
19157
+ # def inspect -> String
19158
+ def inspect
19159
+ InspectVisitor.compose(self)
20295
19160
  end
20296
19161
 
20297
19162
  # Sometimes you want to check an instance of a node against a list of
@@ -20335,8 +19200,11 @@ module Prism
20335
19200
 
20336
19201
  # Flags for arguments nodes.
20337
19202
  module ArgumentsNodeFlags
19203
+ # if arguments contain keywords
19204
+ CONTAINS_KEYWORDS = 1 << 0
19205
+
20338
19206
  # if arguments contain keyword splat
20339
- CONTAINS_KEYWORD_SPLAT = 1 << 0
19207
+ CONTAINS_KEYWORD_SPLAT = 1 << 1
20340
19208
  end
20341
19209
 
20342
19210
  # Flags for array nodes.
@@ -20453,6 +19321,12 @@ module Prism
20453
19321
  FORCED_US_ASCII_ENCODING = 1 << 10
20454
19322
  end
20455
19323
 
19324
+ # Flags for return nodes.
19325
+ module ReturnNodeFlags
19326
+ # a return statement that is redundant because it is the last statement in a method
19327
+ REDUNDANT = 1 << 0
19328
+ end
19329
+
20456
19330
  # Flags for shareable constant nodes.
20457
19331
  module ShareableConstantNodeFlags
20458
19332
  # constant writes that should be modified with shareable constant value literal