prism 0.29.0 → 0.30.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -1
  3. data/CONTRIBUTING.md +0 -4
  4. data/README.md +1 -0
  5. data/config.yml +66 -9
  6. data/docs/fuzzing.md +1 -1
  7. data/docs/ripper_translation.md +22 -0
  8. data/ext/prism/api_node.c +30 -12
  9. data/ext/prism/extension.c +107 -372
  10. data/ext/prism/extension.h +1 -1
  11. data/include/prism/ast.h +138 -70
  12. data/include/prism/diagnostic.h +7 -2
  13. data/include/prism/node.h +0 -21
  14. data/include/prism/parser.h +23 -25
  15. data/include/prism/regexp.h +17 -8
  16. data/include/prism/static_literals.h +3 -2
  17. data/include/prism/util/pm_char.h +1 -2
  18. data/include/prism/util/pm_constant_pool.h +0 -8
  19. data/include/prism/util/pm_integer.h +16 -9
  20. data/include/prism/util/pm_string.h +0 -8
  21. data/include/prism/version.h +2 -2
  22. data/include/prism.h +0 -11
  23. data/lib/prism/compiler.rb +3 -0
  24. data/lib/prism/dispatcher.rb +14 -0
  25. data/lib/prism/dot_visitor.rb +22 -3
  26. data/lib/prism/dsl.rb +7 -2
  27. data/lib/prism/ffi.rb +24 -3
  28. data/lib/prism/inspect_visitor.rb +10 -8
  29. data/lib/prism/mutation_compiler.rb +6 -1
  30. data/lib/prism/node.rb +166 -241
  31. data/lib/prism/node_ext.rb +21 -5
  32. data/lib/prism/parse_result/comments.rb +0 -7
  33. data/lib/prism/parse_result/newlines.rb +101 -11
  34. data/lib/prism/parse_result.rb +17 -0
  35. data/lib/prism/reflection.rb +3 -1
  36. data/lib/prism/serialize.rb +80 -67
  37. data/lib/prism/translation/parser/compiler.rb +134 -114
  38. data/lib/prism/translation/parser.rb +6 -1
  39. data/lib/prism/translation/ripper.rb +8 -6
  40. data/lib/prism/translation/ruby_parser.rb +23 -5
  41. data/lib/prism/visitor.rb +3 -0
  42. data/lib/prism.rb +0 -4
  43. data/prism.gemspec +1 -4
  44. data/rbi/prism/node.rbi +63 -6
  45. data/rbi/prism/visitor.rbi +3 -0
  46. data/rbi/prism.rbi +6 -0
  47. data/sig/prism/dsl.rbs +4 -1
  48. data/sig/prism/mutation_compiler.rbs +1 -0
  49. data/sig/prism/node.rbs +28 -4
  50. data/sig/prism/visitor.rbs +1 -0
  51. data/sig/prism.rbs +21 -0
  52. data/src/diagnostic.c +27 -17
  53. data/src/node.c +408 -1666
  54. data/src/prettyprint.c +49 -6
  55. data/src/prism.c +958 -991
  56. data/src/regexp.c +133 -68
  57. data/src/serialize.c +6 -1
  58. data/src/static_literals.c +63 -84
  59. data/src/token_type.c +2 -2
  60. data/src/util/pm_constant_pool.c +0 -8
  61. data/src/util/pm_integer.c +39 -11
  62. data/src/util/pm_string.c +0 -12
  63. data/src/util/pm_strpbrk.c +32 -6
  64. metadata +2 -5
  65. data/include/prism/util/pm_string_list.h +0 -44
  66. data/lib/prism/debug.rb +0 -249
  67. data/src/util/pm_string_list.c +0 -28
data/lib/prism/node.rb CHANGED
@@ -36,18 +36,6 @@ module Prism
36
36
  location.is_a?(Location) ? location.end_offset : ((location >> 32) + (location & 0xFFFFFFFF))
37
37
  end
38
38
 
39
- def newline? # :nodoc:
40
- @newline ? true : false
41
- end
42
-
43
- def set_newline_flag(newline_marked) # :nodoc:
44
- line = location.start_line
45
- unless newline_marked[line]
46
- newline_marked[line] = true
47
- @newline = true
48
- end
49
- end
50
-
51
39
  # Returns all of the lines of the source code associated with this node.
52
40
  def source_lines
53
41
  location.source_lines
@@ -189,7 +177,6 @@ module Prism
189
177
  # def initialize: (Prism::node new_name, Prism::node old_name, Location keyword_loc, Location location) -> void
190
178
  def initialize(source, new_name, old_name, keyword_loc, location)
191
179
  @source = source
192
- @newline = false
193
180
  @location = location
194
181
  @new_name = new_name
195
182
  @old_name = old_name
@@ -307,7 +294,6 @@ module Prism
307
294
  # def initialize: (Prism::node new_name, Prism::node old_name, Location keyword_loc, Location location) -> void
308
295
  def initialize(source, new_name, old_name, keyword_loc, location)
309
296
  @source = source
310
- @newline = false
311
297
  @location = location
312
298
  @new_name = new_name
313
299
  @old_name = old_name
@@ -416,7 +402,6 @@ module Prism
416
402
  # def initialize: (Prism::node left, Prism::node right, Location operator_loc, Location location) -> void
417
403
  def initialize(source, left, right, operator_loc, location)
418
404
  @source = source
419
- @newline = false
420
405
  @location = location
421
406
  @left = left
422
407
  @right = right
@@ -525,7 +510,6 @@ module Prism
525
510
  # def initialize: (Prism::node left, Prism::node right, Location operator_loc, Location location) -> void
526
511
  def initialize(source, left, right, operator_loc, location)
527
512
  @source = source
528
- @newline = false
529
513
  @location = location
530
514
  @left = left
531
515
  @right = right
@@ -649,7 +633,6 @@ module Prism
649
633
  # def initialize: (Integer flags, Array[Prism::node] arguments, Location location) -> void
650
634
  def initialize(source, flags, arguments, location)
651
635
  @source = source
652
- @newline = false
653
636
  @location = location
654
637
  @flags = flags
655
638
  @arguments = arguments
@@ -756,7 +739,6 @@ module Prism
756
739
  # def initialize: (Integer flags, Array[Prism::node] elements, Location? opening_loc, Location? closing_loc, Location location) -> void
757
740
  def initialize(source, flags, elements, opening_loc, closing_loc, location)
758
741
  @source = source
759
- @newline = false
760
742
  @location = location
761
743
  @flags = flags
762
744
  @elements = elements
@@ -920,7 +902,6 @@ module Prism
920
902
  # def initialize: (Prism::node? constant, Array[Prism::node] requireds, Prism::node? rest, Array[Prism::node] posts, Location? opening_loc, Location? closing_loc, Location location) -> void
921
903
  def initialize(source, constant, requireds, rest, posts, opening_loc, closing_loc, location)
922
904
  @source = source
923
- @newline = false
924
905
  @location = location
925
906
  @constant = constant
926
907
  @requireds = requireds
@@ -1072,7 +1053,6 @@ module Prism
1072
1053
  # def initialize: (Prism::node key, Prism::node value, Location? operator_loc, Location location) -> void
1073
1054
  def initialize(source, key, value, operator_loc, location)
1074
1055
  @source = source
1075
- @newline = false
1076
1056
  @location = location
1077
1057
  @key = key
1078
1058
  @value = value
@@ -1205,7 +1185,6 @@ module Prism
1205
1185
  # def initialize: (Prism::node? value, Location operator_loc, Location location) -> void
1206
1186
  def initialize(source, value, operator_loc, location)
1207
1187
  @source = source
1208
- @newline = false
1209
1188
  @location = location
1210
1189
  @value = value
1211
1190
  @operator_loc = operator_loc
@@ -1317,7 +1296,6 @@ module Prism
1317
1296
  # def initialize: (Symbol name, Location location) -> void
1318
1297
  def initialize(source, name, location)
1319
1298
  @source = source
1320
- @newline = false
1321
1299
  @location = location
1322
1300
  @name = name
1323
1301
  end
@@ -1413,7 +1391,6 @@ module Prism
1413
1391
  # def initialize: (Location? begin_keyword_loc, StatementsNode? statements, RescueNode? rescue_clause, ElseNode? else_clause, EnsureNode? ensure_clause, Location? end_keyword_loc, Location location) -> void
1414
1392
  def initialize(source, begin_keyword_loc, statements, rescue_clause, else_clause, ensure_clause, end_keyword_loc, location)
1415
1393
  @source = source
1416
- @newline = false
1417
1394
  @location = location
1418
1395
  @begin_keyword_loc = begin_keyword_loc
1419
1396
  @statements = statements
@@ -1428,10 +1405,6 @@ module Prism
1428
1405
  visitor.visit_begin_node(self)
1429
1406
  end
1430
1407
 
1431
- def set_newline_flag(newline_marked) # :nodoc:
1432
- # Never mark BeginNode with a newline flag, mark children instead
1433
- end
1434
-
1435
1408
  # def child_nodes: () -> Array[nil | Node]
1436
1409
  def child_nodes
1437
1410
  [statements, rescue_clause, else_clause, ensure_clause]
@@ -1567,7 +1540,6 @@ module Prism
1567
1540
  # def initialize: (Prism::node? expression, Location operator_loc, Location location) -> void
1568
1541
  def initialize(source, expression, operator_loc, location)
1569
1542
  @source = source
1570
- @newline = false
1571
1543
  @location = location
1572
1544
  @expression = expression
1573
1545
  @operator_loc = operator_loc
@@ -1673,7 +1645,6 @@ module Prism
1673
1645
  # def initialize: (Integer flags, Symbol name, Location location) -> void
1674
1646
  def initialize(source, flags, name, location)
1675
1647
  @source = source
1676
- @newline = false
1677
1648
  @location = location
1678
1649
  @flags = flags
1679
1650
  @name = name
@@ -1774,7 +1745,6 @@ module Prism
1774
1745
  # def initialize: (Array[Symbol] locals, Prism::node? parameters, Prism::node? body, Location opening_loc, Location closing_loc, Location location) -> void
1775
1746
  def initialize(source, locals, parameters, body, opening_loc, closing_loc, location)
1776
1747
  @source = source
1777
- @newline = false
1778
1748
  @location = location
1779
1749
  @locals = locals
1780
1750
  @parameters = parameters
@@ -1907,7 +1877,6 @@ module Prism
1907
1877
  # def initialize: (Integer flags, Symbol? name, Location? name_loc, Location operator_loc, Location location) -> void
1908
1878
  def initialize(source, flags, name, name_loc, operator_loc, location)
1909
1879
  @source = source
1910
- @newline = false
1911
1880
  @location = location
1912
1881
  @flags = flags
1913
1882
  @name = name
@@ -2041,7 +2010,6 @@ module Prism
2041
2010
  # def initialize: (ParametersNode? parameters, Array[BlockLocalVariableNode] locals, Location? opening_loc, Location? closing_loc, Location location) -> void
2042
2011
  def initialize(source, parameters, locals, opening_loc, closing_loc, location)
2043
2012
  @source = source
2044
- @newline = false
2045
2013
  @location = location
2046
2014
  @parameters = parameters
2047
2015
  @locals = locals
@@ -2180,7 +2148,6 @@ module Prism
2180
2148
  # def initialize: (ArgumentsNode? arguments, Location keyword_loc, Location location) -> void
2181
2149
  def initialize(source, arguments, keyword_loc, location)
2182
2150
  @source = source
2183
- @newline = false
2184
2151
  @location = location
2185
2152
  @arguments = arguments
2186
2153
  @keyword_loc = keyword_loc
@@ -2292,7 +2259,6 @@ module Prism
2292
2259
  # def initialize: (Integer flags, Prism::node? receiver, Location? call_operator_loc, Location? message_loc, Symbol read_name, Symbol write_name, Location operator_loc, Prism::node value, Location location) -> void
2293
2260
  def initialize(source, flags, receiver, call_operator_loc, message_loc, read_name, write_name, operator_loc, value, location)
2294
2261
  @source = source
2295
- @newline = false
2296
2262
  @location = location
2297
2263
  @flags = flags
2298
2264
  @receiver = receiver
@@ -2495,7 +2461,6 @@ module Prism
2495
2461
  # def initialize: (Integer flags, Prism::node? receiver, Location? call_operator_loc, Symbol name, Location? message_loc, Location? opening_loc, ArgumentsNode? arguments, Location? closing_loc, Prism::node? block, Location location) -> void
2496
2462
  def initialize(source, flags, receiver, call_operator_loc, name, message_loc, opening_loc, arguments, closing_loc, block, location)
2497
2463
  @source = source
2498
- @newline = false
2499
2464
  @location = location
2500
2465
  @flags = flags
2501
2466
  @receiver = receiver
@@ -2719,7 +2684,6 @@ module Prism
2719
2684
  # def initialize: (Integer flags, Prism::node? receiver, Location? call_operator_loc, Location? message_loc, Symbol read_name, Symbol write_name, Symbol binary_operator, Location binary_operator_loc, Prism::node value, Location location) -> void
2720
2685
  def initialize(source, flags, receiver, call_operator_loc, message_loc, read_name, write_name, binary_operator, binary_operator_loc, value, location)
2721
2686
  @source = source
2722
- @newline = false
2723
2687
  @location = location
2724
2688
  @flags = flags
2725
2689
  @receiver = receiver
@@ -2907,7 +2871,6 @@ module Prism
2907
2871
  # def initialize: (Integer flags, Prism::node? receiver, Location? call_operator_loc, Location? message_loc, Symbol read_name, Symbol write_name, Location operator_loc, Prism::node value, Location location) -> void
2908
2872
  def initialize(source, flags, receiver, call_operator_loc, message_loc, read_name, write_name, operator_loc, value, location)
2909
2873
  @source = source
2910
- @newline = false
2911
2874
  @location = location
2912
2875
  @flags = flags
2913
2876
  @receiver = receiver
@@ -3103,7 +3066,6 @@ module Prism
3103
3066
  # def initialize: (Integer flags, Prism::node receiver, Location call_operator_loc, Symbol name, Location message_loc, Location location) -> void
3104
3067
  def initialize(source, flags, receiver, call_operator_loc, name, message_loc, location)
3105
3068
  @source = source
3106
- @newline = false
3107
3069
  @location = location
3108
3070
  @flags = flags
3109
3071
  @receiver = receiver
@@ -3252,7 +3214,6 @@ module Prism
3252
3214
  # def initialize: (Prism::node value, Prism::node target, Location operator_loc, Location location) -> void
3253
3215
  def initialize(source, value, target, operator_loc, location)
3254
3216
  @source = source
3255
- @newline = false
3256
3217
  @location = location
3257
3218
  @value = value
3258
3219
  @target = target
@@ -3363,7 +3324,6 @@ module Prism
3363
3324
  # def initialize: (Prism::node? predicate, Array[Prism::node] conditions, ElseNode? consequent, Location case_keyword_loc, Location end_keyword_loc, Location location) -> void
3364
3325
  def initialize(source, predicate, conditions, consequent, case_keyword_loc, end_keyword_loc, location)
3365
3326
  @source = source
3366
- @newline = false
3367
3327
  @location = location
3368
3328
  @predicate = predicate
3369
3329
  @conditions = conditions
@@ -3498,7 +3458,6 @@ module Prism
3498
3458
  # def initialize: (Prism::node? predicate, Array[Prism::node] conditions, ElseNode? consequent, Location case_keyword_loc, Location end_keyword_loc, Location location) -> void
3499
3459
  def initialize(source, predicate, conditions, consequent, case_keyword_loc, end_keyword_loc, location)
3500
3460
  @source = source
3501
- @newline = false
3502
3461
  @location = location
3503
3462
  @predicate = predicate
3504
3463
  @conditions = conditions
@@ -3631,7 +3590,6 @@ module Prism
3631
3590
  # def initialize: (Array[Symbol] locals, Location class_keyword_loc, Prism::node constant_path, Location? inheritance_operator_loc, Prism::node? superclass, Prism::node? body, Location end_keyword_loc, Symbol name, Location location) -> void
3632
3591
  def initialize(source, locals, class_keyword_loc, constant_path, inheritance_operator_loc, superclass, body, end_keyword_loc, name, location)
3633
3592
  @source = source
3634
- @newline = false
3635
3593
  @location = location
3636
3594
  @locals = locals
3637
3595
  @class_keyword_loc = class_keyword_loc
@@ -3794,7 +3752,6 @@ module Prism
3794
3752
  # def initialize: (Symbol name, Location name_loc, Location operator_loc, Prism::node value, Location location) -> void
3795
3753
  def initialize(source, name, name_loc, operator_loc, value, location)
3796
3754
  @source = source
3797
- @newline = false
3798
3755
  @location = location
3799
3756
  @name = name
3800
3757
  @name_loc = name_loc
@@ -3912,7 +3869,6 @@ module Prism
3912
3869
  # def initialize: (Symbol name, Location name_loc, Location binary_operator_loc, Prism::node value, Symbol binary_operator, Location location) -> void
3913
3870
  def initialize(source, name, name_loc, binary_operator_loc, value, binary_operator, location)
3914
3871
  @source = source
3915
- @newline = false
3916
3872
  @location = location
3917
3873
  @name = name
3918
3874
  @name_loc = name_loc
@@ -4030,7 +3986,6 @@ module Prism
4030
3986
  # def initialize: (Symbol name, Location name_loc, Location operator_loc, Prism::node value, Location location) -> void
4031
3987
  def initialize(source, name, name_loc, operator_loc, value, location)
4032
3988
  @source = source
4033
- @newline = false
4034
3989
  @location = location
4035
3990
  @name = name
4036
3991
  @name_loc = name_loc
@@ -4148,7 +4103,6 @@ module Prism
4148
4103
  # def initialize: (Symbol name, Location location) -> void
4149
4104
  def initialize(source, name, location)
4150
4105
  @source = source
4151
- @newline = false
4152
4106
  @location = location
4153
4107
  @name = name
4154
4108
  end
@@ -4242,7 +4196,6 @@ module Prism
4242
4196
  # def initialize: (Symbol name, Location location) -> void
4243
4197
  def initialize(source, name, location)
4244
4198
  @source = source
4245
- @newline = false
4246
4199
  @location = location
4247
4200
  @name = name
4248
4201
  end
@@ -4332,7 +4285,6 @@ module Prism
4332
4285
  # def initialize: (Symbol name, Location name_loc, Prism::node value, Location operator_loc, Location location) -> void
4333
4286
  def initialize(source, name, name_loc, value, operator_loc, location)
4334
4287
  @source = source
4335
- @newline = false
4336
4288
  @location = location
4337
4289
  @name = name
4338
4290
  @name_loc = name_loc
@@ -4466,7 +4418,6 @@ module Prism
4466
4418
  # def initialize: (Symbol name, Location name_loc, Location operator_loc, Prism::node value, Location location) -> void
4467
4419
  def initialize(source, name, name_loc, operator_loc, value, location)
4468
4420
  @source = source
4469
- @newline = false
4470
4421
  @location = location
4471
4422
  @name = name
4472
4423
  @name_loc = name_loc
@@ -4584,7 +4535,6 @@ module Prism
4584
4535
  # def initialize: (Symbol name, Location name_loc, Location binary_operator_loc, Prism::node value, Symbol binary_operator, Location location) -> void
4585
4536
  def initialize(source, name, name_loc, binary_operator_loc, value, binary_operator, location)
4586
4537
  @source = source
4587
- @newline = false
4588
4538
  @location = location
4589
4539
  @name = name
4590
4540
  @name_loc = name_loc
@@ -4702,7 +4652,6 @@ module Prism
4702
4652
  # def initialize: (Symbol name, Location name_loc, Location operator_loc, Prism::node value, Location location) -> void
4703
4653
  def initialize(source, name, name_loc, operator_loc, value, location)
4704
4654
  @source = source
4705
- @newline = false
4706
4655
  @location = location
4707
4656
  @name = name
4708
4657
  @name_loc = name_loc
@@ -4820,7 +4769,6 @@ module Prism
4820
4769
  # def initialize: (ConstantPathNode target, Location operator_loc, Prism::node value, Location location) -> void
4821
4770
  def initialize(source, target, operator_loc, value, location)
4822
4771
  @source = source
4823
- @newline = false
4824
4772
  @location = location
4825
4773
  @target = target
4826
4774
  @operator_loc = operator_loc
@@ -4929,7 +4877,6 @@ module Prism
4929
4877
  # def initialize: (Prism::node? parent, Symbol? name, Location delimiter_loc, Location name_loc, Location location) -> void
4930
4878
  def initialize(source, parent, name, delimiter_loc, name_loc, location)
4931
4879
  @source = source
4932
- @newline = false
4933
4880
  @location = location
4934
4881
  @parent = parent
4935
4882
  @name = name
@@ -5070,7 +5017,6 @@ module Prism
5070
5017
  # def initialize: (ConstantPathNode target, Location binary_operator_loc, Prism::node value, Symbol binary_operator, Location location) -> void
5071
5018
  def initialize(source, target, binary_operator_loc, value, binary_operator, location)
5072
5019
  @source = source
5073
- @newline = false
5074
5020
  @location = location
5075
5021
  @target = target
5076
5022
  @binary_operator_loc = binary_operator_loc
@@ -5179,7 +5125,6 @@ module Prism
5179
5125
  # def initialize: (ConstantPathNode target, Location operator_loc, Prism::node value, Location location) -> void
5180
5126
  def initialize(source, target, operator_loc, value, location)
5181
5127
  @source = source
5182
- @newline = false
5183
5128
  @location = location
5184
5129
  @target = target
5185
5130
  @operator_loc = operator_loc
@@ -5288,7 +5233,6 @@ module Prism
5288
5233
  # def initialize: (Prism::node? parent, Symbol? name, Location delimiter_loc, Location name_loc, Location location) -> void
5289
5234
  def initialize(source, parent, name, delimiter_loc, name_loc, location)
5290
5235
  @source = source
5291
- @newline = false
5292
5236
  @location = location
5293
5237
  @parent = parent
5294
5238
  @name = name
@@ -5414,7 +5358,6 @@ module Prism
5414
5358
  # def initialize: (ConstantPathNode target, Location operator_loc, Prism::node value, Location location) -> void
5415
5359
  def initialize(source, target, operator_loc, value, location)
5416
5360
  @source = source
5417
- @newline = false
5418
5361
  @location = location
5419
5362
  @target = target
5420
5363
  @operator_loc = operator_loc
@@ -5535,7 +5478,6 @@ module Prism
5535
5478
  # def initialize: (Symbol name, Location location) -> void
5536
5479
  def initialize(source, name, location)
5537
5480
  @source = source
5538
- @newline = false
5539
5481
  @location = location
5540
5482
  @name = name
5541
5483
  end
@@ -5629,7 +5571,6 @@ module Prism
5629
5571
  # def initialize: (Symbol name, Location location) -> void
5630
5572
  def initialize(source, name, location)
5631
5573
  @source = source
5632
- @newline = false
5633
5574
  @location = location
5634
5575
  @name = name
5635
5576
  end
@@ -5719,7 +5660,6 @@ module Prism
5719
5660
  # def initialize: (Symbol name, Location name_loc, Prism::node value, Location operator_loc, Location location) -> void
5720
5661
  def initialize(source, name, name_loc, value, operator_loc, location)
5721
5662
  @source = source
5722
- @newline = false
5723
5663
  @location = location
5724
5664
  @name = name
5725
5665
  @name_loc = name_loc
@@ -5854,7 +5794,6 @@ module Prism
5854
5794
  # def initialize: (Symbol name, Location name_loc, Prism::node? receiver, ParametersNode? parameters, Prism::node? body, Array[Symbol] locals, Location def_keyword_loc, Location? operator_loc, Location? lparen_loc, Location? rparen_loc, Location? equal_loc, Location? end_keyword_loc, Location location) -> void
5855
5795
  def initialize(source, name, name_loc, receiver, parameters, body, locals, def_keyword_loc, operator_loc, lparen_loc, rparen_loc, equal_loc, end_keyword_loc, location)
5856
5796
  @source = source
5857
- @newline = false
5858
5797
  @location = location
5859
5798
  @name = name
5860
5799
  @name_loc = name_loc
@@ -6092,7 +6031,6 @@ module Prism
6092
6031
  # def initialize: (Location? lparen_loc, Prism::node value, Location? rparen_loc, Location keyword_loc, Location location) -> void
6093
6032
  def initialize(source, lparen_loc, value, rparen_loc, keyword_loc, location)
6094
6033
  @source = source
6095
- @newline = false
6096
6034
  @location = location
6097
6035
  @lparen_loc = lparen_loc
6098
6036
  @value = value
@@ -6236,7 +6174,6 @@ module Prism
6236
6174
  # def initialize: (Location else_keyword_loc, StatementsNode? statements, Location? end_keyword_loc, Location location) -> void
6237
6175
  def initialize(source, else_keyword_loc, statements, end_keyword_loc, location)
6238
6176
  @source = source
6239
- @newline = false
6240
6177
  @location = location
6241
6178
  @else_keyword_loc = else_keyword_loc
6242
6179
  @statements = statements
@@ -6362,7 +6299,6 @@ module Prism
6362
6299
  # def initialize: (Location opening_loc, StatementsNode? statements, Location closing_loc, Location location) -> void
6363
6300
  def initialize(source, opening_loc, statements, closing_loc, location)
6364
6301
  @source = source
6365
- @newline = false
6366
6302
  @location = location
6367
6303
  @opening_loc = opening_loc
6368
6304
  @statements = statements
@@ -6482,7 +6418,6 @@ module Prism
6482
6418
  # def initialize: (Location operator_loc, Prism::node variable, Location location) -> void
6483
6419
  def initialize(source, operator_loc, variable, location)
6484
6420
  @source = source
6485
- @newline = false
6486
6421
  @location = location
6487
6422
  @operator_loc = operator_loc
6488
6423
  @variable = variable
@@ -6590,7 +6525,6 @@ module Prism
6590
6525
  # def initialize: (Location ensure_keyword_loc, StatementsNode? statements, Location end_keyword_loc, Location location) -> void
6591
6526
  def initialize(source, ensure_keyword_loc, statements, end_keyword_loc, location)
6592
6527
  @source = source
6593
- @newline = false
6594
6528
  @location = location
6595
6529
  @ensure_keyword_loc = ensure_keyword_loc
6596
6530
  @statements = statements
@@ -6710,7 +6644,6 @@ module Prism
6710
6644
  # def initialize: (Location location) -> void
6711
6645
  def initialize(source, location)
6712
6646
  @source = source
6713
- @newline = false
6714
6647
  @location = location
6715
6648
  end
6716
6649
 
@@ -6801,7 +6734,6 @@ module Prism
6801
6734
  # def initialize: (Prism::node? constant, Prism::node left, Array[Prism::node] requireds, Prism::node right, Location? opening_loc, Location? closing_loc, Location location) -> void
6802
6735
  def initialize(source, constant, left, requireds, right, opening_loc, closing_loc, location)
6803
6736
  @source = source
6804
- @newline = false
6805
6737
  @location = location
6806
6738
  @constant = constant
6807
6739
  @left = left
@@ -6952,7 +6884,6 @@ module Prism
6952
6884
  # def initialize: (Integer flags, Prism::node? left, Prism::node? right, Location operator_loc, Location location) -> void
6953
6885
  def initialize(source, flags, left, right, operator_loc, location)
6954
6886
  @source = source
6955
- @newline = false
6956
6887
  @location = location
6957
6888
  @flags = flags
6958
6889
  @left = left
@@ -7075,7 +7006,6 @@ module Prism
7075
7006
  # def initialize: (Float value, Location location) -> void
7076
7007
  def initialize(source, value, location)
7077
7008
  @source = source
7078
- @newline = false
7079
7009
  @location = location
7080
7010
  @value = value
7081
7011
  end
@@ -7165,7 +7095,6 @@ module Prism
7165
7095
  # def initialize: (Prism::node index, Prism::node collection, StatementsNode? statements, Location for_keyword_loc, Location in_keyword_loc, Location? do_keyword_loc, Location end_keyword_loc, Location location) -> void
7166
7096
  def initialize(source, index, collection, statements, for_keyword_loc, in_keyword_loc, do_keyword_loc, end_keyword_loc, location)
7167
7097
  @source = source
7168
- @newline = false
7169
7098
  @location = location
7170
7099
  @index = index
7171
7100
  @collection = collection
@@ -7213,30 +7142,50 @@ module Prism
7213
7142
  { index: index, collection: collection, statements: statements, for_keyword_loc: for_keyword_loc, in_keyword_loc: in_keyword_loc, do_keyword_loc: do_keyword_loc, end_keyword_loc: end_keyword_loc, location: location }
7214
7143
  end
7215
7144
 
7216
- # attr_reader index: Prism::node
7145
+ # The index expression for `for` loops.
7146
+ #
7147
+ # for i in a end
7148
+ # ^
7217
7149
  attr_reader :index
7218
7150
 
7219
- # attr_reader collection: Prism::node
7151
+ # The collection to iterate over.
7152
+ #
7153
+ # for i in a end
7154
+ # ^
7220
7155
  attr_reader :collection
7221
7156
 
7222
- # attr_reader statements: StatementsNode?
7157
+ # Represents the body of statements to execute for each iteration of the loop.
7158
+ #
7159
+ # for i in a
7160
+ # foo(i)
7161
+ # ^^^^^^
7162
+ # end
7223
7163
  attr_reader :statements
7224
7164
 
7225
- # attr_reader for_keyword_loc: Location
7165
+ # The location of the `for` keyword.
7166
+ #
7167
+ # for i in a end
7168
+ # ^^^
7226
7169
  def for_keyword_loc
7227
7170
  location = @for_keyword_loc
7228
7171
  return location if location.is_a?(Location)
7229
7172
  @for_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
7230
7173
  end
7231
7174
 
7232
- # attr_reader in_keyword_loc: Location
7175
+ # The location of the `in` keyword.
7176
+ #
7177
+ # for i in a end
7178
+ # ^^
7233
7179
  def in_keyword_loc
7234
7180
  location = @in_keyword_loc
7235
7181
  return location if location.is_a?(Location)
7236
7182
  @in_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
7237
7183
  end
7238
7184
 
7239
- # attr_reader do_keyword_loc: Location?
7185
+ # The location of the `do` keyword, if present.
7186
+ #
7187
+ # for i in a do end
7188
+ # ^^
7240
7189
  def do_keyword_loc
7241
7190
  location = @do_keyword_loc
7242
7191
  case location
@@ -7249,7 +7198,10 @@ module Prism
7249
7198
  end
7250
7199
  end
7251
7200
 
7252
- # attr_reader end_keyword_loc: Location
7201
+ # The location of the `end` keyword.
7202
+ #
7203
+ # for i in a end
7204
+ # ^^^
7253
7205
  def end_keyword_loc
7254
7206
  location = @end_keyword_loc
7255
7207
  return location if location.is_a?(Location)
@@ -7333,7 +7285,6 @@ module Prism
7333
7285
  # def initialize: (Location location) -> void
7334
7286
  def initialize(source, location)
7335
7287
  @source = source
7336
- @newline = false
7337
7288
  @location = location
7338
7289
  end
7339
7290
 
@@ -7419,7 +7370,6 @@ module Prism
7419
7370
  # def initialize: (Location location) -> void
7420
7371
  def initialize(source, location)
7421
7372
  @source = source
7422
- @newline = false
7423
7373
  @location = location
7424
7374
  end
7425
7375
 
@@ -7504,7 +7454,6 @@ module Prism
7504
7454
  # def initialize: (BlockNode? block, Location location) -> void
7505
7455
  def initialize(source, block, location)
7506
7456
  @source = source
7507
- @newline = false
7508
7457
  @location = location
7509
7458
  @block = block
7510
7459
  end
@@ -7596,7 +7545,6 @@ module Prism
7596
7545
  # def initialize: (Symbol name, Location name_loc, Location operator_loc, Prism::node value, Location location) -> void
7597
7546
  def initialize(source, name, name_loc, operator_loc, value, location)
7598
7547
  @source = source
7599
- @newline = false
7600
7548
  @location = location
7601
7549
  @name = name
7602
7550
  @name_loc = name_loc
@@ -7714,7 +7662,6 @@ module Prism
7714
7662
  # def initialize: (Symbol name, Location name_loc, Location binary_operator_loc, Prism::node value, Symbol binary_operator, Location location) -> void
7715
7663
  def initialize(source, name, name_loc, binary_operator_loc, value, binary_operator, location)
7716
7664
  @source = source
7717
- @newline = false
7718
7665
  @location = location
7719
7666
  @name = name
7720
7667
  @name_loc = name_loc
@@ -7832,7 +7779,6 @@ module Prism
7832
7779
  # def initialize: (Symbol name, Location name_loc, Location operator_loc, Prism::node value, Location location) -> void
7833
7780
  def initialize(source, name, name_loc, operator_loc, value, location)
7834
7781
  @source = source
7835
- @newline = false
7836
7782
  @location = location
7837
7783
  @name = name
7838
7784
  @name_loc = name_loc
@@ -7950,7 +7896,6 @@ module Prism
7950
7896
  # def initialize: (Symbol name, Location location) -> void
7951
7897
  def initialize(source, name, location)
7952
7898
  @source = source
7953
- @newline = false
7954
7899
  @location = location
7955
7900
  @name = name
7956
7901
  end
@@ -8044,7 +7989,6 @@ module Prism
8044
7989
  # def initialize: (Symbol name, Location location) -> void
8045
7990
  def initialize(source, name, location)
8046
7991
  @source = source
8047
- @newline = false
8048
7992
  @location = location
8049
7993
  @name = name
8050
7994
  end
@@ -8134,7 +8078,6 @@ module Prism
8134
8078
  # def initialize: (Symbol name, Location name_loc, Prism::node value, Location operator_loc, Location location) -> void
8135
8079
  def initialize(source, name, name_loc, value, operator_loc, location)
8136
8080
  @source = source
8137
- @newline = false
8138
8081
  @location = location
8139
8082
  @name = name
8140
8083
  @name_loc = name_loc
@@ -8268,7 +8211,6 @@ module Prism
8268
8211
  # def initialize: (Location opening_loc, Array[AssocNode | AssocSplatNode] elements, Location closing_loc, Location location) -> void
8269
8212
  def initialize(source, opening_loc, elements, closing_loc, location)
8270
8213
  @source = source
8271
- @newline = false
8272
8214
  @location = location
8273
8215
  @opening_loc = opening_loc
8274
8216
  @elements = elements
@@ -8402,7 +8344,6 @@ module Prism
8402
8344
  # def initialize: (Prism::node? constant, Array[AssocNode] elements, AssocSplatNode | NoKeywordsParameterNode | nil rest, Location? opening_loc, Location? closing_loc, Location location) -> void
8403
8345
  def initialize(source, constant, elements, rest, opening_loc, closing_loc, location)
8404
8346
  @source = source
8405
- @newline = false
8406
8347
  @location = location
8407
8348
  @constant = constant
8408
8349
  @elements = elements
@@ -8553,7 +8494,6 @@ module Prism
8553
8494
  # def initialize: (Location? if_keyword_loc, Prism::node predicate, Location? then_keyword_loc, StatementsNode? statements, Prism::node? consequent, Location? end_keyword_loc, Location location) -> void
8554
8495
  def initialize(source, if_keyword_loc, predicate, then_keyword_loc, statements, consequent, end_keyword_loc, location)
8555
8496
  @source = source
8556
- @newline = false
8557
8497
  @location = location
8558
8498
  @if_keyword_loc = if_keyword_loc
8559
8499
  @predicate = predicate
@@ -8568,10 +8508,6 @@ module Prism
8568
8508
  visitor.visit_if_node(self)
8569
8509
  end
8570
8510
 
8571
- def set_newline_flag(newline_marked) # :nodoc:
8572
- predicate.set_newline_flag(newline_marked)
8573
- end
8574
-
8575
8511
  # def child_nodes: () -> Array[nil | Node]
8576
8512
  def child_nodes
8577
8513
  [predicate, statements, consequent]
@@ -8767,7 +8703,6 @@ module Prism
8767
8703
  # def initialize: (FloatNode | IntegerNode | RationalNode numeric, Location location) -> void
8768
8704
  def initialize(source, numeric, location)
8769
8705
  @source = source
8770
- @newline = false
8771
8706
  @location = location
8772
8707
  @numeric = numeric
8773
8708
  end
@@ -8863,7 +8798,6 @@ module Prism
8863
8798
  # def initialize: (Prism::node value, Location location) -> void
8864
8799
  def initialize(source, value, location)
8865
8800
  @source = source
8866
- @newline = false
8867
8801
  @location = location
8868
8802
  @value = value
8869
8803
  end
@@ -8962,7 +8896,6 @@ module Prism
8962
8896
  # def initialize: (Location location) -> void
8963
8897
  def initialize(source, location)
8964
8898
  @source = source
8965
- @newline = false
8966
8899
  @location = location
8967
8900
  end
8968
8901
 
@@ -9047,7 +8980,6 @@ module Prism
9047
8980
  # def initialize: (Prism::node pattern, StatementsNode? statements, Location in_loc, Location? then_loc, Location location) -> void
9048
8981
  def initialize(source, pattern, statements, in_loc, then_loc, location)
9049
8982
  @source = source
9050
- @newline = false
9051
8983
  @location = location
9052
8984
  @pattern = pattern
9053
8985
  @statements = statements
@@ -9179,7 +9111,6 @@ module Prism
9179
9111
  # def initialize: (Integer flags, Prism::node? receiver, Location? call_operator_loc, Location opening_loc, ArgumentsNode? arguments, Location closing_loc, Prism::node? block, Location operator_loc, Prism::node value, Location location) -> void
9180
9112
  def initialize(source, flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, operator_loc, value, location)
9181
9113
  @source = source
9182
- @newline = false
9183
9114
  @location = location
9184
9115
  @flags = flags
9185
9116
  @receiver = receiver
@@ -9377,7 +9308,6 @@ module Prism
9377
9308
  # def initialize: (Integer flags, Prism::node? receiver, Location? call_operator_loc, Location opening_loc, ArgumentsNode? arguments, Location closing_loc, Prism::node? block, Symbol binary_operator, Location binary_operator_loc, Prism::node value, Location location) -> void
9378
9309
  def initialize(source, flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, binary_operator, binary_operator_loc, value, location)
9379
9310
  @source = source
9380
- @newline = false
9381
9311
  @location = location
9382
9312
  @flags = flags
9383
9313
  @receiver = receiver
@@ -9575,7 +9505,6 @@ module Prism
9575
9505
  # def initialize: (Integer flags, Prism::node? receiver, Location? call_operator_loc, Location opening_loc, ArgumentsNode? arguments, Location closing_loc, Prism::node? block, Location operator_loc, Prism::node value, Location location) -> void
9576
9506
  def initialize(source, flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, operator_loc, value, location)
9577
9507
  @source = source
9578
- @newline = false
9579
9508
  @location = location
9580
9509
  @flags = flags
9581
9510
  @receiver = receiver
@@ -9781,7 +9710,6 @@ module Prism
9781
9710
  # def initialize: (Integer flags, Prism::node receiver, Location opening_loc, ArgumentsNode? arguments, Location closing_loc, Prism::node? block, Location location) -> void
9782
9711
  def initialize(source, flags, receiver, opening_loc, arguments, closing_loc, block, location)
9783
9712
  @source = source
9784
- @newline = false
9785
9713
  @location = location
9786
9714
  @flags = flags
9787
9715
  @receiver = receiver
@@ -9939,7 +9867,6 @@ module Prism
9939
9867
  # def initialize: (Symbol name, Location name_loc, Location operator_loc, Prism::node value, Location location) -> void
9940
9868
  def initialize(source, name, name_loc, operator_loc, value, location)
9941
9869
  @source = source
9942
- @newline = false
9943
9870
  @location = location
9944
9871
  @name = name
9945
9872
  @name_loc = name_loc
@@ -10057,7 +9984,6 @@ module Prism
10057
9984
  # def initialize: (Symbol name, Location name_loc, Location binary_operator_loc, Prism::node value, Symbol binary_operator, Location location) -> void
10058
9985
  def initialize(source, name, name_loc, binary_operator_loc, value, binary_operator, location)
10059
9986
  @source = source
10060
- @newline = false
10061
9987
  @location = location
10062
9988
  @name = name
10063
9989
  @name_loc = name_loc
@@ -10175,7 +10101,6 @@ module Prism
10175
10101
  # def initialize: (Symbol name, Location name_loc, Location operator_loc, Prism::node value, Location location) -> void
10176
10102
  def initialize(source, name, name_loc, operator_loc, value, location)
10177
10103
  @source = source
10178
- @newline = false
10179
10104
  @location = location
10180
10105
  @name = name
10181
10106
  @name_loc = name_loc
@@ -10293,7 +10218,6 @@ module Prism
10293
10218
  # def initialize: (Symbol name, Location location) -> void
10294
10219
  def initialize(source, name, location)
10295
10220
  @source = source
10296
- @newline = false
10297
10221
  @location = location
10298
10222
  @name = name
10299
10223
  end
@@ -10387,7 +10311,6 @@ module Prism
10387
10311
  # def initialize: (Symbol name, Location location) -> void
10388
10312
  def initialize(source, name, location)
10389
10313
  @source = source
10390
- @newline = false
10391
10314
  @location = location
10392
10315
  @name = name
10393
10316
  end
@@ -10477,7 +10400,6 @@ module Prism
10477
10400
  # def initialize: (Symbol name, Location name_loc, Prism::node value, Location operator_loc, Location location) -> void
10478
10401
  def initialize(source, name, name_loc, value, operator_loc, location)
10479
10402
  @source = source
10480
- @newline = false
10481
10403
  @location = location
10482
10404
  @name = name
10483
10405
  @name_loc = name_loc
@@ -10611,7 +10533,6 @@ module Prism
10611
10533
  # def initialize: (Integer flags, Integer value, Location location) -> void
10612
10534
  def initialize(source, flags, value, location)
10613
10535
  @source = source
10614
- @newline = false
10615
10536
  @location = location
10616
10537
  @flags = flags
10617
10538
  @value = value
@@ -10727,7 +10648,6 @@ module Prism
10727
10648
  # def initialize: (Integer flags, Location opening_loc, Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] parts, Location closing_loc, Location location) -> void
10728
10649
  def initialize(source, flags, opening_loc, parts, closing_loc, location)
10729
10650
  @source = source
10730
- @newline = false
10731
10651
  @location = location
10732
10652
  @flags = flags
10733
10653
  @opening_loc = opening_loc
@@ -10740,11 +10660,6 @@ module Prism
10740
10660
  visitor.visit_interpolated_match_last_line_node(self)
10741
10661
  end
10742
10662
 
10743
- def set_newline_flag(newline_marked) # :nodoc:
10744
- first = parts.first
10745
- first.set_newline_flag(newline_marked) if first
10746
- end
10747
-
10748
10663
  # def child_nodes: () -> Array[nil | Node]
10749
10664
  def child_nodes
10750
10665
  [*parts]
@@ -10912,7 +10827,6 @@ module Prism
10912
10827
  # def initialize: (Integer flags, Location opening_loc, Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] parts, Location closing_loc, Location location) -> void
10913
10828
  def initialize(source, flags, opening_loc, parts, closing_loc, location)
10914
10829
  @source = source
10915
- @newline = false
10916
10830
  @location = location
10917
10831
  @flags = flags
10918
10832
  @opening_loc = opening_loc
@@ -10925,11 +10839,6 @@ module Prism
10925
10839
  visitor.visit_interpolated_regular_expression_node(self)
10926
10840
  end
10927
10841
 
10928
- def set_newline_flag(newline_marked) # :nodoc:
10929
- first = parts.first
10930
- first.set_newline_flag(newline_marked) if first
10931
- end
10932
-
10933
10842
  # def child_nodes: () -> Array[nil | Node]
10934
10843
  def child_nodes
10935
10844
  [*parts]
@@ -11097,7 +11006,6 @@ module Prism
11097
11006
  # def initialize: (Integer flags, Location? opening_loc, Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode] parts, Location? closing_loc, Location location) -> void
11098
11007
  def initialize(source, flags, opening_loc, parts, closing_loc, location)
11099
11008
  @source = source
11100
- @newline = false
11101
11009
  @location = location
11102
11010
  @flags = flags
11103
11011
  @opening_loc = opening_loc
@@ -11110,11 +11018,6 @@ module Prism
11110
11018
  visitor.visit_interpolated_string_node(self)
11111
11019
  end
11112
11020
 
11113
- def set_newline_flag(newline_marked) # :nodoc:
11114
- first = parts.first
11115
- first.set_newline_flag(newline_marked) if first
11116
- end
11117
-
11118
11021
  # def child_nodes: () -> Array[nil | Node]
11119
11022
  def child_nodes
11120
11023
  [*parts]
@@ -11249,7 +11152,6 @@ module Prism
11249
11152
  # def initialize: (Location? opening_loc, Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] parts, Location? closing_loc, Location location) -> void
11250
11153
  def initialize(source, opening_loc, parts, closing_loc, location)
11251
11154
  @source = source
11252
- @newline = false
11253
11155
  @location = location
11254
11156
  @opening_loc = opening_loc
11255
11157
  @parts = parts
@@ -11261,11 +11163,6 @@ module Prism
11261
11163
  visitor.visit_interpolated_symbol_node(self)
11262
11164
  end
11263
11165
 
11264
- def set_newline_flag(newline_marked) # :nodoc:
11265
- first = parts.first
11266
- first.set_newline_flag(newline_marked) if first
11267
- end
11268
-
11269
11166
  # def child_nodes: () -> Array[nil | Node]
11270
11167
  def child_nodes
11271
11168
  [*parts]
@@ -11385,7 +11282,6 @@ module Prism
11385
11282
  # def initialize: (Location opening_loc, Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] parts, Location closing_loc, Location location) -> void
11386
11283
  def initialize(source, opening_loc, parts, closing_loc, location)
11387
11284
  @source = source
11388
- @newline = false
11389
11285
  @location = location
11390
11286
  @opening_loc = opening_loc
11391
11287
  @parts = parts
@@ -11397,11 +11293,6 @@ module Prism
11397
11293
  visitor.visit_interpolated_x_string_node(self)
11398
11294
  end
11399
11295
 
11400
- def set_newline_flag(newline_marked) # :nodoc:
11401
- first = parts.first
11402
- first.set_newline_flag(newline_marked) if first
11403
- end
11404
-
11405
11296
  # def child_nodes: () -> Array[nil | Node]
11406
11297
  def child_nodes
11407
11298
  [*parts]
@@ -11501,6 +11392,90 @@ module Prism
11501
11392
  end
11502
11393
  end
11503
11394
 
11395
+ # Represents reading from the implicit `it` local variable.
11396
+ #
11397
+ # -> { it }
11398
+ # ^^
11399
+ class ItLocalVariableReadNode < Node
11400
+ # def initialize: (Location location) -> void
11401
+ def initialize(source, location)
11402
+ @source = source
11403
+ @location = location
11404
+ end
11405
+
11406
+ # def accept: (Visitor visitor) -> void
11407
+ def accept(visitor)
11408
+ visitor.visit_it_local_variable_read_node(self)
11409
+ end
11410
+
11411
+ # def child_nodes: () -> Array[nil | Node]
11412
+ def child_nodes
11413
+ []
11414
+ end
11415
+
11416
+ # def compact_child_nodes: () -> Array[Node]
11417
+ def compact_child_nodes
11418
+ []
11419
+ end
11420
+
11421
+ # def comment_targets: () -> Array[Node | Location]
11422
+ def comment_targets
11423
+ [] #: Array[Prism::node | Location]
11424
+ end
11425
+
11426
+ # def copy: (?location: Location) -> ItLocalVariableReadNode
11427
+ def copy(location: self.location)
11428
+ ItLocalVariableReadNode.new(source, location)
11429
+ end
11430
+
11431
+ # def deconstruct: () -> Array[nil | Node]
11432
+ alias deconstruct child_nodes
11433
+
11434
+ # def deconstruct_keys: (Array[Symbol] keys) -> { location: Location }
11435
+ def deconstruct_keys(keys)
11436
+ { location: location }
11437
+ end
11438
+
11439
+ # def inspect -> String
11440
+ def inspect
11441
+ InspectVisitor.compose(self)
11442
+ end
11443
+
11444
+ # Sometimes you want to check an instance of a node against a list of
11445
+ # classes to see what kind of behavior to perform. Usually this is done by
11446
+ # calling `[cls1, cls2].include?(node.class)` or putting the node into a
11447
+ # case statement and doing `case node; when cls1; when cls2; end`. Both of
11448
+ # these approaches are relatively slow because of the constant lookups,
11449
+ # method calls, and/or array allocations.
11450
+ #
11451
+ # Instead, you can call #type, which will return to you a symbol that you
11452
+ # can use for comparison. This is faster than the other approaches because
11453
+ # it uses a single integer comparison, but also because if you're on CRuby
11454
+ # you can take advantage of the fact that case statements with all symbol
11455
+ # keys will use a jump table.
11456
+ #
11457
+ # def type: () -> Symbol
11458
+ def type
11459
+ :it_local_variable_read_node
11460
+ end
11461
+
11462
+ # Similar to #type, this method returns a symbol that you can use for
11463
+ # splitting on the type of the node without having to do a long === chain.
11464
+ # Note that like #type, it will still be slower than using == for a single
11465
+ # class, but should be faster in a case statement or an array comparison.
11466
+ #
11467
+ # def self.type: () -> Symbol
11468
+ def self.type
11469
+ :it_local_variable_read_node
11470
+ end
11471
+
11472
+ # Implements case-equality for the node. This is effectively == but without
11473
+ # comparing the value of locations. Locations are checked only for presence.
11474
+ def ===(other)
11475
+ other.is_a?(ItLocalVariableReadNode)
11476
+ end
11477
+ end
11478
+
11504
11479
  # Represents an implicit set of parameters through the use of the `it` keyword within a block or lambda.
11505
11480
  #
11506
11481
  # -> { it + it }
@@ -11509,7 +11484,6 @@ module Prism
11509
11484
  # def initialize: (Location location) -> void
11510
11485
  def initialize(source, location)
11511
11486
  @source = source
11512
- @newline = false
11513
11487
  @location = location
11514
11488
  end
11515
11489
 
@@ -11594,7 +11568,6 @@ module Prism
11594
11568
  # def initialize: (Integer flags, Array[AssocNode | AssocSplatNode] elements, Location location) -> void
11595
11569
  def initialize(source, flags, elements, location)
11596
11570
  @source = source
11597
- @newline = false
11598
11571
  @location = location
11599
11572
  @flags = flags
11600
11573
  @elements = elements
@@ -11697,7 +11670,6 @@ module Prism
11697
11670
  # def initialize: (Integer flags, Symbol? name, Location? name_loc, Location operator_loc, Location location) -> void
11698
11671
  def initialize(source, flags, name, name_loc, operator_loc, location)
11699
11672
  @source = source
11700
- @newline = false
11701
11673
  @location = location
11702
11674
  @flags = flags
11703
11675
  @name = name
@@ -11827,7 +11799,6 @@ module Prism
11827
11799
  # def initialize: (Array[Symbol] locals, Location operator_loc, Location opening_loc, Location closing_loc, Prism::node? parameters, Prism::node? body, Location location) -> void
11828
11800
  def initialize(source, locals, operator_loc, opening_loc, closing_loc, parameters, body, location)
11829
11801
  @source = source
11830
- @newline = false
11831
11802
  @location = location
11832
11803
  @locals = locals
11833
11804
  @operator_loc = operator_loc
@@ -11973,7 +11944,6 @@ module Prism
11973
11944
  # def initialize: (Location name_loc, Location operator_loc, Prism::node value, Symbol name, Integer depth, Location location) -> void
11974
11945
  def initialize(source, name_loc, operator_loc, value, name, depth, location)
11975
11946
  @source = source
11976
- @newline = false
11977
11947
  @location = location
11978
11948
  @name_loc = name_loc
11979
11949
  @operator_loc = operator_loc
@@ -12096,7 +12066,6 @@ module Prism
12096
12066
  # def initialize: (Location name_loc, Location binary_operator_loc, Prism::node value, Symbol name, Symbol binary_operator, Integer depth, Location location) -> void
12097
12067
  def initialize(source, name_loc, binary_operator_loc, value, name, binary_operator, depth, location)
12098
12068
  @source = source
12099
- @newline = false
12100
12069
  @location = location
12101
12070
  @name_loc = name_loc
12102
12071
  @binary_operator_loc = binary_operator_loc
@@ -12219,7 +12188,6 @@ module Prism
12219
12188
  # def initialize: (Location name_loc, Location operator_loc, Prism::node value, Symbol name, Integer depth, Location location) -> void
12220
12189
  def initialize(source, name_loc, operator_loc, value, name, depth, location)
12221
12190
  @source = source
12222
- @newline = false
12223
12191
  @location = location
12224
12192
  @name_loc = name_loc
12225
12193
  @operator_loc = operator_loc
@@ -12342,7 +12310,6 @@ module Prism
12342
12310
  # def initialize: (Symbol name, Integer depth, Location location) -> void
12343
12311
  def initialize(source, name, depth, location)
12344
12312
  @source = source
12345
- @newline = false
12346
12313
  @location = location
12347
12314
  @name = name
12348
12315
  @depth = depth
@@ -12390,10 +12357,6 @@ module Prism
12390
12357
  # Note that this can also be an underscore followed by a number for the default block parameters.
12391
12358
  #
12392
12359
  # _1 # name `:_1`
12393
- #
12394
- # Finally, for the default `it` block parameter, the name is `0it`. This is to distinguish it from an `it` local variable that is explicitly declared.
12395
- #
12396
- # it # name `:0it`
12397
12360
  attr_reader :name
12398
12361
 
12399
12362
  # The number of visible scopes that should be searched to find the origin of this local variable.
@@ -12455,7 +12418,6 @@ module Prism
12455
12418
  # def initialize: (Symbol name, Integer depth, Location location) -> void
12456
12419
  def initialize(source, name, depth, location)
12457
12420
  @source = source
12458
- @newline = false
12459
12421
  @location = location
12460
12422
  @name = name
12461
12423
  @depth = depth
@@ -12550,7 +12512,6 @@ module Prism
12550
12512
  # def initialize: (Symbol name, Integer depth, Location name_loc, Prism::node value, Location operator_loc, Location location) -> void
12551
12513
  def initialize(source, name, depth, name_loc, value, operator_loc, location)
12552
12514
  @source = source
12553
- @newline = false
12554
12515
  @location = location
12555
12516
  @name = name
12556
12517
  @depth = depth
@@ -12699,7 +12660,6 @@ module Prism
12699
12660
  # def initialize: (Integer flags, Location opening_loc, Location content_loc, Location closing_loc, String unescaped, Location location) -> void
12700
12661
  def initialize(source, flags, opening_loc, content_loc, closing_loc, unescaped, location)
12701
12662
  @source = source
12702
- @newline = false
12703
12663
  @location = location
12704
12664
  @flags = flags
12705
12665
  @opening_loc = opening_loc
@@ -12892,7 +12852,6 @@ module Prism
12892
12852
  # def initialize: (Prism::node value, Prism::node pattern, Location operator_loc, Location location) -> void
12893
12853
  def initialize(source, value, pattern, operator_loc, location)
12894
12854
  @source = source
12895
- @newline = false
12896
12855
  @location = location
12897
12856
  @value = value
12898
12857
  @pattern = pattern
@@ -13001,7 +12960,6 @@ module Prism
13001
12960
  # def initialize: (Prism::node value, Prism::node pattern, Location operator_loc, Location location) -> void
13002
12961
  def initialize(source, value, pattern, operator_loc, location)
13003
12962
  @source = source
13004
- @newline = false
13005
12963
  @location = location
13006
12964
  @value = value
13007
12965
  @pattern = pattern
@@ -13110,7 +13068,6 @@ module Prism
13110
13068
  # def initialize: (CallNode call, Array[LocalVariableTargetNode] targets, Location location) -> void
13111
13069
  def initialize(source, call, targets, location)
13112
13070
  @source = source
13113
- @newline = false
13114
13071
  @location = location
13115
13072
  @call = call
13116
13073
  @targets = targets
@@ -13203,7 +13160,6 @@ module Prism
13203
13160
  # def initialize: (Location location) -> void
13204
13161
  def initialize(source, location)
13205
13162
  @source = source
13206
- @newline = false
13207
13163
  @location = location
13208
13164
  end
13209
13165
 
@@ -13288,7 +13244,6 @@ module Prism
13288
13244
  # def initialize: (Array[Symbol] locals, Location module_keyword_loc, Prism::node constant_path, Prism::node? body, Location end_keyword_loc, Symbol name, Location location) -> void
13289
13245
  def initialize(source, locals, module_keyword_loc, constant_path, body, end_keyword_loc, name, location)
13290
13246
  @source = source
13291
- @newline = false
13292
13247
  @location = location
13293
13248
  @locals = locals
13294
13249
  @module_keyword_loc = module_keyword_loc
@@ -13425,7 +13380,6 @@ module Prism
13425
13380
  # def initialize: (Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode] lefts, Prism::node? rest, Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode] rights, Location? lparen_loc, Location? rparen_loc, Location location) -> void
13426
13381
  def initialize(source, lefts, rest, rights, lparen_loc, rparen_loc, location)
13427
13382
  @source = source
13428
- @newline = false
13429
13383
  @location = location
13430
13384
  @lefts = lefts
13431
13385
  @rest = rest
@@ -13571,7 +13525,6 @@ module Prism
13571
13525
  # def initialize: (Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode] lefts, Prism::node? rest, Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode] rights, Location? lparen_loc, Location? rparen_loc, Location operator_loc, Prism::node value, Location location) -> void
13572
13526
  def initialize(source, lefts, rest, rights, lparen_loc, rparen_loc, operator_loc, value, location)
13573
13527
  @source = source
13574
- @newline = false
13575
13528
  @location = location
13576
13529
  @lefts = lefts
13577
13530
  @rest = rest
@@ -13737,7 +13690,6 @@ module Prism
13737
13690
  # def initialize: (ArgumentsNode? arguments, Location keyword_loc, Location location) -> void
13738
13691
  def initialize(source, arguments, keyword_loc, location)
13739
13692
  @source = source
13740
- @newline = false
13741
13693
  @location = location
13742
13694
  @arguments = arguments
13743
13695
  @keyword_loc = keyword_loc
@@ -13843,7 +13795,6 @@ module Prism
13843
13795
  # def initialize: (Location location) -> void
13844
13796
  def initialize(source, location)
13845
13797
  @source = source
13846
- @newline = false
13847
13798
  @location = location
13848
13799
  end
13849
13800
 
@@ -13929,7 +13880,6 @@ module Prism
13929
13880
  # def initialize: (Location operator_loc, Location keyword_loc, Location location) -> void
13930
13881
  def initialize(source, operator_loc, keyword_loc, location)
13931
13882
  @source = source
13932
- @newline = false
13933
13883
  @location = location
13934
13884
  @operator_loc = operator_loc
13935
13885
  @keyword_loc = keyword_loc
@@ -14042,7 +13992,6 @@ module Prism
14042
13992
  # def initialize: (Integer maximum, Location location) -> void
14043
13993
  def initialize(source, maximum, location)
14044
13994
  @source = source
14045
- @newline = false
14046
13995
  @location = location
14047
13996
  @maximum = maximum
14048
13997
  end
@@ -14132,7 +14081,6 @@ module Prism
14132
14081
  # def initialize: (Integer number, Location location) -> void
14133
14082
  def initialize(source, number, location)
14134
14083
  @source = source
14135
- @newline = false
14136
14084
  @location = location
14137
14085
  @number = number
14138
14086
  end
@@ -14229,7 +14177,6 @@ module Prism
14229
14177
  # def initialize: (Integer flags, Symbol name, Location name_loc, Prism::node value, Location location) -> void
14230
14178
  def initialize(source, flags, name, name_loc, value, location)
14231
14179
  @source = source
14232
- @newline = false
14233
14180
  @location = location
14234
14181
  @flags = flags
14235
14182
  @name = name
@@ -14345,7 +14292,6 @@ module Prism
14345
14292
  # def initialize: (Integer flags, Symbol name, Location name_loc, Location operator_loc, Prism::node value, Location location) -> void
14346
14293
  def initialize(source, flags, name, name_loc, operator_loc, value, location)
14347
14294
  @source = source
14348
- @newline = false
14349
14295
  @location = location
14350
14296
  @flags = flags
14351
14297
  @name = name
@@ -14474,7 +14420,6 @@ module Prism
14474
14420
  # def initialize: (Prism::node left, Prism::node right, Location operator_loc, Location location) -> void
14475
14421
  def initialize(source, left, right, operator_loc, location)
14476
14422
  @source = source
14477
- @newline = false
14478
14423
  @location = location
14479
14424
  @left = left
14480
14425
  @right = right
@@ -14599,7 +14544,6 @@ module Prism
14599
14544
  # def initialize: (Array[RequiredParameterNode | MultiTargetNode] requireds, Array[OptionalParameterNode] optionals, RestParameterNode | ImplicitRestNode | nil rest, Array[RequiredParameterNode | MultiTargetNode | KeywordRestParameterNode | NoKeywordsParameterNode | ForwardingParameterNode] posts, Array[RequiredKeywordParameterNode | OptionalKeywordParameterNode] keywords, KeywordRestParameterNode | ForwardingParameterNode | NoKeywordsParameterNode | nil keyword_rest, BlockParameterNode? block, Location location) -> void
14600
14545
  def initialize(source, requireds, optionals, rest, posts, keywords, keyword_rest, block, location)
14601
14546
  @source = source
14602
- @newline = false
14603
14547
  @location = location
14604
14548
  @requireds = requireds
14605
14549
  @optionals = optionals
@@ -14731,7 +14675,6 @@ module Prism
14731
14675
  # def initialize: (Prism::node? body, Location opening_loc, Location closing_loc, Location location) -> void
14732
14676
  def initialize(source, body, opening_loc, closing_loc, location)
14733
14677
  @source = source
14734
- @newline = false
14735
14678
  @location = location
14736
14679
  @body = body
14737
14680
  @opening_loc = opening_loc
@@ -14743,10 +14686,6 @@ module Prism
14743
14686
  visitor.visit_parentheses_node(self)
14744
14687
  end
14745
14688
 
14746
- def set_newline_flag(newline_marked) # :nodoc:
14747
- # Never mark ParenthesesNode with a newline flag, mark children instead
14748
- end
14749
-
14750
14689
  # def child_nodes: () -> Array[nil | Node]
14751
14690
  def child_nodes
14752
14691
  [body]
@@ -14855,7 +14794,6 @@ module Prism
14855
14794
  # def initialize: (Prism::node expression, Location operator_loc, Location lparen_loc, Location rparen_loc, Location location) -> void
14856
14795
  def initialize(source, expression, operator_loc, lparen_loc, rparen_loc, location)
14857
14796
  @source = source
14858
- @newline = false
14859
14797
  @location = location
14860
14798
  @expression = expression
14861
14799
  @operator_loc = operator_loc
@@ -14987,7 +14925,6 @@ module Prism
14987
14925
  # def initialize: (Prism::node variable, Location operator_loc, Location location) -> void
14988
14926
  def initialize(source, variable, operator_loc, location)
14989
14927
  @source = source
14990
- @newline = false
14991
14928
  @location = location
14992
14929
  @variable = variable
14993
14930
  @operator_loc = operator_loc
@@ -15091,7 +15028,6 @@ module Prism
15091
15028
  # def initialize: (StatementsNode? statements, Location keyword_loc, Location opening_loc, Location closing_loc, Location location) -> void
15092
15029
  def initialize(source, statements, keyword_loc, opening_loc, closing_loc, location)
15093
15030
  @source = source
15094
- @newline = false
15095
15031
  @location = location
15096
15032
  @statements = statements
15097
15033
  @keyword_loc = keyword_loc
@@ -15225,7 +15161,6 @@ module Prism
15225
15161
  # def initialize: (StatementsNode? statements, Location keyword_loc, Location opening_loc, Location closing_loc, Location location) -> void
15226
15162
  def initialize(source, statements, keyword_loc, opening_loc, closing_loc, location)
15227
15163
  @source = source
15228
- @newline = false
15229
15164
  @location = location
15230
15165
  @statements = statements
15231
15166
  @keyword_loc = keyword_loc
@@ -15356,7 +15291,6 @@ module Prism
15356
15291
  # def initialize: (Array[Symbol] locals, StatementsNode statements, Location location) -> void
15357
15292
  def initialize(source, locals, statements, location)
15358
15293
  @source = source
15359
- @newline = false
15360
15294
  @location = location
15361
15295
  @locals = locals
15362
15296
  @statements = statements
@@ -15455,7 +15389,6 @@ module Prism
15455
15389
  # def initialize: (Integer flags, Prism::node? left, Prism::node? right, Location operator_loc, Location location) -> void
15456
15390
  def initialize(source, flags, left, right, operator_loc, location)
15457
15391
  @source = source
15458
- @newline = false
15459
15392
  @location = location
15460
15393
  @flags = flags
15461
15394
  @left = left
@@ -15588,12 +15521,13 @@ module Prism
15588
15521
  # 1.0r
15589
15522
  # ^^^^
15590
15523
  class RationalNode < Node
15591
- # def initialize: (Prism::node numeric, Location location) -> void
15592
- def initialize(source, numeric, location)
15524
+ # def initialize: (Integer flags, Integer numerator, Integer denominator, Location location) -> void
15525
+ def initialize(source, flags, numerator, denominator, location)
15593
15526
  @source = source
15594
- @newline = false
15595
15527
  @location = location
15596
- @numeric = numeric
15528
+ @flags = flags
15529
+ @numerator = numerator
15530
+ @denominator = denominator
15597
15531
  end
15598
15532
 
15599
15533
  # def accept: (Visitor visitor) -> void
@@ -15603,34 +15537,65 @@ module Prism
15603
15537
 
15604
15538
  # def child_nodes: () -> Array[nil | Node]
15605
15539
  def child_nodes
15606
- [numeric]
15540
+ []
15607
15541
  end
15608
15542
 
15609
15543
  # def compact_child_nodes: () -> Array[Node]
15610
15544
  def compact_child_nodes
15611
- [numeric]
15545
+ []
15612
15546
  end
15613
15547
 
15614
15548
  # def comment_targets: () -> Array[Node | Location]
15615
15549
  def comment_targets
15616
- [numeric] #: Array[Prism::node | Location]
15550
+ [] #: Array[Prism::node | Location]
15617
15551
  end
15618
15552
 
15619
- # def copy: (?numeric: Prism::node, ?location: Location) -> RationalNode
15620
- def copy(numeric: self.numeric, location: self.location)
15621
- RationalNode.new(source, numeric, location)
15553
+ # def copy: (?flags: Integer, ?numerator: Integer, ?denominator: Integer, ?location: Location) -> RationalNode
15554
+ def copy(flags: self.flags, numerator: self.numerator, denominator: self.denominator, location: self.location)
15555
+ RationalNode.new(source, flags, numerator, denominator, location)
15622
15556
  end
15623
15557
 
15624
15558
  # def deconstruct: () -> Array[nil | Node]
15625
15559
  alias deconstruct child_nodes
15626
15560
 
15627
- # def deconstruct_keys: (Array[Symbol] keys) -> { numeric: Prism::node, location: Location }
15561
+ # def deconstruct_keys: (Array[Symbol] keys) -> { flags: Integer, numerator: Integer, denominator: Integer, location: Location }
15628
15562
  def deconstruct_keys(keys)
15629
- { numeric: numeric, location: location }
15563
+ { flags: flags, numerator: numerator, denominator: denominator, location: location }
15630
15564
  end
15631
15565
 
15632
- # attr_reader numeric: Prism::node
15633
- attr_reader :numeric
15566
+ # protected attr_reader flags: Integer
15567
+ attr_reader :flags
15568
+ protected :flags
15569
+
15570
+ # The numerator of the rational number.
15571
+ #
15572
+ # 1.5r # numerator 3
15573
+ attr_reader :numerator
15574
+
15575
+ # The denominator of the rational number.
15576
+ #
15577
+ # 1.5r # denominator 2
15578
+ attr_reader :denominator
15579
+
15580
+ # def binary?: () -> bool
15581
+ def binary?
15582
+ flags.anybits?(IntegerBaseFlags::BINARY)
15583
+ end
15584
+
15585
+ # def decimal?: () -> bool
15586
+ def decimal?
15587
+ flags.anybits?(IntegerBaseFlags::DECIMAL)
15588
+ end
15589
+
15590
+ # def octal?: () -> bool
15591
+ def octal?
15592
+ flags.anybits?(IntegerBaseFlags::OCTAL)
15593
+ end
15594
+
15595
+ # def hexadecimal?: () -> bool
15596
+ def hexadecimal?
15597
+ flags.anybits?(IntegerBaseFlags::HEXADECIMAL)
15598
+ end
15634
15599
 
15635
15600
  # def inspect -> String
15636
15601
  def inspect
@@ -15669,7 +15634,9 @@ module Prism
15669
15634
  # comparing the value of locations. Locations are checked only for presence.
15670
15635
  def ===(other)
15671
15636
  other.is_a?(RationalNode) &&
15672
- (numeric === other.numeric)
15637
+ (flags === other.flags) &&
15638
+ (numerator === other.numerator) &&
15639
+ (denominator === other.denominator)
15673
15640
  end
15674
15641
  end
15675
15642
 
@@ -15681,7 +15648,6 @@ module Prism
15681
15648
  # def initialize: (Location location) -> void
15682
15649
  def initialize(source, location)
15683
15650
  @source = source
15684
- @newline = false
15685
15651
  @location = location
15686
15652
  end
15687
15653
 
@@ -15766,7 +15732,6 @@ module Prism
15766
15732
  # def initialize: (Integer flags, Location opening_loc, Location content_loc, Location closing_loc, String unescaped, Location location) -> void
15767
15733
  def initialize(source, flags, opening_loc, content_loc, closing_loc, unescaped, location)
15768
15734
  @source = source
15769
- @newline = false
15770
15735
  @location = location
15771
15736
  @flags = flags
15772
15737
  @opening_loc = opening_loc
@@ -15960,7 +15925,6 @@ module Prism
15960
15925
  # def initialize: (Integer flags, Symbol name, Location name_loc, Location location) -> void
15961
15926
  def initialize(source, flags, name, name_loc, location)
15962
15927
  @source = source
15963
- @newline = false
15964
15928
  @location = location
15965
15929
  @flags = flags
15966
15930
  @name = name
@@ -16071,7 +16035,6 @@ module Prism
16071
16035
  # def initialize: (Integer flags, Symbol name, Location location) -> void
16072
16036
  def initialize(source, flags, name, location)
16073
16037
  @source = source
16074
- @newline = false
16075
16038
  @location = location
16076
16039
  @flags = flags
16077
16040
  @name = name
@@ -16172,7 +16135,6 @@ module Prism
16172
16135
  # def initialize: (Prism::node expression, Location keyword_loc, Prism::node rescue_expression, Location location) -> void
16173
16136
  def initialize(source, expression, keyword_loc, rescue_expression, location)
16174
16137
  @source = source
16175
- @newline = false
16176
16138
  @location = location
16177
16139
  @expression = expression
16178
16140
  @keyword_loc = keyword_loc
@@ -16184,10 +16146,6 @@ module Prism
16184
16146
  visitor.visit_rescue_modifier_node(self)
16185
16147
  end
16186
16148
 
16187
- def set_newline_flag(newline_marked) # :nodoc:
16188
- expression.set_newline_flag(newline_marked)
16189
- end
16190
-
16191
16149
  # def child_nodes: () -> Array[nil | Node]
16192
16150
  def child_nodes
16193
16151
  [expression, rescue_expression]
@@ -16290,7 +16248,6 @@ module Prism
16290
16248
  # def initialize: (Location keyword_loc, Array[Prism::node] exceptions, Location? operator_loc, Prism::node? reference, StatementsNode? statements, RescueNode? consequent, Location location) -> void
16291
16249
  def initialize(source, keyword_loc, exceptions, operator_loc, reference, statements, consequent, location)
16292
16250
  @source = source
16293
- @newline = false
16294
16251
  @location = location
16295
16252
  @keyword_loc = keyword_loc
16296
16253
  @exceptions = exceptions
@@ -16436,7 +16393,6 @@ module Prism
16436
16393
  # def initialize: (Integer flags, Symbol? name, Location? name_loc, Location operator_loc, Location location) -> void
16437
16394
  def initialize(source, flags, name, name_loc, operator_loc, location)
16438
16395
  @source = source
16439
- @newline = false
16440
16396
  @location = location
16441
16397
  @flags = flags
16442
16398
  @name = name
@@ -16566,7 +16522,6 @@ module Prism
16566
16522
  # def initialize: (Location location) -> void
16567
16523
  def initialize(source, location)
16568
16524
  @source = source
16569
- @newline = false
16570
16525
  @location = location
16571
16526
  end
16572
16527
 
@@ -16651,7 +16606,6 @@ module Prism
16651
16606
  # def initialize: (Integer flags, Location keyword_loc, ArgumentsNode? arguments, Location location) -> void
16652
16607
  def initialize(source, flags, keyword_loc, arguments, location)
16653
16608
  @source = source
16654
- @newline = false
16655
16609
  @location = location
16656
16610
  @flags = flags
16657
16611
  @keyword_loc = keyword_loc
@@ -16768,7 +16722,6 @@ module Prism
16768
16722
  # def initialize: (Location location) -> void
16769
16723
  def initialize(source, location)
16770
16724
  @source = source
16771
- @newline = false
16772
16725
  @location = location
16773
16726
  end
16774
16727
 
@@ -16854,7 +16807,6 @@ module Prism
16854
16807
  # def initialize: (Integer flags, ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode write, Location location) -> void
16855
16808
  def initialize(source, flags, write, location)
16856
16809
  @source = source
16857
- @newline = false
16858
16810
  @location = location
16859
16811
  @flags = flags
16860
16812
  @write = write
@@ -16965,7 +16917,6 @@ module Prism
16965
16917
  # def initialize: (Array[Symbol] locals, Location class_keyword_loc, Location operator_loc, Prism::node expression, Prism::node? body, Location end_keyword_loc, Location location) -> void
16966
16918
  def initialize(source, locals, class_keyword_loc, operator_loc, expression, body, end_keyword_loc, location)
16967
16919
  @source = source
16968
- @newline = false
16969
16920
  @location = location
16970
16921
  @locals = locals
16971
16922
  @class_keyword_loc = class_keyword_loc
@@ -17111,7 +17062,6 @@ module Prism
17111
17062
  # def initialize: (Location location) -> void
17112
17063
  def initialize(source, location)
17113
17064
  @source = source
17114
- @newline = false
17115
17065
  @location = location
17116
17066
  end
17117
17067
 
@@ -17196,7 +17146,6 @@ module Prism
17196
17146
  # def initialize: (Integer flags, String filepath, Location location) -> void
17197
17147
  def initialize(source, flags, filepath, location)
17198
17148
  @source = source
17199
- @newline = false
17200
17149
  @location = location
17201
17150
  @flags = flags
17202
17151
  @filepath = filepath
@@ -17312,7 +17261,6 @@ module Prism
17312
17261
  # def initialize: (Location location) -> void
17313
17262
  def initialize(source, location)
17314
17263
  @source = source
17315
- @newline = false
17316
17264
  @location = location
17317
17265
  end
17318
17266
 
@@ -17397,7 +17345,6 @@ module Prism
17397
17345
  # def initialize: (Location operator_loc, Prism::node? expression, Location location) -> void
17398
17346
  def initialize(source, operator_loc, expression, location)
17399
17347
  @source = source
17400
- @newline = false
17401
17348
  @location = location
17402
17349
  @operator_loc = operator_loc
17403
17350
  @expression = expression
@@ -17503,7 +17450,6 @@ module Prism
17503
17450
  # def initialize: (Array[Prism::node] body, Location location) -> void
17504
17451
  def initialize(source, body, location)
17505
17452
  @source = source
17506
- @newline = false
17507
17453
  @location = location
17508
17454
  @body = body
17509
17455
  end
@@ -17600,7 +17546,6 @@ module Prism
17600
17546
  # def initialize: (Integer flags, Location? opening_loc, Location content_loc, Location? closing_loc, String unescaped, Location location) -> void
17601
17547
  def initialize(source, flags, opening_loc, content_loc, closing_loc, unescaped, location)
17602
17548
  @source = source
17603
- @newline = false
17604
17549
  @location = location
17605
17550
  @flags = flags
17606
17551
  @opening_loc = opening_loc
@@ -17773,7 +17718,6 @@ module Prism
17773
17718
  # def initialize: (Location keyword_loc, Location? lparen_loc, ArgumentsNode? arguments, Location? rparen_loc, Prism::node? block, Location location) -> void
17774
17719
  def initialize(source, keyword_loc, lparen_loc, arguments, rparen_loc, block, location)
17775
17720
  @source = source
17776
- @newline = false
17777
17721
  @location = location
17778
17722
  @keyword_loc = keyword_loc
17779
17723
  @lparen_loc = lparen_loc
@@ -17928,7 +17872,6 @@ module Prism
17928
17872
  # def initialize: (Integer flags, Location? opening_loc, Location? value_loc, Location? closing_loc, String unescaped, Location location) -> void
17929
17873
  def initialize(source, flags, opening_loc, value_loc, closing_loc, unescaped, location)
17930
17874
  @source = source
17931
- @newline = false
17932
17875
  @location = location
17933
17876
  @flags = flags
17934
17877
  @opening_loc = opening_loc
@@ -18099,7 +18042,6 @@ module Prism
18099
18042
  # def initialize: (Location location) -> void
18100
18043
  def initialize(source, location)
18101
18044
  @source = source
18102
- @newline = false
18103
18045
  @location = location
18104
18046
  end
18105
18047
 
@@ -18184,7 +18126,6 @@ module Prism
18184
18126
  # def initialize: (Array[SymbolNode | InterpolatedSymbolNode] names, Location keyword_loc, Location location) -> void
18185
18127
  def initialize(source, names, keyword_loc, location)
18186
18128
  @source = source
18187
- @newline = false
18188
18129
  @location = location
18189
18130
  @names = names
18190
18131
  @keyword_loc = keyword_loc
@@ -18292,7 +18233,6 @@ module Prism
18292
18233
  # def initialize: (Location keyword_loc, Prism::node predicate, Location? then_keyword_loc, StatementsNode? statements, ElseNode? consequent, Location? end_keyword_loc, Location location) -> void
18293
18234
  def initialize(source, keyword_loc, predicate, then_keyword_loc, statements, consequent, end_keyword_loc, location)
18294
18235
  @source = source
18295
- @newline = false
18296
18236
  @location = location
18297
18237
  @keyword_loc = keyword_loc
18298
18238
  @predicate = predicate
@@ -18307,10 +18247,6 @@ module Prism
18307
18247
  visitor.visit_unless_node(self)
18308
18248
  end
18309
18249
 
18310
- def set_newline_flag(newline_marked) # :nodoc:
18311
- predicate.set_newline_flag(newline_marked)
18312
- end
18313
-
18314
18250
  # def child_nodes: () -> Array[nil | Node]
18315
18251
  def child_nodes
18316
18252
  [predicate, statements, consequent]
@@ -18366,7 +18302,9 @@ module Prism
18366
18302
  attr_reader :predicate
18367
18303
 
18368
18304
  # The location of the `then` keyword, if present.
18369
- # unless cond then bar end ^^^^
18305
+ #
18306
+ # unless cond then bar end
18307
+ # ^^^^
18370
18308
  def then_keyword_loc
18371
18309
  location = @then_keyword_loc
18372
18310
  case location
@@ -18480,7 +18418,6 @@ module Prism
18480
18418
  # def initialize: (Integer flags, Location keyword_loc, Location? closing_loc, Prism::node predicate, StatementsNode? statements, Location location) -> void
18481
18419
  def initialize(source, flags, keyword_loc, closing_loc, predicate, statements, location)
18482
18420
  @source = source
18483
- @newline = false
18484
18421
  @location = location
18485
18422
  @flags = flags
18486
18423
  @keyword_loc = keyword_loc
@@ -18494,10 +18431,6 @@ module Prism
18494
18431
  visitor.visit_until_node(self)
18495
18432
  end
18496
18433
 
18497
- def set_newline_flag(newline_marked) # :nodoc:
18498
- predicate.set_newline_flag(newline_marked)
18499
- end
18500
-
18501
18434
  # def child_nodes: () -> Array[nil | Node]
18502
18435
  def child_nodes
18503
18436
  [predicate, statements]
@@ -18629,7 +18562,6 @@ module Prism
18629
18562
  # def initialize: (Location keyword_loc, Array[Prism::node] conditions, Location? then_keyword_loc, StatementsNode? statements, Location location) -> void
18630
18563
  def initialize(source, keyword_loc, conditions, then_keyword_loc, statements, location)
18631
18564
  @source = source
18632
- @newline = false
18633
18565
  @location = location
18634
18566
  @keyword_loc = keyword_loc
18635
18567
  @conditions = conditions
@@ -18765,7 +18697,6 @@ module Prism
18765
18697
  # def initialize: (Integer flags, Location keyword_loc, Location? closing_loc, Prism::node predicate, StatementsNode? statements, Location location) -> void
18766
18698
  def initialize(source, flags, keyword_loc, closing_loc, predicate, statements, location)
18767
18699
  @source = source
18768
- @newline = false
18769
18700
  @location = location
18770
18701
  @flags = flags
18771
18702
  @keyword_loc = keyword_loc
@@ -18779,10 +18710,6 @@ module Prism
18779
18710
  visitor.visit_while_node(self)
18780
18711
  end
18781
18712
 
18782
- def set_newline_flag(newline_marked) # :nodoc:
18783
- predicate.set_newline_flag(newline_marked)
18784
- end
18785
-
18786
18713
  # def child_nodes: () -> Array[nil | Node]
18787
18714
  def child_nodes
18788
18715
  [predicate, statements]
@@ -18912,7 +18839,6 @@ module Prism
18912
18839
  # def initialize: (Integer flags, Location opening_loc, Location content_loc, Location closing_loc, String unescaped, Location location) -> void
18913
18840
  def initialize(source, flags, opening_loc, content_loc, closing_loc, unescaped, location)
18914
18841
  @source = source
18915
- @newline = false
18916
18842
  @location = location
18917
18843
  @flags = flags
18918
18844
  @opening_loc = opening_loc
@@ -19060,7 +18986,6 @@ module Prism
19060
18986
  # def initialize: (Location keyword_loc, Location? lparen_loc, ArgumentsNode? arguments, Location? rparen_loc, Location location) -> void
19061
18987
  def initialize(source, keyword_loc, lparen_loc, arguments, rparen_loc, location)
19062
18988
  @source = source
19063
- @newline = false
19064
18989
  @location = location
19065
18990
  @keyword_loc = keyword_loc
19066
18991
  @lparen_loc = lparen_loc