@@ -10522,21 +10522,6 @@ def on_sclass(target, bodystmt)
10522
10522
# value
10523
10523
# end
10524
10524
10525
- # stmts_add is a parser event that represents a single statement inside a
10526
- # list of statements within any lexical block. It accepts as arguments the
10527
- # parent stmts node as well as an stmt which can be any expression in
10528
- # Ruby.
10529
- def on_stmts_add ( statements , statement )
10530
- location =
10531
- if statements . body . empty?
10532
- statement . location
10533
- else
10534
- statements . location . to ( statement . location )
10535
- end
10536
-
10537
- Statements . new ( self , body : statements . body << statement , location : location )
10538
- end
10539
-
10540
10525
# Everything that has a block of code inside of it has a list of statements.
10541
10526
# Normally we would just track those as a node that has an array body, but we
10542
10527
# have some special handling in order to handle empty statement lists. They
@@ -10711,6 +10696,21 @@ def attach_comments(start_char, end_char)
10711
10696
end
10712
10697
end
10713
10698
10699
+ # stmts_add is a parser event that represents a single statement inside a
10700
+ # list of statements within any lexical block. It accepts as arguments the
10701
+ # parent stmts node as well as an stmt which can be any expression in
10702
+ # Ruby.
10703
+ def on_stmts_add ( statements , statement )
10704
+ location =
10705
+ if statements . body . empty?
10706
+ statement . location
10707
+ else
10708
+ statements . location . to ( statement . location )
10709
+ end
10710
+
10711
+ Statements . new ( self , body : statements . body << statement , location : location )
10712
+ end
10713
+
10714
10714
# :call-seq:
10715
10715
# on_stmts_new: () -> Statements
10716
10716
def on_stmts_new
@@ -10982,10 +10982,15 @@ def on_string_embexpr(statements)
10982
10982
embexpr_end . location . start_char
10983
10983
)
10984
10984
10985
- StringEmbExpr . new (
10986
- statements : statements ,
10987
- location : embexpr_beg . location . to ( embexpr_end . location )
10988
- )
10985
+ location =
10986
+ Location . new (
10987
+ start_line : embexpr_beg . location . start_line ,
10988
+ start_char : embexpr_beg . location . start_char ,
10989
+ end_line : [ embexpr_end . location . end_line , statements . location . end_line ] . max ,
10990
+ end_char : embexpr_end . location . end_char
10991
+ )
10992
+
10993
+ StringEmbExpr . new ( statements : statements , location : location )
10989
10994
end
10990
10995
10991
10996
# StringLiteral represents a string literal.
@@ -11087,10 +11092,18 @@ def on_string_literal(string)
11087
11092
tstring_beg = find_token ( TStringBeg )
11088
11093
tstring_end = find_token ( TStringEnd )
11089
11094
11095
+ location =
11096
+ Location . new (
11097
+ start_line : tstring_beg . location . start_line ,
11098
+ start_char : tstring_beg . location . start_char ,
11099
+ end_line : [ tstring_end . location . end_line , string . location . end_line ] . max ,
11100
+ end_char : tstring_end . location . end_char
11101
+ )
11102
+
11090
11103
StringLiteral . new (
11091
11104
parts : string . parts ,
11092
11105
quote : tstring_beg . value ,
11093
- location : tstring_beg . location . to ( tstring_end . location )
11106
+ location : location
11094
11107
)
11095
11108
end
11096
11109
end
0 commit comments