@@ -549,7 +549,7 @@ class ARef
549549 # [untyped] the value being indexed
550550 attr_reader :collection
551551
552- # [nil | Args | ArgsAddBlock ] the value being passed within the brackets
552+ # [nil | Args] the value being passed within the brackets
553553 attr_reader :index
554554
555555 # [Location] the location of this node
@@ -582,7 +582,7 @@ def to_json(*opts)
582582 end
583583
584584 # :call-seq:
585- # on_aref: (untyped collection, (nil | Args | ArgsAddBlock ) index) -> ARef
585+ # on_aref: (untyped collection, (nil | Args) index) -> ARef
586586 def on_aref ( collection , index )
587587 find_token ( LBracket )
588588 rbracket = find_token ( RBracket )
@@ -605,7 +605,7 @@ class ARefField
605605 # [untyped] the value being indexed
606606 attr_reader :collection
607607
608- # [nil | ArgsAddBlock ] the value being passed within the brackets
608+ # [nil | Args ] the value being passed within the brackets
609609 attr_reader :index
610610
611611 # [Location] the location of this node
@@ -640,7 +640,7 @@ def to_json(*opts)
640640 # :call-seq:
641641 # on_aref_field: (
642642 # untyped collection,
643- # (nil | ArgsAddBlock ) index
643+ # (nil | Args ) index
644644 # ) -> ARefField
645645 def on_aref_field ( collection , index )
646646 find_token ( LBracket )
@@ -662,15 +662,14 @@ def on_aref_field(collection, index)
662662 #
663663 # method(argument)
664664 #
665- # In the example above, there would be an ArgParen node around the
666- # ArgsAddBlock node that represents the set of arguments being sent to the
667- # method method. The argument child node can be +nil+ if no arguments were
668- # passed, as in:
665+ # In the example above, there would be an ArgParen node around the Args node
666+ # that represents the set of arguments being sent to the method method. The
667+ # argument child node can be +nil+ if no arguments were passed, as in:
669668 #
670669 # method()
671670 #
672671 class ArgParen
673- # [nil | Args | ArgsAddBlock | ArgsForward] the arguments inside the
672+ # [nil | Args | ArgsForward] the arguments inside the
674673 # parentheses
675674 attr_reader :arguments
676675
@@ -697,7 +696,7 @@ def to_json(*opts)
697696
698697 # :call-seq:
699698 # on_arg_paren: (
700- # (nil | Args | ArgsAddBlock | ArgsForward) arguments
699+ # (nil | Args | ArgsForward) arguments
701700 # ) -> ArgParen
702701 def on_arg_paren ( arguments )
703702 lparen = find_token ( LParen )
@@ -767,61 +766,53 @@ def on_args_add(arguments, argument)
767766 end
768767 end
769768
770- # ArgsAddBlock represents a list of arguments and potentially a block
771- # argument. ArgsAddBlock is commonly seen being passed to any method where you
772- # use parentheses (wrapped in an ArgParen node). It’s also used to pass
773- # arguments to the various control-flow keywords like +return+.
769+ # ArgBlock represents using a block operator on an expression.
774770 #
775- # method(argument, &block )
771+ # method(&expression )
776772 #
777- class ArgsAddBlock
778- # [Args] the arguments before the optional block
779- attr_reader :arguments
780-
781- # [nil | untyped] the optional block argument
782- attr_reader :block
773+ class ArgBlock
774+ # [untyped] the expression being turned into a block
775+ attr_reader :value
783776
784777 # [Location] the location of this node
785778 attr_reader :location
786779
787- def initialize ( arguments :, block :, location :)
788- @arguments = arguments
789- @block = block
780+ def initialize ( value :, location :)
781+ @value = value
790782 @location = location
791783 end
792784
793785 def pretty_print ( q )
794786 q . group ( 2 , '(' , ')' ) do
795- q . text ( 'args_add_block' )
796- q . breakable
797- q . pp ( arguments )
787+ q . text ( 'arg_block' )
788+
798789 q . breakable
799- q . pp ( block )
790+ q . pp ( value )
800791 end
801792 end
802793
803794 def to_json ( *opts )
804- {
805- type : :args_add_block ,
806- args : arguments ,
807- block : block ,
808- loc : location
809- } . to_json ( *opts )
795+ { type : :arg_block , value : value , loc : location } . to_json ( *opts )
810796 end
811797 end
812798
813799 # :call-seq:
814800 # on_args_add_block: (
815801 # Args arguments,
816802 # (false | untyped) block
817- # ) -> ArgsAddBlock
803+ # ) -> Args
818804 def on_args_add_block ( arguments , block )
819- ending = block || arguments
805+ return arguments unless block
820806
821- ArgsAddBlock . new (
822- arguments : arguments ,
823- block : block || nil ,
824- location : arguments . location . to ( ending . location )
807+ arg_block =
808+ ArgBlock . new (
809+ value : block ,
810+ location : find_token ( Op , '&' ) . location . to ( block . location )
811+ )
812+
813+ Args . new (
814+ parts : arguments . parts << arg_block ,
815+ location : arguments . location . to ( arg_block . location )
825816 )
826817 end
827818
@@ -1785,7 +1776,7 @@ def on_brace_block(block_var, statements)
17851776 # break 1
17861777 #
17871778 class Break
1788- # [Args | ArgsAddBlock ] the arguments being sent to the keyword
1779+ # [Args] the arguments being sent to the keyword
17891780 attr_reader :arguments
17901781
17911782 # [Location] the location of this node
@@ -1810,12 +1801,12 @@ def to_json(*opts)
18101801 end
18111802
18121803 # :call-seq:
1813- # on_break: (( Args | ArgsAddBlock) arguments) -> Break
1804+ # on_break: (Args arguments) -> Break
18141805 def on_break ( arguments )
18151806 keyword = find_token ( Kw , 'break' )
18161807
18171808 location = keyword . location
1818- location = location . to ( arguments . location ) unless arguments . is_a? ( Args )
1809+ location = location . to ( arguments . location ) if arguments . parts . any?
18191810
18201811 Break . new ( arguments : arguments , location : location )
18211812 end
@@ -2157,7 +2148,7 @@ class Command
21572148 # [Const | Ident] the message being sent to the implicit receiver
21582149 attr_reader :message
21592150
2160- # [Args | ArgsAddBlock ] the arguments being sent with the message
2151+ # [Args] the arguments being sent with the message
21612152 attr_reader :arguments
21622153
21632154 # [Location] the location of this node
@@ -2192,10 +2183,7 @@ def to_json(*opts)
21922183 end
21932184
21942185 # :call-seq:
2195- # on_command: (
2196- # (Const | Ident) message,
2197- # (Args | ArgsAddBlock) arguments
2198- # ) -> Command
2186+ # on_command: ((Const | Ident) message, Args arguments) -> Command
21992187 def on_command ( message , arguments )
22002188 Command . new (
22012189 message : message ,
@@ -2219,7 +2207,7 @@ class CommandCall
22192207 # [Const | Ident | Op] the message being send
22202208 attr_reader :message
22212209
2222- # [Args | ArgsAddBlock ] the arguments going along with the message
2210+ # [Args] the arguments going along with the message
22232211 attr_reader :arguments
22242212
22252213 # [Location] the location of this node
@@ -2268,7 +2256,7 @@ def to_json(*opts)
22682256 # untyped receiver,
22692257 # (:"::" | Op | Period) operator,
22702258 # (Const | Ident | Op) message,
2271- # ( Args | ArgsAddBlock) arguments
2259+ # Args arguments
22722260 # ) -> CommandCall
22732261 def on_command_call ( receiver , operator , message , arguments )
22742262 ending = arguments || message
@@ -5068,7 +5056,7 @@ class MethodAddArg
50685056 # [Call | FCall] the method call
50695057 attr_reader :call
50705058
5071- # [ArgParen | Args | ArgsAddBlock ] the arguments to the method call
5059+ # [ArgParen | Args] the arguments to the method call
50725060 attr_reader :arguments
50735061
50745062 # [Location] the location of this node
@@ -5105,11 +5093,10 @@ def to_json(*opts)
51055093 # :call-seq:
51065094 # on_method_add_arg: (
51075095 # (Call | FCall) call,
5108- # (ArgParen | Args | ArgsAddBlock ) arguments
5096+ # (ArgParen | Args) arguments
51095097 # ) -> MethodAddArg
51105098 def on_method_add_arg ( call , arguments )
51115099 location = call . location
5112-
51135100 location = location . to ( arguments . location ) unless arguments . is_a? ( Args )
51145101
51155102 MethodAddArg . new ( call : call , arguments : arguments , location : location )
@@ -5457,7 +5444,7 @@ def on_mrhs_new_from_args(arguments)
54575444 # next(value)
54585445 #
54595446 class Next
5460- # [Args | ArgsAddBlock ] the arguments passed to the next keyword
5447+ # [Args] the arguments passed to the next keyword
54615448 attr_reader :arguments
54625449
54635450 # [Location] the location of this node
@@ -5483,12 +5470,12 @@ def to_json(*opts)
54835470 end
54845471
54855472 # :call-seq:
5486- # on_next: (( Args | ArgsAddBlock) arguments) -> Next
5473+ # on_next: (Args arguments) -> Next
54875474 def on_next ( arguments )
54885475 keyword = find_token ( Kw , 'next' )
54895476
54905477 location = keyword . location
5491- location = location . to ( arguments . location ) unless arguments . is_a? ( Args )
5478+ location = location . to ( arguments . location ) if arguments . parts . any?
54925479
54935480 Next . new ( arguments : arguments , location : location )
54945481 end
@@ -6751,7 +6738,7 @@ def on_retry
67516738 # return value
67526739 #
67536740 class Return
6754- # [Args | ArgsAddBlock ] the arguments being passed to the keyword
6741+ # [Args] the arguments being passed to the keyword
67556742 attr_reader :arguments
67566743
67576744 # [Location] the location of this node
@@ -6777,7 +6764,7 @@ def to_json(*opts)
67776764 end
67786765
67796766 # :call-seq:
6780- # on_return: (( Args | ArgsAddBlock) arguments) -> Return
6767+ # on_return: (Args arguments) -> Return
67816768 def on_return ( arguments )
67826769 keyword = find_token ( Kw , 'return' )
67836770
@@ -7294,7 +7281,7 @@ def on_string_literal(string)
72947281 # super(value)
72957282 #
72967283 class Super
7297- # [ArgParen | Args | ArgsAddBlock ] the arguments to the keyword
7284+ # [ArgParen | Args] the arguments to the keyword
72987285 attr_reader :arguments
72997286
73007287 # [Location] the location of this node
@@ -7320,7 +7307,7 @@ def to_json(*opts)
73207307 end
73217308
73227309 # :call-seq:
7323- # on_super: ((ArgParen | Args | ArgsAddBlock ) arguments) -> Super
7310+ # on_super: ((ArgParen | Args) arguments) -> Super
73247311 def on_super ( arguments )
73257312 keyword = find_token ( Kw , 'super' )
73267313
@@ -8899,7 +8886,7 @@ def on_xstring_literal(xstring)
88998886 # yield value
89008887 #
89018888 class Yield
8902- # [ArgsAddBlock | Paren] the arguments passed to the yield
8889+ # [Args | Paren] the arguments passed to the yield
89038890 attr_reader :arguments
89048891
89058892 # [Location] the location of this node
@@ -8925,7 +8912,7 @@ def to_json(*opts)
89258912 end
89268913
89278914 # :call-seq:
8928- # on_yield: ((ArgsAddBlock | Paren) arguments) -> Yield
8915+ # on_yield: ((Args | Paren) arguments) -> Yield
89298916 def on_yield ( arguments )
89308917 keyword = find_token ( Kw , 'yield' )
89318918
0 commit comments