prism 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/config.yml CHANGED
@@ -855,6 +855,11 @@ nodes:
855
855
  ^^^^^^^^^
856
856
  - name: keyword_loc
857
857
  type: location
858
+ comment: |
859
+ Represents the location of the `alias` keyword.
860
+
861
+ alias foo bar
862
+ ^^^^^
858
863
  comment: |
859
864
  Represents the use of the `alias` keyword to alias a method.
860
865
 
@@ -932,6 +937,11 @@ nodes:
932
937
  - name: arguments
933
938
  type: node[]
934
939
  kind: non-void expression
940
+ comment: |
941
+ The list of arguments, if present. These can be any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
942
+
943
+ foo(bar, baz)
944
+ ^^^^^^^^
935
945
  comment: |
936
946
  Represents a set of arguments to a method or a keyword.
937
947
 
@@ -977,16 +987,41 @@ nodes:
977
987
  - name: requireds
978
988
  type: node[]
979
989
  kind: pattern expression
990
+ comment: |
991
+ Represents the required elements of the array pattern.
992
+
993
+ foo in [1, 2]
994
+ ^ ^
980
995
  - name: rest
981
996
  type: node?
982
997
  kind: pattern expression
998
+ comment: |
999
+ Represents the rest element of the array pattern.
1000
+
1001
+ foo in *bar
1002
+ ^^^^
983
1003
  - name: posts
984
1004
  type: node[]
985
1005
  kind: pattern expression
1006
+ comment: |
1007
+ Represents the elements after the rest element of the array pattern.
1008
+
1009
+ foo in *bar, baz
1010
+ ^^^
986
1011
  - name: opening_loc
987
1012
  type: location?
1013
+ comment: |
1014
+ Represents the opening location of the array pattern.
1015
+
1016
+ foo in [1, 2]
1017
+ ^
988
1018
  - name: closing_loc
989
1019
  type: location?
1020
+ comment: |
1021
+ Represents the closing location of the array pattern.
1022
+
1023
+ foo in [1, 2]
1024
+ ^
990
1025
  comment: |
991
1026
  Represents an array pattern in pattern matching.
992
1027
 
@@ -996,8 +1031,8 @@ nodes:
996
1031
  foo in [1, 2]
997
1032
  ^^^^^^^^^^^^^
998
1033
 
999
- foo in *1
1000
- ^^^^^^^^^
1034
+ foo in *bar
1035
+ ^^^^^^^^^^^
1001
1036
 
1002
1037
  foo in Bar[]
1003
1038
  ^^^^^^^^^^^^
@@ -1084,20 +1119,50 @@ nodes:
1084
1119
  fields:
1085
1120
  - name: begin_keyword_loc
1086
1121
  type: location?
1122
+ comment: |
1123
+ Represents the location of the `begin` keyword.
1124
+
1125
+ begin x end
1126
+ ^^^^^
1087
1127
  - name: statements
1088
1128
  type: node?
1089
1129
  kind: StatementsNode
1130
+ comment: |
1131
+ Represents the statements within the begin block.
1132
+
1133
+ begin x end
1134
+ ^
1090
1135
  - name: rescue_clause
1091
1136
  type: node?
1092
1137
  kind: RescueNode
1138
+ comment: |
1139
+ Represents the rescue clause within the begin block.
1140
+
1141
+ begin x; rescue y; end
1142
+ ^^^^^^^^
1093
1143
  - name: else_clause
1094
1144
  type: node?
1095
1145
  kind: ElseNode
1146
+ comment: |
1147
+ Represents the else clause within the begin block.
1148
+
1149
+ begin x; rescue y; else z; end
1150
+ ^^^^^^
1096
1151
  - name: ensure_clause
1097
1152
  type: node?
1098
1153
  kind: EnsureNode
1154
+ comment: |
1155
+ Represents the ensure clause within the begin block.
1156
+
1157
+ begin x; ensure y; end
1158
+ ^^^^^^^^
1099
1159
  - name: end_keyword_loc
1100
1160
  type: location?
1161
+ comment: |
1162
+ Represents the location of the `end` keyword.
1163
+
1164
+ begin x end
1165
+ ^^^
1101
1166
  newline: false
1102
1167
  comment: |
1103
1168
  Represents a begin statement.
@@ -1111,8 +1176,18 @@ nodes:
1111
1176
  - name: expression
1112
1177
  type: node?
1113
1178
  kind: non-void expression
1179
+ comment: |
1180
+ The expression that is being passed as a block argument. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
1181
+
1182
+ foo(&args)
1183
+ ^^^^^
1114
1184
  - name: operator_loc
1115
1185
  type: location
1186
+ comment: |
1187
+ Represents the location of the `&` operator.
1188
+
1189
+ foo(&args)
1190
+ ^
1116
1191
  comment: |
1117
1192
  Represents a block argument using `&`.
1118
1193
 
@@ -1123,6 +1198,11 @@ nodes:
1123
1198
  fields:
1124
1199
  - name: name
1125
1200
  type: constant
1201
+ comment: |
1202
+ The name of the block local variable.
1203
+
1204
+ a { |; b| } # name `:b`
1205
+ ^
1126
1206
  comment: |
1127
1207
  Represents a block local variable.
1128
1208
 
@@ -1132,21 +1212,50 @@ nodes:
1132
1212
  fields:
1133
1213
  - name: locals
1134
1214
  type: constant[]
1215
+ comment: |
1216
+ The local variables declared in the block.
1217
+
1218
+ [1, 2, 3].each { |i| puts x } # locals: [:i]
1219
+ ^
1135
1220
  - name: parameters
1136
1221
  type: node?
1137
1222
  kind:
1138
1223
  - BlockParametersNode
1139
1224
  - NumberedParametersNode
1140
1225
  - ItParametersNode
1226
+ comment: |
1227
+ The parameters of the block.
1228
+
1229
+ [1, 2, 3].each { |i| puts x }
1230
+ ^^^
1231
+ [1, 2, 3].each { puts _1 }
1232
+ ^^^^^^^^^^^
1233
+ [1, 2, 3].each { puts it }
1234
+ ^^^^^^^^^^^
1141
1235
  - name: body
1142
1236
  type: node?
1143
1237
  kind:
1144
1238
  - StatementsNode
1145
1239
  - BeginNode
1240
+ comment: |
1241
+ The body of the block.
1242
+
1243
+ [1, 2, 3].each { |i| puts x }
1244
+ ^^^^^^
1146
1245
  - name: opening_loc
1147
1246
  type: location
1247
+ comment: |
1248
+ Represents the location of the opening `|`.
1249
+
1250
+ [1, 2, 3].each { |i| puts x }
1251
+ ^
1148
1252
  - name: closing_loc
1149
1253
  type: location
1254
+ comment: |
1255
+ Represents the location of the closing `|`.
1256
+
1257
+ [1, 2, 3].each { |i| puts x }
1258
+ ^
1150
1259
  comment: |
1151
1260
  Represents a block of ruby code.
1152
1261
 
@@ -1157,10 +1266,27 @@ nodes:
1157
1266
  fields:
1158
1267
  - name: name
1159
1268
  type: constant?
1269
+ comment: |
1270
+ The name of the block parameter.
1271
+
1272
+ def a(&b) # name `:b`
1273
+ ^
1274
+ end
1160
1275
  - name: name_loc
1161
1276
  type: location?
1277
+ comment: |
1278
+ Represents the location of the block parameter name.
1279
+
1280
+ def a(&b)
1281
+ ^
1162
1282
  - name: operator_loc
1163
1283
  type: location
1284
+ comment: |
1285
+ Represents the location of the `&` operator.
1286
+
1287
+ def a(&b)
1288
+ ^
1289
+ end
1164
1290
  comment: |
1165
1291
  Represents a block parameter of a method, block, or lambda definition.
1166
1292
 
@@ -1172,13 +1298,49 @@ nodes:
1172
1298
  - name: parameters
1173
1299
  type: node?
1174
1300
  kind: ParametersNode
1301
+ comment: |
1302
+ Represents the parameters of the block.
1303
+
1304
+ -> (a, b = 1; local) { }
1305
+ ^^^^^^^^
1306
+
1307
+ foo do |a, b = 1; local|
1308
+ ^^^^^^^^
1309
+ end
1175
1310
  - name: locals
1176
1311
  type: node[]
1177
1312
  kind: BlockLocalVariableNode
1313
+ comment: |
1314
+ Represents the local variables of the block.
1315
+
1316
+ -> (a, b = 1; local) { }
1317
+ ^^^^^
1318
+
1319
+ foo do |a, b = 1; local|
1320
+ ^^^^^
1321
+ end
1178
1322
  - name: opening_loc
1179
1323
  type: location?
1324
+ comment: |
1325
+ Represents the opening location of the block parameters.
1326
+
1327
+ -> (a, b = 1; local) { }
1328
+ ^
1329
+
1330
+ foo do |a, b = 1; local|
1331
+ ^
1332
+ end
1180
1333
  - name: closing_loc
1181
1334
  type: location?
1335
+ comment: |
1336
+ Represents the closing location of the block parameters.
1337
+
1338
+ -> (a, b = 1; local) { }
1339
+ ^
1340
+
1341
+ foo do |a, b = 1; local|
1342
+ ^
1343
+ end
1182
1344
  comment: |
1183
1345
  Represents a block's parameters declaration.
1184
1346
 
@@ -1216,19 +1378,54 @@ nodes:
1216
1378
  - name: receiver
1217
1379
  type: node?
1218
1380
  kind: non-void expression
1381
+ comment: |
1382
+ 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).
1383
+
1384
+ foo.bar &&= value
1385
+ ^^^
1219
1386
  - name: call_operator_loc
1220
1387
  type: location?
1388
+ comment: |
1389
+ Represents the location of the call operator.
1390
+
1391
+ foo.bar &&= value
1392
+ ^
1221
1393
  - name: message_loc
1222
1394
  type: location?
1395
+ comment: |
1396
+ Represents the location of the message.
1397
+
1398
+ foo.bar &&= value
1399
+ ^^^
1223
1400
  - name: read_name
1224
1401
  type: constant
1402
+ comment: |
1403
+ Represents the name of the method being called.
1404
+
1405
+ foo.bar &&= value # read_name `:bar`
1406
+ ^^^
1225
1407
  - name: write_name
1226
1408
  type: constant
1409
+ comment: |
1410
+ Represents the name of the method being written to.
1411
+
1412
+ foo.bar &&= value # write_name `:bar=`
1413
+ ^^^
1227
1414
  - name: operator_loc
1228
1415
  type: location
1416
+ comment: |
1417
+ Represents the location of the operator.
1418
+
1419
+ foo.bar &&= value
1420
+ ^^^
1229
1421
  - name: value
1230
1422
  type: node
1231
1423
  kind: non-void expression
1424
+ comment: |
1425
+ Represents the value being assigned.
1426
+
1427
+ foo.bar &&= value
1428
+ ^^^^^
1232
1429
  comment: |
1233
1430
  Represents the use of the `&&=` operator on a call.
1234
1431
 
@@ -1253,22 +1450,59 @@ nodes:
1253
1450
  ^^^
1254
1451
  - name: call_operator_loc
1255
1452
  type: location?
1453
+ comment: |
1454
+ Represents the location of the call operator.
1455
+
1456
+ foo.bar
1457
+ ^
1458
+
1459
+ foo&.bar
1460
+ ^^
1256
1461
  - name: name
1257
1462
  type: constant
1463
+ comment: |
1464
+ Represents the name of the method being called.
1465
+
1466
+ foo.bar # name `:foo`
1467
+ ^^^
1258
1468
  - name: message_loc
1259
1469
  type: location?
1470
+ comment: |
1471
+ Represents the location of the message.
1472
+
1473
+ foo.bar
1474
+ ^^^
1260
1475
  - name: opening_loc
1261
1476
  type: location?
1477
+ comment: |
1478
+ Represents the location of the left parenthesis.
1479
+ foo(bar)
1480
+ ^
1262
1481
  - name: arguments
1263
1482
  type: node?
1264
1483
  kind: ArgumentsNode
1484
+ comment: |
1485
+ Represents the arguments to the method call. These can be any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
1486
+
1487
+ foo(bar)
1488
+ ^^^
1265
1489
  - name: closing_loc
1266
1490
  type: location?
1491
+ comment: |
1492
+ Represents the location of the right parenthesis.
1493
+
1494
+ foo(bar)
1495
+ ^
1267
1496
  - name: block
1268
1497
  type: node?
1269
1498
  kind:
1270
1499
  - BlockNode
1271
1500
  - BlockArgumentNode
1501
+ comment: |
1502
+ Represents the block that is being passed to the method.
1503
+
1504
+ foo { |a| a }
1505
+ ^^^^^^^^^
1272
1506
  comment: |
1273
1507
  Represents a method call, in all of the various forms that can take.
1274
1508
 
@@ -1295,21 +1529,61 @@ nodes:
1295
1529
  - name: receiver
1296
1530
  type: node?
1297
1531
  kind: non-void expression
1532
+ comment: |
1533
+ The object that the method is being called on. This can be either `nil` or any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
1534
+
1535
+ foo.bar += value
1536
+ ^^^
1298
1537
  - name: call_operator_loc
1299
1538
  type: location?
1539
+ comment: |
1540
+ Represents the location of the call operator.
1541
+
1542
+ foo.bar += value
1543
+ ^
1300
1544
  - name: message_loc
1301
1545
  type: location?
1546
+ comment: |
1547
+ Represents the location of the message.
1548
+
1549
+ foo.bar += value
1550
+ ^^^
1302
1551
  - name: read_name
1303
1552
  type: constant
1553
+ comment: |
1554
+ Represents the name of the method being called.
1555
+
1556
+ foo.bar += value # read_name `:bar`
1557
+ ^^^
1304
1558
  - name: write_name
1305
1559
  type: constant
1560
+ comment: |
1561
+ Represents the name of the method being written to.
1562
+
1563
+ foo.bar += value # write_name `:bar=`
1564
+ ^^^
1306
1565
  - name: binary_operator
1307
1566
  type: constant
1567
+ comment: |
1568
+ Represents the binary operator being used.
1569
+
1570
+ foo.bar += value # binary_operator `:+`
1571
+ ^
1308
1572
  - name: binary_operator_loc
1309
1573
  type: location
1574
+ comment: |
1575
+ Represents the location of the binary operator.
1576
+
1577
+ foo.bar += value
1578
+ ^^
1310
1579
  - name: value
1311
1580
  type: node
1312
1581
  kind: non-void expression
1582
+ comment: |
1583
+ Represents the value being assigned.
1584
+
1585
+ foo.bar += value
1586
+ ^^^^^
1313
1587
  comment: |
1314
1588
  Represents the use of an assignment operator on a call.
1315
1589
 
@@ -1321,19 +1595,54 @@ nodes:
1321
1595
  - name: receiver
1322
1596
  type: node?
1323
1597
  kind: non-void expression
1598
+ comment: |
1599
+ The object that the method is being called on. This can be either `nil` or any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
1600
+
1601
+ foo.bar ||= value
1602
+ ^^^
1324
1603
  - name: call_operator_loc
1325
1604
  type: location?
1605
+ comment: |
1606
+ Represents the location of the call operator.
1607
+
1608
+ foo.bar ||= value
1609
+ ^
1326
1610
  - name: message_loc
1327
1611
  type: location?
1612
+ comment: |
1613
+ Represents the location of the message.
1614
+
1615
+ foo.bar ||= value
1616
+ ^^^
1328
1617
  - name: read_name
1329
1618
  type: constant
1619
+ comment: |
1620
+ Represents the name of the method being called.
1621
+
1622
+ foo.bar ||= value # read_name `:bar`
1623
+ ^^^
1330
1624
  - name: write_name
1331
1625
  type: constant
1626
+ comment: |
1627
+ Represents the name of the method being written to.
1628
+
1629
+ foo.bar ||= value # write_name `:bar=`
1630
+ ^^^
1332
1631
  - name: operator_loc
1333
1632
  type: location
1633
+ comment: |
1634
+ Represents the location of the operator.
1635
+
1636
+ foo.bar ||= value
1637
+ ^^^
1334
1638
  - name: value
1335
1639
  type: node
1336
1640
  kind: non-void expression
1641
+ comment: |
1642
+ Represents the value being assigned.
1643
+
1644
+ foo.bar ||= value
1645
+ ^^^^^
1337
1646
  comment: |
1338
1647
  Represents the use of the `||=` operator on a call.
1339
1648
 
@@ -1345,12 +1654,32 @@ nodes:
1345
1654
  - name: receiver
1346
1655
  type: node
1347
1656
  kind: non-void expression
1657
+ comment: |
1658
+ The object that the method is being called on. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
1659
+
1660
+ foo.bar = 1
1661
+ ^^^
1348
1662
  - name: call_operator_loc
1349
1663
  type: location
1664
+ comment: |
1665
+ Represents the location of the call operator.
1666
+
1667
+ foo.bar = 1
1668
+ ^
1350
1669
  - name: name
1351
1670
  type: constant
1671
+ comment: |
1672
+ Represents the name of the method being called.
1673
+
1674
+ foo.bar = 1 # name `:foo`
1675
+ ^^^
1352
1676
  - name: message_loc
1353
1677
  type: location
1678
+ comment: |
1679
+ Represents the location of the message.
1680
+
1681
+ foo.bar = 1
1682
+ ^^^
1354
1683
  comment: |
1355
1684
  Represents assigning to a method call.
1356
1685
 
@@ -1369,11 +1698,26 @@ nodes:
1369
1698
  - name: value
1370
1699
  type: node
1371
1700
  kind: pattern expression
1701
+ comment: |
1702
+ Represents the value to capture.
1703
+
1704
+ foo => bar
1705
+ ^^^
1372
1706
  - name: target
1373
1707
  type: node
1374
1708
  kind: LocalVariableTargetNode
1709
+ comment: |
1710
+ Represents the target of the capture.
1711
+
1712
+ foo => bar
1713
+ ^^^
1375
1714
  - name: operator_loc
1376
1715
  type: location
1716
+ comment: |
1717
+ Represents the location of the `=>` operator.
1718
+
1719
+ foo => bar
1720
+ ^^
1377
1721
  comment: |
1378
1722
  Represents assigning to a local variable in pattern matching.
1379
1723
 
@@ -1384,16 +1728,41 @@ nodes:
1384
1728
  - name: predicate
1385
1729
  type: node?
1386
1730
  kind: non-void expression
1731
+ comment: |
1732
+ Represents the predicate of the case match. This can be either `nil` or any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
1733
+
1734
+ case true; in false; end
1735
+ ^^^^
1387
1736
  - name: conditions
1388
1737
  type: node[]
1389
1738
  kind: InNode
1739
+ comment: |
1740
+ Represents the conditions of the case match.
1741
+
1742
+ case true; in false; end
1743
+ ^^^^^^^^
1390
1744
  - name: else_clause
1391
1745
  type: node?
1392
1746
  kind: ElseNode
1747
+ comment: |
1748
+ Represents the else clause of the case match.
1749
+
1750
+ case true; in false; else; end
1751
+ ^^^^
1393
1752
  - name: case_keyword_loc
1394
1753
  type: location
1754
+ comment: |
1755
+ Represents the location of the `case` keyword.
1756
+
1757
+ case true; in false; end
1758
+ ^^^^
1395
1759
  - name: end_keyword_loc
1396
1760
  type: location
1761
+ comment: |
1762
+ Represents the location of the `end` keyword.
1763
+
1764
+ case true; in false; end
1765
+ ^^^
1397
1766
  comment: |
1398
1767
  Represents the use of a case statement for pattern matching.
1399
1768
 
@@ -1406,16 +1775,41 @@ nodes:
1406
1775
  - name: predicate
1407
1776
  type: node?
1408
1777
  kind: non-void expression
1778
+ comment: |
1779
+ Represents the predicate of the case statement. This can be either `nil` or any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
1780
+
1781
+ case true; when false; end
1782
+ ^^^^
1409
1783
  - name: conditions
1410
1784
  type: node[]
1411
1785
  kind: WhenNode
1786
+ comment: |
1787
+ Represents the conditions of the case statement.
1788
+
1789
+ case true; when false; end
1790
+ ^^^^^^^^^^
1412
1791
  - name: else_clause
1413
1792
  type: node?
1414
1793
  kind: ElseNode
1794
+ comment: |
1795
+ Represents the else clause of the case statement.
1796
+
1797
+ case true; when false; else; end
1798
+ ^^^^
1415
1799
  - name: case_keyword_loc
1416
1800
  type: location
1801
+ comment: |
1802
+ Represents the location of the `case` keyword.
1803
+
1804
+ case true; when false; end
1805
+ ^^^^
1417
1806
  - name: end_keyword_loc
1418
1807
  type: location
1808
+ comment: |
1809
+ Represents the location of the `end` keyword.
1810
+
1811
+ case true; when false; end
1812
+ ^^^
1419
1813
  comment: |
1420
1814
  Represents the use of a case statement.
1421
1815
 
@@ -1458,13 +1852,33 @@ nodes:
1458
1852
  fields:
1459
1853
  - name: name
1460
1854
  type: constant
1855
+ comment: |
1856
+ The name of the class variable, which is a `@@` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
1857
+
1858
+ @@target &&= value # name `:@@target`
1859
+ ^^^^^^^^
1461
1860
  - name: name_loc
1462
1861
  type: location
1862
+ comment: |
1863
+ Represents the location of the variable name.
1864
+
1865
+ @@target &&= value
1866
+ ^^^^^^^^
1463
1867
  - name: operator_loc
1464
1868
  type: location
1869
+ comment: |
1870
+ Represents the location of the `&&=` operator.
1871
+
1872
+ @@target &&= value
1873
+ ^^^
1465
1874
  - name: value
1466
1875
  type: node
1467
1876
  kind: non-void expression
1877
+ comment: |
1878
+ Represents the value being assigned. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
1879
+
1880
+ @@target &&= value
1881
+ ^^^^^
1468
1882
  comment: |
1469
1883
  Represents the use of the `&&=` operator for assignment to a class variable.
1470
1884
 
@@ -3967,6 +4381,8 @@ nodes:
3967
4381
  fields:
3968
4382
  - name: keyword_loc
3969
4383
  type: location
4384
+ - name: do_keyword_loc
4385
+ type: location?
3970
4386
  - name: closing_loc
3971
4387
  type: location?
3972
4388
  - name: predicate
@@ -4008,6 +4424,8 @@ nodes:
4008
4424
  fields:
4009
4425
  - name: keyword_loc
4010
4426
  type: location
4427
+ - name: do_keyword_loc
4428
+ type: location?
4011
4429
  - name: closing_loc
4012
4430
  type: location?
4013
4431
  - name: predicate