@@ -554,7 +554,7 @@ def visit_call_node(node)
554
554
case node . name
555
555
when :[]
556
556
receiver = visit ( node . receiver )
557
- arguments , block = visit_call_node_arguments ( node . arguments , node . block )
557
+ arguments , block = visit_call_node_arguments ( node . arguments , node . block , trailing_comma? ( node . arguments &. location || node . location , node . closing_loc ) )
558
558
559
559
bounds ( node . location )
560
560
call = on_aref ( receiver , arguments )
@@ -612,7 +612,7 @@ def visit_call_node(node)
612
612
if node . variable_call?
613
613
on_vcall ( message )
614
614
else
615
- arguments , block = visit_call_node_arguments ( node . arguments , node . block )
615
+ arguments , block = visit_call_node_arguments ( node . arguments , node . block , trailing_comma? ( node . arguments &. location || node . location , node . closing_loc || node . location ) )
616
616
call =
617
617
if node . opening_loc . nil? && ( arguments &.any? || block . nil? )
618
618
bounds ( node . location )
@@ -653,7 +653,7 @@ def visit_call_node(node)
653
653
bounds ( node . location )
654
654
on_assign ( on_field ( receiver , call_operator , message ) , value )
655
655
else
656
- arguments , block = visit_call_node_arguments ( node . arguments , node . block )
656
+ arguments , block = visit_call_node_arguments ( node . arguments , node . block , trailing_comma? ( node . arguments &. location || node . location , node . closing_loc || node . location ) )
657
657
call =
658
658
if node . opening_loc . nil?
659
659
bounds ( node . location )
@@ -683,7 +683,7 @@ def visit_call_node(node)
683
683
684
684
# Visit the arguments and block of a call node and return the arguments
685
685
# and block as they should be used.
686
- private def visit_call_node_arguments ( arguments_node , block_node )
686
+ private def visit_call_node_arguments ( arguments_node , block_node , trailing_comma )
687
687
arguments = arguments_node &.arguments || [ ]
688
688
block = block_node
689
689
@@ -698,7 +698,7 @@ def visit_call_node(node)
698
698
elsif arguments . any?
699
699
args = visit_arguments ( arguments )
700
700
701
- if block_node . is_a? ( BlockArgumentNode ) || arguments . last . is_a? ( ForwardingArgumentsNode )
701
+ if block_node . is_a? ( BlockArgumentNode ) || arguments . last . is_a? ( ForwardingArgumentsNode ) || trailing_comma
702
702
args
703
703
else
704
704
bounds ( arguments . first . location )
@@ -2479,7 +2479,7 @@ def visit_string_node(node)
2479
2479
# super(foo)
2480
2480
# ^^^^^^^^^^
2481
2481
def visit_super_node ( node )
2482
- arguments , block = visit_call_node_arguments ( node . arguments , node . block )
2482
+ arguments , block = visit_call_node_arguments ( node . arguments , node . block , trailing_comma? ( node . arguments &. location || node . location , node . rparen_loc || node . location ) )
2483
2483
2484
2484
if !node . lparen_loc . nil?
2485
2485
bounds ( node . lparen_loc )
@@ -2696,6 +2696,11 @@ def result
2696
2696
# Helpers
2697
2697
##########################################################################
2698
2698
2699
+ # Returns true if there is a comma between the two locations.
2700
+ def trailing_comma? ( left , right )
2701
+ source . byteslice ( left . end_offset ...right . start_offset ) . include? ( "," )
2702
+ end
2703
+
2699
2704
# Returns true if there is a semicolon between the two locations.
2700
2705
def void_stmt? ( left , right )
2701
2706
source . byteslice ( left . end_offset ...right . start_offset ) . match? ( /[;#]/ )
0 commit comments