prism 0.26.0 → 0.27.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -1
- data/Makefile +3 -2
- data/config.yml +278 -5
- data/ext/prism/api_node.c +70 -72
- data/ext/prism/extconf.rb +23 -4
- data/ext/prism/extension.c +11 -6
- data/ext/prism/extension.h +1 -1
- data/include/prism/ast.h +271 -4
- data/include/prism/diagnostic.h +3 -0
- data/include/prism/version.h +2 -2
- data/lib/prism/ffi.rb +1 -1
- data/lib/prism/lex_compat.rb +18 -1
- data/lib/prism/node.rb +1772 -265
- data/lib/prism/parse_result/newlines.rb +0 -2
- data/lib/prism/parse_result.rb +59 -13
- data/lib/prism/reflection.rb +18 -28
- data/lib/prism/serialize.rb +7 -4
- data/lib/prism/translation/parser/compiler.rb +32 -13
- data/lib/prism/translation/ripper.rb +59 -59
- data/lib/prism/translation/ruby_parser.rb +66 -28
- data/lib/prism.rb +1 -1
- data/prism.gemspec +1 -1
- data/rbi/prism/node.rbi +5 -2
- data/rbi/prism/parse_result.rbi +62 -34
- data/rbi/prism/reflection.rbi +7 -13
- data/rbi/prism.rbi +9 -9
- data/sig/prism/node.rbs +4 -1
- data/sig/prism/parse_result.rbs +30 -10
- data/sig/prism/reflection.rbs +2 -8
- data/sig/prism/serialize.rbs +2 -3
- data/sig/prism.rbs +9 -9
- data/src/diagnostic.c +7 -1
- data/src/prism.c +16 -3
- data/src/util/pm_integer.c +9 -2
- metadata +2 -2
data/lib/prism/node.rb
CHANGED
@@ -176,20 +176,28 @@ module Prism
|
|
176
176
|
{ new_name: new_name, old_name: old_name, keyword_loc: keyword_loc, location: location }
|
177
177
|
end
|
178
178
|
|
179
|
-
#
|
179
|
+
# Represents the new name of the global variable that can be used after aliasing. This can be either a global variable, a back reference, or a numbered reference.
|
180
|
+
#
|
181
|
+
# alias $foo $bar
|
182
|
+
# ^^^^
|
180
183
|
attr_reader :new_name
|
181
184
|
|
182
|
-
#
|
185
|
+
# Represents the old name of the global variable that could be used before aliasing. This can be either a global variable, a back reference, or a numbered reference.
|
186
|
+
#
|
187
|
+
# alias $foo $bar
|
188
|
+
# ^^^^
|
183
189
|
attr_reader :old_name
|
184
190
|
|
185
|
-
#
|
191
|
+
# The location of the `alias` keyword.
|
192
|
+
#
|
193
|
+
# alias $foo $bar
|
194
|
+
# ^^^^^
|
186
195
|
def keyword_loc
|
187
196
|
location = @keyword_loc
|
188
197
|
return location if location.is_a?(Location)
|
189
198
|
@keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
190
199
|
end
|
191
200
|
|
192
|
-
|
193
201
|
# def keyword: () -> String
|
194
202
|
def keyword
|
195
203
|
keyword_loc.slice
|
@@ -233,6 +241,15 @@ module Prism
|
|
233
241
|
def self.type
|
234
242
|
:alias_global_variable_node
|
235
243
|
end
|
244
|
+
|
245
|
+
# Implements case-equality for the node. This is effectively == but without
|
246
|
+
# comparing the value of locations. Locations are checked only for presence.
|
247
|
+
def ===(other)
|
248
|
+
other.is_a?(AliasGlobalVariableNode) &&
|
249
|
+
(new_name === other.new_name) &&
|
250
|
+
(old_name === other.old_name) &&
|
251
|
+
(keyword_loc.nil? == other.keyword_loc.nil?)
|
252
|
+
end
|
236
253
|
end
|
237
254
|
|
238
255
|
# Represents the use of the `alias` keyword to alias a method.
|
@@ -296,7 +313,6 @@ module Prism
|
|
296
313
|
@keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
297
314
|
end
|
298
315
|
|
299
|
-
|
300
316
|
# def keyword: () -> String
|
301
317
|
def keyword
|
302
318
|
keyword_loc.slice
|
@@ -340,6 +356,15 @@ module Prism
|
|
340
356
|
def self.type
|
341
357
|
:alias_method_node
|
342
358
|
end
|
359
|
+
|
360
|
+
# Implements case-equality for the node. This is effectively == but without
|
361
|
+
# comparing the value of locations. Locations are checked only for presence.
|
362
|
+
def ===(other)
|
363
|
+
other.is_a?(AliasMethodNode) &&
|
364
|
+
(new_name === other.new_name) &&
|
365
|
+
(old_name === other.old_name) &&
|
366
|
+
(keyword_loc.nil? == other.keyword_loc.nil?)
|
367
|
+
end
|
343
368
|
end
|
344
369
|
|
345
370
|
# Represents an alternation pattern in pattern matching.
|
@@ -403,7 +428,6 @@ module Prism
|
|
403
428
|
@operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
404
429
|
end
|
405
430
|
|
406
|
-
|
407
431
|
# def operator: () -> String
|
408
432
|
def operator
|
409
433
|
operator_loc.slice
|
@@ -447,6 +471,15 @@ module Prism
|
|
447
471
|
def self.type
|
448
472
|
:alternation_pattern_node
|
449
473
|
end
|
474
|
+
|
475
|
+
# Implements case-equality for the node. This is effectively == but without
|
476
|
+
# comparing the value of locations. Locations are checked only for presence.
|
477
|
+
def ===(other)
|
478
|
+
other.is_a?(AlternationPatternNode) &&
|
479
|
+
(left === other.left) &&
|
480
|
+
(right === other.right) &&
|
481
|
+
(operator_loc.nil? == other.operator_loc.nil?)
|
482
|
+
end
|
450
483
|
end
|
451
484
|
|
452
485
|
# Represents the use of the `&&` operator or the `and` keyword.
|
@@ -525,7 +558,6 @@ module Prism
|
|
525
558
|
@operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
526
559
|
end
|
527
560
|
|
528
|
-
|
529
561
|
# def operator: () -> String
|
530
562
|
def operator
|
531
563
|
operator_loc.slice
|
@@ -569,6 +601,15 @@ module Prism
|
|
569
601
|
def self.type
|
570
602
|
:and_node
|
571
603
|
end
|
604
|
+
|
605
|
+
# Implements case-equality for the node. This is effectively == but without
|
606
|
+
# comparing the value of locations. Locations are checked only for presence.
|
607
|
+
def ===(other)
|
608
|
+
other.is_a?(AndNode) &&
|
609
|
+
(left === other.left) &&
|
610
|
+
(right === other.right) &&
|
611
|
+
(operator_loc.nil? == other.operator_loc.nil?)
|
612
|
+
end
|
572
613
|
end
|
573
614
|
|
574
615
|
# Represents a set of arguments to a method or a keyword.
|
@@ -618,14 +659,13 @@ module Prism
|
|
618
659
|
{ flags: flags, arguments: arguments, location: location }
|
619
660
|
end
|
620
661
|
|
621
|
-
#
|
662
|
+
# protected attr_reader flags: Integer
|
622
663
|
attr_reader :flags
|
623
|
-
|
664
|
+
protected :flags
|
624
665
|
|
625
666
|
# attr_reader arguments: Array[Prism::node]
|
626
667
|
attr_reader :arguments
|
627
668
|
|
628
|
-
|
629
669
|
# def contains_keyword_splat?: () -> bool
|
630
670
|
def contains_keyword_splat?
|
631
671
|
flags.anybits?(ArgumentsNodeFlags::CONTAINS_KEYWORD_SPLAT)
|
@@ -667,6 +707,15 @@ module Prism
|
|
667
707
|
def self.type
|
668
708
|
:arguments_node
|
669
709
|
end
|
710
|
+
|
711
|
+
# Implements case-equality for the node. This is effectively == but without
|
712
|
+
# comparing the value of locations. Locations are checked only for presence.
|
713
|
+
def ===(other)
|
714
|
+
other.is_a?(ArgumentsNode) &&
|
715
|
+
(flags === other.flags) &&
|
716
|
+
(arguments.length == other.arguments.length) &&
|
717
|
+
arguments.zip(other.arguments).all? { |left, right| left === right }
|
718
|
+
end
|
670
719
|
end
|
671
720
|
|
672
721
|
# Represents an array literal. This can be a regular array using brackets or a special array using % like %w or %i.
|
@@ -718,14 +767,19 @@ module Prism
|
|
718
767
|
{ flags: flags, elements: elements, opening_loc: opening_loc, closing_loc: closing_loc, location: location }
|
719
768
|
end
|
720
769
|
|
721
|
-
#
|
770
|
+
# protected attr_reader flags: Integer
|
722
771
|
attr_reader :flags
|
723
|
-
|
772
|
+
protected :flags
|
724
773
|
|
725
|
-
#
|
774
|
+
# Represent the list of zero or more [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression) within the array.
|
726
775
|
attr_reader :elements
|
727
776
|
|
728
|
-
#
|
777
|
+
# Represents the optional source location for the opening token.
|
778
|
+
#
|
779
|
+
# [1,2,3] # "["
|
780
|
+
# %w[foo bar baz] # "%w["
|
781
|
+
# %I(apple orange banana) # "%I("
|
782
|
+
# foo = 1, 2, 3 # nil
|
729
783
|
def opening_loc
|
730
784
|
location = @opening_loc
|
731
785
|
case location
|
@@ -738,7 +792,12 @@ module Prism
|
|
738
792
|
end
|
739
793
|
end
|
740
794
|
|
741
|
-
#
|
795
|
+
# Represents the optional source location for the closing token.
|
796
|
+
#
|
797
|
+
# [1,2,3] # "]"
|
798
|
+
# %w[foo bar baz] # "]"
|
799
|
+
# %I(apple orange banana) # ")"
|
800
|
+
# foo = 1, 2, 3 # nil
|
742
801
|
def closing_loc
|
743
802
|
location = @closing_loc
|
744
803
|
case location
|
@@ -751,7 +810,6 @@ module Prism
|
|
751
810
|
end
|
752
811
|
end
|
753
812
|
|
754
|
-
|
755
813
|
# def contains_splat?: () -> bool
|
756
814
|
def contains_splat?
|
757
815
|
flags.anybits?(ArrayNodeFlags::CONTAINS_SPLAT)
|
@@ -805,6 +863,17 @@ module Prism
|
|
805
863
|
def self.type
|
806
864
|
:array_node
|
807
865
|
end
|
866
|
+
|
867
|
+
# Implements case-equality for the node. This is effectively == but without
|
868
|
+
# comparing the value of locations. Locations are checked only for presence.
|
869
|
+
def ===(other)
|
870
|
+
other.is_a?(ArrayNode) &&
|
871
|
+
(flags === other.flags) &&
|
872
|
+
(elements.length == other.elements.length) &&
|
873
|
+
elements.zip(other.elements).all? { |left, right| left === right } &&
|
874
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
875
|
+
(closing_loc.nil? == other.closing_loc.nil?)
|
876
|
+
end
|
808
877
|
end
|
809
878
|
|
810
879
|
# Represents an array pattern in pattern matching.
|
@@ -913,7 +982,6 @@ module Prism
|
|
913
982
|
end
|
914
983
|
end
|
915
984
|
|
916
|
-
|
917
985
|
# def opening: () -> String?
|
918
986
|
def opening
|
919
987
|
opening_loc&.slice
|
@@ -973,6 +1041,20 @@ module Prism
|
|
973
1041
|
def self.type
|
974
1042
|
:array_pattern_node
|
975
1043
|
end
|
1044
|
+
|
1045
|
+
# Implements case-equality for the node. This is effectively == but without
|
1046
|
+
# comparing the value of locations. Locations are checked only for presence.
|
1047
|
+
def ===(other)
|
1048
|
+
other.is_a?(ArrayPatternNode) &&
|
1049
|
+
(constant === other.constant) &&
|
1050
|
+
(requireds.length == other.requireds.length) &&
|
1051
|
+
requireds.zip(other.requireds).all? { |left, right| left === right } &&
|
1052
|
+
(rest === other.rest) &&
|
1053
|
+
(posts.length == other.posts.length) &&
|
1054
|
+
posts.zip(other.posts).all? { |left, right| left === right } &&
|
1055
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
1056
|
+
(closing_loc.nil? == other.closing_loc.nil?)
|
1057
|
+
end
|
976
1058
|
end
|
977
1059
|
|
978
1060
|
# Represents a hash key/value pair.
|
@@ -1060,7 +1142,6 @@ module Prism
|
|
1060
1142
|
end
|
1061
1143
|
end
|
1062
1144
|
|
1063
|
-
|
1064
1145
|
# def operator: () -> String?
|
1065
1146
|
def operator
|
1066
1147
|
operator_loc&.slice
|
@@ -1104,6 +1185,15 @@ module Prism
|
|
1104
1185
|
def self.type
|
1105
1186
|
:assoc_node
|
1106
1187
|
end
|
1188
|
+
|
1189
|
+
# Implements case-equality for the node. This is effectively == but without
|
1190
|
+
# comparing the value of locations. Locations are checked only for presence.
|
1191
|
+
def ===(other)
|
1192
|
+
other.is_a?(AssocNode) &&
|
1193
|
+
(key === other.key) &&
|
1194
|
+
(value === other.value) &&
|
1195
|
+
(operator_loc.nil? == other.operator_loc.nil?)
|
1196
|
+
end
|
1107
1197
|
end
|
1108
1198
|
|
1109
1199
|
# Represents a splat in a hash literal.
|
@@ -1171,7 +1261,6 @@ module Prism
|
|
1171
1261
|
@operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
1172
1262
|
end
|
1173
1263
|
|
1174
|
-
|
1175
1264
|
# def operator: () -> String
|
1176
1265
|
def operator
|
1177
1266
|
operator_loc.slice
|
@@ -1217,6 +1306,14 @@ module Prism
|
|
1217
1306
|
def self.type
|
1218
1307
|
:assoc_splat_node
|
1219
1308
|
end
|
1309
|
+
|
1310
|
+
# Implements case-equality for the node. This is effectively == but without
|
1311
|
+
# comparing the value of locations. Locations are checked only for presence.
|
1312
|
+
def ===(other)
|
1313
|
+
other.is_a?(AssocSplatNode) &&
|
1314
|
+
(value === other.value) &&
|
1315
|
+
(operator_loc.nil? == other.operator_loc.nil?)
|
1316
|
+
end
|
1220
1317
|
end
|
1221
1318
|
|
1222
1319
|
# Represents reading a reference to a field in the previous match.
|
@@ -1272,7 +1369,6 @@ module Prism
|
|
1272
1369
|
# $+ # name `:$+`
|
1273
1370
|
attr_reader :name
|
1274
1371
|
|
1275
|
-
|
1276
1372
|
# def inspect(NodeInspector inspector) -> String
|
1277
1373
|
def inspect(inspector = NodeInspector.new)
|
1278
1374
|
inspector << inspector.header(self)
|
@@ -1307,6 +1403,13 @@ module Prism
|
|
1307
1403
|
def self.type
|
1308
1404
|
:back_reference_read_node
|
1309
1405
|
end
|
1406
|
+
|
1407
|
+
# Implements case-equality for the node. This is effectively == but without
|
1408
|
+
# comparing the value of locations. Locations are checked only for presence.
|
1409
|
+
def ===(other)
|
1410
|
+
other.is_a?(BackReferenceReadNode) &&
|
1411
|
+
(name === other.name)
|
1412
|
+
end
|
1310
1413
|
end
|
1311
1414
|
|
1312
1415
|
# Represents a begin statement.
|
@@ -1409,7 +1512,6 @@ module Prism
|
|
1409
1512
|
end
|
1410
1513
|
end
|
1411
1514
|
|
1412
|
-
|
1413
1515
|
# def begin_keyword: () -> String?
|
1414
1516
|
def begin_keyword
|
1415
1517
|
begin_keyword_loc&.slice
|
@@ -1479,6 +1581,18 @@ module Prism
|
|
1479
1581
|
def self.type
|
1480
1582
|
:begin_node
|
1481
1583
|
end
|
1584
|
+
|
1585
|
+
# Implements case-equality for the node. This is effectively == but without
|
1586
|
+
# comparing the value of locations. Locations are checked only for presence.
|
1587
|
+
def ===(other)
|
1588
|
+
other.is_a?(BeginNode) &&
|
1589
|
+
(begin_keyword_loc.nil? == other.begin_keyword_loc.nil?) &&
|
1590
|
+
(statements === other.statements) &&
|
1591
|
+
(rescue_clause === other.rescue_clause) &&
|
1592
|
+
(else_clause === other.else_clause) &&
|
1593
|
+
(ensure_clause === other.ensure_clause) &&
|
1594
|
+
(end_keyword_loc.nil? == other.end_keyword_loc.nil?)
|
1595
|
+
end
|
1482
1596
|
end
|
1483
1597
|
|
1484
1598
|
# Represents block method arguments.
|
@@ -1540,7 +1654,6 @@ module Prism
|
|
1540
1654
|
@operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
1541
1655
|
end
|
1542
1656
|
|
1543
|
-
|
1544
1657
|
# def operator: () -> String
|
1545
1658
|
def operator
|
1546
1659
|
operator_loc.slice
|
@@ -1586,6 +1699,14 @@ module Prism
|
|
1586
1699
|
def self.type
|
1587
1700
|
:block_argument_node
|
1588
1701
|
end
|
1702
|
+
|
1703
|
+
# Implements case-equality for the node. This is effectively == but without
|
1704
|
+
# comparing the value of locations. Locations are checked only for presence.
|
1705
|
+
def ===(other)
|
1706
|
+
other.is_a?(BlockArgumentNode) &&
|
1707
|
+
(expression === other.expression) &&
|
1708
|
+
(operator_loc.nil? == other.operator_loc.nil?)
|
1709
|
+
end
|
1589
1710
|
end
|
1590
1711
|
|
1591
1712
|
# Represents a block local variable.
|
@@ -1635,14 +1756,13 @@ module Prism
|
|
1635
1756
|
{ flags: flags, name: name, location: location }
|
1636
1757
|
end
|
1637
1758
|
|
1638
|
-
#
|
1759
|
+
# protected attr_reader flags: Integer
|
1639
1760
|
attr_reader :flags
|
1640
|
-
|
1761
|
+
protected :flags
|
1641
1762
|
|
1642
1763
|
# attr_reader name: Symbol
|
1643
1764
|
attr_reader :name
|
1644
1765
|
|
1645
|
-
|
1646
1766
|
# def repeated_parameter?: () -> bool
|
1647
1767
|
def repeated_parameter?
|
1648
1768
|
flags.anybits?(ParameterFlags::REPEATED_PARAMETER)
|
@@ -1684,6 +1804,14 @@ module Prism
|
|
1684
1804
|
def self.type
|
1685
1805
|
:block_local_variable_node
|
1686
1806
|
end
|
1807
|
+
|
1808
|
+
# Implements case-equality for the node. This is effectively == but without
|
1809
|
+
# comparing the value of locations. Locations are checked only for presence.
|
1810
|
+
def ===(other)
|
1811
|
+
other.is_a?(BlockLocalVariableNode) &&
|
1812
|
+
(flags === other.flags) &&
|
1813
|
+
(name === other.name)
|
1814
|
+
end
|
1687
1815
|
end
|
1688
1816
|
|
1689
1817
|
# Represents a block of ruby code.
|
@@ -1762,7 +1890,6 @@ module Prism
|
|
1762
1890
|
@closing_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
1763
1891
|
end
|
1764
1892
|
|
1765
|
-
|
1766
1893
|
# def opening: () -> String
|
1767
1894
|
def opening
|
1768
1895
|
opening_loc.slice
|
@@ -1821,6 +1948,18 @@ module Prism
|
|
1821
1948
|
def self.type
|
1822
1949
|
:block_node
|
1823
1950
|
end
|
1951
|
+
|
1952
|
+
# Implements case-equality for the node. This is effectively == but without
|
1953
|
+
# comparing the value of locations. Locations are checked only for presence.
|
1954
|
+
def ===(other)
|
1955
|
+
other.is_a?(BlockNode) &&
|
1956
|
+
(locals.length == other.locals.length) &&
|
1957
|
+
locals.zip(other.locals).all? { |left, right| left === right } &&
|
1958
|
+
(parameters === other.parameters) &&
|
1959
|
+
(body === other.body) &&
|
1960
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
1961
|
+
(closing_loc.nil? == other.closing_loc.nil?)
|
1962
|
+
end
|
1824
1963
|
end
|
1825
1964
|
|
1826
1965
|
# Represents a block parameter to a method, block, or lambda definition.
|
@@ -1873,9 +2012,9 @@ module Prism
|
|
1873
2012
|
{ flags: flags, name: name, name_loc: name_loc, operator_loc: operator_loc, location: location }
|
1874
2013
|
end
|
1875
2014
|
|
1876
|
-
#
|
2015
|
+
# protected attr_reader flags: Integer
|
1877
2016
|
attr_reader :flags
|
1878
|
-
|
2017
|
+
protected :flags
|
1879
2018
|
|
1880
2019
|
# attr_reader name: Symbol?
|
1881
2020
|
attr_reader :name
|
@@ -1900,7 +2039,6 @@ module Prism
|
|
1900
2039
|
@operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
1901
2040
|
end
|
1902
2041
|
|
1903
|
-
|
1904
2042
|
# def repeated_parameter?: () -> bool
|
1905
2043
|
def repeated_parameter?
|
1906
2044
|
flags.anybits?(ParameterFlags::REPEATED_PARAMETER)
|
@@ -1953,6 +2091,16 @@ module Prism
|
|
1953
2091
|
def self.type
|
1954
2092
|
:block_parameter_node
|
1955
2093
|
end
|
2094
|
+
|
2095
|
+
# Implements case-equality for the node. This is effectively == but without
|
2096
|
+
# comparing the value of locations. Locations are checked only for presence.
|
2097
|
+
def ===(other)
|
2098
|
+
other.is_a?(BlockParameterNode) &&
|
2099
|
+
(flags === other.flags) &&
|
2100
|
+
(name === other.name) &&
|
2101
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
2102
|
+
(operator_loc.nil? == other.operator_loc.nil?)
|
2103
|
+
end
|
1956
2104
|
end
|
1957
2105
|
|
1958
2106
|
# Represents a block's parameters declaration.
|
@@ -2043,7 +2191,6 @@ module Prism
|
|
2043
2191
|
end
|
2044
2192
|
end
|
2045
2193
|
|
2046
|
-
|
2047
2194
|
# def opening: () -> String?
|
2048
2195
|
def opening
|
2049
2196
|
opening_loc&.slice
|
@@ -2096,6 +2243,17 @@ module Prism
|
|
2096
2243
|
def self.type
|
2097
2244
|
:block_parameters_node
|
2098
2245
|
end
|
2246
|
+
|
2247
|
+
# Implements case-equality for the node. This is effectively == but without
|
2248
|
+
# comparing the value of locations. Locations are checked only for presence.
|
2249
|
+
def ===(other)
|
2250
|
+
other.is_a?(BlockParametersNode) &&
|
2251
|
+
(parameters === other.parameters) &&
|
2252
|
+
(locals.length == other.locals.length) &&
|
2253
|
+
locals.zip(other.locals).all? { |left, right| left === right } &&
|
2254
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
2255
|
+
(closing_loc.nil? == other.closing_loc.nil?)
|
2256
|
+
end
|
2099
2257
|
end
|
2100
2258
|
|
2101
2259
|
# Represents the use of the `break` keyword.
|
@@ -2147,17 +2305,22 @@ module Prism
|
|
2147
2305
|
{ arguments: arguments, keyword_loc: keyword_loc, location: location }
|
2148
2306
|
end
|
2149
2307
|
|
2150
|
-
#
|
2308
|
+
# The arguments to the break statement, if present. These can be any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
|
2309
|
+
#
|
2310
|
+
# break foo
|
2311
|
+
# ^^^
|
2151
2312
|
attr_reader :arguments
|
2152
2313
|
|
2153
|
-
#
|
2314
|
+
# The location of the `break` keyword.
|
2315
|
+
#
|
2316
|
+
# break foo
|
2317
|
+
# ^^^^^
|
2154
2318
|
def keyword_loc
|
2155
2319
|
location = @keyword_loc
|
2156
2320
|
return location if location.is_a?(Location)
|
2157
2321
|
@keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
2158
2322
|
end
|
2159
2323
|
|
2160
|
-
|
2161
2324
|
# def keyword: () -> String
|
2162
2325
|
def keyword
|
2163
2326
|
keyword_loc.slice
|
@@ -2203,6 +2366,14 @@ module Prism
|
|
2203
2366
|
def self.type
|
2204
2367
|
:break_node
|
2205
2368
|
end
|
2369
|
+
|
2370
|
+
# Implements case-equality for the node. This is effectively == but without
|
2371
|
+
# comparing the value of locations. Locations are checked only for presence.
|
2372
|
+
def ===(other)
|
2373
|
+
other.is_a?(BreakNode) &&
|
2374
|
+
(arguments === other.arguments) &&
|
2375
|
+
(keyword_loc.nil? == other.keyword_loc.nil?)
|
2376
|
+
end
|
2206
2377
|
end
|
2207
2378
|
|
2208
2379
|
# Represents the use of the `&&=` operator on a call.
|
@@ -2261,9 +2432,9 @@ module Prism
|
|
2261
2432
|
{ flags: flags, receiver: receiver, call_operator_loc: call_operator_loc, message_loc: message_loc, read_name: read_name, write_name: write_name, operator_loc: operator_loc, value: value, location: location }
|
2262
2433
|
end
|
2263
2434
|
|
2264
|
-
#
|
2435
|
+
# protected attr_reader flags: Integer
|
2265
2436
|
attr_reader :flags
|
2266
|
-
|
2437
|
+
protected :flags
|
2267
2438
|
|
2268
2439
|
# attr_reader receiver: Prism::node?
|
2269
2440
|
attr_reader :receiver
|
@@ -2310,7 +2481,6 @@ module Prism
|
|
2310
2481
|
# attr_reader value: Prism::node
|
2311
2482
|
attr_reader :value
|
2312
2483
|
|
2313
|
-
|
2314
2484
|
# def safe_navigation?: () -> bool
|
2315
2485
|
def safe_navigation?
|
2316
2486
|
flags.anybits?(CallNodeFlags::SAFE_NAVIGATION)
|
@@ -2394,6 +2564,20 @@ module Prism
|
|
2394
2564
|
def self.type
|
2395
2565
|
:call_and_write_node
|
2396
2566
|
end
|
2567
|
+
|
2568
|
+
# Implements case-equality for the node. This is effectively == but without
|
2569
|
+
# comparing the value of locations. Locations are checked only for presence.
|
2570
|
+
def ===(other)
|
2571
|
+
other.is_a?(CallAndWriteNode) &&
|
2572
|
+
(flags === other.flags) &&
|
2573
|
+
(receiver === other.receiver) &&
|
2574
|
+
(call_operator_loc.nil? == other.call_operator_loc.nil?) &&
|
2575
|
+
(message_loc.nil? == other.message_loc.nil?) &&
|
2576
|
+
(read_name === other.read_name) &&
|
2577
|
+
(write_name === other.write_name) &&
|
2578
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
2579
|
+
(value === other.value)
|
2580
|
+
end
|
2397
2581
|
end
|
2398
2582
|
|
2399
2583
|
# Represents a method call, in all of the various forms that can take.
|
@@ -2469,9 +2653,9 @@ module Prism
|
|
2469
2653
|
{ flags: flags, receiver: receiver, call_operator_loc: call_operator_loc, name: name, message_loc: message_loc, opening_loc: opening_loc, arguments: arguments, closing_loc: closing_loc, block: block, location: location }
|
2470
2654
|
end
|
2471
2655
|
|
2472
|
-
#
|
2656
|
+
# protected attr_reader flags: Integer
|
2473
2657
|
attr_reader :flags
|
2474
|
-
|
2658
|
+
protected :flags
|
2475
2659
|
|
2476
2660
|
# The object that the method is being called on. This can be either `nil` or any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
|
2477
2661
|
#
|
@@ -2546,7 +2730,6 @@ module Prism
|
|
2546
2730
|
# attr_reader block: Prism::node?
|
2547
2731
|
attr_reader :block
|
2548
2732
|
|
2549
|
-
|
2550
2733
|
# def safe_navigation?: () -> bool
|
2551
2734
|
def safe_navigation?
|
2552
2735
|
flags.anybits?(CallNodeFlags::SAFE_NAVIGATION)
|
@@ -2645,6 +2828,21 @@ module Prism
|
|
2645
2828
|
def self.type
|
2646
2829
|
:call_node
|
2647
2830
|
end
|
2831
|
+
|
2832
|
+
# Implements case-equality for the node. This is effectively == but without
|
2833
|
+
# comparing the value of locations. Locations are checked only for presence.
|
2834
|
+
def ===(other)
|
2835
|
+
other.is_a?(CallNode) &&
|
2836
|
+
(flags === other.flags) &&
|
2837
|
+
(receiver === other.receiver) &&
|
2838
|
+
(call_operator_loc.nil? == other.call_operator_loc.nil?) &&
|
2839
|
+
(name === other.name) &&
|
2840
|
+
(message_loc.nil? == other.message_loc.nil?) &&
|
2841
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
2842
|
+
(arguments === other.arguments) &&
|
2843
|
+
(closing_loc.nil? == other.closing_loc.nil?) &&
|
2844
|
+
(block === other.block)
|
2845
|
+
end
|
2648
2846
|
end
|
2649
2847
|
|
2650
2848
|
# Represents the use of an assignment operator on a call.
|
@@ -2704,9 +2902,9 @@ module Prism
|
|
2704
2902
|
{ flags: flags, receiver: receiver, call_operator_loc: call_operator_loc, message_loc: message_loc, read_name: read_name, write_name: write_name, operator: operator, operator_loc: operator_loc, value: value, location: location }
|
2705
2903
|
end
|
2706
2904
|
|
2707
|
-
#
|
2905
|
+
# protected attr_reader flags: Integer
|
2708
2906
|
attr_reader :flags
|
2709
|
-
|
2907
|
+
protected :flags
|
2710
2908
|
|
2711
2909
|
# attr_reader receiver: Prism::node?
|
2712
2910
|
attr_reader :receiver
|
@@ -2756,7 +2954,6 @@ module Prism
|
|
2756
2954
|
# attr_reader value: Prism::node
|
2757
2955
|
attr_reader :value
|
2758
2956
|
|
2759
|
-
|
2760
2957
|
# def safe_navigation?: () -> bool
|
2761
2958
|
def safe_navigation?
|
2762
2959
|
flags.anybits?(CallNodeFlags::SAFE_NAVIGATION)
|
@@ -2836,6 +3033,21 @@ module Prism
|
|
2836
3033
|
def self.type
|
2837
3034
|
:call_operator_write_node
|
2838
3035
|
end
|
3036
|
+
|
3037
|
+
# Implements case-equality for the node. This is effectively == but without
|
3038
|
+
# comparing the value of locations. Locations are checked only for presence.
|
3039
|
+
def ===(other)
|
3040
|
+
other.is_a?(CallOperatorWriteNode) &&
|
3041
|
+
(flags === other.flags) &&
|
3042
|
+
(receiver === other.receiver) &&
|
3043
|
+
(call_operator_loc.nil? == other.call_operator_loc.nil?) &&
|
3044
|
+
(message_loc.nil? == other.message_loc.nil?) &&
|
3045
|
+
(read_name === other.read_name) &&
|
3046
|
+
(write_name === other.write_name) &&
|
3047
|
+
(operator === other.operator) &&
|
3048
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
3049
|
+
(value === other.value)
|
3050
|
+
end
|
2839
3051
|
end
|
2840
3052
|
|
2841
3053
|
# Represents the use of the `||=` operator on a call.
|
@@ -2894,9 +3106,9 @@ module Prism
|
|
2894
3106
|
{ flags: flags, receiver: receiver, call_operator_loc: call_operator_loc, message_loc: message_loc, read_name: read_name, write_name: write_name, operator_loc: operator_loc, value: value, location: location }
|
2895
3107
|
end
|
2896
3108
|
|
2897
|
-
#
|
3109
|
+
# protected attr_reader flags: Integer
|
2898
3110
|
attr_reader :flags
|
2899
|
-
|
3111
|
+
protected :flags
|
2900
3112
|
|
2901
3113
|
# attr_reader receiver: Prism::node?
|
2902
3114
|
attr_reader :receiver
|
@@ -2943,7 +3155,6 @@ module Prism
|
|
2943
3155
|
# attr_reader value: Prism::node
|
2944
3156
|
attr_reader :value
|
2945
3157
|
|
2946
|
-
|
2947
3158
|
# def safe_navigation?: () -> bool
|
2948
3159
|
def safe_navigation?
|
2949
3160
|
flags.anybits?(CallNodeFlags::SAFE_NAVIGATION)
|
@@ -3027,6 +3238,20 @@ module Prism
|
|
3027
3238
|
def self.type
|
3028
3239
|
:call_or_write_node
|
3029
3240
|
end
|
3241
|
+
|
3242
|
+
# Implements case-equality for the node. This is effectively == but without
|
3243
|
+
# comparing the value of locations. Locations are checked only for presence.
|
3244
|
+
def ===(other)
|
3245
|
+
other.is_a?(CallOrWriteNode) &&
|
3246
|
+
(flags === other.flags) &&
|
3247
|
+
(receiver === other.receiver) &&
|
3248
|
+
(call_operator_loc.nil? == other.call_operator_loc.nil?) &&
|
3249
|
+
(message_loc.nil? == other.message_loc.nil?) &&
|
3250
|
+
(read_name === other.read_name) &&
|
3251
|
+
(write_name === other.write_name) &&
|
3252
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
3253
|
+
(value === other.value)
|
3254
|
+
end
|
3030
3255
|
end
|
3031
3256
|
|
3032
3257
|
# Represents assigning to a method call.
|
@@ -3087,9 +3312,9 @@ module Prism
|
|
3087
3312
|
{ flags: flags, receiver: receiver, call_operator_loc: call_operator_loc, name: name, message_loc: message_loc, location: location }
|
3088
3313
|
end
|
3089
3314
|
|
3090
|
-
#
|
3315
|
+
# protected attr_reader flags: Integer
|
3091
3316
|
attr_reader :flags
|
3092
|
-
|
3317
|
+
protected :flags
|
3093
3318
|
|
3094
3319
|
# attr_reader receiver: Prism::node
|
3095
3320
|
attr_reader :receiver
|
@@ -3111,7 +3336,6 @@ module Prism
|
|
3111
3336
|
@message_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
3112
3337
|
end
|
3113
3338
|
|
3114
|
-
|
3115
3339
|
# def safe_navigation?: () -> bool
|
3116
3340
|
def safe_navigation?
|
3117
3341
|
flags.anybits?(CallNodeFlags::SAFE_NAVIGATION)
|
@@ -3182,6 +3406,17 @@ module Prism
|
|
3182
3406
|
def self.type
|
3183
3407
|
:call_target_node
|
3184
3408
|
end
|
3409
|
+
|
3410
|
+
# Implements case-equality for the node. This is effectively == but without
|
3411
|
+
# comparing the value of locations. Locations are checked only for presence.
|
3412
|
+
def ===(other)
|
3413
|
+
other.is_a?(CallTargetNode) &&
|
3414
|
+
(flags === other.flags) &&
|
3415
|
+
(receiver === other.receiver) &&
|
3416
|
+
(call_operator_loc.nil? == other.call_operator_loc.nil?) &&
|
3417
|
+
(name === other.name) &&
|
3418
|
+
(message_loc.nil? == other.message_loc.nil?)
|
3419
|
+
end
|
3185
3420
|
end
|
3186
3421
|
|
3187
3422
|
# Represents assigning to a local variable in pattern matching.
|
@@ -3245,7 +3480,6 @@ module Prism
|
|
3245
3480
|
@operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
3246
3481
|
end
|
3247
3482
|
|
3248
|
-
|
3249
3483
|
# def operator: () -> String
|
3250
3484
|
def operator
|
3251
3485
|
operator_loc.slice
|
@@ -3289,6 +3523,15 @@ module Prism
|
|
3289
3523
|
def self.type
|
3290
3524
|
:capture_pattern_node
|
3291
3525
|
end
|
3526
|
+
|
3527
|
+
# Implements case-equality for the node. This is effectively == but without
|
3528
|
+
# comparing the value of locations. Locations are checked only for presence.
|
3529
|
+
def ===(other)
|
3530
|
+
other.is_a?(CapturePatternNode) &&
|
3531
|
+
(value === other.value) &&
|
3532
|
+
(target === other.target) &&
|
3533
|
+
(operator_loc.nil? == other.operator_loc.nil?)
|
3534
|
+
end
|
3292
3535
|
end
|
3293
3536
|
|
3294
3537
|
# Represents the use of a case statement for pattern matching.
|
@@ -3370,7 +3613,6 @@ module Prism
|
|
3370
3613
|
@end_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
3371
3614
|
end
|
3372
3615
|
|
3373
|
-
|
3374
3616
|
# def case_keyword: () -> String
|
3375
3617
|
def case_keyword
|
3376
3618
|
case_keyword_loc.slice
|
@@ -3429,6 +3671,18 @@ module Prism
|
|
3429
3671
|
def self.type
|
3430
3672
|
:case_match_node
|
3431
3673
|
end
|
3674
|
+
|
3675
|
+
# Implements case-equality for the node. This is effectively == but without
|
3676
|
+
# comparing the value of locations. Locations are checked only for presence.
|
3677
|
+
def ===(other)
|
3678
|
+
other.is_a?(CaseMatchNode) &&
|
3679
|
+
(predicate === other.predicate) &&
|
3680
|
+
(conditions.length == other.conditions.length) &&
|
3681
|
+
conditions.zip(other.conditions).all? { |left, right| left === right } &&
|
3682
|
+
(consequent === other.consequent) &&
|
3683
|
+
(case_keyword_loc.nil? == other.case_keyword_loc.nil?) &&
|
3684
|
+
(end_keyword_loc.nil? == other.end_keyword_loc.nil?)
|
3685
|
+
end
|
3432
3686
|
end
|
3433
3687
|
|
3434
3688
|
# Represents the use of a case statement.
|
@@ -3510,7 +3764,6 @@ module Prism
|
|
3510
3764
|
@end_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
3511
3765
|
end
|
3512
3766
|
|
3513
|
-
|
3514
3767
|
# def case_keyword: () -> String
|
3515
3768
|
def case_keyword
|
3516
3769
|
case_keyword_loc.slice
|
@@ -3569,6 +3822,18 @@ module Prism
|
|
3569
3822
|
def self.type
|
3570
3823
|
:case_node
|
3571
3824
|
end
|
3825
|
+
|
3826
|
+
# Implements case-equality for the node. This is effectively == but without
|
3827
|
+
# comparing the value of locations. Locations are checked only for presence.
|
3828
|
+
def ===(other)
|
3829
|
+
other.is_a?(CaseNode) &&
|
3830
|
+
(predicate === other.predicate) &&
|
3831
|
+
(conditions.length == other.conditions.length) &&
|
3832
|
+
conditions.zip(other.conditions).all? { |left, right| left === right } &&
|
3833
|
+
(consequent === other.consequent) &&
|
3834
|
+
(case_keyword_loc.nil? == other.case_keyword_loc.nil?) &&
|
3835
|
+
(end_keyword_loc.nil? == other.end_keyword_loc.nil?)
|
3836
|
+
end
|
3572
3837
|
end
|
3573
3838
|
|
3574
3839
|
# Represents a class declaration involving the `class` keyword.
|
@@ -3670,7 +3935,6 @@ module Prism
|
|
3670
3935
|
# attr_reader name: Symbol
|
3671
3936
|
attr_reader :name
|
3672
3937
|
|
3673
|
-
|
3674
3938
|
# def class_keyword: () -> String
|
3675
3939
|
def class_keyword
|
3676
3940
|
class_keyword_loc.slice
|
@@ -3738,6 +4002,21 @@ module Prism
|
|
3738
4002
|
def self.type
|
3739
4003
|
:class_node
|
3740
4004
|
end
|
4005
|
+
|
4006
|
+
# Implements case-equality for the node. This is effectively == but without
|
4007
|
+
# comparing the value of locations. Locations are checked only for presence.
|
4008
|
+
def ===(other)
|
4009
|
+
other.is_a?(ClassNode) &&
|
4010
|
+
(locals.length == other.locals.length) &&
|
4011
|
+
locals.zip(other.locals).all? { |left, right| left === right } &&
|
4012
|
+
(class_keyword_loc.nil? == other.class_keyword_loc.nil?) &&
|
4013
|
+
(constant_path === other.constant_path) &&
|
4014
|
+
(inheritance_operator_loc.nil? == other.inheritance_operator_loc.nil?) &&
|
4015
|
+
(superclass === other.superclass) &&
|
4016
|
+
(body === other.body) &&
|
4017
|
+
(end_keyword_loc.nil? == other.end_keyword_loc.nil?) &&
|
4018
|
+
(name === other.name)
|
4019
|
+
end
|
3741
4020
|
end
|
3742
4021
|
|
3743
4022
|
# Represents the use of the `&&=` operator for assignment to a class variable.
|
@@ -3809,7 +4088,6 @@ module Prism
|
|
3809
4088
|
# attr_reader value: Prism::node
|
3810
4089
|
attr_reader :value
|
3811
4090
|
|
3812
|
-
|
3813
4091
|
# def operator: () -> String
|
3814
4092
|
def operator
|
3815
4093
|
operator_loc.slice
|
@@ -3853,6 +4131,16 @@ module Prism
|
|
3853
4131
|
def self.type
|
3854
4132
|
:class_variable_and_write_node
|
3855
4133
|
end
|
4134
|
+
|
4135
|
+
# Implements case-equality for the node. This is effectively == but without
|
4136
|
+
# comparing the value of locations. Locations are checked only for presence.
|
4137
|
+
def ===(other)
|
4138
|
+
other.is_a?(ClassVariableAndWriteNode) &&
|
4139
|
+
(name === other.name) &&
|
4140
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
4141
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
4142
|
+
(value === other.value)
|
4143
|
+
end
|
3856
4144
|
end
|
3857
4145
|
|
3858
4146
|
# Represents assigning to a class variable using an operator that isn't `=`.
|
@@ -3928,7 +4216,6 @@ module Prism
|
|
3928
4216
|
# attr_reader operator: Symbol
|
3929
4217
|
attr_reader :operator
|
3930
4218
|
|
3931
|
-
|
3932
4219
|
# def inspect(NodeInspector inspector) -> String
|
3933
4220
|
def inspect(inspector = NodeInspector.new)
|
3934
4221
|
inspector << inspector.header(self)
|
@@ -3968,6 +4255,17 @@ module Prism
|
|
3968
4255
|
def self.type
|
3969
4256
|
:class_variable_operator_write_node
|
3970
4257
|
end
|
4258
|
+
|
4259
|
+
# Implements case-equality for the node. This is effectively == but without
|
4260
|
+
# comparing the value of locations. Locations are checked only for presence.
|
4261
|
+
def ===(other)
|
4262
|
+
other.is_a?(ClassVariableOperatorWriteNode) &&
|
4263
|
+
(name === other.name) &&
|
4264
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
4265
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
4266
|
+
(value === other.value) &&
|
4267
|
+
(operator === other.operator)
|
4268
|
+
end
|
3971
4269
|
end
|
3972
4270
|
|
3973
4271
|
# Represents the use of the `||=` operator for assignment to a class variable.
|
@@ -4039,7 +4337,6 @@ module Prism
|
|
4039
4337
|
# attr_reader value: Prism::node
|
4040
4338
|
attr_reader :value
|
4041
4339
|
|
4042
|
-
|
4043
4340
|
# def operator: () -> String
|
4044
4341
|
def operator
|
4045
4342
|
operator_loc.slice
|
@@ -4083,6 +4380,16 @@ module Prism
|
|
4083
4380
|
def self.type
|
4084
4381
|
:class_variable_or_write_node
|
4085
4382
|
end
|
4383
|
+
|
4384
|
+
# Implements case-equality for the node. This is effectively == but without
|
4385
|
+
# comparing the value of locations. Locations are checked only for presence.
|
4386
|
+
def ===(other)
|
4387
|
+
other.is_a?(ClassVariableOrWriteNode) &&
|
4388
|
+
(name === other.name) &&
|
4389
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
4390
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
4391
|
+
(value === other.value)
|
4392
|
+
end
|
4086
4393
|
end
|
4087
4394
|
|
4088
4395
|
# Represents referencing a class variable.
|
@@ -4138,7 +4445,6 @@ module Prism
|
|
4138
4445
|
# @@_test # name `:@@_test`
|
4139
4446
|
attr_reader :name
|
4140
4447
|
|
4141
|
-
|
4142
4448
|
# def inspect(NodeInspector inspector) -> String
|
4143
4449
|
def inspect(inspector = NodeInspector.new)
|
4144
4450
|
inspector << inspector.header(self)
|
@@ -4173,6 +4479,13 @@ module Prism
|
|
4173
4479
|
def self.type
|
4174
4480
|
:class_variable_read_node
|
4175
4481
|
end
|
4482
|
+
|
4483
|
+
# Implements case-equality for the node. This is effectively == but without
|
4484
|
+
# comparing the value of locations. Locations are checked only for presence.
|
4485
|
+
def ===(other)
|
4486
|
+
other.is_a?(ClassVariableReadNode) &&
|
4487
|
+
(name === other.name)
|
4488
|
+
end
|
4176
4489
|
end
|
4177
4490
|
|
4178
4491
|
# Represents writing to a class variable in a context that doesn't have an explicit value.
|
@@ -4224,7 +4537,6 @@ module Prism
|
|
4224
4537
|
# attr_reader name: Symbol
|
4225
4538
|
attr_reader :name
|
4226
4539
|
|
4227
|
-
|
4228
4540
|
# def inspect(NodeInspector inspector) -> String
|
4229
4541
|
def inspect(inspector = NodeInspector.new)
|
4230
4542
|
inspector << inspector.header(self)
|
@@ -4259,6 +4571,13 @@ module Prism
|
|
4259
4571
|
def self.type
|
4260
4572
|
:class_variable_target_node
|
4261
4573
|
end
|
4574
|
+
|
4575
|
+
# Implements case-equality for the node. This is effectively == but without
|
4576
|
+
# comparing the value of locations. Locations are checked only for presence.
|
4577
|
+
def ===(other)
|
4578
|
+
other.is_a?(ClassVariableTargetNode) &&
|
4579
|
+
(name === other.name)
|
4580
|
+
end
|
4262
4581
|
end
|
4263
4582
|
|
4264
4583
|
# Represents writing to a class variable.
|
@@ -4327,8 +4646,7 @@ module Prism
|
|
4327
4646
|
@name_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
4328
4647
|
end
|
4329
4648
|
|
4330
|
-
# The value to
|
4331
|
-
# represents a non-void expression.
|
4649
|
+
# The value to write to the class variable. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
|
4332
4650
|
#
|
4333
4651
|
# @@foo = :bar
|
4334
4652
|
# ^^^^
|
@@ -4347,7 +4665,6 @@ module Prism
|
|
4347
4665
|
@operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
4348
4666
|
end
|
4349
4667
|
|
4350
|
-
|
4351
4668
|
# def operator: () -> String
|
4352
4669
|
def operator
|
4353
4670
|
operator_loc.slice
|
@@ -4391,6 +4708,16 @@ module Prism
|
|
4391
4708
|
def self.type
|
4392
4709
|
:class_variable_write_node
|
4393
4710
|
end
|
4711
|
+
|
4712
|
+
# Implements case-equality for the node. This is effectively == but without
|
4713
|
+
# comparing the value of locations. Locations are checked only for presence.
|
4714
|
+
def ===(other)
|
4715
|
+
other.is_a?(ClassVariableWriteNode) &&
|
4716
|
+
(name === other.name) &&
|
4717
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
4718
|
+
(value === other.value) &&
|
4719
|
+
(operator_loc.nil? == other.operator_loc.nil?)
|
4720
|
+
end
|
4394
4721
|
end
|
4395
4722
|
|
4396
4723
|
# Represents the use of the `&&=` operator for assignment to a constant.
|
@@ -4462,7 +4789,6 @@ module Prism
|
|
4462
4789
|
# attr_reader value: Prism::node
|
4463
4790
|
attr_reader :value
|
4464
4791
|
|
4465
|
-
|
4466
4792
|
# def operator: () -> String
|
4467
4793
|
def operator
|
4468
4794
|
operator_loc.slice
|
@@ -4506,6 +4832,16 @@ module Prism
|
|
4506
4832
|
def self.type
|
4507
4833
|
:constant_and_write_node
|
4508
4834
|
end
|
4835
|
+
|
4836
|
+
# Implements case-equality for the node. This is effectively == but without
|
4837
|
+
# comparing the value of locations. Locations are checked only for presence.
|
4838
|
+
def ===(other)
|
4839
|
+
other.is_a?(ConstantAndWriteNode) &&
|
4840
|
+
(name === other.name) &&
|
4841
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
4842
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
4843
|
+
(value === other.value)
|
4844
|
+
end
|
4509
4845
|
end
|
4510
4846
|
|
4511
4847
|
# Represents assigning to a constant using an operator that isn't `=`.
|
@@ -4581,7 +4917,6 @@ module Prism
|
|
4581
4917
|
# attr_reader operator: Symbol
|
4582
4918
|
attr_reader :operator
|
4583
4919
|
|
4584
|
-
|
4585
4920
|
# def inspect(NodeInspector inspector) -> String
|
4586
4921
|
def inspect(inspector = NodeInspector.new)
|
4587
4922
|
inspector << inspector.header(self)
|
@@ -4621,6 +4956,17 @@ module Prism
|
|
4621
4956
|
def self.type
|
4622
4957
|
:constant_operator_write_node
|
4623
4958
|
end
|
4959
|
+
|
4960
|
+
# Implements case-equality for the node. This is effectively == but without
|
4961
|
+
# comparing the value of locations. Locations are checked only for presence.
|
4962
|
+
def ===(other)
|
4963
|
+
other.is_a?(ConstantOperatorWriteNode) &&
|
4964
|
+
(name === other.name) &&
|
4965
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
4966
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
4967
|
+
(value === other.value) &&
|
4968
|
+
(operator === other.operator)
|
4969
|
+
end
|
4624
4970
|
end
|
4625
4971
|
|
4626
4972
|
# Represents the use of the `||=` operator for assignment to a constant.
|
@@ -4692,7 +5038,6 @@ module Prism
|
|
4692
5038
|
# attr_reader value: Prism::node
|
4693
5039
|
attr_reader :value
|
4694
5040
|
|
4695
|
-
|
4696
5041
|
# def operator: () -> String
|
4697
5042
|
def operator
|
4698
5043
|
operator_loc.slice
|
@@ -4736,6 +5081,16 @@ module Prism
|
|
4736
5081
|
def self.type
|
4737
5082
|
:constant_or_write_node
|
4738
5083
|
end
|
5084
|
+
|
5085
|
+
# Implements case-equality for the node. This is effectively == but without
|
5086
|
+
# comparing the value of locations. Locations are checked only for presence.
|
5087
|
+
def ===(other)
|
5088
|
+
other.is_a?(ConstantOrWriteNode) &&
|
5089
|
+
(name === other.name) &&
|
5090
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
5091
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
5092
|
+
(value === other.value)
|
5093
|
+
end
|
4739
5094
|
end
|
4740
5095
|
|
4741
5096
|
# Represents the use of the `&&=` operator for assignment to a constant path.
|
@@ -4799,7 +5154,6 @@ module Prism
|
|
4799
5154
|
# attr_reader value: Prism::node
|
4800
5155
|
attr_reader :value
|
4801
5156
|
|
4802
|
-
|
4803
5157
|
# def operator: () -> String
|
4804
5158
|
def operator
|
4805
5159
|
operator_loc.slice
|
@@ -4843,6 +5197,15 @@ module Prism
|
|
4843
5197
|
def self.type
|
4844
5198
|
:constant_path_and_write_node
|
4845
5199
|
end
|
5200
|
+
|
5201
|
+
# Implements case-equality for the node. This is effectively == but without
|
5202
|
+
# comparing the value of locations. Locations are checked only for presence.
|
5203
|
+
def ===(other)
|
5204
|
+
other.is_a?(ConstantPathAndWriteNode) &&
|
5205
|
+
(target === other.target) &&
|
5206
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
5207
|
+
(value === other.value)
|
5208
|
+
end
|
4846
5209
|
end
|
4847
5210
|
|
4848
5211
|
# Represents accessing a constant through a path of `::` operators.
|
@@ -4896,20 +5259,44 @@ module Prism
|
|
4896
5259
|
{ parent: parent, child: child, delimiter_loc: delimiter_loc, location: location }
|
4897
5260
|
end
|
4898
5261
|
|
4899
|
-
#
|
5262
|
+
# 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.
|
5263
|
+
#
|
5264
|
+
# Foo::Bar
|
5265
|
+
# ^^^
|
5266
|
+
#
|
5267
|
+
# self::Test
|
5268
|
+
# ^^^^
|
5269
|
+
#
|
5270
|
+
# a.b::C
|
5271
|
+
# ^^^
|
4900
5272
|
attr_reader :parent
|
4901
5273
|
|
4902
|
-
#
|
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
|
+
# ^
|
4903
5285
|
attr_reader :child
|
4904
5286
|
|
4905
|
-
#
|
5287
|
+
# The location of the `::` delimiter.
|
5288
|
+
#
|
5289
|
+
# ::Foo
|
5290
|
+
# ^^
|
5291
|
+
#
|
5292
|
+
# One::Two
|
5293
|
+
# ^^
|
4906
5294
|
def delimiter_loc
|
4907
5295
|
location = @delimiter_loc
|
4908
5296
|
return location if location.is_a?(Location)
|
4909
5297
|
@delimiter_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
4910
5298
|
end
|
4911
5299
|
|
4912
|
-
|
4913
5300
|
# def delimiter: () -> String
|
4914
5301
|
def delimiter
|
4915
5302
|
delimiter_loc.slice
|
@@ -4957,6 +5344,15 @@ module Prism
|
|
4957
5344
|
def self.type
|
4958
5345
|
:constant_path_node
|
4959
5346
|
end
|
5347
|
+
|
5348
|
+
# Implements case-equality for the node. This is effectively == but without
|
5349
|
+
# comparing the value of locations. Locations are checked only for presence.
|
5350
|
+
def ===(other)
|
5351
|
+
other.is_a?(ConstantPathNode) &&
|
5352
|
+
(parent === other.parent) &&
|
5353
|
+
(child === other.child) &&
|
5354
|
+
(delimiter_loc.nil? == other.delimiter_loc.nil?)
|
5355
|
+
end
|
4960
5356
|
end
|
4961
5357
|
|
4962
5358
|
# Represents assigning to a constant path using an operator that isn't `=`.
|
@@ -5024,7 +5420,6 @@ module Prism
|
|
5024
5420
|
# attr_reader operator: Symbol
|
5025
5421
|
attr_reader :operator
|
5026
5422
|
|
5027
|
-
|
5028
5423
|
# def inspect(NodeInspector inspector) -> String
|
5029
5424
|
def inspect(inspector = NodeInspector.new)
|
5030
5425
|
inspector << inspector.header(self)
|
@@ -5064,6 +5459,16 @@ module Prism
|
|
5064
5459
|
def self.type
|
5065
5460
|
:constant_path_operator_write_node
|
5066
5461
|
end
|
5462
|
+
|
5463
|
+
# Implements case-equality for the node. This is effectively == but without
|
5464
|
+
# comparing the value of locations. Locations are checked only for presence.
|
5465
|
+
def ===(other)
|
5466
|
+
other.is_a?(ConstantPathOperatorWriteNode) &&
|
5467
|
+
(target === other.target) &&
|
5468
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
5469
|
+
(value === other.value) &&
|
5470
|
+
(operator === other.operator)
|
5471
|
+
end
|
5067
5472
|
end
|
5068
5473
|
|
5069
5474
|
# Represents the use of the `||=` operator for assignment to a constant path.
|
@@ -5127,7 +5532,6 @@ module Prism
|
|
5127
5532
|
# attr_reader value: Prism::node
|
5128
5533
|
attr_reader :value
|
5129
5534
|
|
5130
|
-
|
5131
5535
|
# def operator: () -> String
|
5132
5536
|
def operator
|
5133
5537
|
operator_loc.slice
|
@@ -5171,6 +5575,15 @@ module Prism
|
|
5171
5575
|
def self.type
|
5172
5576
|
:constant_path_or_write_node
|
5173
5577
|
end
|
5578
|
+
|
5579
|
+
# Implements case-equality for the node. This is effectively == but without
|
5580
|
+
# comparing the value of locations. Locations are checked only for presence.
|
5581
|
+
def ===(other)
|
5582
|
+
other.is_a?(ConstantPathOrWriteNode) &&
|
5583
|
+
(target === other.target) &&
|
5584
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
5585
|
+
(value === other.value)
|
5586
|
+
end
|
5174
5587
|
end
|
5175
5588
|
|
5176
5589
|
# Represents writing to a constant path in a context that doesn't have an explicit value.
|
@@ -5237,7 +5650,6 @@ module Prism
|
|
5237
5650
|
@delimiter_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
5238
5651
|
end
|
5239
5652
|
|
5240
|
-
|
5241
5653
|
# def delimiter: () -> String
|
5242
5654
|
def delimiter
|
5243
5655
|
delimiter_loc.slice
|
@@ -5285,6 +5697,15 @@ module Prism
|
|
5285
5697
|
def self.type
|
5286
5698
|
:constant_path_target_node
|
5287
5699
|
end
|
5700
|
+
|
5701
|
+
# Implements case-equality for the node. This is effectively == but without
|
5702
|
+
# comparing the value of locations. Locations are checked only for presence.
|
5703
|
+
def ===(other)
|
5704
|
+
other.is_a?(ConstantPathTargetNode) &&
|
5705
|
+
(parent === other.parent) &&
|
5706
|
+
(child === other.child) &&
|
5707
|
+
(delimiter_loc.nil? == other.delimiter_loc.nil?)
|
5708
|
+
end
|
5288
5709
|
end
|
5289
5710
|
|
5290
5711
|
# Represents writing to a constant path.
|
@@ -5341,20 +5762,31 @@ module Prism
|
|
5341
5762
|
{ target: target, operator_loc: operator_loc, value: value, location: location }
|
5342
5763
|
end
|
5343
5764
|
|
5344
|
-
#
|
5765
|
+
# A node representing the constant path being written to.
|
5766
|
+
#
|
5767
|
+
# Foo::Bar = 1
|
5768
|
+
# ^^^^^^^^
|
5769
|
+
#
|
5770
|
+
# ::Foo = :abc
|
5771
|
+
# ^^^^^
|
5345
5772
|
attr_reader :target
|
5346
5773
|
|
5347
|
-
#
|
5774
|
+
# The location of the `=` operator.
|
5775
|
+
#
|
5776
|
+
# ::ABC = 123
|
5777
|
+
# ^
|
5348
5778
|
def operator_loc
|
5349
5779
|
location = @operator_loc
|
5350
5780
|
return location if location.is_a?(Location)
|
5351
5781
|
@operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
5352
5782
|
end
|
5353
5783
|
|
5354
|
-
#
|
5784
|
+
# The value to write to the constant path. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
|
5785
|
+
#
|
5786
|
+
# FOO::BAR = :abc
|
5787
|
+
# ^^^^
|
5355
5788
|
attr_reader :value
|
5356
5789
|
|
5357
|
-
|
5358
5790
|
# def operator: () -> String
|
5359
5791
|
def operator
|
5360
5792
|
operator_loc.slice
|
@@ -5398,6 +5830,15 @@ module Prism
|
|
5398
5830
|
def self.type
|
5399
5831
|
:constant_path_write_node
|
5400
5832
|
end
|
5833
|
+
|
5834
|
+
# Implements case-equality for the node. This is effectively == but without
|
5835
|
+
# comparing the value of locations. Locations are checked only for presence.
|
5836
|
+
def ===(other)
|
5837
|
+
other.is_a?(ConstantPathWriteNode) &&
|
5838
|
+
(target === other.target) &&
|
5839
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
5840
|
+
(value === other.value)
|
5841
|
+
end
|
5401
5842
|
end
|
5402
5843
|
|
5403
5844
|
# Represents referencing a constant.
|
@@ -5453,7 +5894,6 @@ module Prism
|
|
5453
5894
|
# SOME_CONSTANT # name `:SOME_CONSTANT`
|
5454
5895
|
attr_reader :name
|
5455
5896
|
|
5456
|
-
|
5457
5897
|
# def inspect(NodeInspector inspector) -> String
|
5458
5898
|
def inspect(inspector = NodeInspector.new)
|
5459
5899
|
inspector << inspector.header(self)
|
@@ -5488,6 +5928,13 @@ module Prism
|
|
5488
5928
|
def self.type
|
5489
5929
|
:constant_read_node
|
5490
5930
|
end
|
5931
|
+
|
5932
|
+
# Implements case-equality for the node. This is effectively == but without
|
5933
|
+
# comparing the value of locations. Locations are checked only for presence.
|
5934
|
+
def ===(other)
|
5935
|
+
other.is_a?(ConstantReadNode) &&
|
5936
|
+
(name === other.name)
|
5937
|
+
end
|
5491
5938
|
end
|
5492
5939
|
|
5493
5940
|
# Represents writing to a constant in a context that doesn't have an explicit value.
|
@@ -5539,7 +5986,6 @@ module Prism
|
|
5539
5986
|
# attr_reader name: Symbol
|
5540
5987
|
attr_reader :name
|
5541
5988
|
|
5542
|
-
|
5543
5989
|
# def inspect(NodeInspector inspector) -> String
|
5544
5990
|
def inspect(inspector = NodeInspector.new)
|
5545
5991
|
inspector << inspector.header(self)
|
@@ -5574,6 +6020,13 @@ module Prism
|
|
5574
6020
|
def self.type
|
5575
6021
|
:constant_target_node
|
5576
6022
|
end
|
6023
|
+
|
6024
|
+
# Implements case-equality for the node. This is effectively == but without
|
6025
|
+
# comparing the value of locations. Locations are checked only for presence.
|
6026
|
+
def ===(other)
|
6027
|
+
other.is_a?(ConstantTargetNode) &&
|
6028
|
+
(name === other.name)
|
6029
|
+
end
|
5577
6030
|
end
|
5578
6031
|
|
5579
6032
|
# Represents writing to a constant.
|
@@ -5625,27 +6078,42 @@ module Prism
|
|
5625
6078
|
{ name: name, name_loc: name_loc, value: value, operator_loc: operator_loc, location: location }
|
5626
6079
|
end
|
5627
6080
|
|
5628
|
-
#
|
6081
|
+
# The name of the [constant](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#constants).
|
6082
|
+
#
|
6083
|
+
# Foo = :bar # name `:Foo`
|
6084
|
+
#
|
6085
|
+
# XYZ = 1 # name `:XYZ`
|
5629
6086
|
attr_reader :name
|
5630
6087
|
|
5631
|
-
#
|
6088
|
+
# The location of the constant name.
|
6089
|
+
#
|
6090
|
+
# FOO = 1
|
6091
|
+
# ^^^
|
5632
6092
|
def name_loc
|
5633
6093
|
location = @name_loc
|
5634
6094
|
return location if location.is_a?(Location)
|
5635
6095
|
@name_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
5636
6096
|
end
|
5637
6097
|
|
5638
|
-
#
|
6098
|
+
# The value to write to the constant. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
|
6099
|
+
#
|
6100
|
+
# FOO = :bar
|
6101
|
+
# ^^^^
|
6102
|
+
#
|
6103
|
+
# MyClass = Class.new
|
6104
|
+
# ^^^^^^^^^
|
5639
6105
|
attr_reader :value
|
5640
6106
|
|
5641
|
-
#
|
6107
|
+
# The location of the `=` operator.
|
6108
|
+
#
|
6109
|
+
# FOO = :bar
|
6110
|
+
# ^
|
5642
6111
|
def operator_loc
|
5643
6112
|
location = @operator_loc
|
5644
6113
|
return location if location.is_a?(Location)
|
5645
6114
|
@operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
5646
6115
|
end
|
5647
6116
|
|
5648
|
-
|
5649
6117
|
# def operator: () -> String
|
5650
6118
|
def operator
|
5651
6119
|
operator_loc.slice
|
@@ -5689,6 +6157,16 @@ module Prism
|
|
5689
6157
|
def self.type
|
5690
6158
|
:constant_write_node
|
5691
6159
|
end
|
6160
|
+
|
6161
|
+
# Implements case-equality for the node. This is effectively == but without
|
6162
|
+
# comparing the value of locations. Locations are checked only for presence.
|
6163
|
+
def ===(other)
|
6164
|
+
other.is_a?(ConstantWriteNode) &&
|
6165
|
+
(name === other.name) &&
|
6166
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
6167
|
+
(value === other.value) &&
|
6168
|
+
(operator_loc.nil? == other.operator_loc.nil?)
|
6169
|
+
end
|
5692
6170
|
end
|
5693
6171
|
|
5694
6172
|
# Represents a method definition.
|
@@ -5847,7 +6325,6 @@ module Prism
|
|
5847
6325
|
end
|
5848
6326
|
end
|
5849
6327
|
|
5850
|
-
|
5851
6328
|
# def def_keyword: () -> String
|
5852
6329
|
def def_keyword
|
5853
6330
|
def_keyword_loc.slice
|
@@ -5938,6 +6415,25 @@ module Prism
|
|
5938
6415
|
def self.type
|
5939
6416
|
:def_node
|
5940
6417
|
end
|
6418
|
+
|
6419
|
+
# Implements case-equality for the node. This is effectively == but without
|
6420
|
+
# comparing the value of locations. Locations are checked only for presence.
|
6421
|
+
def ===(other)
|
6422
|
+
other.is_a?(DefNode) &&
|
6423
|
+
(name === other.name) &&
|
6424
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
6425
|
+
(receiver === other.receiver) &&
|
6426
|
+
(parameters === other.parameters) &&
|
6427
|
+
(body === other.body) &&
|
6428
|
+
(locals.length == other.locals.length) &&
|
6429
|
+
locals.zip(other.locals).all? { |left, right| left === right } &&
|
6430
|
+
(def_keyword_loc.nil? == other.def_keyword_loc.nil?) &&
|
6431
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
6432
|
+
(lparen_loc.nil? == other.lparen_loc.nil?) &&
|
6433
|
+
(rparen_loc.nil? == other.rparen_loc.nil?) &&
|
6434
|
+
(equal_loc.nil? == other.equal_loc.nil?) &&
|
6435
|
+
(end_keyword_loc.nil? == other.end_keyword_loc.nil?)
|
6436
|
+
end
|
5941
6437
|
end
|
5942
6438
|
|
5943
6439
|
# Represents the use of the `defined?` keyword.
|
@@ -6025,7 +6521,6 @@ module Prism
|
|
6025
6521
|
@keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
6026
6522
|
end
|
6027
6523
|
|
6028
|
-
|
6029
6524
|
# def lparen: () -> String?
|
6030
6525
|
def lparen
|
6031
6526
|
lparen_loc&.slice
|
@@ -6079,6 +6574,16 @@ module Prism
|
|
6079
6574
|
def self.type
|
6080
6575
|
:defined_node
|
6081
6576
|
end
|
6577
|
+
|
6578
|
+
# Implements case-equality for the node. This is effectively == but without
|
6579
|
+
# comparing the value of locations. Locations are checked only for presence.
|
6580
|
+
def ===(other)
|
6581
|
+
other.is_a?(DefinedNode) &&
|
6582
|
+
(lparen_loc.nil? == other.lparen_loc.nil?) &&
|
6583
|
+
(value === other.value) &&
|
6584
|
+
(rparen_loc.nil? == other.rparen_loc.nil?) &&
|
6585
|
+
(keyword_loc.nil? == other.keyword_loc.nil?)
|
6586
|
+
end
|
6082
6587
|
end
|
6083
6588
|
|
6084
6589
|
# Represents an `else` clause in a `case`, `if`, or `unless` statement.
|
@@ -6154,7 +6659,6 @@ module Prism
|
|
6154
6659
|
end
|
6155
6660
|
end
|
6156
6661
|
|
6157
|
-
|
6158
6662
|
# def else_keyword: () -> String
|
6159
6663
|
def else_keyword
|
6160
6664
|
else_keyword_loc.slice
|
@@ -6206,6 +6710,15 @@ module Prism
|
|
6206
6710
|
def self.type
|
6207
6711
|
:else_node
|
6208
6712
|
end
|
6713
|
+
|
6714
|
+
# Implements case-equality for the node. This is effectively == but without
|
6715
|
+
# comparing the value of locations. Locations are checked only for presence.
|
6716
|
+
def ===(other)
|
6717
|
+
other.is_a?(ElseNode) &&
|
6718
|
+
(else_keyword_loc.nil? == other.else_keyword_loc.nil?) &&
|
6719
|
+
(statements === other.statements) &&
|
6720
|
+
(end_keyword_loc.nil? == other.end_keyword_loc.nil?)
|
6721
|
+
end
|
6209
6722
|
end
|
6210
6723
|
|
6211
6724
|
# Represents an interpolated set of statements.
|
@@ -6275,7 +6788,6 @@ module Prism
|
|
6275
6788
|
@closing_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
6276
6789
|
end
|
6277
6790
|
|
6278
|
-
|
6279
6791
|
# def opening: () -> String
|
6280
6792
|
def opening
|
6281
6793
|
opening_loc.slice
|
@@ -6327,6 +6839,15 @@ module Prism
|
|
6327
6839
|
def self.type
|
6328
6840
|
:embedded_statements_node
|
6329
6841
|
end
|
6842
|
+
|
6843
|
+
# Implements case-equality for the node. This is effectively == but without
|
6844
|
+
# comparing the value of locations. Locations are checked only for presence.
|
6845
|
+
def ===(other)
|
6846
|
+
other.is_a?(EmbeddedStatementsNode) &&
|
6847
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
6848
|
+
(statements === other.statements) &&
|
6849
|
+
(closing_loc.nil? == other.closing_loc.nil?)
|
6850
|
+
end
|
6330
6851
|
end
|
6331
6852
|
|
6332
6853
|
# Represents an interpolated variable.
|
@@ -6386,7 +6907,6 @@ module Prism
|
|
6386
6907
|
# attr_reader variable: Prism::node
|
6387
6908
|
attr_reader :variable
|
6388
6909
|
|
6389
|
-
|
6390
6910
|
# def operator: () -> String
|
6391
6911
|
def operator
|
6392
6912
|
operator_loc.slice
|
@@ -6428,6 +6948,14 @@ module Prism
|
|
6428
6948
|
def self.type
|
6429
6949
|
:embedded_variable_node
|
6430
6950
|
end
|
6951
|
+
|
6952
|
+
# Implements case-equality for the node. This is effectively == but without
|
6953
|
+
# comparing the value of locations. Locations are checked only for presence.
|
6954
|
+
def ===(other)
|
6955
|
+
other.is_a?(EmbeddedVariableNode) &&
|
6956
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
6957
|
+
(variable === other.variable)
|
6958
|
+
end
|
6431
6959
|
end
|
6432
6960
|
|
6433
6961
|
# Represents an `ensure` clause in a `begin` statement.
|
@@ -6501,7 +7029,6 @@ module Prism
|
|
6501
7029
|
@end_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
6502
7030
|
end
|
6503
7031
|
|
6504
|
-
|
6505
7032
|
# def ensure_keyword: () -> String
|
6506
7033
|
def ensure_keyword
|
6507
7034
|
ensure_keyword_loc.slice
|
@@ -6553,6 +7080,15 @@ module Prism
|
|
6553
7080
|
def self.type
|
6554
7081
|
:ensure_node
|
6555
7082
|
end
|
7083
|
+
|
7084
|
+
# Implements case-equality for the node. This is effectively == but without
|
7085
|
+
# comparing the value of locations. Locations are checked only for presence.
|
7086
|
+
def ===(other)
|
7087
|
+
other.is_a?(EnsureNode) &&
|
7088
|
+
(ensure_keyword_loc.nil? == other.ensure_keyword_loc.nil?) &&
|
7089
|
+
(statements === other.statements) &&
|
7090
|
+
(end_keyword_loc.nil? == other.end_keyword_loc.nil?)
|
7091
|
+
end
|
6556
7092
|
end
|
6557
7093
|
|
6558
7094
|
# Represents the use of the literal `false` keyword.
|
@@ -6600,7 +7136,6 @@ module Prism
|
|
6600
7136
|
{ location: location }
|
6601
7137
|
end
|
6602
7138
|
|
6603
|
-
|
6604
7139
|
# def inspect(NodeInspector inspector) -> String
|
6605
7140
|
def inspect(inspector = NodeInspector.new)
|
6606
7141
|
inspector << inspector.header(self)
|
@@ -6634,6 +7169,12 @@ module Prism
|
|
6634
7169
|
def self.type
|
6635
7170
|
:false_node
|
6636
7171
|
end
|
7172
|
+
|
7173
|
+
# Implements case-equality for the node. This is effectively == but without
|
7174
|
+
# comparing the value of locations. Locations are checked only for presence.
|
7175
|
+
def ===(other)
|
7176
|
+
other.is_a?(FalseNode)
|
7177
|
+
end
|
6637
7178
|
end
|
6638
7179
|
|
6639
7180
|
# Represents a find pattern in pattern matching.
|
@@ -6736,7 +7277,6 @@ module Prism
|
|
6736
7277
|
end
|
6737
7278
|
end
|
6738
7279
|
|
6739
|
-
|
6740
7280
|
# def opening: () -> String?
|
6741
7281
|
def opening
|
6742
7282
|
opening_loc&.slice
|
@@ -6793,6 +7333,19 @@ module Prism
|
|
6793
7333
|
def self.type
|
6794
7334
|
:find_pattern_node
|
6795
7335
|
end
|
7336
|
+
|
7337
|
+
# Implements case-equality for the node. This is effectively == but without
|
7338
|
+
# comparing the value of locations. Locations are checked only for presence.
|
7339
|
+
def ===(other)
|
7340
|
+
other.is_a?(FindPatternNode) &&
|
7341
|
+
(constant === other.constant) &&
|
7342
|
+
(left === other.left) &&
|
7343
|
+
(requireds.length == other.requireds.length) &&
|
7344
|
+
requireds.zip(other.requireds).all? { |left, right| left === right } &&
|
7345
|
+
(right === other.right) &&
|
7346
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
7347
|
+
(closing_loc.nil? == other.closing_loc.nil?)
|
7348
|
+
end
|
6796
7349
|
end
|
6797
7350
|
|
6798
7351
|
# Represents the use of the `..` or `...` operators to create flip flops.
|
@@ -6847,9 +7400,9 @@ module Prism
|
|
6847
7400
|
{ flags: flags, left: left, right: right, operator_loc: operator_loc, location: location }
|
6848
7401
|
end
|
6849
7402
|
|
6850
|
-
#
|
7403
|
+
# protected attr_reader flags: Integer
|
6851
7404
|
attr_reader :flags
|
6852
|
-
|
7405
|
+
protected :flags
|
6853
7406
|
|
6854
7407
|
# attr_reader left: Prism::node?
|
6855
7408
|
attr_reader :left
|
@@ -6864,7 +7417,6 @@ module Prism
|
|
6864
7417
|
@operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
6865
7418
|
end
|
6866
7419
|
|
6867
|
-
|
6868
7420
|
# def exclude_end?: () -> bool
|
6869
7421
|
def exclude_end?
|
6870
7422
|
flags.anybits?(RangeFlags::EXCLUDE_END)
|
@@ -6923,6 +7475,16 @@ module Prism
|
|
6923
7475
|
def self.type
|
6924
7476
|
:flip_flop_node
|
6925
7477
|
end
|
7478
|
+
|
7479
|
+
# Implements case-equality for the node. This is effectively == but without
|
7480
|
+
# comparing the value of locations. Locations are checked only for presence.
|
7481
|
+
def ===(other)
|
7482
|
+
other.is_a?(FlipFlopNode) &&
|
7483
|
+
(flags === other.flags) &&
|
7484
|
+
(left === other.left) &&
|
7485
|
+
(right === other.right) &&
|
7486
|
+
(operator_loc.nil? == other.operator_loc.nil?)
|
7487
|
+
end
|
6926
7488
|
end
|
6927
7489
|
|
6928
7490
|
# Represents a floating point number literal.
|
@@ -6974,7 +7536,6 @@ module Prism
|
|
6974
7536
|
# The value of the floating point number as a Float.
|
6975
7537
|
attr_reader :value
|
6976
7538
|
|
6977
|
-
|
6978
7539
|
# def inspect(NodeInspector inspector) -> String
|
6979
7540
|
def inspect(inspector = NodeInspector.new)
|
6980
7541
|
inspector << inspector.header(self)
|
@@ -7009,6 +7570,13 @@ module Prism
|
|
7009
7570
|
def self.type
|
7010
7571
|
:float_node
|
7011
7572
|
end
|
7573
|
+
|
7574
|
+
# Implements case-equality for the node. This is effectively == but without
|
7575
|
+
# comparing the value of locations. Locations are checked only for presence.
|
7576
|
+
def ===(other)
|
7577
|
+
other.is_a?(FloatNode) &&
|
7578
|
+
(value === other.value)
|
7579
|
+
end
|
7012
7580
|
end
|
7013
7581
|
|
7014
7582
|
# Represents the use of the `for` keyword.
|
@@ -7110,7 +7678,6 @@ module Prism
|
|
7110
7678
|
@end_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
7111
7679
|
end
|
7112
7680
|
|
7113
|
-
|
7114
7681
|
# def for_keyword: () -> String
|
7115
7682
|
def for_keyword
|
7116
7683
|
for_keyword_loc.slice
|
@@ -7178,6 +7745,19 @@ module Prism
|
|
7178
7745
|
def self.type
|
7179
7746
|
:for_node
|
7180
7747
|
end
|
7748
|
+
|
7749
|
+
# Implements case-equality for the node. This is effectively == but without
|
7750
|
+
# comparing the value of locations. Locations are checked only for presence.
|
7751
|
+
def ===(other)
|
7752
|
+
other.is_a?(ForNode) &&
|
7753
|
+
(index === other.index) &&
|
7754
|
+
(collection === other.collection) &&
|
7755
|
+
(statements === other.statements) &&
|
7756
|
+
(for_keyword_loc.nil? == other.for_keyword_loc.nil?) &&
|
7757
|
+
(in_keyword_loc.nil? == other.in_keyword_loc.nil?) &&
|
7758
|
+
(do_keyword_loc.nil? == other.do_keyword_loc.nil?) &&
|
7759
|
+
(end_keyword_loc.nil? == other.end_keyword_loc.nil?)
|
7760
|
+
end
|
7181
7761
|
end
|
7182
7762
|
|
7183
7763
|
# Represents forwarding all arguments to this method to another method.
|
@@ -7227,7 +7807,6 @@ module Prism
|
|
7227
7807
|
{ location: location }
|
7228
7808
|
end
|
7229
7809
|
|
7230
|
-
|
7231
7810
|
# def inspect(NodeInspector inspector) -> String
|
7232
7811
|
def inspect(inspector = NodeInspector.new)
|
7233
7812
|
inspector << inspector.header(self)
|
@@ -7261,6 +7840,12 @@ module Prism
|
|
7261
7840
|
def self.type
|
7262
7841
|
:forwarding_arguments_node
|
7263
7842
|
end
|
7843
|
+
|
7844
|
+
# Implements case-equality for the node. This is effectively == but without
|
7845
|
+
# comparing the value of locations. Locations are checked only for presence.
|
7846
|
+
def ===(other)
|
7847
|
+
other.is_a?(ForwardingArgumentsNode)
|
7848
|
+
end
|
7264
7849
|
end
|
7265
7850
|
|
7266
7851
|
# Represents the use of the forwarding parameter in a method, block, or lambda declaration.
|
@@ -7309,7 +7894,6 @@ module Prism
|
|
7309
7894
|
{ location: location }
|
7310
7895
|
end
|
7311
7896
|
|
7312
|
-
|
7313
7897
|
# def inspect(NodeInspector inspector) -> String
|
7314
7898
|
def inspect(inspector = NodeInspector.new)
|
7315
7899
|
inspector << inspector.header(self)
|
@@ -7343,6 +7927,12 @@ module Prism
|
|
7343
7927
|
def self.type
|
7344
7928
|
:forwarding_parameter_node
|
7345
7929
|
end
|
7930
|
+
|
7931
|
+
# Implements case-equality for the node. This is effectively == but without
|
7932
|
+
# comparing the value of locations. Locations are checked only for presence.
|
7933
|
+
def ===(other)
|
7934
|
+
other.is_a?(ForwardingParameterNode)
|
7935
|
+
end
|
7346
7936
|
end
|
7347
7937
|
|
7348
7938
|
# Represents the use of the `super` keyword without parentheses or arguments.
|
@@ -7396,7 +7986,6 @@ module Prism
|
|
7396
7986
|
# attr_reader block: BlockNode?
|
7397
7987
|
attr_reader :block
|
7398
7988
|
|
7399
|
-
|
7400
7989
|
# def inspect(NodeInspector inspector) -> String
|
7401
7990
|
def inspect(inspector = NodeInspector.new)
|
7402
7991
|
inspector << inspector.header(self)
|
@@ -7436,6 +8025,13 @@ module Prism
|
|
7436
8025
|
def self.type
|
7437
8026
|
:forwarding_super_node
|
7438
8027
|
end
|
8028
|
+
|
8029
|
+
# Implements case-equality for the node. This is effectively == but without
|
8030
|
+
# comparing the value of locations. Locations are checked only for presence.
|
8031
|
+
def ===(other)
|
8032
|
+
other.is_a?(ForwardingSuperNode) &&
|
8033
|
+
(block === other.block)
|
8034
|
+
end
|
7439
8035
|
end
|
7440
8036
|
|
7441
8037
|
# Represents the use of the `&&=` operator for assignment to a global variable.
|
@@ -7507,7 +8103,6 @@ module Prism
|
|
7507
8103
|
# attr_reader value: Prism::node
|
7508
8104
|
attr_reader :value
|
7509
8105
|
|
7510
|
-
|
7511
8106
|
# def operator: () -> String
|
7512
8107
|
def operator
|
7513
8108
|
operator_loc.slice
|
@@ -7551,6 +8146,16 @@ module Prism
|
|
7551
8146
|
def self.type
|
7552
8147
|
:global_variable_and_write_node
|
7553
8148
|
end
|
8149
|
+
|
8150
|
+
# Implements case-equality for the node. This is effectively == but without
|
8151
|
+
# comparing the value of locations. Locations are checked only for presence.
|
8152
|
+
def ===(other)
|
8153
|
+
other.is_a?(GlobalVariableAndWriteNode) &&
|
8154
|
+
(name === other.name) &&
|
8155
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
8156
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
8157
|
+
(value === other.value)
|
8158
|
+
end
|
7554
8159
|
end
|
7555
8160
|
|
7556
8161
|
# Represents assigning to a global variable using an operator that isn't `=`.
|
@@ -7626,7 +8231,6 @@ module Prism
|
|
7626
8231
|
# attr_reader operator: Symbol
|
7627
8232
|
attr_reader :operator
|
7628
8233
|
|
7629
|
-
|
7630
8234
|
# def inspect(NodeInspector inspector) -> String
|
7631
8235
|
def inspect(inspector = NodeInspector.new)
|
7632
8236
|
inspector << inspector.header(self)
|
@@ -7666,6 +8270,17 @@ module Prism
|
|
7666
8270
|
def self.type
|
7667
8271
|
:global_variable_operator_write_node
|
7668
8272
|
end
|
8273
|
+
|
8274
|
+
# Implements case-equality for the node. This is effectively == but without
|
8275
|
+
# comparing the value of locations. Locations are checked only for presence.
|
8276
|
+
def ===(other)
|
8277
|
+
other.is_a?(GlobalVariableOperatorWriteNode) &&
|
8278
|
+
(name === other.name) &&
|
8279
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
8280
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
8281
|
+
(value === other.value) &&
|
8282
|
+
(operator === other.operator)
|
8283
|
+
end
|
7669
8284
|
end
|
7670
8285
|
|
7671
8286
|
# Represents the use of the `||=` operator for assignment to a global variable.
|
@@ -7737,7 +8352,6 @@ module Prism
|
|
7737
8352
|
# attr_reader value: Prism::node
|
7738
8353
|
attr_reader :value
|
7739
8354
|
|
7740
|
-
|
7741
8355
|
# def operator: () -> String
|
7742
8356
|
def operator
|
7743
8357
|
operator_loc.slice
|
@@ -7781,6 +8395,16 @@ module Prism
|
|
7781
8395
|
def self.type
|
7782
8396
|
:global_variable_or_write_node
|
7783
8397
|
end
|
8398
|
+
|
8399
|
+
# Implements case-equality for the node. This is effectively == but without
|
8400
|
+
# comparing the value of locations. Locations are checked only for presence.
|
8401
|
+
def ===(other)
|
8402
|
+
other.is_a?(GlobalVariableOrWriteNode) &&
|
8403
|
+
(name === other.name) &&
|
8404
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
8405
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
8406
|
+
(value === other.value)
|
8407
|
+
end
|
7784
8408
|
end
|
7785
8409
|
|
7786
8410
|
# Represents referencing a global variable.
|
@@ -7836,7 +8460,6 @@ module Prism
|
|
7836
8460
|
# $_Test # name `:$_Test`
|
7837
8461
|
attr_reader :name
|
7838
8462
|
|
7839
|
-
|
7840
8463
|
# def inspect(NodeInspector inspector) -> String
|
7841
8464
|
def inspect(inspector = NodeInspector.new)
|
7842
8465
|
inspector << inspector.header(self)
|
@@ -7871,6 +8494,13 @@ module Prism
|
|
7871
8494
|
def self.type
|
7872
8495
|
:global_variable_read_node
|
7873
8496
|
end
|
8497
|
+
|
8498
|
+
# Implements case-equality for the node. This is effectively == but without
|
8499
|
+
# comparing the value of locations. Locations are checked only for presence.
|
8500
|
+
def ===(other)
|
8501
|
+
other.is_a?(GlobalVariableReadNode) &&
|
8502
|
+
(name === other.name)
|
8503
|
+
end
|
7874
8504
|
end
|
7875
8505
|
|
7876
8506
|
# Represents writing to a global variable in a context that doesn't have an explicit value.
|
@@ -7922,7 +8552,6 @@ module Prism
|
|
7922
8552
|
# attr_reader name: Symbol
|
7923
8553
|
attr_reader :name
|
7924
8554
|
|
7925
|
-
|
7926
8555
|
# def inspect(NodeInspector inspector) -> String
|
7927
8556
|
def inspect(inspector = NodeInspector.new)
|
7928
8557
|
inspector << inspector.header(self)
|
@@ -7957,6 +8586,13 @@ module Prism
|
|
7957
8586
|
def self.type
|
7958
8587
|
:global_variable_target_node
|
7959
8588
|
end
|
8589
|
+
|
8590
|
+
# Implements case-equality for the node. This is effectively == but without
|
8591
|
+
# comparing the value of locations. Locations are checked only for presence.
|
8592
|
+
def ===(other)
|
8593
|
+
other.is_a?(GlobalVariableTargetNode) &&
|
8594
|
+
(name === other.name)
|
8595
|
+
end
|
7960
8596
|
end
|
7961
8597
|
|
7962
8598
|
# Represents writing to a global variable.
|
@@ -8008,27 +8644,42 @@ module Prism
|
|
8008
8644
|
{ name: name, name_loc: name_loc, value: value, operator_loc: operator_loc, location: location }
|
8009
8645
|
end
|
8010
8646
|
|
8011
|
-
#
|
8647
|
+
# The name of the global variable, which is a `$` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifier). Alternatively, it can be one of the special global variables designated by a symbol.
|
8648
|
+
#
|
8649
|
+
# $foo = :bar # name `:$foo`
|
8650
|
+
#
|
8651
|
+
# $_Test = 123 # name `:$_Test`
|
8012
8652
|
attr_reader :name
|
8013
8653
|
|
8014
|
-
#
|
8654
|
+
# The location of the global variable's name.
|
8655
|
+
#
|
8656
|
+
# $foo = :bar
|
8657
|
+
# ^^^^
|
8015
8658
|
def name_loc
|
8016
8659
|
location = @name_loc
|
8017
8660
|
return location if location.is_a?(Location)
|
8018
8661
|
@name_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
8019
8662
|
end
|
8020
8663
|
|
8021
|
-
#
|
8664
|
+
# The value to write to the global variable. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
|
8665
|
+
#
|
8666
|
+
# $foo = :bar
|
8667
|
+
# ^^^^
|
8668
|
+
#
|
8669
|
+
# $-xyz = 123
|
8670
|
+
# ^^^
|
8022
8671
|
attr_reader :value
|
8023
8672
|
|
8024
|
-
#
|
8673
|
+
# The location of the `=` operator.
|
8674
|
+
#
|
8675
|
+
# $foo = :bar
|
8676
|
+
# ^
|
8025
8677
|
def operator_loc
|
8026
8678
|
location = @operator_loc
|
8027
8679
|
return location if location.is_a?(Location)
|
8028
8680
|
@operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
8029
8681
|
end
|
8030
8682
|
|
8031
|
-
|
8032
8683
|
# def operator: () -> String
|
8033
8684
|
def operator
|
8034
8685
|
operator_loc.slice
|
@@ -8072,6 +8723,16 @@ module Prism
|
|
8072
8723
|
def self.type
|
8073
8724
|
:global_variable_write_node
|
8074
8725
|
end
|
8726
|
+
|
8727
|
+
# Implements case-equality for the node. This is effectively == but without
|
8728
|
+
# comparing the value of locations. Locations are checked only for presence.
|
8729
|
+
def ===(other)
|
8730
|
+
other.is_a?(GlobalVariableWriteNode) &&
|
8731
|
+
(name === other.name) &&
|
8732
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
8733
|
+
(value === other.value) &&
|
8734
|
+
(operator_loc.nil? == other.operator_loc.nil?)
|
8735
|
+
end
|
8075
8736
|
end
|
8076
8737
|
|
8077
8738
|
# Represents a hash literal.
|
@@ -8151,7 +8812,6 @@ module Prism
|
|
8151
8812
|
@closing_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
8152
8813
|
end
|
8153
8814
|
|
8154
|
-
|
8155
8815
|
# def opening: () -> String
|
8156
8816
|
def opening
|
8157
8817
|
opening_loc.slice
|
@@ -8198,6 +8858,16 @@ module Prism
|
|
8198
8858
|
def self.type
|
8199
8859
|
:hash_node
|
8200
8860
|
end
|
8861
|
+
|
8862
|
+
# Implements case-equality for the node. This is effectively == but without
|
8863
|
+
# comparing the value of locations. Locations are checked only for presence.
|
8864
|
+
def ===(other)
|
8865
|
+
other.is_a?(HashNode) &&
|
8866
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
8867
|
+
(elements.length == other.elements.length) &&
|
8868
|
+
elements.zip(other.elements).all? { |left, right| left === right } &&
|
8869
|
+
(closing_loc.nil? == other.closing_loc.nil?)
|
8870
|
+
end
|
8201
8871
|
end
|
8202
8872
|
|
8203
8873
|
# Represents a hash pattern in pattern matching.
|
@@ -8292,7 +8962,6 @@ module Prism
|
|
8292
8962
|
end
|
8293
8963
|
end
|
8294
8964
|
|
8295
|
-
|
8296
8965
|
# def opening: () -> String?
|
8297
8966
|
def opening
|
8298
8967
|
opening_loc&.slice
|
@@ -8351,15 +9020,30 @@ module Prism
|
|
8351
9020
|
def self.type
|
8352
9021
|
:hash_pattern_node
|
8353
9022
|
end
|
9023
|
+
|
9024
|
+
# Implements case-equality for the node. This is effectively == but without
|
9025
|
+
# comparing the value of locations. Locations are checked only for presence.
|
9026
|
+
def ===(other)
|
9027
|
+
other.is_a?(HashPatternNode) &&
|
9028
|
+
(constant === other.constant) &&
|
9029
|
+
(elements.length == other.elements.length) &&
|
9030
|
+
elements.zip(other.elements).all? { |left, right| left === right } &&
|
9031
|
+
(rest === other.rest) &&
|
9032
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
9033
|
+
(closing_loc.nil? == other.closing_loc.nil?)
|
9034
|
+
end
|
8354
9035
|
end
|
8355
9036
|
|
8356
|
-
# Represents the use of the `if` keyword, either in the block form or the modifier form.
|
9037
|
+
# Represents the use of the `if` keyword, either in the block form or the modifier form, or a ternary expression.
|
8357
9038
|
#
|
8358
9039
|
# bar if foo
|
8359
9040
|
# ^^^^^^^^^^
|
8360
9041
|
#
|
8361
9042
|
# if foo then bar end
|
8362
9043
|
# ^^^^^^^^^^^^^^^^^^^
|
9044
|
+
#
|
9045
|
+
# foo ? bar : baz
|
9046
|
+
# ^^^^^^^^^^^^^^^
|
8363
9047
|
class IfNode < Node
|
8364
9048
|
# 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
|
8365
9049
|
def initialize(source, if_keyword_loc, predicate, then_keyword_loc, statements, consequent, end_keyword_loc, location)
|
@@ -8415,7 +9099,12 @@ module Prism
|
|
8415
9099
|
{ if_keyword_loc: if_keyword_loc, predicate: predicate, then_keyword_loc: then_keyword_loc, statements: statements, consequent: consequent, end_keyword_loc: end_keyword_loc, location: location }
|
8416
9100
|
end
|
8417
9101
|
|
8418
|
-
#
|
9102
|
+
# The location of the `if` keyword if present.
|
9103
|
+
#
|
9104
|
+
# bar if foo
|
9105
|
+
# ^^
|
9106
|
+
#
|
9107
|
+
# The `if_keyword_loc` field will be `nil` when the `IfNode` represents a ternary expression.
|
8419
9108
|
def if_keyword_loc
|
8420
9109
|
location = @if_keyword_loc
|
8421
9110
|
case location
|
@@ -8428,10 +9117,27 @@ module Prism
|
|
8428
9117
|
end
|
8429
9118
|
end
|
8430
9119
|
|
8431
|
-
#
|
9120
|
+
# The node for the condition the `IfNode` is testing.
|
9121
|
+
#
|
9122
|
+
# if foo
|
9123
|
+
# ^^^
|
9124
|
+
# bar
|
9125
|
+
# end
|
9126
|
+
#
|
9127
|
+
# bar if foo
|
9128
|
+
# ^^^
|
9129
|
+
#
|
9130
|
+
# foo ? bar : baz
|
9131
|
+
# ^^^
|
8432
9132
|
attr_reader :predicate
|
8433
9133
|
|
8434
|
-
#
|
9134
|
+
# The location of the `then` keyword (if present) or the `?` in a ternary expression, `nil` otherwise.
|
9135
|
+
#
|
9136
|
+
# if foo then bar end
|
9137
|
+
# ^^^^
|
9138
|
+
#
|
9139
|
+
# a ? b : c
|
9140
|
+
# ^
|
8435
9141
|
def then_keyword_loc
|
8436
9142
|
location = @then_keyword_loc
|
8437
9143
|
case location
|
@@ -8444,13 +9150,37 @@ module Prism
|
|
8444
9150
|
end
|
8445
9151
|
end
|
8446
9152
|
|
8447
|
-
#
|
9153
|
+
# Represents the body of statements that will be executed when the predicate is evaluated as truthy. Will be `nil` when no body is provided.
|
9154
|
+
#
|
9155
|
+
# if foo
|
9156
|
+
# bar
|
9157
|
+
# ^^^
|
9158
|
+
# baz
|
9159
|
+
# ^^^
|
9160
|
+
# end
|
8448
9161
|
attr_reader :statements
|
8449
9162
|
|
8450
|
-
#
|
9163
|
+
# Represents an `ElseNode` or an `IfNode` when there is an `else` or an `elsif` in the `if` statement.
|
9164
|
+
#
|
9165
|
+
# if foo
|
9166
|
+
# bar
|
9167
|
+
# elsif baz
|
9168
|
+
# ^^^^^^^^^
|
9169
|
+
# qux
|
9170
|
+
# ^^^
|
9171
|
+
# end
|
9172
|
+
# ^^^
|
9173
|
+
#
|
9174
|
+
# if foo then bar else baz end
|
9175
|
+
# ^^^^^^^^^^^^
|
8451
9176
|
attr_reader :consequent
|
8452
9177
|
|
8453
|
-
#
|
9178
|
+
# The location of the `end` keyword if present, `nil` otherwise.
|
9179
|
+
#
|
9180
|
+
# if foo
|
9181
|
+
# bar
|
9182
|
+
# end
|
9183
|
+
# ^^^
|
8454
9184
|
def end_keyword_loc
|
8455
9185
|
location = @end_keyword_loc
|
8456
9186
|
case location
|
@@ -8463,7 +9193,6 @@ module Prism
|
|
8463
9193
|
end
|
8464
9194
|
end
|
8465
9195
|
|
8466
|
-
|
8467
9196
|
# def if_keyword: () -> String?
|
8468
9197
|
def if_keyword
|
8469
9198
|
if_keyword_loc&.slice
|
@@ -8529,6 +9258,18 @@ module Prism
|
|
8529
9258
|
def self.type
|
8530
9259
|
:if_node
|
8531
9260
|
end
|
9261
|
+
|
9262
|
+
# Implements case-equality for the node. This is effectively == but without
|
9263
|
+
# comparing the value of locations. Locations are checked only for presence.
|
9264
|
+
def ===(other)
|
9265
|
+
other.is_a?(IfNode) &&
|
9266
|
+
(if_keyword_loc.nil? == other.if_keyword_loc.nil?) &&
|
9267
|
+
(predicate === other.predicate) &&
|
9268
|
+
(then_keyword_loc.nil? == other.then_keyword_loc.nil?) &&
|
9269
|
+
(statements === other.statements) &&
|
9270
|
+
(consequent === other.consequent) &&
|
9271
|
+
(end_keyword_loc.nil? == other.end_keyword_loc.nil?)
|
9272
|
+
end
|
8532
9273
|
end
|
8533
9274
|
|
8534
9275
|
# Represents an imaginary number literal.
|
@@ -8580,7 +9321,6 @@ module Prism
|
|
8580
9321
|
# attr_reader numeric: FloatNode | IntegerNode | RationalNode
|
8581
9322
|
attr_reader :numeric
|
8582
9323
|
|
8583
|
-
|
8584
9324
|
# def inspect(NodeInspector inspector) -> String
|
8585
9325
|
def inspect(inspector = NodeInspector.new)
|
8586
9326
|
inspector << inspector.header(self)
|
@@ -8616,6 +9356,13 @@ module Prism
|
|
8616
9356
|
def self.type
|
8617
9357
|
:imaginary_node
|
8618
9358
|
end
|
9359
|
+
|
9360
|
+
# Implements case-equality for the node. This is effectively == but without
|
9361
|
+
# comparing the value of locations. Locations are checked only for presence.
|
9362
|
+
def ===(other)
|
9363
|
+
other.is_a?(ImaginaryNode) &&
|
9364
|
+
(numeric === other.numeric)
|
9365
|
+
end
|
8619
9366
|
end
|
8620
9367
|
|
8621
9368
|
# Represents a node that is implicitly being added to the tree but doesn't correspond directly to a node in the source.
|
@@ -8673,7 +9420,6 @@ module Prism
|
|
8673
9420
|
# attr_reader value: Prism::node
|
8674
9421
|
attr_reader :value
|
8675
9422
|
|
8676
|
-
|
8677
9423
|
# def inspect(NodeInspector inspector) -> String
|
8678
9424
|
def inspect(inspector = NodeInspector.new)
|
8679
9425
|
inspector << inspector.header(self)
|
@@ -8709,6 +9455,13 @@ module Prism
|
|
8709
9455
|
def self.type
|
8710
9456
|
:implicit_node
|
8711
9457
|
end
|
9458
|
+
|
9459
|
+
# Implements case-equality for the node. This is effectively == but without
|
9460
|
+
# comparing the value of locations. Locations are checked only for presence.
|
9461
|
+
def ===(other)
|
9462
|
+
other.is_a?(ImplicitNode) &&
|
9463
|
+
(value === other.value)
|
9464
|
+
end
|
8712
9465
|
end
|
8713
9466
|
|
8714
9467
|
# Represents using a trailing comma to indicate an implicit rest parameter.
|
@@ -8765,7 +9518,6 @@ module Prism
|
|
8765
9518
|
{ location: location }
|
8766
9519
|
end
|
8767
9520
|
|
8768
|
-
|
8769
9521
|
# def inspect(NodeInspector inspector) -> String
|
8770
9522
|
def inspect(inspector = NodeInspector.new)
|
8771
9523
|
inspector << inspector.header(self)
|
@@ -8799,6 +9551,12 @@ module Prism
|
|
8799
9551
|
def self.type
|
8800
9552
|
:implicit_rest_node
|
8801
9553
|
end
|
9554
|
+
|
9555
|
+
# Implements case-equality for the node. This is effectively == but without
|
9556
|
+
# comparing the value of locations. Locations are checked only for presence.
|
9557
|
+
def ===(other)
|
9558
|
+
other.is_a?(ImplicitRestNode)
|
9559
|
+
end
|
8802
9560
|
end
|
8803
9561
|
|
8804
9562
|
# Represents the use of the `in` keyword in a case statement.
|
@@ -8879,7 +9637,6 @@ module Prism
|
|
8879
9637
|
end
|
8880
9638
|
end
|
8881
9639
|
|
8882
|
-
|
8883
9640
|
# def in: () -> String
|
8884
9641
|
def in
|
8885
9642
|
in_loc.slice
|
@@ -8933,6 +9690,16 @@ module Prism
|
|
8933
9690
|
def self.type
|
8934
9691
|
:in_node
|
8935
9692
|
end
|
9693
|
+
|
9694
|
+
# Implements case-equality for the node. This is effectively == but without
|
9695
|
+
# comparing the value of locations. Locations are checked only for presence.
|
9696
|
+
def ===(other)
|
9697
|
+
other.is_a?(InNode) &&
|
9698
|
+
(pattern === other.pattern) &&
|
9699
|
+
(statements === other.statements) &&
|
9700
|
+
(in_loc.nil? == other.in_loc.nil?) &&
|
9701
|
+
(then_loc.nil? == other.then_loc.nil?)
|
9702
|
+
end
|
8936
9703
|
end
|
8937
9704
|
|
8938
9705
|
# Represents the use of the `&&=` operator on a call to the `[]` method.
|
@@ -8994,9 +9761,9 @@ module Prism
|
|
8994
9761
|
{ flags: flags, receiver: receiver, call_operator_loc: call_operator_loc, opening_loc: opening_loc, arguments: arguments, closing_loc: closing_loc, block: block, operator_loc: operator_loc, value: value, location: location }
|
8995
9762
|
end
|
8996
9763
|
|
8997
|
-
#
|
9764
|
+
# protected attr_reader flags: Integer
|
8998
9765
|
attr_reader :flags
|
8999
|
-
|
9766
|
+
protected :flags
|
9000
9767
|
|
9001
9768
|
# attr_reader receiver: Prism::node?
|
9002
9769
|
attr_reader :receiver
|
@@ -9044,7 +9811,6 @@ module Prism
|
|
9044
9811
|
# attr_reader value: Prism::node
|
9045
9812
|
attr_reader :value
|
9046
9813
|
|
9047
|
-
|
9048
9814
|
# def safe_navigation?: () -> bool
|
9049
9815
|
def safe_navigation?
|
9050
9816
|
flags.anybits?(CallNodeFlags::SAFE_NAVIGATION)
|
@@ -9144,6 +9910,21 @@ module Prism
|
|
9144
9910
|
def self.type
|
9145
9911
|
:index_and_write_node
|
9146
9912
|
end
|
9913
|
+
|
9914
|
+
# Implements case-equality for the node. This is effectively == but without
|
9915
|
+
# comparing the value of locations. Locations are checked only for presence.
|
9916
|
+
def ===(other)
|
9917
|
+
other.is_a?(IndexAndWriteNode) &&
|
9918
|
+
(flags === other.flags) &&
|
9919
|
+
(receiver === other.receiver) &&
|
9920
|
+
(call_operator_loc.nil? == other.call_operator_loc.nil?) &&
|
9921
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
9922
|
+
(arguments === other.arguments) &&
|
9923
|
+
(closing_loc.nil? == other.closing_loc.nil?) &&
|
9924
|
+
(block === other.block) &&
|
9925
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
9926
|
+
(value === other.value)
|
9927
|
+
end
|
9147
9928
|
end
|
9148
9929
|
|
9149
9930
|
# Represents the use of an assignment operator on a call to `[]`.
|
@@ -9206,9 +9987,9 @@ module Prism
|
|
9206
9987
|
{ flags: flags, receiver: receiver, call_operator_loc: call_operator_loc, opening_loc: opening_loc, arguments: arguments, closing_loc: closing_loc, block: block, operator: operator, operator_loc: operator_loc, value: value, location: location }
|
9207
9988
|
end
|
9208
9989
|
|
9209
|
-
#
|
9990
|
+
# protected attr_reader flags: Integer
|
9210
9991
|
attr_reader :flags
|
9211
|
-
|
9992
|
+
protected :flags
|
9212
9993
|
|
9213
9994
|
# attr_reader receiver: Prism::node?
|
9214
9995
|
attr_reader :receiver
|
@@ -9259,7 +10040,6 @@ module Prism
|
|
9259
10040
|
# attr_reader value: Prism::node
|
9260
10041
|
attr_reader :value
|
9261
10042
|
|
9262
|
-
|
9263
10043
|
# def safe_navigation?: () -> bool
|
9264
10044
|
def safe_navigation?
|
9265
10045
|
flags.anybits?(CallNodeFlags::SAFE_NAVIGATION)
|
@@ -9355,6 +10135,22 @@ module Prism
|
|
9355
10135
|
def self.type
|
9356
10136
|
:index_operator_write_node
|
9357
10137
|
end
|
10138
|
+
|
10139
|
+
# Implements case-equality for the node. This is effectively == but without
|
10140
|
+
# comparing the value of locations. Locations are checked only for presence.
|
10141
|
+
def ===(other)
|
10142
|
+
other.is_a?(IndexOperatorWriteNode) &&
|
10143
|
+
(flags === other.flags) &&
|
10144
|
+
(receiver === other.receiver) &&
|
10145
|
+
(call_operator_loc.nil? == other.call_operator_loc.nil?) &&
|
10146
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
10147
|
+
(arguments === other.arguments) &&
|
10148
|
+
(closing_loc.nil? == other.closing_loc.nil?) &&
|
10149
|
+
(block === other.block) &&
|
10150
|
+
(operator === other.operator) &&
|
10151
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
10152
|
+
(value === other.value)
|
10153
|
+
end
|
9358
10154
|
end
|
9359
10155
|
|
9360
10156
|
# Represents the use of the `||=` operator on a call to `[]`.
|
@@ -9416,9 +10212,9 @@ module Prism
|
|
9416
10212
|
{ flags: flags, receiver: receiver, call_operator_loc: call_operator_loc, opening_loc: opening_loc, arguments: arguments, closing_loc: closing_loc, block: block, operator_loc: operator_loc, value: value, location: location }
|
9417
10213
|
end
|
9418
10214
|
|
9419
|
-
#
|
10215
|
+
# protected attr_reader flags: Integer
|
9420
10216
|
attr_reader :flags
|
9421
|
-
|
10217
|
+
protected :flags
|
9422
10218
|
|
9423
10219
|
# attr_reader receiver: Prism::node?
|
9424
10220
|
attr_reader :receiver
|
@@ -9466,7 +10262,6 @@ module Prism
|
|
9466
10262
|
# attr_reader value: Prism::node
|
9467
10263
|
attr_reader :value
|
9468
10264
|
|
9469
|
-
|
9470
10265
|
# def safe_navigation?: () -> bool
|
9471
10266
|
def safe_navigation?
|
9472
10267
|
flags.anybits?(CallNodeFlags::SAFE_NAVIGATION)
|
@@ -9566,6 +10361,21 @@ module Prism
|
|
9566
10361
|
def self.type
|
9567
10362
|
:index_or_write_node
|
9568
10363
|
end
|
10364
|
+
|
10365
|
+
# Implements case-equality for the node. This is effectively == but without
|
10366
|
+
# comparing the value of locations. Locations are checked only for presence.
|
10367
|
+
def ===(other)
|
10368
|
+
other.is_a?(IndexOrWriteNode) &&
|
10369
|
+
(flags === other.flags) &&
|
10370
|
+
(receiver === other.receiver) &&
|
10371
|
+
(call_operator_loc.nil? == other.call_operator_loc.nil?) &&
|
10372
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
10373
|
+
(arguments === other.arguments) &&
|
10374
|
+
(closing_loc.nil? == other.closing_loc.nil?) &&
|
10375
|
+
(block === other.block) &&
|
10376
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
10377
|
+
(value === other.value)
|
10378
|
+
end
|
9569
10379
|
end
|
9570
10380
|
|
9571
10381
|
# Represents assigning to an index.
|
@@ -9631,9 +10441,9 @@ module Prism
|
|
9631
10441
|
{ flags: flags, receiver: receiver, opening_loc: opening_loc, arguments: arguments, closing_loc: closing_loc, block: block, location: location }
|
9632
10442
|
end
|
9633
10443
|
|
9634
|
-
#
|
10444
|
+
# protected attr_reader flags: Integer
|
9635
10445
|
attr_reader :flags
|
9636
|
-
|
10446
|
+
protected :flags
|
9637
10447
|
|
9638
10448
|
# attr_reader receiver: Prism::node
|
9639
10449
|
attr_reader :receiver
|
@@ -9658,7 +10468,6 @@ module Prism
|
|
9658
10468
|
# attr_reader block: Prism::node?
|
9659
10469
|
attr_reader :block
|
9660
10470
|
|
9661
|
-
|
9662
10471
|
# def safe_navigation?: () -> bool
|
9663
10472
|
def safe_navigation?
|
9664
10473
|
flags.anybits?(CallNodeFlags::SAFE_NAVIGATION)
|
@@ -9740,6 +10549,18 @@ module Prism
|
|
9740
10549
|
def self.type
|
9741
10550
|
:index_target_node
|
9742
10551
|
end
|
10552
|
+
|
10553
|
+
# Implements case-equality for the node. This is effectively == but without
|
10554
|
+
# comparing the value of locations. Locations are checked only for presence.
|
10555
|
+
def ===(other)
|
10556
|
+
other.is_a?(IndexTargetNode) &&
|
10557
|
+
(flags === other.flags) &&
|
10558
|
+
(receiver === other.receiver) &&
|
10559
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
10560
|
+
(arguments === other.arguments) &&
|
10561
|
+
(closing_loc.nil? == other.closing_loc.nil?) &&
|
10562
|
+
(block === other.block)
|
10563
|
+
end
|
9743
10564
|
end
|
9744
10565
|
|
9745
10566
|
# Represents the use of the `&&=` operator for assignment to an instance variable.
|
@@ -9811,7 +10632,6 @@ module Prism
|
|
9811
10632
|
# attr_reader value: Prism::node
|
9812
10633
|
attr_reader :value
|
9813
10634
|
|
9814
|
-
|
9815
10635
|
# def operator: () -> String
|
9816
10636
|
def operator
|
9817
10637
|
operator_loc.slice
|
@@ -9855,6 +10675,16 @@ module Prism
|
|
9855
10675
|
def self.type
|
9856
10676
|
:instance_variable_and_write_node
|
9857
10677
|
end
|
10678
|
+
|
10679
|
+
# Implements case-equality for the node. This is effectively == but without
|
10680
|
+
# comparing the value of locations. Locations are checked only for presence.
|
10681
|
+
def ===(other)
|
10682
|
+
other.is_a?(InstanceVariableAndWriteNode) &&
|
10683
|
+
(name === other.name) &&
|
10684
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
10685
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
10686
|
+
(value === other.value)
|
10687
|
+
end
|
9858
10688
|
end
|
9859
10689
|
|
9860
10690
|
# Represents assigning to an instance variable using an operator that isn't `=`.
|
@@ -9930,7 +10760,6 @@ module Prism
|
|
9930
10760
|
# attr_reader operator: Symbol
|
9931
10761
|
attr_reader :operator
|
9932
10762
|
|
9933
|
-
|
9934
10763
|
# def inspect(NodeInspector inspector) -> String
|
9935
10764
|
def inspect(inspector = NodeInspector.new)
|
9936
10765
|
inspector << inspector.header(self)
|
@@ -9970,6 +10799,17 @@ module Prism
|
|
9970
10799
|
def self.type
|
9971
10800
|
:instance_variable_operator_write_node
|
9972
10801
|
end
|
10802
|
+
|
10803
|
+
# Implements case-equality for the node. This is effectively == but without
|
10804
|
+
# comparing the value of locations. Locations are checked only for presence.
|
10805
|
+
def ===(other)
|
10806
|
+
other.is_a?(InstanceVariableOperatorWriteNode) &&
|
10807
|
+
(name === other.name) &&
|
10808
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
10809
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
10810
|
+
(value === other.value) &&
|
10811
|
+
(operator === other.operator)
|
10812
|
+
end
|
9973
10813
|
end
|
9974
10814
|
|
9975
10815
|
# Represents the use of the `||=` operator for assignment to an instance variable.
|
@@ -10041,7 +10881,6 @@ module Prism
|
|
10041
10881
|
# attr_reader value: Prism::node
|
10042
10882
|
attr_reader :value
|
10043
10883
|
|
10044
|
-
|
10045
10884
|
# def operator: () -> String
|
10046
10885
|
def operator
|
10047
10886
|
operator_loc.slice
|
@@ -10085,6 +10924,16 @@ module Prism
|
|
10085
10924
|
def self.type
|
10086
10925
|
:instance_variable_or_write_node
|
10087
10926
|
end
|
10927
|
+
|
10928
|
+
# Implements case-equality for the node. This is effectively == but without
|
10929
|
+
# comparing the value of locations. Locations are checked only for presence.
|
10930
|
+
def ===(other)
|
10931
|
+
other.is_a?(InstanceVariableOrWriteNode) &&
|
10932
|
+
(name === other.name) &&
|
10933
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
10934
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
10935
|
+
(value === other.value)
|
10936
|
+
end
|
10088
10937
|
end
|
10089
10938
|
|
10090
10939
|
# Represents referencing an instance variable.
|
@@ -10140,7 +10989,6 @@ module Prism
|
|
10140
10989
|
# @_test # name `:@_test`
|
10141
10990
|
attr_reader :name
|
10142
10991
|
|
10143
|
-
|
10144
10992
|
# def inspect(NodeInspector inspector) -> String
|
10145
10993
|
def inspect(inspector = NodeInspector.new)
|
10146
10994
|
inspector << inspector.header(self)
|
@@ -10175,6 +11023,13 @@ module Prism
|
|
10175
11023
|
def self.type
|
10176
11024
|
:instance_variable_read_node
|
10177
11025
|
end
|
11026
|
+
|
11027
|
+
# Implements case-equality for the node. This is effectively == but without
|
11028
|
+
# comparing the value of locations. Locations are checked only for presence.
|
11029
|
+
def ===(other)
|
11030
|
+
other.is_a?(InstanceVariableReadNode) &&
|
11031
|
+
(name === other.name)
|
11032
|
+
end
|
10178
11033
|
end
|
10179
11034
|
|
10180
11035
|
# Represents writing to an instance variable in a context that doesn't have an explicit value.
|
@@ -10226,7 +11081,6 @@ module Prism
|
|
10226
11081
|
# attr_reader name: Symbol
|
10227
11082
|
attr_reader :name
|
10228
11083
|
|
10229
|
-
|
10230
11084
|
# def inspect(NodeInspector inspector) -> String
|
10231
11085
|
def inspect(inspector = NodeInspector.new)
|
10232
11086
|
inspector << inspector.header(self)
|
@@ -10261,6 +11115,13 @@ module Prism
|
|
10261
11115
|
def self.type
|
10262
11116
|
:instance_variable_target_node
|
10263
11117
|
end
|
11118
|
+
|
11119
|
+
# Implements case-equality for the node. This is effectively == but without
|
11120
|
+
# comparing the value of locations. Locations are checked only for presence.
|
11121
|
+
def ===(other)
|
11122
|
+
other.is_a?(InstanceVariableTargetNode) &&
|
11123
|
+
(name === other.name)
|
11124
|
+
end
|
10264
11125
|
end
|
10265
11126
|
|
10266
11127
|
# Represents writing to an instance variable.
|
@@ -10329,8 +11190,7 @@ module Prism
|
|
10329
11190
|
@name_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
10330
11191
|
end
|
10331
11192
|
|
10332
|
-
# The value to
|
10333
|
-
# represents a non-void expression.
|
11193
|
+
# The value to write to the instance variable. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
|
10334
11194
|
#
|
10335
11195
|
# @foo = :bar
|
10336
11196
|
# ^^^^
|
@@ -10349,7 +11209,6 @@ module Prism
|
|
10349
11209
|
@operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
10350
11210
|
end
|
10351
11211
|
|
10352
|
-
|
10353
11212
|
# def operator: () -> String
|
10354
11213
|
def operator
|
10355
11214
|
operator_loc.slice
|
@@ -10393,6 +11252,16 @@ module Prism
|
|
10393
11252
|
def self.type
|
10394
11253
|
:instance_variable_write_node
|
10395
11254
|
end
|
11255
|
+
|
11256
|
+
# Implements case-equality for the node. This is effectively == but without
|
11257
|
+
# comparing the value of locations. Locations are checked only for presence.
|
11258
|
+
def ===(other)
|
11259
|
+
other.is_a?(InstanceVariableWriteNode) &&
|
11260
|
+
(name === other.name) &&
|
11261
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
11262
|
+
(value === other.value) &&
|
11263
|
+
(operator_loc.nil? == other.operator_loc.nil?)
|
11264
|
+
end
|
10396
11265
|
end
|
10397
11266
|
|
10398
11267
|
# Represents an integer number literal.
|
@@ -10442,14 +11311,13 @@ module Prism
|
|
10442
11311
|
{ flags: flags, value: value, location: location }
|
10443
11312
|
end
|
10444
11313
|
|
10445
|
-
#
|
11314
|
+
# protected attr_reader flags: Integer
|
10446
11315
|
attr_reader :flags
|
10447
|
-
|
11316
|
+
protected :flags
|
10448
11317
|
|
10449
11318
|
# The value of the integer literal as a number.
|
10450
11319
|
attr_reader :value
|
10451
11320
|
|
10452
|
-
|
10453
11321
|
# def binary?: () -> bool
|
10454
11322
|
def binary?
|
10455
11323
|
flags.anybits?(IntegerBaseFlags::BINARY)
|
@@ -10506,6 +11374,14 @@ module Prism
|
|
10506
11374
|
def self.type
|
10507
11375
|
:integer_node
|
10508
11376
|
end
|
11377
|
+
|
11378
|
+
# Implements case-equality for the node. This is effectively == but without
|
11379
|
+
# comparing the value of locations. Locations are checked only for presence.
|
11380
|
+
def ===(other)
|
11381
|
+
other.is_a?(IntegerNode) &&
|
11382
|
+
(flags === other.flags) &&
|
11383
|
+
(value === other.value)
|
11384
|
+
end
|
10509
11385
|
end
|
10510
11386
|
|
10511
11387
|
# Represents a regular expression literal that contains interpolation that is being used in the predicate of a conditional to implicitly match against the last line read by an IO object.
|
@@ -10562,9 +11438,9 @@ module Prism
|
|
10562
11438
|
{ flags: flags, opening_loc: opening_loc, parts: parts, closing_loc: closing_loc, location: location }
|
10563
11439
|
end
|
10564
11440
|
|
10565
|
-
#
|
11441
|
+
# protected attr_reader flags: Integer
|
10566
11442
|
attr_reader :flags
|
10567
|
-
|
11443
|
+
protected :flags
|
10568
11444
|
|
10569
11445
|
# attr_reader opening_loc: Location
|
10570
11446
|
def opening_loc
|
@@ -10583,7 +11459,6 @@ module Prism
|
|
10583
11459
|
@closing_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
10584
11460
|
end
|
10585
11461
|
|
10586
|
-
|
10587
11462
|
# def ignore_case?: () -> bool
|
10588
11463
|
def ignore_case?
|
10589
11464
|
flags.anybits?(RegularExpressionFlags::IGNORE_CASE)
|
@@ -10687,6 +11562,17 @@ module Prism
|
|
10687
11562
|
def self.type
|
10688
11563
|
:interpolated_match_last_line_node
|
10689
11564
|
end
|
11565
|
+
|
11566
|
+
# Implements case-equality for the node. This is effectively == but without
|
11567
|
+
# comparing the value of locations. Locations are checked only for presence.
|
11568
|
+
def ===(other)
|
11569
|
+
other.is_a?(InterpolatedMatchLastLineNode) &&
|
11570
|
+
(flags === other.flags) &&
|
11571
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
11572
|
+
(parts.length == other.parts.length) &&
|
11573
|
+
parts.zip(other.parts).all? { |left, right| left === right } &&
|
11574
|
+
(closing_loc.nil? == other.closing_loc.nil?)
|
11575
|
+
end
|
10690
11576
|
end
|
10691
11577
|
|
10692
11578
|
# Represents a regular expression literal that contains interpolation.
|
@@ -10743,9 +11629,9 @@ module Prism
|
|
10743
11629
|
{ flags: flags, opening_loc: opening_loc, parts: parts, closing_loc: closing_loc, location: location }
|
10744
11630
|
end
|
10745
11631
|
|
10746
|
-
#
|
11632
|
+
# protected attr_reader flags: Integer
|
10747
11633
|
attr_reader :flags
|
10748
|
-
|
11634
|
+
protected :flags
|
10749
11635
|
|
10750
11636
|
# attr_reader opening_loc: Location
|
10751
11637
|
def opening_loc
|
@@ -10764,7 +11650,6 @@ module Prism
|
|
10764
11650
|
@closing_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
10765
11651
|
end
|
10766
11652
|
|
10767
|
-
|
10768
11653
|
# def ignore_case?: () -> bool
|
10769
11654
|
def ignore_case?
|
10770
11655
|
flags.anybits?(RegularExpressionFlags::IGNORE_CASE)
|
@@ -10868,6 +11753,17 @@ module Prism
|
|
10868
11753
|
def self.type
|
10869
11754
|
:interpolated_regular_expression_node
|
10870
11755
|
end
|
11756
|
+
|
11757
|
+
# Implements case-equality for the node. This is effectively == but without
|
11758
|
+
# comparing the value of locations. Locations are checked only for presence.
|
11759
|
+
def ===(other)
|
11760
|
+
other.is_a?(InterpolatedRegularExpressionNode) &&
|
11761
|
+
(flags === other.flags) &&
|
11762
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
11763
|
+
(parts.length == other.parts.length) &&
|
11764
|
+
parts.zip(other.parts).all? { |left, right| left === right } &&
|
11765
|
+
(closing_loc.nil? == other.closing_loc.nil?)
|
11766
|
+
end
|
10871
11767
|
end
|
10872
11768
|
|
10873
11769
|
# Represents a string literal that contains interpolation.
|
@@ -10924,9 +11820,9 @@ module Prism
|
|
10924
11820
|
{ flags: flags, opening_loc: opening_loc, parts: parts, closing_loc: closing_loc, location: location }
|
10925
11821
|
end
|
10926
11822
|
|
10927
|
-
#
|
11823
|
+
# protected attr_reader flags: Integer
|
10928
11824
|
attr_reader :flags
|
10929
|
-
|
11825
|
+
protected :flags
|
10930
11826
|
|
10931
11827
|
# attr_reader opening_loc: Location?
|
10932
11828
|
def opening_loc
|
@@ -10957,7 +11853,6 @@ module Prism
|
|
10957
11853
|
end
|
10958
11854
|
end
|
10959
11855
|
|
10960
|
-
|
10961
11856
|
# def frozen?: () -> bool
|
10962
11857
|
def frozen?
|
10963
11858
|
flags.anybits?(InterpolatedStringNodeFlags::FROZEN)
|
@@ -11016,6 +11911,17 @@ module Prism
|
|
11016
11911
|
def self.type
|
11017
11912
|
:interpolated_string_node
|
11018
11913
|
end
|
11914
|
+
|
11915
|
+
# Implements case-equality for the node. This is effectively == but without
|
11916
|
+
# comparing the value of locations. Locations are checked only for presence.
|
11917
|
+
def ===(other)
|
11918
|
+
other.is_a?(InterpolatedStringNode) &&
|
11919
|
+
(flags === other.flags) &&
|
11920
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
11921
|
+
(parts.length == other.parts.length) &&
|
11922
|
+
parts.zip(other.parts).all? { |left, right| left === right } &&
|
11923
|
+
(closing_loc.nil? == other.closing_loc.nil?)
|
11924
|
+
end
|
11019
11925
|
end
|
11020
11926
|
|
11021
11927
|
# Represents a symbol literal that contains interpolation.
|
@@ -11100,7 +12006,6 @@ module Prism
|
|
11100
12006
|
end
|
11101
12007
|
end
|
11102
12008
|
|
11103
|
-
|
11104
12009
|
# def opening: () -> String?
|
11105
12010
|
def opening
|
11106
12011
|
opening_loc&.slice
|
@@ -11147,6 +12052,16 @@ module Prism
|
|
11147
12052
|
def self.type
|
11148
12053
|
:interpolated_symbol_node
|
11149
12054
|
end
|
12055
|
+
|
12056
|
+
# Implements case-equality for the node. This is effectively == but without
|
12057
|
+
# comparing the value of locations. Locations are checked only for presence.
|
12058
|
+
def ===(other)
|
12059
|
+
other.is_a?(InterpolatedSymbolNode) &&
|
12060
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
12061
|
+
(parts.length == other.parts.length) &&
|
12062
|
+
parts.zip(other.parts).all? { |left, right| left === right } &&
|
12063
|
+
(closing_loc.nil? == other.closing_loc.nil?)
|
12064
|
+
end
|
11150
12065
|
end
|
11151
12066
|
|
11152
12067
|
# Represents an xstring literal that contains interpolation.
|
@@ -11219,7 +12134,6 @@ module Prism
|
|
11219
12134
|
@closing_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
11220
12135
|
end
|
11221
12136
|
|
11222
|
-
|
11223
12137
|
# def opening: () -> String
|
11224
12138
|
def opening
|
11225
12139
|
opening_loc.slice
|
@@ -11266,6 +12180,16 @@ module Prism
|
|
11266
12180
|
def self.type
|
11267
12181
|
:interpolated_x_string_node
|
11268
12182
|
end
|
12183
|
+
|
12184
|
+
# Implements case-equality for the node. This is effectively == but without
|
12185
|
+
# comparing the value of locations. Locations are checked only for presence.
|
12186
|
+
def ===(other)
|
12187
|
+
other.is_a?(InterpolatedXStringNode) &&
|
12188
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
12189
|
+
(parts.length == other.parts.length) &&
|
12190
|
+
parts.zip(other.parts).all? { |left, right| left === right } &&
|
12191
|
+
(closing_loc.nil? == other.closing_loc.nil?)
|
12192
|
+
end
|
11269
12193
|
end
|
11270
12194
|
|
11271
12195
|
# Represents an implicit set of parameters through the use of the `it` keyword within a block or lambda.
|
@@ -11313,7 +12237,6 @@ module Prism
|
|
11313
12237
|
{ location: location }
|
11314
12238
|
end
|
11315
12239
|
|
11316
|
-
|
11317
12240
|
# def inspect(NodeInspector inspector) -> String
|
11318
12241
|
def inspect(inspector = NodeInspector.new)
|
11319
12242
|
inspector << inspector.header(self)
|
@@ -11347,6 +12270,12 @@ module Prism
|
|
11347
12270
|
def self.type
|
11348
12271
|
:it_parameters_node
|
11349
12272
|
end
|
12273
|
+
|
12274
|
+
# Implements case-equality for the node. This is effectively == but without
|
12275
|
+
# comparing the value of locations. Locations are checked only for presence.
|
12276
|
+
def ===(other)
|
12277
|
+
other.is_a?(ItParametersNode)
|
12278
|
+
end
|
11350
12279
|
end
|
11351
12280
|
|
11352
12281
|
# Represents a hash literal without opening and closing braces.
|
@@ -11396,14 +12325,13 @@ module Prism
|
|
11396
12325
|
{ flags: flags, elements: elements, location: location }
|
11397
12326
|
end
|
11398
12327
|
|
11399
|
-
#
|
12328
|
+
# protected attr_reader flags: Integer
|
11400
12329
|
attr_reader :flags
|
11401
|
-
|
12330
|
+
protected :flags
|
11402
12331
|
|
11403
12332
|
# attr_reader elements: Array[AssocNode | AssocSplatNode]
|
11404
12333
|
attr_reader :elements
|
11405
12334
|
|
11406
|
-
|
11407
12335
|
# def symbol_keys?: () -> bool
|
11408
12336
|
def symbol_keys?
|
11409
12337
|
flags.anybits?(KeywordHashNodeFlags::SYMBOL_KEYS)
|
@@ -11445,6 +12373,15 @@ module Prism
|
|
11445
12373
|
def self.type
|
11446
12374
|
:keyword_hash_node
|
11447
12375
|
end
|
12376
|
+
|
12377
|
+
# Implements case-equality for the node. This is effectively == but without
|
12378
|
+
# comparing the value of locations. Locations are checked only for presence.
|
12379
|
+
def ===(other)
|
12380
|
+
other.is_a?(KeywordHashNode) &&
|
12381
|
+
(flags === other.flags) &&
|
12382
|
+
(elements.length == other.elements.length) &&
|
12383
|
+
elements.zip(other.elements).all? { |left, right| left === right }
|
12384
|
+
end
|
11448
12385
|
end
|
11449
12386
|
|
11450
12387
|
# Represents a keyword rest parameter to a method, block, or lambda definition.
|
@@ -11497,9 +12434,9 @@ module Prism
|
|
11497
12434
|
{ flags: flags, name: name, name_loc: name_loc, operator_loc: operator_loc, location: location }
|
11498
12435
|
end
|
11499
12436
|
|
11500
|
-
#
|
12437
|
+
# protected attr_reader flags: Integer
|
11501
12438
|
attr_reader :flags
|
11502
|
-
|
12439
|
+
protected :flags
|
11503
12440
|
|
11504
12441
|
# attr_reader name: Symbol?
|
11505
12442
|
attr_reader :name
|
@@ -11524,7 +12461,6 @@ module Prism
|
|
11524
12461
|
@operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
11525
12462
|
end
|
11526
12463
|
|
11527
|
-
|
11528
12464
|
# def repeated_parameter?: () -> bool
|
11529
12465
|
def repeated_parameter?
|
11530
12466
|
flags.anybits?(ParameterFlags::REPEATED_PARAMETER)
|
@@ -11577,6 +12513,16 @@ module Prism
|
|
11577
12513
|
def self.type
|
11578
12514
|
:keyword_rest_parameter_node
|
11579
12515
|
end
|
12516
|
+
|
12517
|
+
# Implements case-equality for the node. This is effectively == but without
|
12518
|
+
# comparing the value of locations. Locations are checked only for presence.
|
12519
|
+
def ===(other)
|
12520
|
+
other.is_a?(KeywordRestParameterNode) &&
|
12521
|
+
(flags === other.flags) &&
|
12522
|
+
(name === other.name) &&
|
12523
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
12524
|
+
(operator_loc.nil? == other.operator_loc.nil?)
|
12525
|
+
end
|
11580
12526
|
end
|
11581
12527
|
|
11582
12528
|
# Represents using a lambda literal (not the lambda method call).
|
@@ -11663,7 +12609,6 @@ module Prism
|
|
11663
12609
|
# attr_reader body: Prism::node?
|
11664
12610
|
attr_reader :body
|
11665
12611
|
|
11666
|
-
|
11667
12612
|
# def operator: () -> String
|
11668
12613
|
def operator
|
11669
12614
|
operator_loc.slice
|
@@ -11728,6 +12673,19 @@ module Prism
|
|
11728
12673
|
def self.type
|
11729
12674
|
:lambda_node
|
11730
12675
|
end
|
12676
|
+
|
12677
|
+
# Implements case-equality for the node. This is effectively == but without
|
12678
|
+
# comparing the value of locations. Locations are checked only for presence.
|
12679
|
+
def ===(other)
|
12680
|
+
other.is_a?(LambdaNode) &&
|
12681
|
+
(locals.length == other.locals.length) &&
|
12682
|
+
locals.zip(other.locals).all? { |left, right| left === right } &&
|
12683
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
12684
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
12685
|
+
(closing_loc.nil? == other.closing_loc.nil?) &&
|
12686
|
+
(parameters === other.parameters) &&
|
12687
|
+
(body === other.body)
|
12688
|
+
end
|
11731
12689
|
end
|
11732
12690
|
|
11733
12691
|
# Represents the use of the `&&=` operator for assignment to a local variable.
|
@@ -11803,7 +12761,6 @@ module Prism
|
|
11803
12761
|
# attr_reader depth: Integer
|
11804
12762
|
attr_reader :depth
|
11805
12763
|
|
11806
|
-
|
11807
12764
|
# def operator: () -> String
|
11808
12765
|
def operator
|
11809
12766
|
operator_loc.slice
|
@@ -11848,6 +12805,17 @@ module Prism
|
|
11848
12805
|
def self.type
|
11849
12806
|
:local_variable_and_write_node
|
11850
12807
|
end
|
12808
|
+
|
12809
|
+
# Implements case-equality for the node. This is effectively == but without
|
12810
|
+
# comparing the value of locations. Locations are checked only for presence.
|
12811
|
+
def ===(other)
|
12812
|
+
other.is_a?(LocalVariableAndWriteNode) &&
|
12813
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
12814
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
12815
|
+
(value === other.value) &&
|
12816
|
+
(name === other.name) &&
|
12817
|
+
(depth === other.depth)
|
12818
|
+
end
|
11851
12819
|
end
|
11852
12820
|
|
11853
12821
|
# Represents assigning to a local variable using an operator that isn't `=`.
|
@@ -11927,7 +12895,6 @@ module Prism
|
|
11927
12895
|
# attr_reader depth: Integer
|
11928
12896
|
attr_reader :depth
|
11929
12897
|
|
11930
|
-
|
11931
12898
|
# def inspect(NodeInspector inspector) -> String
|
11932
12899
|
def inspect(inspector = NodeInspector.new)
|
11933
12900
|
inspector << inspector.header(self)
|
@@ -11968,6 +12935,18 @@ module Prism
|
|
11968
12935
|
def self.type
|
11969
12936
|
:local_variable_operator_write_node
|
11970
12937
|
end
|
12938
|
+
|
12939
|
+
# Implements case-equality for the node. This is effectively == but without
|
12940
|
+
# comparing the value of locations. Locations are checked only for presence.
|
12941
|
+
def ===(other)
|
12942
|
+
other.is_a?(LocalVariableOperatorWriteNode) &&
|
12943
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
12944
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
12945
|
+
(value === other.value) &&
|
12946
|
+
(name === other.name) &&
|
12947
|
+
(operator === other.operator) &&
|
12948
|
+
(depth === other.depth)
|
12949
|
+
end
|
11971
12950
|
end
|
11972
12951
|
|
11973
12952
|
# Represents the use of the `||=` operator for assignment to a local variable.
|
@@ -12043,7 +13022,6 @@ module Prism
|
|
12043
13022
|
# attr_reader depth: Integer
|
12044
13023
|
attr_reader :depth
|
12045
13024
|
|
12046
|
-
|
12047
13025
|
# def operator: () -> String
|
12048
13026
|
def operator
|
12049
13027
|
operator_loc.slice
|
@@ -12088,6 +13066,17 @@ module Prism
|
|
12088
13066
|
def self.type
|
12089
13067
|
:local_variable_or_write_node
|
12090
13068
|
end
|
13069
|
+
|
13070
|
+
# Implements case-equality for the node. This is effectively == but without
|
13071
|
+
# comparing the value of locations. Locations are checked only for presence.
|
13072
|
+
def ===(other)
|
13073
|
+
other.is_a?(LocalVariableOrWriteNode) &&
|
13074
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
13075
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
13076
|
+
(value === other.value) &&
|
13077
|
+
(name === other.name) &&
|
13078
|
+
(depth === other.depth)
|
13079
|
+
end
|
12091
13080
|
end
|
12092
13081
|
|
12093
13082
|
# Represents reading a local variable. Note that this requires that a local variable of the same name has already been written to in the same scope, otherwise it is parsed as a method call.
|
@@ -12161,7 +13150,6 @@ module Prism
|
|
12161
13150
|
# 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).
|
12162
13151
|
attr_reader :depth
|
12163
13152
|
|
12164
|
-
|
12165
13153
|
# def inspect(NodeInspector inspector) -> String
|
12166
13154
|
def inspect(inspector = NodeInspector.new)
|
12167
13155
|
inspector << inspector.header(self)
|
@@ -12197,6 +13185,14 @@ module Prism
|
|
12197
13185
|
def self.type
|
12198
13186
|
:local_variable_read_node
|
12199
13187
|
end
|
13188
|
+
|
13189
|
+
# Implements case-equality for the node. This is effectively == but without
|
13190
|
+
# comparing the value of locations. Locations are checked only for presence.
|
13191
|
+
def ===(other)
|
13192
|
+
other.is_a?(LocalVariableReadNode) &&
|
13193
|
+
(name === other.name) &&
|
13194
|
+
(depth === other.depth)
|
13195
|
+
end
|
12200
13196
|
end
|
12201
13197
|
|
12202
13198
|
# Represents writing to a local variable in a context that doesn't have an explicit value.
|
@@ -12252,7 +13248,6 @@ module Prism
|
|
12252
13248
|
# attr_reader depth: Integer
|
12253
13249
|
attr_reader :depth
|
12254
13250
|
|
12255
|
-
|
12256
13251
|
# def inspect(NodeInspector inspector) -> String
|
12257
13252
|
def inspect(inspector = NodeInspector.new)
|
12258
13253
|
inspector << inspector.header(self)
|
@@ -12288,6 +13283,14 @@ module Prism
|
|
12288
13283
|
def self.type
|
12289
13284
|
:local_variable_target_node
|
12290
13285
|
end
|
13286
|
+
|
13287
|
+
# Implements case-equality for the node. This is effectively == but without
|
13288
|
+
# comparing the value of locations. Locations are checked only for presence.
|
13289
|
+
def ===(other)
|
13290
|
+
other.is_a?(LocalVariableTargetNode) &&
|
13291
|
+
(name === other.name) &&
|
13292
|
+
(depth === other.depth)
|
13293
|
+
end
|
12291
13294
|
end
|
12292
13295
|
|
12293
13296
|
# Represents writing to a local variable.
|
@@ -12340,30 +13343,55 @@ module Prism
|
|
12340
13343
|
{ name: name, depth: depth, name_loc: name_loc, value: value, operator_loc: operator_loc, location: location }
|
12341
13344
|
end
|
12342
13345
|
|
12343
|
-
#
|
13346
|
+
# The name of the local variable, which is an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
|
13347
|
+
#
|
13348
|
+
# foo = :bar # name `:foo`
|
13349
|
+
#
|
13350
|
+
# abc = 123 # name `:abc`
|
12344
13351
|
attr_reader :name
|
12345
13352
|
|
12346
|
-
#
|
13353
|
+
# The number of semantic scopes we have to traverse to find the declaration of this variable.
|
13354
|
+
#
|
13355
|
+
# foo = 1 # depth 0
|
13356
|
+
#
|
13357
|
+
# tap { foo = 1 } # depth 1
|
13358
|
+
#
|
13359
|
+
# 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).
|
12347
13360
|
attr_reader :depth
|
12348
13361
|
|
12349
|
-
#
|
13362
|
+
# The location of the variable name.
|
13363
|
+
#
|
13364
|
+
# foo = :bar
|
13365
|
+
# ^^^
|
12350
13366
|
def name_loc
|
12351
13367
|
location = @name_loc
|
12352
13368
|
return location if location.is_a?(Location)
|
12353
13369
|
@name_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
12354
13370
|
end
|
12355
13371
|
|
12356
|
-
#
|
13372
|
+
# The value to write to the local variable. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
|
13373
|
+
#
|
13374
|
+
# foo = :bar
|
13375
|
+
# ^^^^
|
13376
|
+
#
|
13377
|
+
# abc = 1234
|
13378
|
+
# ^^^^
|
13379
|
+
#
|
13380
|
+
# Note that since the name of a local variable is known before the value is parsed, it is valid for a local variable to appear within the value of its own write.
|
13381
|
+
#
|
13382
|
+
# foo = foo
|
12357
13383
|
attr_reader :value
|
12358
13384
|
|
12359
|
-
#
|
13385
|
+
# The location of the `=` operator.
|
13386
|
+
#
|
13387
|
+
# x = :y
|
13388
|
+
# ^
|
12360
13389
|
def operator_loc
|
12361
13390
|
location = @operator_loc
|
12362
13391
|
return location if location.is_a?(Location)
|
12363
13392
|
@operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
12364
13393
|
end
|
12365
13394
|
|
12366
|
-
|
12367
13395
|
# def operator: () -> String
|
12368
13396
|
def operator
|
12369
13397
|
operator_loc.slice
|
@@ -12408,6 +13436,17 @@ module Prism
|
|
12408
13436
|
def self.type
|
12409
13437
|
:local_variable_write_node
|
12410
13438
|
end
|
13439
|
+
|
13440
|
+
# Implements case-equality for the node. This is effectively == but without
|
13441
|
+
# comparing the value of locations. Locations are checked only for presence.
|
13442
|
+
def ===(other)
|
13443
|
+
other.is_a?(LocalVariableWriteNode) &&
|
13444
|
+
(name === other.name) &&
|
13445
|
+
(depth === other.depth) &&
|
13446
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
13447
|
+
(value === other.value) &&
|
13448
|
+
(operator_loc.nil? == other.operator_loc.nil?)
|
13449
|
+
end
|
12411
13450
|
end
|
12412
13451
|
|
12413
13452
|
# Represents a regular expression literal used in the predicate of a conditional to implicitly match against the last line read by an IO object.
|
@@ -12460,9 +13499,9 @@ module Prism
|
|
12460
13499
|
{ flags: flags, opening_loc: opening_loc, content_loc: content_loc, closing_loc: closing_loc, unescaped: unescaped, location: location }
|
12461
13500
|
end
|
12462
13501
|
|
12463
|
-
#
|
13502
|
+
# protected attr_reader flags: Integer
|
12464
13503
|
attr_reader :flags
|
12465
|
-
|
13504
|
+
protected :flags
|
12466
13505
|
|
12467
13506
|
# attr_reader opening_loc: Location
|
12468
13507
|
def opening_loc
|
@@ -12488,7 +13527,6 @@ module Prism
|
|
12488
13527
|
# attr_reader unescaped: String
|
12489
13528
|
attr_reader :unescaped
|
12490
13529
|
|
12491
|
-
|
12492
13530
|
# def ignore_case?: () -> bool
|
12493
13531
|
def ignore_case?
|
12494
13532
|
flags.anybits?(RegularExpressionFlags::IGNORE_CASE)
|
@@ -12598,6 +13636,17 @@ module Prism
|
|
12598
13636
|
def self.type
|
12599
13637
|
:match_last_line_node
|
12600
13638
|
end
|
13639
|
+
|
13640
|
+
# Implements case-equality for the node. This is effectively == but without
|
13641
|
+
# comparing the value of locations. Locations are checked only for presence.
|
13642
|
+
def ===(other)
|
13643
|
+
other.is_a?(MatchLastLineNode) &&
|
13644
|
+
(flags === other.flags) &&
|
13645
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
13646
|
+
(content_loc.nil? == other.content_loc.nil?) &&
|
13647
|
+
(closing_loc.nil? == other.closing_loc.nil?) &&
|
13648
|
+
(unescaped === other.unescaped)
|
13649
|
+
end
|
12601
13650
|
end
|
12602
13651
|
|
12603
13652
|
# Represents the use of the modifier `in` operator.
|
@@ -12661,7 +13710,6 @@ module Prism
|
|
12661
13710
|
@operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
12662
13711
|
end
|
12663
13712
|
|
12664
|
-
|
12665
13713
|
# def operator: () -> String
|
12666
13714
|
def operator
|
12667
13715
|
operator_loc.slice
|
@@ -12705,6 +13753,15 @@ module Prism
|
|
12705
13753
|
def self.type
|
12706
13754
|
:match_predicate_node
|
12707
13755
|
end
|
13756
|
+
|
13757
|
+
# Implements case-equality for the node. This is effectively == but without
|
13758
|
+
# comparing the value of locations. Locations are checked only for presence.
|
13759
|
+
def ===(other)
|
13760
|
+
other.is_a?(MatchPredicateNode) &&
|
13761
|
+
(value === other.value) &&
|
13762
|
+
(pattern === other.pattern) &&
|
13763
|
+
(operator_loc.nil? == other.operator_loc.nil?)
|
13764
|
+
end
|
12708
13765
|
end
|
12709
13766
|
|
12710
13767
|
# Represents the use of the `=>` operator.
|
@@ -12768,7 +13825,6 @@ module Prism
|
|
12768
13825
|
@operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
12769
13826
|
end
|
12770
13827
|
|
12771
|
-
|
12772
13828
|
# def operator: () -> String
|
12773
13829
|
def operator
|
12774
13830
|
operator_loc.slice
|
@@ -12812,6 +13868,15 @@ module Prism
|
|
12812
13868
|
def self.type
|
12813
13869
|
:match_required_node
|
12814
13870
|
end
|
13871
|
+
|
13872
|
+
# Implements case-equality for the node. This is effectively == but without
|
13873
|
+
# comparing the value of locations. Locations are checked only for presence.
|
13874
|
+
def ===(other)
|
13875
|
+
other.is_a?(MatchRequiredNode) &&
|
13876
|
+
(value === other.value) &&
|
13877
|
+
(pattern === other.pattern) &&
|
13878
|
+
(operator_loc.nil? == other.operator_loc.nil?)
|
13879
|
+
end
|
12815
13880
|
end
|
12816
13881
|
|
12817
13882
|
# Represents writing local variables using a regular expression match with named capture groups.
|
@@ -12867,7 +13932,6 @@ module Prism
|
|
12867
13932
|
# attr_reader targets: Array[LocalVariableTargetNode]
|
12868
13933
|
attr_reader :targets
|
12869
13934
|
|
12870
|
-
|
12871
13935
|
# def inspect(NodeInspector inspector) -> String
|
12872
13936
|
def inspect(inspector = NodeInspector.new)
|
12873
13937
|
inspector << inspector.header(self)
|
@@ -12904,6 +13968,15 @@ module Prism
|
|
12904
13968
|
def self.type
|
12905
13969
|
:match_write_node
|
12906
13970
|
end
|
13971
|
+
|
13972
|
+
# Implements case-equality for the node. This is effectively == but without
|
13973
|
+
# comparing the value of locations. Locations are checked only for presence.
|
13974
|
+
def ===(other)
|
13975
|
+
other.is_a?(MatchWriteNode) &&
|
13976
|
+
(call === other.call) &&
|
13977
|
+
(targets.length == other.targets.length) &&
|
13978
|
+
targets.zip(other.targets).all? { |left, right| left === right }
|
13979
|
+
end
|
12907
13980
|
end
|
12908
13981
|
|
12909
13982
|
# Represents a node that is missing from the source and results in a syntax error.
|
@@ -12948,7 +14021,6 @@ module Prism
|
|
12948
14021
|
{ location: location }
|
12949
14022
|
end
|
12950
14023
|
|
12951
|
-
|
12952
14024
|
# def inspect(NodeInspector inspector) -> String
|
12953
14025
|
def inspect(inspector = NodeInspector.new)
|
12954
14026
|
inspector << inspector.header(self)
|
@@ -12982,6 +14054,12 @@ module Prism
|
|
12982
14054
|
def self.type
|
12983
14055
|
:missing_node
|
12984
14056
|
end
|
14057
|
+
|
14058
|
+
# Implements case-equality for the node. This is effectively == but without
|
14059
|
+
# comparing the value of locations. Locations are checked only for presence.
|
14060
|
+
def ===(other)
|
14061
|
+
other.is_a?(MissingNode)
|
14062
|
+
end
|
12985
14063
|
end
|
12986
14064
|
|
12987
14065
|
# Represents a module declaration involving the `module` keyword.
|
@@ -13064,7 +14142,6 @@ module Prism
|
|
13064
14142
|
# attr_reader name: Symbol
|
13065
14143
|
attr_reader :name
|
13066
14144
|
|
13067
|
-
|
13068
14145
|
# def module_keyword: () -> String
|
13069
14146
|
def module_keyword
|
13070
14147
|
module_keyword_loc.slice
|
@@ -13120,6 +14197,19 @@ module Prism
|
|
13120
14197
|
def self.type
|
13121
14198
|
:module_node
|
13122
14199
|
end
|
14200
|
+
|
14201
|
+
# Implements case-equality for the node. This is effectively == but without
|
14202
|
+
# comparing the value of locations. Locations are checked only for presence.
|
14203
|
+
def ===(other)
|
14204
|
+
other.is_a?(ModuleNode) &&
|
14205
|
+
(locals.length == other.locals.length) &&
|
14206
|
+
locals.zip(other.locals).all? { |left, right| left === right } &&
|
14207
|
+
(module_keyword_loc.nil? == other.module_keyword_loc.nil?) &&
|
14208
|
+
(constant_path === other.constant_path) &&
|
14209
|
+
(body === other.body) &&
|
14210
|
+
(end_keyword_loc.nil? == other.end_keyword_loc.nil?) &&
|
14211
|
+
(name === other.name)
|
14212
|
+
end
|
13123
14213
|
end
|
13124
14214
|
|
13125
14215
|
# Represents a multi-target expression.
|
@@ -13211,7 +14301,6 @@ module Prism
|
|
13211
14301
|
end
|
13212
14302
|
end
|
13213
14303
|
|
13214
|
-
|
13215
14304
|
# def lparen: () -> String?
|
13216
14305
|
def lparen
|
13217
14306
|
lparen_loc&.slice
|
@@ -13265,6 +14354,19 @@ module Prism
|
|
13265
14354
|
def self.type
|
13266
14355
|
:multi_target_node
|
13267
14356
|
end
|
14357
|
+
|
14358
|
+
# Implements case-equality for the node. This is effectively == but without
|
14359
|
+
# comparing the value of locations. Locations are checked only for presence.
|
14360
|
+
def ===(other)
|
14361
|
+
other.is_a?(MultiTargetNode) &&
|
14362
|
+
(lefts.length == other.lefts.length) &&
|
14363
|
+
lefts.zip(other.lefts).all? { |left, right| left === right } &&
|
14364
|
+
(rest === other.rest) &&
|
14365
|
+
(rights.length == other.rights.length) &&
|
14366
|
+
rights.zip(other.rights).all? { |left, right| left === right } &&
|
14367
|
+
(lparen_loc.nil? == other.lparen_loc.nil?) &&
|
14368
|
+
(rparen_loc.nil? == other.rparen_loc.nil?)
|
14369
|
+
end
|
13268
14370
|
end
|
13269
14371
|
|
13270
14372
|
# Represents a write to a multi-target expression.
|
@@ -13369,7 +14471,6 @@ module Prism
|
|
13369
14471
|
# attr_reader value: Prism::node
|
13370
14472
|
attr_reader :value
|
13371
14473
|
|
13372
|
-
|
13373
14474
|
# def lparen: () -> String?
|
13374
14475
|
def lparen
|
13375
14476
|
lparen_loc&.slice
|
@@ -13431,6 +14532,21 @@ module Prism
|
|
13431
14532
|
def self.type
|
13432
14533
|
:multi_write_node
|
13433
14534
|
end
|
14535
|
+
|
14536
|
+
# Implements case-equality for the node. This is effectively == but without
|
14537
|
+
# comparing the value of locations. Locations are checked only for presence.
|
14538
|
+
def ===(other)
|
14539
|
+
other.is_a?(MultiWriteNode) &&
|
14540
|
+
(lefts.length == other.lefts.length) &&
|
14541
|
+
lefts.zip(other.lefts).all? { |left, right| left === right } &&
|
14542
|
+
(rest === other.rest) &&
|
14543
|
+
(rights.length == other.rights.length) &&
|
14544
|
+
rights.zip(other.rights).all? { |left, right| left === right } &&
|
14545
|
+
(lparen_loc.nil? == other.lparen_loc.nil?) &&
|
14546
|
+
(rparen_loc.nil? == other.rparen_loc.nil?) &&
|
14547
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
14548
|
+
(value === other.value)
|
14549
|
+
end
|
13434
14550
|
end
|
13435
14551
|
|
13436
14552
|
# Represents the use of the `next` keyword.
|
@@ -13492,7 +14608,6 @@ module Prism
|
|
13492
14608
|
@keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
13493
14609
|
end
|
13494
14610
|
|
13495
|
-
|
13496
14611
|
# def keyword: () -> String
|
13497
14612
|
def keyword
|
13498
14613
|
keyword_loc.slice
|
@@ -13538,6 +14653,14 @@ module Prism
|
|
13538
14653
|
def self.type
|
13539
14654
|
:next_node
|
13540
14655
|
end
|
14656
|
+
|
14657
|
+
# Implements case-equality for the node. This is effectively == but without
|
14658
|
+
# comparing the value of locations. Locations are checked only for presence.
|
14659
|
+
def ===(other)
|
14660
|
+
other.is_a?(NextNode) &&
|
14661
|
+
(arguments === other.arguments) &&
|
14662
|
+
(keyword_loc.nil? == other.keyword_loc.nil?)
|
14663
|
+
end
|
13541
14664
|
end
|
13542
14665
|
|
13543
14666
|
# Represents the use of the `nil` keyword.
|
@@ -13585,7 +14708,6 @@ module Prism
|
|
13585
14708
|
{ location: location }
|
13586
14709
|
end
|
13587
14710
|
|
13588
|
-
|
13589
14711
|
# def inspect(NodeInspector inspector) -> String
|
13590
14712
|
def inspect(inspector = NodeInspector.new)
|
13591
14713
|
inspector << inspector.header(self)
|
@@ -13619,6 +14741,12 @@ module Prism
|
|
13619
14741
|
def self.type
|
13620
14742
|
:nil_node
|
13621
14743
|
end
|
14744
|
+
|
14745
|
+
# Implements case-equality for the node. This is effectively == but without
|
14746
|
+
# comparing the value of locations. Locations are checked only for presence.
|
14747
|
+
def ===(other)
|
14748
|
+
other.is_a?(NilNode)
|
14749
|
+
end
|
13622
14750
|
end
|
13623
14751
|
|
13624
14752
|
# Represents the use of `**nil` inside method arguments.
|
@@ -13683,7 +14811,6 @@ module Prism
|
|
13683
14811
|
@keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
13684
14812
|
end
|
13685
14813
|
|
13686
|
-
|
13687
14814
|
# def operator: () -> String
|
13688
14815
|
def operator
|
13689
14816
|
operator_loc.slice
|
@@ -13729,6 +14856,14 @@ module Prism
|
|
13729
14856
|
def self.type
|
13730
14857
|
:no_keywords_parameter_node
|
13731
14858
|
end
|
14859
|
+
|
14860
|
+
# Implements case-equality for the node. This is effectively == but without
|
14861
|
+
# comparing the value of locations. Locations are checked only for presence.
|
14862
|
+
def ===(other)
|
14863
|
+
other.is_a?(NoKeywordsParameterNode) &&
|
14864
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
14865
|
+
(keyword_loc.nil? == other.keyword_loc.nil?)
|
14866
|
+
end
|
13732
14867
|
end
|
13733
14868
|
|
13734
14869
|
# Represents an implicit set of parameters through the use of numbered parameters within a block or lambda.
|
@@ -13780,7 +14915,6 @@ module Prism
|
|
13780
14915
|
# attr_reader maximum: Integer
|
13781
14916
|
attr_reader :maximum
|
13782
14917
|
|
13783
|
-
|
13784
14918
|
# def inspect(NodeInspector inspector) -> String
|
13785
14919
|
def inspect(inspector = NodeInspector.new)
|
13786
14920
|
inspector << inspector.header(self)
|
@@ -13815,6 +14949,13 @@ module Prism
|
|
13815
14949
|
def self.type
|
13816
14950
|
:numbered_parameters_node
|
13817
14951
|
end
|
14952
|
+
|
14953
|
+
# Implements case-equality for the node. This is effectively == but without
|
14954
|
+
# comparing the value of locations. Locations are checked only for presence.
|
14955
|
+
def ===(other)
|
14956
|
+
other.is_a?(NumberedParametersNode) &&
|
14957
|
+
(maximum === other.maximum)
|
14958
|
+
end
|
13818
14959
|
end
|
13819
14960
|
|
13820
14961
|
# Represents reading a numbered reference to a capture in the previous match.
|
@@ -13872,7 +15013,6 @@ module Prism
|
|
13872
15013
|
# $4294967296 # number `0`
|
13873
15014
|
attr_reader :number
|
13874
15015
|
|
13875
|
-
|
13876
15016
|
# def inspect(NodeInspector inspector) -> String
|
13877
15017
|
def inspect(inspector = NodeInspector.new)
|
13878
15018
|
inspector << inspector.header(self)
|
@@ -13907,6 +15047,13 @@ module Prism
|
|
13907
15047
|
def self.type
|
13908
15048
|
:numbered_reference_read_node
|
13909
15049
|
end
|
15050
|
+
|
15051
|
+
# Implements case-equality for the node. This is effectively == but without
|
15052
|
+
# comparing the value of locations. Locations are checked only for presence.
|
15053
|
+
def ===(other)
|
15054
|
+
other.is_a?(NumberedReferenceReadNode) &&
|
15055
|
+
(number === other.number)
|
15056
|
+
end
|
13910
15057
|
end
|
13911
15058
|
|
13912
15059
|
# Represents an optional keyword parameter to a method, block, or lambda definition.
|
@@ -13959,9 +15106,9 @@ module Prism
|
|
13959
15106
|
{ flags: flags, name: name, name_loc: name_loc, value: value, location: location }
|
13960
15107
|
end
|
13961
15108
|
|
13962
|
-
#
|
15109
|
+
# protected attr_reader flags: Integer
|
13963
15110
|
attr_reader :flags
|
13964
|
-
|
15111
|
+
protected :flags
|
13965
15112
|
|
13966
15113
|
# attr_reader name: Symbol
|
13967
15114
|
attr_reader :name
|
@@ -13976,7 +15123,6 @@ module Prism
|
|
13976
15123
|
# attr_reader value: Prism::node
|
13977
15124
|
attr_reader :value
|
13978
15125
|
|
13979
|
-
|
13980
15126
|
# def repeated_parameter?: () -> bool
|
13981
15127
|
def repeated_parameter?
|
13982
15128
|
flags.anybits?(ParameterFlags::REPEATED_PARAMETER)
|
@@ -14021,6 +15167,16 @@ module Prism
|
|
14021
15167
|
def self.type
|
14022
15168
|
:optional_keyword_parameter_node
|
14023
15169
|
end
|
15170
|
+
|
15171
|
+
# Implements case-equality for the node. This is effectively == but without
|
15172
|
+
# comparing the value of locations. Locations are checked only for presence.
|
15173
|
+
def ===(other)
|
15174
|
+
other.is_a?(OptionalKeywordParameterNode) &&
|
15175
|
+
(flags === other.flags) &&
|
15176
|
+
(name === other.name) &&
|
15177
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
15178
|
+
(value === other.value)
|
15179
|
+
end
|
14024
15180
|
end
|
14025
15181
|
|
14026
15182
|
# Represents an optional parameter to a method, block, or lambda definition.
|
@@ -14074,9 +15230,9 @@ module Prism
|
|
14074
15230
|
{ flags: flags, name: name, name_loc: name_loc, operator_loc: operator_loc, value: value, location: location }
|
14075
15231
|
end
|
14076
15232
|
|
14077
|
-
#
|
15233
|
+
# protected attr_reader flags: Integer
|
14078
15234
|
attr_reader :flags
|
14079
|
-
|
15235
|
+
protected :flags
|
14080
15236
|
|
14081
15237
|
# attr_reader name: Symbol
|
14082
15238
|
attr_reader :name
|
@@ -14098,7 +15254,6 @@ module Prism
|
|
14098
15254
|
# attr_reader value: Prism::node
|
14099
15255
|
attr_reader :value
|
14100
15256
|
|
14101
|
-
|
14102
15257
|
# def repeated_parameter?: () -> bool
|
14103
15258
|
def repeated_parameter?
|
14104
15259
|
flags.anybits?(ParameterFlags::REPEATED_PARAMETER)
|
@@ -14149,6 +15304,17 @@ module Prism
|
|
14149
15304
|
def self.type
|
14150
15305
|
:optional_parameter_node
|
14151
15306
|
end
|
15307
|
+
|
15308
|
+
# Implements case-equality for the node. This is effectively == but without
|
15309
|
+
# comparing the value of locations. Locations are checked only for presence.
|
15310
|
+
def ===(other)
|
15311
|
+
other.is_a?(OptionalParameterNode) &&
|
15312
|
+
(flags === other.flags) &&
|
15313
|
+
(name === other.name) &&
|
15314
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
15315
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
15316
|
+
(value === other.value)
|
15317
|
+
end
|
14152
15318
|
end
|
14153
15319
|
|
14154
15320
|
# Represents the use of the `||` operator or the `or` keyword.
|
@@ -14227,7 +15393,6 @@ module Prism
|
|
14227
15393
|
@operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
14228
15394
|
end
|
14229
15395
|
|
14230
|
-
|
14231
15396
|
# def operator: () -> String
|
14232
15397
|
def operator
|
14233
15398
|
operator_loc.slice
|
@@ -14271,6 +15436,15 @@ module Prism
|
|
14271
15436
|
def self.type
|
14272
15437
|
:or_node
|
14273
15438
|
end
|
15439
|
+
|
15440
|
+
# Implements case-equality for the node. This is effectively == but without
|
15441
|
+
# comparing the value of locations. Locations are checked only for presence.
|
15442
|
+
def ===(other)
|
15443
|
+
other.is_a?(OrNode) &&
|
15444
|
+
(left === other.left) &&
|
15445
|
+
(right === other.right) &&
|
15446
|
+
(operator_loc.nil? == other.operator_loc.nil?)
|
15447
|
+
end
|
14274
15448
|
end
|
14275
15449
|
|
14276
15450
|
# Represents the list of parameters on a method, block, or lambda definition.
|
@@ -14355,7 +15529,6 @@ module Prism
|
|
14355
15529
|
# attr_reader block: BlockParameterNode?
|
14356
15530
|
attr_reader :block
|
14357
15531
|
|
14358
|
-
|
14359
15532
|
# def inspect(NodeInspector inspector) -> String
|
14360
15533
|
def inspect(inspector = NodeInspector.new)
|
14361
15534
|
inspector << inspector.header(self)
|
@@ -14411,6 +15584,23 @@ module Prism
|
|
14411
15584
|
def self.type
|
14412
15585
|
:parameters_node
|
14413
15586
|
end
|
15587
|
+
|
15588
|
+
# Implements case-equality for the node. This is effectively == but without
|
15589
|
+
# comparing the value of locations. Locations are checked only for presence.
|
15590
|
+
def ===(other)
|
15591
|
+
other.is_a?(ParametersNode) &&
|
15592
|
+
(requireds.length == other.requireds.length) &&
|
15593
|
+
requireds.zip(other.requireds).all? { |left, right| left === right } &&
|
15594
|
+
(optionals.length == other.optionals.length) &&
|
15595
|
+
optionals.zip(other.optionals).all? { |left, right| left === right } &&
|
15596
|
+
(rest === other.rest) &&
|
15597
|
+
(posts.length == other.posts.length) &&
|
15598
|
+
posts.zip(other.posts).all? { |left, right| left === right } &&
|
15599
|
+
(keywords.length == other.keywords.length) &&
|
15600
|
+
keywords.zip(other.keywords).all? { |left, right| left === right } &&
|
15601
|
+
(keyword_rest === other.keyword_rest) &&
|
15602
|
+
(block === other.block)
|
15603
|
+
end
|
14414
15604
|
end
|
14415
15605
|
|
14416
15606
|
# Represents a parenthesized expression
|
@@ -14484,7 +15674,6 @@ module Prism
|
|
14484
15674
|
@closing_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
14485
15675
|
end
|
14486
15676
|
|
14487
|
-
|
14488
15677
|
# def opening: () -> String
|
14489
15678
|
def opening
|
14490
15679
|
opening_loc.slice
|
@@ -14536,6 +15725,15 @@ module Prism
|
|
14536
15725
|
def self.type
|
14537
15726
|
:parentheses_node
|
14538
15727
|
end
|
15728
|
+
|
15729
|
+
# Implements case-equality for the node. This is effectively == but without
|
15730
|
+
# comparing the value of locations. Locations are checked only for presence.
|
15731
|
+
def ===(other)
|
15732
|
+
other.is_a?(ParenthesesNode) &&
|
15733
|
+
(body === other.body) &&
|
15734
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
15735
|
+
(closing_loc.nil? == other.closing_loc.nil?)
|
15736
|
+
end
|
14539
15737
|
end
|
14540
15738
|
|
14541
15739
|
# Represents the use of the `^` operator for pinning an expression in a pattern matching expression.
|
@@ -14611,7 +15809,6 @@ module Prism
|
|
14611
15809
|
@rparen_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
14612
15810
|
end
|
14613
15811
|
|
14614
|
-
|
14615
15812
|
# def operator: () -> String
|
14616
15813
|
def operator
|
14617
15814
|
operator_loc.slice
|
@@ -14665,6 +15862,16 @@ module Prism
|
|
14665
15862
|
def self.type
|
14666
15863
|
:pinned_expression_node
|
14667
15864
|
end
|
15865
|
+
|
15866
|
+
# Implements case-equality for the node. This is effectively == but without
|
15867
|
+
# comparing the value of locations. Locations are checked only for presence.
|
15868
|
+
def ===(other)
|
15869
|
+
other.is_a?(PinnedExpressionNode) &&
|
15870
|
+
(expression === other.expression) &&
|
15871
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
15872
|
+
(lparen_loc.nil? == other.lparen_loc.nil?) &&
|
15873
|
+
(rparen_loc.nil? == other.rparen_loc.nil?)
|
15874
|
+
end
|
14668
15875
|
end
|
14669
15876
|
|
14670
15877
|
# Represents the use of the `^` operator for pinning a variable in a pattern matching expression.
|
@@ -14724,7 +15931,6 @@ module Prism
|
|
14724
15931
|
@operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
14725
15932
|
end
|
14726
15933
|
|
14727
|
-
|
14728
15934
|
# def operator: () -> String
|
14729
15935
|
def operator
|
14730
15936
|
operator_loc.slice
|
@@ -14766,6 +15972,14 @@ module Prism
|
|
14766
15972
|
def self.type
|
14767
15973
|
:pinned_variable_node
|
14768
15974
|
end
|
15975
|
+
|
15976
|
+
# Implements case-equality for the node. This is effectively == but without
|
15977
|
+
# comparing the value of locations. Locations are checked only for presence.
|
15978
|
+
def ===(other)
|
15979
|
+
other.is_a?(PinnedVariableNode) &&
|
15980
|
+
(variable === other.variable) &&
|
15981
|
+
(operator_loc.nil? == other.operator_loc.nil?)
|
15982
|
+
end
|
14769
15983
|
end
|
14770
15984
|
|
14771
15985
|
# Represents the use of the `END` keyword.
|
@@ -14843,7 +16057,6 @@ module Prism
|
|
14843
16057
|
@closing_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
14844
16058
|
end
|
14845
16059
|
|
14846
|
-
|
14847
16060
|
# def keyword: () -> String
|
14848
16061
|
def keyword
|
14849
16062
|
keyword_loc.slice
|
@@ -14901,6 +16114,16 @@ module Prism
|
|
14901
16114
|
def self.type
|
14902
16115
|
:post_execution_node
|
14903
16116
|
end
|
16117
|
+
|
16118
|
+
# Implements case-equality for the node. This is effectively == but without
|
16119
|
+
# comparing the value of locations. Locations are checked only for presence.
|
16120
|
+
def ===(other)
|
16121
|
+
other.is_a?(PostExecutionNode) &&
|
16122
|
+
(statements === other.statements) &&
|
16123
|
+
(keyword_loc.nil? == other.keyword_loc.nil?) &&
|
16124
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
16125
|
+
(closing_loc.nil? == other.closing_loc.nil?)
|
16126
|
+
end
|
14904
16127
|
end
|
14905
16128
|
|
14906
16129
|
# Represents the use of the `BEGIN` keyword.
|
@@ -14978,7 +16201,6 @@ module Prism
|
|
14978
16201
|
@closing_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
14979
16202
|
end
|
14980
16203
|
|
14981
|
-
|
14982
16204
|
# def keyword: () -> String
|
14983
16205
|
def keyword
|
14984
16206
|
keyword_loc.slice
|
@@ -15036,6 +16258,16 @@ module Prism
|
|
15036
16258
|
def self.type
|
15037
16259
|
:pre_execution_node
|
15038
16260
|
end
|
16261
|
+
|
16262
|
+
# Implements case-equality for the node. This is effectively == but without
|
16263
|
+
# comparing the value of locations. Locations are checked only for presence.
|
16264
|
+
def ===(other)
|
16265
|
+
other.is_a?(PreExecutionNode) &&
|
16266
|
+
(statements === other.statements) &&
|
16267
|
+
(keyword_loc.nil? == other.keyword_loc.nil?) &&
|
16268
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
16269
|
+
(closing_loc.nil? == other.closing_loc.nil?)
|
16270
|
+
end
|
15039
16271
|
end
|
15040
16272
|
|
15041
16273
|
# The top level node of any parse tree.
|
@@ -15088,7 +16320,6 @@ module Prism
|
|
15088
16320
|
# attr_reader statements: StatementsNode
|
15089
16321
|
attr_reader :statements
|
15090
16322
|
|
15091
|
-
|
15092
16323
|
# def inspect(NodeInspector inspector) -> String
|
15093
16324
|
def inspect(inspector = NodeInspector.new)
|
15094
16325
|
inspector << inspector.header(self)
|
@@ -15125,6 +16356,15 @@ module Prism
|
|
15125
16356
|
def self.type
|
15126
16357
|
:program_node
|
15127
16358
|
end
|
16359
|
+
|
16360
|
+
# Implements case-equality for the node. This is effectively == but without
|
16361
|
+
# comparing the value of locations. Locations are checked only for presence.
|
16362
|
+
def ===(other)
|
16363
|
+
other.is_a?(ProgramNode) &&
|
16364
|
+
(locals.length == other.locals.length) &&
|
16365
|
+
locals.zip(other.locals).all? { |left, right| left === right } &&
|
16366
|
+
(statements === other.statements)
|
16367
|
+
end
|
15128
16368
|
end
|
15129
16369
|
|
15130
16370
|
# Represents the use of the `..` or `...` operators.
|
@@ -15182,9 +16422,9 @@ module Prism
|
|
15182
16422
|
{ flags: flags, left: left, right: right, operator_loc: operator_loc, location: location }
|
15183
16423
|
end
|
15184
16424
|
|
15185
|
-
#
|
16425
|
+
# protected attr_reader flags: Integer
|
15186
16426
|
attr_reader :flags
|
15187
|
-
|
16427
|
+
protected :flags
|
15188
16428
|
|
15189
16429
|
# The left-hand side of the range, if present. It can be either `nil` or any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
|
15190
16430
|
#
|
@@ -15212,7 +16452,6 @@ module Prism
|
|
15212
16452
|
@operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
15213
16453
|
end
|
15214
16454
|
|
15215
|
-
|
15216
16455
|
# def exclude_end?: () -> bool
|
15217
16456
|
def exclude_end?
|
15218
16457
|
flags.anybits?(RangeFlags::EXCLUDE_END)
|
@@ -15271,6 +16510,16 @@ module Prism
|
|
15271
16510
|
def self.type
|
15272
16511
|
:range_node
|
15273
16512
|
end
|
16513
|
+
|
16514
|
+
# Implements case-equality for the node. This is effectively == but without
|
16515
|
+
# comparing the value of locations. Locations are checked only for presence.
|
16516
|
+
def ===(other)
|
16517
|
+
other.is_a?(RangeNode) &&
|
16518
|
+
(flags === other.flags) &&
|
16519
|
+
(left === other.left) &&
|
16520
|
+
(right === other.right) &&
|
16521
|
+
(operator_loc.nil? == other.operator_loc.nil?)
|
16522
|
+
end
|
15274
16523
|
end
|
15275
16524
|
|
15276
16525
|
# Represents a rational number literal.
|
@@ -15322,7 +16571,6 @@ module Prism
|
|
15322
16571
|
# attr_reader numeric: Prism::node
|
15323
16572
|
attr_reader :numeric
|
15324
16573
|
|
15325
|
-
|
15326
16574
|
# def inspect(NodeInspector inspector) -> String
|
15327
16575
|
def inspect(inspector = NodeInspector.new)
|
15328
16576
|
inspector << inspector.header(self)
|
@@ -15358,6 +16606,13 @@ module Prism
|
|
15358
16606
|
def self.type
|
15359
16607
|
:rational_node
|
15360
16608
|
end
|
16609
|
+
|
16610
|
+
# Implements case-equality for the node. This is effectively == but without
|
16611
|
+
# comparing the value of locations. Locations are checked only for presence.
|
16612
|
+
def ===(other)
|
16613
|
+
other.is_a?(RationalNode) &&
|
16614
|
+
(numeric === other.numeric)
|
16615
|
+
end
|
15361
16616
|
end
|
15362
16617
|
|
15363
16618
|
# Represents the use of the `redo` keyword.
|
@@ -15405,7 +16660,6 @@ module Prism
|
|
15405
16660
|
{ location: location }
|
15406
16661
|
end
|
15407
16662
|
|
15408
|
-
|
15409
16663
|
# def inspect(NodeInspector inspector) -> String
|
15410
16664
|
def inspect(inspector = NodeInspector.new)
|
15411
16665
|
inspector << inspector.header(self)
|
@@ -15439,6 +16693,12 @@ module Prism
|
|
15439
16693
|
def self.type
|
15440
16694
|
:redo_node
|
15441
16695
|
end
|
16696
|
+
|
16697
|
+
# Implements case-equality for the node. This is effectively == but without
|
16698
|
+
# comparing the value of locations. Locations are checked only for presence.
|
16699
|
+
def ===(other)
|
16700
|
+
other.is_a?(RedoNode)
|
16701
|
+
end
|
15442
16702
|
end
|
15443
16703
|
|
15444
16704
|
# Represents a regular expression literal with no interpolation.
|
@@ -15491,9 +16751,9 @@ module Prism
|
|
15491
16751
|
{ flags: flags, opening_loc: opening_loc, content_loc: content_loc, closing_loc: closing_loc, unescaped: unescaped, location: location }
|
15492
16752
|
end
|
15493
16753
|
|
15494
|
-
#
|
16754
|
+
# protected attr_reader flags: Integer
|
15495
16755
|
attr_reader :flags
|
15496
|
-
|
16756
|
+
protected :flags
|
15497
16757
|
|
15498
16758
|
# attr_reader opening_loc: Location
|
15499
16759
|
def opening_loc
|
@@ -15519,7 +16779,6 @@ module Prism
|
|
15519
16779
|
# attr_reader unescaped: String
|
15520
16780
|
attr_reader :unescaped
|
15521
16781
|
|
15522
|
-
|
15523
16782
|
# def ignore_case?: () -> bool
|
15524
16783
|
def ignore_case?
|
15525
16784
|
flags.anybits?(RegularExpressionFlags::IGNORE_CASE)
|
@@ -15629,6 +16888,17 @@ module Prism
|
|
15629
16888
|
def self.type
|
15630
16889
|
:regular_expression_node
|
15631
16890
|
end
|
16891
|
+
|
16892
|
+
# Implements case-equality for the node. This is effectively == but without
|
16893
|
+
# comparing the value of locations. Locations are checked only for presence.
|
16894
|
+
def ===(other)
|
16895
|
+
other.is_a?(RegularExpressionNode) &&
|
16896
|
+
(flags === other.flags) &&
|
16897
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
16898
|
+
(content_loc.nil? == other.content_loc.nil?) &&
|
16899
|
+
(closing_loc.nil? == other.closing_loc.nil?) &&
|
16900
|
+
(unescaped === other.unescaped)
|
16901
|
+
end
|
15632
16902
|
end
|
15633
16903
|
|
15634
16904
|
# Represents a required keyword parameter to a method, block, or lambda definition.
|
@@ -15680,9 +16950,9 @@ module Prism
|
|
15680
16950
|
{ flags: flags, name: name, name_loc: name_loc, location: location }
|
15681
16951
|
end
|
15682
16952
|
|
15683
|
-
#
|
16953
|
+
# protected attr_reader flags: Integer
|
15684
16954
|
attr_reader :flags
|
15685
|
-
|
16955
|
+
protected :flags
|
15686
16956
|
|
15687
16957
|
# attr_reader name: Symbol
|
15688
16958
|
attr_reader :name
|
@@ -15694,7 +16964,6 @@ module Prism
|
|
15694
16964
|
@name_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
15695
16965
|
end
|
15696
16966
|
|
15697
|
-
|
15698
16967
|
# def repeated_parameter?: () -> bool
|
15699
16968
|
def repeated_parameter?
|
15700
16969
|
flags.anybits?(ParameterFlags::REPEATED_PARAMETER)
|
@@ -15737,6 +17006,15 @@ module Prism
|
|
15737
17006
|
def self.type
|
15738
17007
|
:required_keyword_parameter_node
|
15739
17008
|
end
|
17009
|
+
|
17010
|
+
# Implements case-equality for the node. This is effectively == but without
|
17011
|
+
# comparing the value of locations. Locations are checked only for presence.
|
17012
|
+
def ===(other)
|
17013
|
+
other.is_a?(RequiredKeywordParameterNode) &&
|
17014
|
+
(flags === other.flags) &&
|
17015
|
+
(name === other.name) &&
|
17016
|
+
(name_loc.nil? == other.name_loc.nil?)
|
17017
|
+
end
|
15740
17018
|
end
|
15741
17019
|
|
15742
17020
|
# Represents a required parameter to a method, block, or lambda definition.
|
@@ -15787,14 +17065,13 @@ module Prism
|
|
15787
17065
|
{ flags: flags, name: name, location: location }
|
15788
17066
|
end
|
15789
17067
|
|
15790
|
-
#
|
17068
|
+
# protected attr_reader flags: Integer
|
15791
17069
|
attr_reader :flags
|
15792
|
-
|
17070
|
+
protected :flags
|
15793
17071
|
|
15794
17072
|
# attr_reader name: Symbol
|
15795
17073
|
attr_reader :name
|
15796
17074
|
|
15797
|
-
|
15798
17075
|
# def repeated_parameter?: () -> bool
|
15799
17076
|
def repeated_parameter?
|
15800
17077
|
flags.anybits?(ParameterFlags::REPEATED_PARAMETER)
|
@@ -15836,6 +17113,14 @@ module Prism
|
|
15836
17113
|
def self.type
|
15837
17114
|
:required_parameter_node
|
15838
17115
|
end
|
17116
|
+
|
17117
|
+
# Implements case-equality for the node. This is effectively == but without
|
17118
|
+
# comparing the value of locations. Locations are checked only for presence.
|
17119
|
+
def ===(other)
|
17120
|
+
other.is_a?(RequiredParameterNode) &&
|
17121
|
+
(flags === other.flags) &&
|
17122
|
+
(name === other.name)
|
17123
|
+
end
|
15839
17124
|
end
|
15840
17125
|
|
15841
17126
|
# Represents an expression modified with a rescue.
|
@@ -15903,7 +17188,6 @@ module Prism
|
|
15903
17188
|
# attr_reader rescue_expression: Prism::node
|
15904
17189
|
attr_reader :rescue_expression
|
15905
17190
|
|
15906
|
-
|
15907
17191
|
# def keyword: () -> String
|
15908
17192
|
def keyword
|
15909
17193
|
keyword_loc.slice
|
@@ -15947,6 +17231,15 @@ module Prism
|
|
15947
17231
|
def self.type
|
15948
17232
|
:rescue_modifier_node
|
15949
17233
|
end
|
17234
|
+
|
17235
|
+
# Implements case-equality for the node. This is effectively == but without
|
17236
|
+
# comparing the value of locations. Locations are checked only for presence.
|
17237
|
+
def ===(other)
|
17238
|
+
other.is_a?(RescueModifierNode) &&
|
17239
|
+
(expression === other.expression) &&
|
17240
|
+
(keyword_loc.nil? == other.keyword_loc.nil?) &&
|
17241
|
+
(rescue_expression === other.rescue_expression)
|
17242
|
+
end
|
15950
17243
|
end
|
15951
17244
|
|
15952
17245
|
# Represents a rescue statement.
|
@@ -16042,7 +17335,6 @@ module Prism
|
|
16042
17335
|
# attr_reader consequent: RescueNode?
|
16043
17336
|
attr_reader :consequent
|
16044
17337
|
|
16045
|
-
|
16046
17338
|
# def keyword: () -> String
|
16047
17339
|
def keyword
|
16048
17340
|
keyword_loc.slice
|
@@ -16107,6 +17399,19 @@ module Prism
|
|
16107
17399
|
def self.type
|
16108
17400
|
:rescue_node
|
16109
17401
|
end
|
17402
|
+
|
17403
|
+
# Implements case-equality for the node. This is effectively == but without
|
17404
|
+
# comparing the value of locations. Locations are checked only for presence.
|
17405
|
+
def ===(other)
|
17406
|
+
other.is_a?(RescueNode) &&
|
17407
|
+
(keyword_loc.nil? == other.keyword_loc.nil?) &&
|
17408
|
+
(exceptions.length == other.exceptions.length) &&
|
17409
|
+
exceptions.zip(other.exceptions).all? { |left, right| left === right } &&
|
17410
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
17411
|
+
(reference === other.reference) &&
|
17412
|
+
(statements === other.statements) &&
|
17413
|
+
(consequent === other.consequent)
|
17414
|
+
end
|
16110
17415
|
end
|
16111
17416
|
|
16112
17417
|
# Represents a rest parameter to a method, block, or lambda definition.
|
@@ -16159,9 +17464,9 @@ module Prism
|
|
16159
17464
|
{ flags: flags, name: name, name_loc: name_loc, operator_loc: operator_loc, location: location }
|
16160
17465
|
end
|
16161
17466
|
|
16162
|
-
#
|
17467
|
+
# protected attr_reader flags: Integer
|
16163
17468
|
attr_reader :flags
|
16164
|
-
|
17469
|
+
protected :flags
|
16165
17470
|
|
16166
17471
|
# attr_reader name: Symbol?
|
16167
17472
|
attr_reader :name
|
@@ -16186,7 +17491,6 @@ module Prism
|
|
16186
17491
|
@operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
16187
17492
|
end
|
16188
17493
|
|
16189
|
-
|
16190
17494
|
# def repeated_parameter?: () -> bool
|
16191
17495
|
def repeated_parameter?
|
16192
17496
|
flags.anybits?(ParameterFlags::REPEATED_PARAMETER)
|
@@ -16239,6 +17543,16 @@ module Prism
|
|
16239
17543
|
def self.type
|
16240
17544
|
:rest_parameter_node
|
16241
17545
|
end
|
17546
|
+
|
17547
|
+
# Implements case-equality for the node. This is effectively == but without
|
17548
|
+
# comparing the value of locations. Locations are checked only for presence.
|
17549
|
+
def ===(other)
|
17550
|
+
other.is_a?(RestParameterNode) &&
|
17551
|
+
(flags === other.flags) &&
|
17552
|
+
(name === other.name) &&
|
17553
|
+
(name_loc.nil? == other.name_loc.nil?) &&
|
17554
|
+
(operator_loc.nil? == other.operator_loc.nil?)
|
17555
|
+
end
|
16242
17556
|
end
|
16243
17557
|
|
16244
17558
|
# Represents the use of the `retry` keyword.
|
@@ -16286,7 +17600,6 @@ module Prism
|
|
16286
17600
|
{ location: location }
|
16287
17601
|
end
|
16288
17602
|
|
16289
|
-
|
16290
17603
|
# def inspect(NodeInspector inspector) -> String
|
16291
17604
|
def inspect(inspector = NodeInspector.new)
|
16292
17605
|
inspector << inspector.header(self)
|
@@ -16320,6 +17633,12 @@ module Prism
|
|
16320
17633
|
def self.type
|
16321
17634
|
:retry_node
|
16322
17635
|
end
|
17636
|
+
|
17637
|
+
# Implements case-equality for the node. This is effectively == but without
|
17638
|
+
# comparing the value of locations. Locations are checked only for presence.
|
17639
|
+
def ===(other)
|
17640
|
+
other.is_a?(RetryNode)
|
17641
|
+
end
|
16323
17642
|
end
|
16324
17643
|
|
16325
17644
|
# Represents the use of the `return` keyword.
|
@@ -16381,7 +17700,6 @@ module Prism
|
|
16381
17700
|
# attr_reader arguments: ArgumentsNode?
|
16382
17701
|
attr_reader :arguments
|
16383
17702
|
|
16384
|
-
|
16385
17703
|
# def keyword: () -> String
|
16386
17704
|
def keyword
|
16387
17705
|
keyword_loc.slice
|
@@ -16427,6 +17745,14 @@ module Prism
|
|
16427
17745
|
def self.type
|
16428
17746
|
:return_node
|
16429
17747
|
end
|
17748
|
+
|
17749
|
+
# Implements case-equality for the node. This is effectively == but without
|
17750
|
+
# comparing the value of locations. Locations are checked only for presence.
|
17751
|
+
def ===(other)
|
17752
|
+
other.is_a?(ReturnNode) &&
|
17753
|
+
(keyword_loc.nil? == other.keyword_loc.nil?) &&
|
17754
|
+
(arguments === other.arguments)
|
17755
|
+
end
|
16430
17756
|
end
|
16431
17757
|
|
16432
17758
|
# Represents the `self` keyword.
|
@@ -16474,7 +17800,6 @@ module Prism
|
|
16474
17800
|
{ location: location }
|
16475
17801
|
end
|
16476
17802
|
|
16477
|
-
|
16478
17803
|
# def inspect(NodeInspector inspector) -> String
|
16479
17804
|
def inspect(inspector = NodeInspector.new)
|
16480
17805
|
inspector << inspector.header(self)
|
@@ -16508,6 +17833,12 @@ module Prism
|
|
16508
17833
|
def self.type
|
16509
17834
|
:self_node
|
16510
17835
|
end
|
17836
|
+
|
17837
|
+
# Implements case-equality for the node. This is effectively == but without
|
17838
|
+
# comparing the value of locations. Locations are checked only for presence.
|
17839
|
+
def ===(other)
|
17840
|
+
other.is_a?(SelfNode)
|
17841
|
+
end
|
16511
17842
|
end
|
16512
17843
|
|
16513
17844
|
# This node wraps a constant write to indicate that when the value is written, it should have its shareability state modified.
|
@@ -16558,14 +17889,13 @@ module Prism
|
|
16558
17889
|
{ flags: flags, write: write, location: location }
|
16559
17890
|
end
|
16560
17891
|
|
16561
|
-
#
|
17892
|
+
# protected attr_reader flags: Integer
|
16562
17893
|
attr_reader :flags
|
16563
|
-
|
17894
|
+
protected :flags
|
16564
17895
|
|
16565
17896
|
# The constant write that should be modified with the shareability state.
|
16566
17897
|
attr_reader :write
|
16567
17898
|
|
16568
|
-
|
16569
17899
|
# def literal?: () -> bool
|
16570
17900
|
def literal?
|
16571
17901
|
flags.anybits?(ShareableConstantNodeFlags::LITERAL)
|
@@ -16618,6 +17948,14 @@ module Prism
|
|
16618
17948
|
def self.type
|
16619
17949
|
:shareable_constant_node
|
16620
17950
|
end
|
17951
|
+
|
17952
|
+
# Implements case-equality for the node. This is effectively == but without
|
17953
|
+
# comparing the value of locations. Locations are checked only for presence.
|
17954
|
+
def ===(other)
|
17955
|
+
other.is_a?(ShareableConstantNode) &&
|
17956
|
+
(flags === other.flags) &&
|
17957
|
+
(write === other.write)
|
17958
|
+
end
|
16621
17959
|
end
|
16622
17960
|
|
16623
17961
|
# Represents a singleton class declaration involving the `class` keyword.
|
@@ -16704,7 +18042,6 @@ module Prism
|
|
16704
18042
|
@end_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
16705
18043
|
end
|
16706
18044
|
|
16707
|
-
|
16708
18045
|
# def class_keyword: () -> String
|
16709
18046
|
def class_keyword
|
16710
18047
|
class_keyword_loc.slice
|
@@ -16765,6 +18102,19 @@ module Prism
|
|
16765
18102
|
def self.type
|
16766
18103
|
:singleton_class_node
|
16767
18104
|
end
|
18105
|
+
|
18106
|
+
# Implements case-equality for the node. This is effectively == but without
|
18107
|
+
# comparing the value of locations. Locations are checked only for presence.
|
18108
|
+
def ===(other)
|
18109
|
+
other.is_a?(SingletonClassNode) &&
|
18110
|
+
(locals.length == other.locals.length) &&
|
18111
|
+
locals.zip(other.locals).all? { |left, right| left === right } &&
|
18112
|
+
(class_keyword_loc.nil? == other.class_keyword_loc.nil?) &&
|
18113
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
18114
|
+
(expression === other.expression) &&
|
18115
|
+
(body === other.body) &&
|
18116
|
+
(end_keyword_loc.nil? == other.end_keyword_loc.nil?)
|
18117
|
+
end
|
16768
18118
|
end
|
16769
18119
|
|
16770
18120
|
# Represents the use of the `__ENCODING__` keyword.
|
@@ -16812,7 +18162,6 @@ module Prism
|
|
16812
18162
|
{ location: location }
|
16813
18163
|
end
|
16814
18164
|
|
16815
|
-
|
16816
18165
|
# def inspect(NodeInspector inspector) -> String
|
16817
18166
|
def inspect(inspector = NodeInspector.new)
|
16818
18167
|
inspector << inspector.header(self)
|
@@ -16846,6 +18195,12 @@ module Prism
|
|
16846
18195
|
def self.type
|
16847
18196
|
:source_encoding_node
|
16848
18197
|
end
|
18198
|
+
|
18199
|
+
# Implements case-equality for the node. This is effectively == but without
|
18200
|
+
# comparing the value of locations. Locations are checked only for presence.
|
18201
|
+
def ===(other)
|
18202
|
+
other.is_a?(SourceEncodingNode)
|
18203
|
+
end
|
16849
18204
|
end
|
16850
18205
|
|
16851
18206
|
# Represents the use of the `__FILE__` keyword.
|
@@ -16895,14 +18250,13 @@ module Prism
|
|
16895
18250
|
{ flags: flags, filepath: filepath, location: location }
|
16896
18251
|
end
|
16897
18252
|
|
16898
|
-
#
|
18253
|
+
# protected attr_reader flags: Integer
|
16899
18254
|
attr_reader :flags
|
16900
|
-
|
18255
|
+
protected :flags
|
16901
18256
|
|
16902
|
-
#
|
18257
|
+
# Represents the file path being parsed. This corresponds directly to the `filepath` option given to the various `Prism::parse*` APIs.
|
16903
18258
|
attr_reader :filepath
|
16904
18259
|
|
16905
|
-
|
16906
18260
|
# def forced_utf8_encoding?: () -> bool
|
16907
18261
|
def forced_utf8_encoding?
|
16908
18262
|
flags.anybits?(StringFlags::FORCED_UTF8_ENCODING)
|
@@ -16959,6 +18313,14 @@ module Prism
|
|
16959
18313
|
def self.type
|
16960
18314
|
:source_file_node
|
16961
18315
|
end
|
18316
|
+
|
18317
|
+
# Implements case-equality for the node. This is effectively == but without
|
18318
|
+
# comparing the value of locations. Locations are checked only for presence.
|
18319
|
+
def ===(other)
|
18320
|
+
other.is_a?(SourceFileNode) &&
|
18321
|
+
(flags === other.flags) &&
|
18322
|
+
(filepath === other.filepath)
|
18323
|
+
end
|
16962
18324
|
end
|
16963
18325
|
|
16964
18326
|
# Represents the use of the `__LINE__` keyword.
|
@@ -17006,7 +18368,6 @@ module Prism
|
|
17006
18368
|
{ location: location }
|
17007
18369
|
end
|
17008
18370
|
|
17009
|
-
|
17010
18371
|
# def inspect(NodeInspector inspector) -> String
|
17011
18372
|
def inspect(inspector = NodeInspector.new)
|
17012
18373
|
inspector << inspector.header(self)
|
@@ -17040,6 +18401,12 @@ module Prism
|
|
17040
18401
|
def self.type
|
17041
18402
|
:source_line_node
|
17042
18403
|
end
|
18404
|
+
|
18405
|
+
# Implements case-equality for the node. This is effectively == but without
|
18406
|
+
# comparing the value of locations. Locations are checked only for presence.
|
18407
|
+
def ===(other)
|
18408
|
+
other.is_a?(SourceLineNode)
|
18409
|
+
end
|
17043
18410
|
end
|
17044
18411
|
|
17045
18412
|
# Represents the use of the splat operator.
|
@@ -17101,7 +18468,6 @@ module Prism
|
|
17101
18468
|
# attr_reader expression: Prism::node?
|
17102
18469
|
attr_reader :expression
|
17103
18470
|
|
17104
|
-
|
17105
18471
|
# def operator: () -> String
|
17106
18472
|
def operator
|
17107
18473
|
operator_loc.slice
|
@@ -17147,6 +18513,14 @@ module Prism
|
|
17147
18513
|
def self.type
|
17148
18514
|
:splat_node
|
17149
18515
|
end
|
18516
|
+
|
18517
|
+
# Implements case-equality for the node. This is effectively == but without
|
18518
|
+
# comparing the value of locations. Locations are checked only for presence.
|
18519
|
+
def ===(other)
|
18520
|
+
other.is_a?(SplatNode) &&
|
18521
|
+
(operator_loc.nil? == other.operator_loc.nil?) &&
|
18522
|
+
(expression === other.expression)
|
18523
|
+
end
|
17150
18524
|
end
|
17151
18525
|
|
17152
18526
|
# Represents a set of statements contained within some scope.
|
@@ -17198,7 +18572,6 @@ module Prism
|
|
17198
18572
|
# attr_reader body: Array[Prism::node]
|
17199
18573
|
attr_reader :body
|
17200
18574
|
|
17201
|
-
|
17202
18575
|
# def inspect(NodeInspector inspector) -> String
|
17203
18576
|
def inspect(inspector = NodeInspector.new)
|
17204
18577
|
inspector << inspector.header(self)
|
@@ -17233,6 +18606,14 @@ module Prism
|
|
17233
18606
|
def self.type
|
17234
18607
|
:statements_node
|
17235
18608
|
end
|
18609
|
+
|
18610
|
+
# Implements case-equality for the node. This is effectively == but without
|
18611
|
+
# comparing the value of locations. Locations are checked only for presence.
|
18612
|
+
def ===(other)
|
18613
|
+
other.is_a?(StatementsNode) &&
|
18614
|
+
(body.length == other.body.length) &&
|
18615
|
+
body.zip(other.body).all? { |left, right| left === right }
|
18616
|
+
end
|
17236
18617
|
end
|
17237
18618
|
|
17238
18619
|
# Represents a string literal, a string contained within a `%w` list, or plain string content within an interpolated string.
|
@@ -17291,9 +18672,9 @@ module Prism
|
|
17291
18672
|
{ flags: flags, opening_loc: opening_loc, content_loc: content_loc, closing_loc: closing_loc, unescaped: unescaped, location: location }
|
17292
18673
|
end
|
17293
18674
|
|
17294
|
-
#
|
18675
|
+
# protected attr_reader flags: Integer
|
17295
18676
|
attr_reader :flags
|
17296
|
-
|
18677
|
+
protected :flags
|
17297
18678
|
|
17298
18679
|
# attr_reader opening_loc: Location?
|
17299
18680
|
def opening_loc
|
@@ -17331,7 +18712,6 @@ module Prism
|
|
17331
18712
|
# attr_reader unescaped: String
|
17332
18713
|
attr_reader :unescaped
|
17333
18714
|
|
17334
|
-
|
17335
18715
|
# def forced_utf8_encoding?: () -> bool
|
17336
18716
|
def forced_utf8_encoding?
|
17337
18717
|
flags.anybits?(StringFlags::FORCED_UTF8_ENCODING)
|
@@ -17406,6 +18786,17 @@ module Prism
|
|
17406
18786
|
def self.type
|
17407
18787
|
:string_node
|
17408
18788
|
end
|
18789
|
+
|
18790
|
+
# Implements case-equality for the node. This is effectively == but without
|
18791
|
+
# comparing the value of locations. Locations are checked only for presence.
|
18792
|
+
def ===(other)
|
18793
|
+
other.is_a?(StringNode) &&
|
18794
|
+
(flags === other.flags) &&
|
18795
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
18796
|
+
(content_loc.nil? == other.content_loc.nil?) &&
|
18797
|
+
(closing_loc.nil? == other.closing_loc.nil?) &&
|
18798
|
+
(unescaped === other.unescaped)
|
18799
|
+
end
|
17409
18800
|
end
|
17410
18801
|
|
17411
18802
|
# Represents the use of the `super` keyword with parentheses or arguments.
|
@@ -17503,7 +18894,6 @@ module Prism
|
|
17503
18894
|
# attr_reader block: Prism::node?
|
17504
18895
|
attr_reader :block
|
17505
18896
|
|
17506
|
-
|
17507
18897
|
# def keyword: () -> String
|
17508
18898
|
def keyword
|
17509
18899
|
keyword_loc.slice
|
@@ -17567,6 +18957,17 @@ module Prism
|
|
17567
18957
|
def self.type
|
17568
18958
|
:super_node
|
17569
18959
|
end
|
18960
|
+
|
18961
|
+
# Implements case-equality for the node. This is effectively == but without
|
18962
|
+
# comparing the value of locations. Locations are checked only for presence.
|
18963
|
+
def ===(other)
|
18964
|
+
other.is_a?(SuperNode) &&
|
18965
|
+
(keyword_loc.nil? == other.keyword_loc.nil?) &&
|
18966
|
+
(lparen_loc.nil? == other.lparen_loc.nil?) &&
|
18967
|
+
(arguments === other.arguments) &&
|
18968
|
+
(rparen_loc.nil? == other.rparen_loc.nil?) &&
|
18969
|
+
(block === other.block)
|
18970
|
+
end
|
17570
18971
|
end
|
17571
18972
|
|
17572
18973
|
# Represents a symbol literal or a symbol contained within a `%i` list.
|
@@ -17622,9 +19023,9 @@ module Prism
|
|
17622
19023
|
{ flags: flags, opening_loc: opening_loc, value_loc: value_loc, closing_loc: closing_loc, unescaped: unescaped, location: location }
|
17623
19024
|
end
|
17624
19025
|
|
17625
|
-
#
|
19026
|
+
# protected attr_reader flags: Integer
|
17626
19027
|
attr_reader :flags
|
17627
|
-
|
19028
|
+
protected :flags
|
17628
19029
|
|
17629
19030
|
# attr_reader opening_loc: Location?
|
17630
19031
|
def opening_loc
|
@@ -17668,7 +19069,6 @@ module Prism
|
|
17668
19069
|
# attr_reader unescaped: String
|
17669
19070
|
attr_reader :unescaped
|
17670
19071
|
|
17671
|
-
|
17672
19072
|
# def forced_utf8_encoding?: () -> bool
|
17673
19073
|
def forced_utf8_encoding?
|
17674
19074
|
flags.anybits?(SymbolFlags::FORCED_UTF8_ENCODING)
|
@@ -17738,6 +19138,17 @@ module Prism
|
|
17738
19138
|
def self.type
|
17739
19139
|
:symbol_node
|
17740
19140
|
end
|
19141
|
+
|
19142
|
+
# Implements case-equality for the node. This is effectively == but without
|
19143
|
+
# comparing the value of locations. Locations are checked only for presence.
|
19144
|
+
def ===(other)
|
19145
|
+
other.is_a?(SymbolNode) &&
|
19146
|
+
(flags === other.flags) &&
|
19147
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
19148
|
+
(value_loc.nil? == other.value_loc.nil?) &&
|
19149
|
+
(closing_loc.nil? == other.closing_loc.nil?) &&
|
19150
|
+
(unescaped === other.unescaped)
|
19151
|
+
end
|
17741
19152
|
end
|
17742
19153
|
|
17743
19154
|
# Represents the use of the literal `true` keyword.
|
@@ -17785,7 +19196,6 @@ module Prism
|
|
17785
19196
|
{ location: location }
|
17786
19197
|
end
|
17787
19198
|
|
17788
|
-
|
17789
19199
|
# def inspect(NodeInspector inspector) -> String
|
17790
19200
|
def inspect(inspector = NodeInspector.new)
|
17791
19201
|
inspector << inspector.header(self)
|
@@ -17819,6 +19229,12 @@ module Prism
|
|
17819
19229
|
def self.type
|
17820
19230
|
:true_node
|
17821
19231
|
end
|
19232
|
+
|
19233
|
+
# Implements case-equality for the node. This is effectively == but without
|
19234
|
+
# comparing the value of locations. Locations are checked only for presence.
|
19235
|
+
def ===(other)
|
19236
|
+
other.is_a?(TrueNode)
|
19237
|
+
end
|
17822
19238
|
end
|
17823
19239
|
|
17824
19240
|
# Represents the use of the `undef` keyword.
|
@@ -17878,7 +19294,6 @@ module Prism
|
|
17878
19294
|
@keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
17879
19295
|
end
|
17880
19296
|
|
17881
|
-
|
17882
19297
|
# def keyword: () -> String
|
17883
19298
|
def keyword
|
17884
19299
|
keyword_loc.slice
|
@@ -17919,6 +19334,15 @@ module Prism
|
|
17919
19334
|
def self.type
|
17920
19335
|
:undef_node
|
17921
19336
|
end
|
19337
|
+
|
19338
|
+
# Implements case-equality for the node. This is effectively == but without
|
19339
|
+
# comparing the value of locations. Locations are checked only for presence.
|
19340
|
+
def ===(other)
|
19341
|
+
other.is_a?(UndefNode) &&
|
19342
|
+
(names.length == other.names.length) &&
|
19343
|
+
names.zip(other.names).all? { |left, right| left === right } &&
|
19344
|
+
(keyword_loc.nil? == other.keyword_loc.nil?)
|
19345
|
+
end
|
17922
19346
|
end
|
17923
19347
|
|
17924
19348
|
# Represents the use of the `unless` keyword, either in the block form or the modifier form.
|
@@ -17983,17 +19407,30 @@ module Prism
|
|
17983
19407
|
{ keyword_loc: keyword_loc, predicate: predicate, then_keyword_loc: then_keyword_loc, statements: statements, consequent: consequent, end_keyword_loc: end_keyword_loc, location: location }
|
17984
19408
|
end
|
17985
19409
|
|
17986
|
-
#
|
19410
|
+
# The location of the `unless` keyword.
|
19411
|
+
#
|
19412
|
+
# unless cond then bar end
|
19413
|
+
# ^^^^^^
|
19414
|
+
#
|
19415
|
+
# bar unless cond
|
19416
|
+
# ^^^^^^
|
17987
19417
|
def keyword_loc
|
17988
19418
|
location = @keyword_loc
|
17989
19419
|
return location if location.is_a?(Location)
|
17990
19420
|
@keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
|
17991
19421
|
end
|
17992
19422
|
|
17993
|
-
#
|
19423
|
+
# The condition to be evaluated for the unless expression. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
|
19424
|
+
#
|
19425
|
+
# unless cond then bar end
|
19426
|
+
# ^^^^
|
19427
|
+
#
|
19428
|
+
# bar unless cond
|
19429
|
+
# ^^^^
|
17994
19430
|
attr_reader :predicate
|
17995
19431
|
|
17996
|
-
#
|
19432
|
+
# The location of the `then` keyword, if present.
|
19433
|
+
# unless cond then bar end ^^^^
|
17997
19434
|
def then_keyword_loc
|
17998
19435
|
location = @then_keyword_loc
|
17999
19436
|
case location
|
@@ -18006,13 +19443,23 @@ module Prism
|
|
18006
19443
|
end
|
18007
19444
|
end
|
18008
19445
|
|
18009
|
-
#
|
19446
|
+
# The body of statements that will executed if the unless condition is
|
19447
|
+
# falsey. Will be `nil` if no body is provided.
|
19448
|
+
#
|
19449
|
+
# unless cond then bar end
|
19450
|
+
# ^^^
|
18010
19451
|
attr_reader :statements
|
18011
19452
|
|
18012
|
-
#
|
19453
|
+
# The else clause of the unless expression, if present.
|
19454
|
+
#
|
19455
|
+
# unless cond then bar else baz end
|
19456
|
+
# ^^^^^^^^
|
18013
19457
|
attr_reader :consequent
|
18014
19458
|
|
18015
|
-
#
|
19459
|
+
# The location of the `end` keyword, if present.
|
19460
|
+
#
|
19461
|
+
# unless cond then bar end
|
19462
|
+
# ^^^
|
18016
19463
|
def end_keyword_loc
|
18017
19464
|
location = @end_keyword_loc
|
18018
19465
|
case location
|
@@ -18025,7 +19472,6 @@ module Prism
|
|
18025
19472
|
end
|
18026
19473
|
end
|
18027
19474
|
|
18028
|
-
|
18029
19475
|
# def keyword: () -> String
|
18030
19476
|
def keyword
|
18031
19477
|
keyword_loc.slice
|
@@ -18091,6 +19537,18 @@ module Prism
|
|
18091
19537
|
def self.type
|
18092
19538
|
:unless_node
|
18093
19539
|
end
|
19540
|
+
|
19541
|
+
# Implements case-equality for the node. This is effectively == but without
|
19542
|
+
# comparing the value of locations. Locations are checked only for presence.
|
19543
|
+
def ===(other)
|
19544
|
+
other.is_a?(UnlessNode) &&
|
19545
|
+
(keyword_loc.nil? == other.keyword_loc.nil?) &&
|
19546
|
+
(predicate === other.predicate) &&
|
19547
|
+
(then_keyword_loc.nil? == other.then_keyword_loc.nil?) &&
|
19548
|
+
(statements === other.statements) &&
|
19549
|
+
(consequent === other.consequent) &&
|
19550
|
+
(end_keyword_loc.nil? == other.end_keyword_loc.nil?)
|
19551
|
+
end
|
18094
19552
|
end
|
18095
19553
|
|
18096
19554
|
# Represents the use of the `until` keyword, either in the block form or the modifier form.
|
@@ -18153,9 +19611,9 @@ module Prism
|
|
18153
19611
|
{ flags: flags, keyword_loc: keyword_loc, closing_loc: closing_loc, predicate: predicate, statements: statements, location: location }
|
18154
19612
|
end
|
18155
19613
|
|
18156
|
-
#
|
19614
|
+
# protected attr_reader flags: Integer
|
18157
19615
|
attr_reader :flags
|
18158
|
-
|
19616
|
+
protected :flags
|
18159
19617
|
|
18160
19618
|
# attr_reader keyword_loc: Location
|
18161
19619
|
def keyword_loc
|
@@ -18183,7 +19641,6 @@ module Prism
|
|
18183
19641
|
# attr_reader statements: StatementsNode?
|
18184
19642
|
attr_reader :statements
|
18185
19643
|
|
18186
|
-
|
18187
19644
|
# def begin_modifier?: () -> bool
|
18188
19645
|
def begin_modifier?
|
18189
19646
|
flags.anybits?(LoopFlags::BEGIN_MODIFIER)
|
@@ -18244,6 +19701,17 @@ module Prism
|
|
18244
19701
|
def self.type
|
18245
19702
|
:until_node
|
18246
19703
|
end
|
19704
|
+
|
19705
|
+
# Implements case-equality for the node. This is effectively == but without
|
19706
|
+
# comparing the value of locations. Locations are checked only for presence.
|
19707
|
+
def ===(other)
|
19708
|
+
other.is_a?(UntilNode) &&
|
19709
|
+
(flags === other.flags) &&
|
19710
|
+
(keyword_loc.nil? == other.keyword_loc.nil?) &&
|
19711
|
+
(closing_loc.nil? == other.closing_loc.nil?) &&
|
19712
|
+
(predicate === other.predicate) &&
|
19713
|
+
(statements === other.statements)
|
19714
|
+
end
|
18247
19715
|
end
|
18248
19716
|
|
18249
19717
|
# Represents the use of the `when` keyword within a case statement.
|
@@ -18326,7 +19794,6 @@ module Prism
|
|
18326
19794
|
# attr_reader statements: StatementsNode?
|
18327
19795
|
attr_reader :statements
|
18328
19796
|
|
18329
|
-
|
18330
19797
|
# def keyword: () -> String
|
18331
19798
|
def keyword
|
18332
19799
|
keyword_loc.slice
|
@@ -18379,6 +19846,17 @@ module Prism
|
|
18379
19846
|
def self.type
|
18380
19847
|
:when_node
|
18381
19848
|
end
|
19849
|
+
|
19850
|
+
# Implements case-equality for the node. This is effectively == but without
|
19851
|
+
# comparing the value of locations. Locations are checked only for presence.
|
19852
|
+
def ===(other)
|
19853
|
+
other.is_a?(WhenNode) &&
|
19854
|
+
(keyword_loc.nil? == other.keyword_loc.nil?) &&
|
19855
|
+
(conditions.length == other.conditions.length) &&
|
19856
|
+
conditions.zip(other.conditions).all? { |left, right| left === right } &&
|
19857
|
+
(then_keyword_loc.nil? == other.then_keyword_loc.nil?) &&
|
19858
|
+
(statements === other.statements)
|
19859
|
+
end
|
18382
19860
|
end
|
18383
19861
|
|
18384
19862
|
# Represents the use of the `while` keyword, either in the block form or the modifier form.
|
@@ -18441,9 +19919,9 @@ module Prism
|
|
18441
19919
|
{ flags: flags, keyword_loc: keyword_loc, closing_loc: closing_loc, predicate: predicate, statements: statements, location: location }
|
18442
19920
|
end
|
18443
19921
|
|
18444
|
-
#
|
19922
|
+
# protected attr_reader flags: Integer
|
18445
19923
|
attr_reader :flags
|
18446
|
-
|
19924
|
+
protected :flags
|
18447
19925
|
|
18448
19926
|
# attr_reader keyword_loc: Location
|
18449
19927
|
def keyword_loc
|
@@ -18471,7 +19949,6 @@ module Prism
|
|
18471
19949
|
# attr_reader statements: StatementsNode?
|
18472
19950
|
attr_reader :statements
|
18473
19951
|
|
18474
|
-
|
18475
19952
|
# def begin_modifier?: () -> bool
|
18476
19953
|
def begin_modifier?
|
18477
19954
|
flags.anybits?(LoopFlags::BEGIN_MODIFIER)
|
@@ -18532,6 +20009,17 @@ module Prism
|
|
18532
20009
|
def self.type
|
18533
20010
|
:while_node
|
18534
20011
|
end
|
20012
|
+
|
20013
|
+
# Implements case-equality for the node. This is effectively == but without
|
20014
|
+
# comparing the value of locations. Locations are checked only for presence.
|
20015
|
+
def ===(other)
|
20016
|
+
other.is_a?(WhileNode) &&
|
20017
|
+
(flags === other.flags) &&
|
20018
|
+
(keyword_loc.nil? == other.keyword_loc.nil?) &&
|
20019
|
+
(closing_loc.nil? == other.closing_loc.nil?) &&
|
20020
|
+
(predicate === other.predicate) &&
|
20021
|
+
(statements === other.statements)
|
20022
|
+
end
|
18535
20023
|
end
|
18536
20024
|
|
18537
20025
|
# Represents an xstring literal with no interpolation.
|
@@ -18584,9 +20072,9 @@ module Prism
|
|
18584
20072
|
{ flags: flags, opening_loc: opening_loc, content_loc: content_loc, closing_loc: closing_loc, unescaped: unescaped, location: location }
|
18585
20073
|
end
|
18586
20074
|
|
18587
|
-
#
|
20075
|
+
# protected attr_reader flags: Integer
|
18588
20076
|
attr_reader :flags
|
18589
|
-
|
20077
|
+
protected :flags
|
18590
20078
|
|
18591
20079
|
# attr_reader opening_loc: Location
|
18592
20080
|
def opening_loc
|
@@ -18612,7 +20100,6 @@ module Prism
|
|
18612
20100
|
# attr_reader unescaped: String
|
18613
20101
|
attr_reader :unescaped
|
18614
20102
|
|
18615
|
-
|
18616
20103
|
# def forced_utf8_encoding?: () -> bool
|
18617
20104
|
def forced_utf8_encoding?
|
18618
20105
|
flags.anybits?(EncodingFlags::FORCED_UTF8_ENCODING)
|
@@ -18677,6 +20164,17 @@ module Prism
|
|
18677
20164
|
def self.type
|
18678
20165
|
:x_string_node
|
18679
20166
|
end
|
20167
|
+
|
20168
|
+
# Implements case-equality for the node. This is effectively == but without
|
20169
|
+
# comparing the value of locations. Locations are checked only for presence.
|
20170
|
+
def ===(other)
|
20171
|
+
other.is_a?(XStringNode) &&
|
20172
|
+
(flags === other.flags) &&
|
20173
|
+
(opening_loc.nil? == other.opening_loc.nil?) &&
|
20174
|
+
(content_loc.nil? == other.content_loc.nil?) &&
|
20175
|
+
(closing_loc.nil? == other.closing_loc.nil?) &&
|
20176
|
+
(unescaped === other.unescaped)
|
20177
|
+
end
|
18680
20178
|
end
|
18681
20179
|
|
18682
20180
|
# Represents the use of the `yield` keyword.
|
@@ -18766,7 +20264,6 @@ module Prism
|
|
18766
20264
|
end
|
18767
20265
|
end
|
18768
20266
|
|
18769
|
-
|
18770
20267
|
# def keyword: () -> String
|
18771
20268
|
def keyword
|
18772
20269
|
keyword_loc.slice
|
@@ -18824,6 +20321,16 @@ module Prism
|
|
18824
20321
|
def self.type
|
18825
20322
|
:yield_node
|
18826
20323
|
end
|
20324
|
+
|
20325
|
+
# Implements case-equality for the node. This is effectively == but without
|
20326
|
+
# comparing the value of locations. Locations are checked only for presence.
|
20327
|
+
def ===(other)
|
20328
|
+
other.is_a?(YieldNode) &&
|
20329
|
+
(keyword_loc.nil? == other.keyword_loc.nil?) &&
|
20330
|
+
(lparen_loc.nil? == other.lparen_loc.nil?) &&
|
20331
|
+
(arguments === other.arguments) &&
|
20332
|
+
(rparen_loc.nil? == other.rparen_loc.nil?)
|
20333
|
+
end
|
18827
20334
|
end
|
18828
20335
|
|
18829
20336
|
# Flags for arguments nodes.
|