Repository navigation
Commit 268350e
Less strict parsing of visibility method arguments (#1803)
NOTE: this PR stacks on #1793. Only [the last three
commits](https://github.com/ruby/rdoc/pull/1803/changes/f4607d26d8db4ca8d96b819028bf083e8ad5f5c4..242a1e9a28d2c5abdc261e7141bd26ba2999e202)
are specific to this PR.
This updates method name argument parsing for the visibility methods:
* `private`, `public`, `protected`
* `private_class_method`, `public_class_method`
* `private_constant`, `public_constant`
* `module_function`
Prior to this PR, the parser is stricter about visibility method name
arguments than it should be: it only parses method names when _all_
arguments are symbols.
This updates the prism parser to behave more like the rdoc 7.2, so every
(non-interpolated) string and symbol in the argument list is used
(`call_node_name_arguments` is used to parse the arguments list).
Additionally:
* Fix `Parser::Ruby` docs for `private_class_method` and
`public_class_method`.
There aren't any `private_class_function` and `public_class_function`
methods. 😉
* Refactor `Parser::Ruby#call_node_name_arguments` into plural and
singular versions.
Since meta-programmed method names are only ever inferred from the first
argument, the singular version only reads the first argument. The plural
version is now free to use `filter_map` and convert `[]` to `nil`,
enabling the short-circuiting pattern used in the visitor.
Arguably, these methods belong more to the visitor than the "scanner".
Since they simply process prism nodes without any ivar references, they
should probably be converted into module functions on a utility module.
But I'm considering that out of scope for this PR.
---------
Co-authored-by: tomoya ishida <tomoyapenguin@gmail.com>1 parent dd6b11a commit 268350e
2 files changed
Lines changed: 66 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
400 | 408 | | |
401 | 409 | | |
402 | 410 | | |
| |||
412 | 420 | | |
413 | 421 | | |
414 | 422 | | |
415 | | - | |
| 423 | + | |
416 | 424 | | |
417 | 425 | | |
418 | 426 | | |
| |||
438 | 446 | | |
439 | 447 | | |
440 | 448 | | |
441 | | - | |
| 449 | + | |
442 | 450 | | |
443 | 451 | | |
444 | 452 | | |
| |||
1216 | 1224 | | |
1217 | 1225 | | |
1218 | 1226 | | |
1219 | | - | |
1220 | | - | |
| 1227 | + | |
1221 | 1228 | | |
1222 | 1229 | | |
1223 | 1230 | | |
| |||
1229 | 1236 | | |
1230 | 1237 | | |
1231 | 1238 | | |
1232 | | - | |
1233 | | - | |
1234 | | - | |
1235 | | - | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
1236 | 1243 | | |
1237 | 1244 | | |
1238 | 1245 | | |
| |||
1322 | 1329 | | |
1323 | 1330 | | |
1324 | 1331 | | |
1325 | | - | |
1326 | | - | |
| 1332 | + | |
| 1333 | + | |
1327 | 1334 | | |
1328 | 1335 | | |
1329 | 1336 | | |
1330 | 1337 | | |
1331 | | - | |
1332 | | - | |
| 1338 | + | |
| 1339 | + | |
1333 | 1340 | | |
1334 | 1341 | | |
1335 | 1342 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
865 | 865 | | |
866 | 866 | | |
867 | 867 | | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
868 | 886 | | |
869 | 887 | | |
870 | 888 | | |
| |||
1372 | 1390 | | |
1373 | 1391 | | |
1374 | 1392 | | |
1375 | | - | |
| 1393 | + | |
1376 | 1394 | | |
1377 | 1395 | | |
1378 | 1396 | | |
| |||
1391 | 1409 | | |
1392 | 1410 | | |
1393 | 1411 | | |
1394 | | - | |
1395 | | - | |
| 1412 | + | |
| 1413 | + | |
1396 | 1414 | | |
1397 | 1415 | | |
1398 | 1416 | | |
| |||
1410 | 1428 | | |
1411 | 1429 | | |
1412 | 1430 | | |
1413 | | - | |
1414 | | - | |
| 1431 | + | |
| 1432 | + | |
1415 | 1433 | | |
1416 | 1434 | | |
1417 | 1435 | | |
1418 | 1436 | | |
1419 | 1437 | | |
1420 | 1438 | | |
1421 | 1439 | | |
1422 | | - | |
1423 | | - | |
| 1440 | + | |
| 1441 | + | |
1424 | 1442 | | |
1425 | 1443 | | |
1426 | 1444 | | |
| |||
1435 | 1453 | | |
1436 | 1454 | | |
1437 | 1455 | | |
1438 | | - | |
| 1456 | + | |
| 1457 | + | |
1439 | 1458 | | |
1440 | 1459 | | |
1441 | 1460 | | |
| |||
1444 | 1463 | | |
1445 | 1464 | | |
1446 | 1465 | | |
1447 | | - | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
1448 | 1470 | | |
1449 | 1471 | | |
1450 | 1472 | | |
| |||
1490 | 1512 | | |
1491 | 1513 | | |
1492 | 1514 | | |
1493 | | - | |
| 1515 | + | |
| 1516 | + | |
1494 | 1517 | | |
1495 | 1518 | | |
1496 | | - | |
| 1519 | + | |
1497 | 1520 | | |
1498 | 1521 | | |
1499 | 1522 | | |
| |||
1943 | 1966 | | |
1944 | 1967 | | |
1945 | 1968 | | |
1946 | | - | |
1947 | | - | |
| 1969 | + | |
| 1970 | + | |
1948 | 1971 | | |
1949 | 1972 | | |
1950 | 1973 | | |
| |||
2706 | 2729 | | |
2707 | 2730 | | |
2708 | 2731 | | |
| 2732 | + | |
2709 | 2733 | | |
2710 | 2734 | | |
2711 | 2735 | | |
| |||
0 commit comments