@@ -738,35 +738,72 @@ def visit_constant_path_node(node)
738
738
# Foo::Foo, Bar::Bar = 1
739
739
# ^^^^^^^^ ^^^^^^^^
740
740
def visit_constant_path_write_node ( node )
741
- parent = visit ( node . target . parent )
742
-
743
- bounds ( node . target . child . location )
744
- child = on_const ( node . target . child . name . to_s )
745
-
746
- bounds ( node . target . location )
747
- target = on_const_path_field ( parent , child )
741
+ target = visit_constant_path_write_node_target ( node . target )
748
742
value = visit ( node . value )
749
743
750
744
bounds ( node . location )
751
745
on_assign ( target , value )
752
746
end
753
747
748
+ # Visit a constant path that is part of a write node.
749
+ private def visit_constant_path_write_node_target ( node )
750
+ if node . parent . nil?
751
+ bounds ( node . child . location )
752
+ child = on_const ( node . child . name . to_s )
753
+
754
+ bounds ( node . location )
755
+ on_top_const_field ( child )
756
+ else
757
+ parent = visit ( node . parent )
758
+
759
+ bounds ( node . child . location )
760
+ child = on_const ( node . child . name . to_s )
761
+
762
+ bounds ( node . location )
763
+ on_const_path_field ( parent , child )
764
+ end
765
+ end
766
+
754
767
# Foo::Bar += baz
755
768
# ^^^^^^^^^^^^^^^
756
769
def visit_constant_path_operator_write_node ( node )
757
- raise NoMethodError , __method__
770
+ target = visit_constant_path_write_node_target ( node . target )
771
+ value = visit ( node . value )
772
+
773
+ bounds ( node . operator_loc )
774
+ operator = on_op ( "#{ node . operator } =" )
775
+ value = visit ( node . value )
776
+
777
+ bounds ( node . location )
778
+ on_opassign ( target , operator , value )
758
779
end
759
780
760
781
# Foo::Bar &&= baz
761
782
# ^^^^^^^^^^^^^^^^
762
783
def visit_constant_path_and_write_node ( node )
763
- raise NoMethodError , __method__
784
+ target = visit_constant_path_write_node_target ( node . target )
785
+ value = visit ( node . value )
786
+
787
+ bounds ( node . operator_loc )
788
+ operator = on_op ( "&&=" )
789
+ value = visit ( node . value )
790
+
791
+ bounds ( node . location )
792
+ on_opassign ( target , operator , value )
764
793
end
765
794
766
795
# Foo::Bar ||= baz
767
796
# ^^^^^^^^^^^^^^^^
768
797
def visit_constant_path_or_write_node ( node )
769
- raise NoMethodError , __method__
798
+ target = visit_constant_path_write_node_target ( node . target )
799
+ value = visit ( node . value )
800
+
801
+ bounds ( node . operator_loc )
802
+ operator = on_op ( "||=" )
803
+ value = visit ( node . value )
804
+
805
+ bounds ( node . location )
806
+ on_opassign ( target , operator , value )
770
807
end
771
808
772
809
# Foo::Bar, = baz
@@ -925,7 +962,8 @@ def visit_forwarding_arguments_node(node)
925
962
# def foo(...); end
926
963
# ^^^
927
964
def visit_forwarding_parameter_node ( node )
928
- raise NoMethodError , __method__
965
+ bounds ( node . location )
966
+ on_args_forward
929
967
end
930
968
931
969
# super
@@ -1522,7 +1560,7 @@ def visit_parameters_node(node)
1522
1560
posts = visit_all ( node . posts ) if node . posts . any?
1523
1561
keywords = visit_all ( node . keywords ) if node . keywords . any?
1524
1562
keyword_rest = visit ( node . keyword_rest )
1525
- block = visit ( node . block )
1563
+ block = node . keyword_rest . is_a? ( ForwardingParameterNode ) ? :& : visit ( node . block )
1526
1564
1527
1565
bounds ( node . location )
1528
1566
on_params ( requireds , optionals , rest , posts , keywords , keyword_rest , block )
0 commit comments