You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: config.yml
+195-3Lines changed: 195 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -992,8 +992,19 @@ nodes:
992
992
- name: constant
993
993
type: node?
994
994
kind:
995
-
- ConstantReadNode
996
995
- ConstantPathNode
996
+
- ConstantReadNode
997
+
comment: |
998
+
Represents the optional constant preceding the Array
999
+
1000
+
foo in Bar[]
1001
+
^^^
1002
+
1003
+
foo in Bar[1, 2, 3]
1004
+
^^^
1005
+
1006
+
foo in Bar::Baz[1, 2, 3]
1007
+
^^^^^^^^
997
1008
- name: requireds
998
1009
type: node[]
999
1010
kind: pattern expression
@@ -2409,23 +2420,68 @@ nodes:
2409
2420
- name: constant
2410
2421
type: node?
2411
2422
kind:
2412
-
- ConstantReadNode
2413
2423
- ConstantPathNode
2424
+
- ConstantReadNode
2425
+
comment: |
2426
+
Represents the optional constant preceding the pattern
2427
+
2428
+
foo in Foo(*bar, baz, *qux)
2429
+
^^^
2414
2430
- name: left
2415
2431
type: node
2416
2432
kind: SplatNode
2433
+
comment: |
2434
+
Represents the first wildcard node in the pattern.
2435
+
2436
+
foo in *bar, baz, *qux
2437
+
^^^^
2438
+
2439
+
foo in Foo(*bar, baz, *qux)
2440
+
^^^^
2417
2441
- name: requireds
2418
2442
type: node[]
2419
2443
kind: pattern expression
2444
+
comment: |
2445
+
Represents the nodes in between the wildcards.
2446
+
2447
+
foo in *bar, baz, *qux
2448
+
^^^
2449
+
2450
+
foo in Foo(*bar, baz, 1, *qux)
2451
+
^^^^^^
2420
2452
- name: right
2421
2453
type: node
2422
2454
kind:
2423
2455
- SplatNode
2424
2456
- on error: MissingNode
2457
+
comment: |
2458
+
Represents the second wildcard node in the pattern.
2459
+
2460
+
foo in *bar, baz, *qux
2461
+
^^^^
2462
+
2463
+
foo in Foo(*bar, baz, *qux)
2464
+
^^^^
2425
2465
- name: opening_loc
2426
2466
type: location?
2467
+
comment: |
2468
+
The location of the opening brace.
2469
+
2470
+
foo in [*bar, baz, *qux]
2471
+
^
2472
+
2473
+
foo in Foo(*bar, baz, *qux)
2474
+
^
2427
2475
- name: closing_loc
2428
2476
type: location?
2477
+
comment: |
2478
+
The location of the closing brace.
2479
+
2480
+
foo in [*bar, baz, *qux]
2481
+
^
2482
+
2483
+
foo in Foo(*bar, baz, *qux)
2484
+
^
2429
2485
comment: |
2430
2486
Represents a find pattern in pattern matching.
2431
2487
@@ -2437,6 +2493,9 @@ nodes:
2437
2493
2438
2494
foo in Foo(*bar, baz, *qux)
2439
2495
^^^^^^^^^^^^^^^^^^^^
2496
+
2497
+
foo => *bar, baz, *qux
2498
+
^^^^^^^^^^^^^^^
2440
2499
- name: FlipFlopNode
2441
2500
flags: RangeFlags
2442
2501
fields:
@@ -2714,20 +2773,60 @@ nodes:
2714
2773
- name: constant
2715
2774
type: node?
2716
2775
kind:
2717
-
- ConstantReadNode
2718
2776
- ConstantPathNode
2777
+
- ConstantReadNode
2778
+
comment: |
2779
+
Represents the optional constant preceding the Hash.
2780
+
2781
+
foo => Bar[a: 1, b: 2]
2782
+
^^^
2783
+
2784
+
foo => Bar::Baz[a: 1, b: 2]
2785
+
^^^^^^^^
2719
2786
- name: elements
2720
2787
type: node[]
2721
2788
kind: AssocNode
2789
+
comment: |
2790
+
Represents the explicit named hash keys and values.
2791
+
2792
+
foo => { a: 1, b:, ** }
2793
+
^^^^^^^^
2722
2794
- name: rest
2723
2795
type: node?
2724
2796
kind:
2725
2797
- AssocSplatNode
2726
2798
- NoKeywordsParameterNode
2799
+
comment: |
2800
+
Represents the rest of the Hash keys and values. This can be named, unnamed, or explicitly forbidden via `**nil`, this last one results in a `NoKeywordsParameterNode`.
2801
+
2802
+
foo => { a: 1, b:, **c }
2803
+
^^^
2804
+
2805
+
foo => { a: 1, b:, ** }
2806
+
^^
2807
+
2808
+
foo => { a: 1, b:, **nil }
2809
+
^^^^^
2727
2810
- name: opening_loc
2728
2811
type: location?
2812
+
comment: |
2813
+
The location of the opening brace.
2814
+
2815
+
foo => { a: 1 }
2816
+
^
2817
+
2818
+
foo => Bar[a: 1]
2819
+
^
2729
2820
- name: closing_loc
2730
2821
type: location?
2822
+
comment: |
2823
+
The location of the closing brace.
2824
+
2825
+
foo => { a: 1 }
2826
+
^
2827
+
2828
+
foo => Bar[a: 1]
2829
+
^
2731
2830
comment: |
2732
2831
Represents a hash pattern in pattern matching.
2733
2832
@@ -2736,6 +2835,12 @@ nodes:
2736
2835
2737
2836
foo => { a: 1, b: 2, **c }
2738
2837
^^^^^^^^^^^^^^^^^^^
2838
+
2839
+
foo => Bar[a: 1, b: 2]
2840
+
^^^^^^^^^^^^^^^
2841
+
2842
+
foo in { a: 1, b: 2 }
2843
+
^^^^^^^^^^^^^^
2739
2844
- name: IfNode
2740
2845
fields:
2741
2846
- name: if_keyword_loc
@@ -3388,6 +3493,9 @@ nodes:
3388
3493
3389
3494
foo, bar = baz
3390
3495
^^^ ^^^
3496
+
3497
+
foo => baz
3498
+
^^^
3391
3499
- name: LocalVariableWriteNode
3392
3500
fields:
3393
3501
- name: name
@@ -3478,11 +3586,65 @@ nodes:
3478
3586
- name: value
3479
3587
type: node
3480
3588
kind: non-void expression
3589
+
comment: |
3590
+
Represents the left-hand side of the operator.
3591
+
3592
+
foo => bar
3593
+
^^^
3481
3594
- name: pattern
3482
3595
type: node
3483
3596
kind: pattern expression
3597
+
comment: |
3598
+
Represents the right-hand side of the operator. The type of the node depends on the expression.
3599
+
3600
+
Anything that looks like a local variable name (including `_`) will result in a `LocalVariableTargetNode`.
3601
+
3602
+
foo => a # This is equivalent to writing `a = foo`
3603
+
^
3604
+
3605
+
Using an explicit `Array` or combining expressions with `,` will result in a `ArrayPatternNode`. This can be preceded by a constant.
3606
+
3607
+
foo => [a]
3608
+
^^^
3609
+
3610
+
foo => a, b
3611
+
^^^^
3612
+
3613
+
foo => Bar[a, b]
3614
+
^^^^^^^^^
3615
+
3616
+
If the array pattern contains at least two wildcard matches, a `FindPatternNode` is created instead.
3617
+
3618
+
foo => *, 1, *a
3619
+
^^^^^
3620
+
3621
+
Using an explicit `Hash` or a constant with square brackets and hash keys in the square brackets will result in a `HashPatternNode`.
3622
+
3623
+
foo => { a: 1, b: }
3624
+
3625
+
foo => Bar[a: 1, b:]
3626
+
3627
+
foo => Bar[**]
3628
+
3629
+
To use any variable that needs run time evaluation, pinning is required. This results in a `PinnedVariableNode`
3630
+
3631
+
foo => ^a
3632
+
^^
3633
+
3634
+
Similar, any expression can be used with pinning. This results in a `PinnedExpressionNode`.
3635
+
3636
+
foo => ^(a + 1)
3637
+
3638
+
Anything else will result in the regular node for that expression, for example a `ConstantReadNode`.
3639
+
3640
+
foo => CONST
3484
3641
- name: operator_loc
3485
3642
type: location
3643
+
comment: |
3644
+
The location of the operator.
3645
+
3646
+
foo => bar
3647
+
^^
3486
3648
comment: |
3487
3649
Represents the use of the `=>` operator.
3488
3650
@@ -3912,12 +4074,32 @@ nodes:
3912
4074
- name: expression
3913
4075
type: node
3914
4076
kind: non-void expression
4077
+
comment: |
4078
+
The expression used in the pinned expression
4079
+
4080
+
foo in ^(bar)
4081
+
^^^
3915
4082
- name: operator_loc
3916
4083
type: location
4084
+
comment: |
4085
+
The location of the `^` operator
4086
+
4087
+
foo in ^(bar)
4088
+
^
3917
4089
- name: lparen_loc
3918
4090
type: location
4091
+
comment: |
4092
+
The location of the opening parenthesis.
4093
+
4094
+
foo in ^(bar)
4095
+
^
3919
4096
- name: rparen_loc
3920
4097
type: location
4098
+
comment: |
4099
+
The location of the closing parenthesis.
4100
+
4101
+
foo in ^(bar)
4102
+
^
3921
4103
comment: |
3922
4104
Represents the use of the `^` operator for pinning an expression in a pattern matching expression.
3923
4105
@@ -3936,8 +4118,18 @@ nodes:
3936
4118
- NumberedReferenceReadNode # foo in ^$1
3937
4119
- ItLocalVariableReadNode # proc { 1 in ^it }
3938
4120
- on error: MissingNode # foo in ^Bar
4121
+
comment: |
4122
+
The variable used in the pinned expression
4123
+
4124
+
foo in ^bar
4125
+
^^^
3939
4126
- name: operator_loc
3940
4127
type: location
4128
+
comment: |
4129
+
The location of the `^` operator
4130
+
4131
+
foo in ^bar
4132
+
^
3941
4133
comment: |
3942
4134
Represents the use of the `^` operator for pinning a variable in a pattern matching expression.
0 commit comments