@@ -302,8 +302,8 @@ def find_next_statement_start(position)
302
302
def on_BEGIN ( statements )
303
303
lbrace = find_token ( LBrace )
304
304
rbrace = find_token ( RBrace )
305
- start_char = find_next_statement_start ( lbrace . location . end_char )
306
305
306
+ start_char = find_next_statement_start ( lbrace . location . end_char )
307
307
statements . bind (
308
308
start_char ,
309
309
start_char - line_counts [ lbrace . location . start_line - 1 ] . start ,
@@ -340,8 +340,8 @@ def on_CHAR(value)
340
340
def on_END ( statements )
341
341
lbrace = find_token ( LBrace )
342
342
rbrace = find_token ( RBrace )
343
- start_char = find_next_statement_start ( lbrace . location . end_char )
344
343
344
+ start_char = find_next_statement_start ( lbrace . location . end_char )
345
345
statements . bind (
346
346
start_char ,
347
347
start_char - line_counts [ lbrace . location . start_line - 1 ] . start ,
@@ -831,8 +831,8 @@ def on_brace_block(block_var, statements)
831
831
lbrace = find_token ( LBrace )
832
832
rbrace = find_token ( RBrace )
833
833
location = ( block_var || lbrace ) . location
834
- start_char = find_next_statement_start ( location . end_char )
835
834
835
+ start_char = find_next_statement_start ( location . end_char )
836
836
statements . bind (
837
837
start_char ,
838
838
start_char - line_counts [ location . start_line - 1 ] . start ,
@@ -1329,8 +1329,8 @@ def on_else(statements)
1329
1329
1330
1330
node = tokens [ index ]
1331
1331
ending = node . value == "end" ? tokens . delete_at ( index ) : node
1332
- start_char = find_next_statement_start ( keyword . location . end_char )
1333
1332
1333
+ start_char = find_next_statement_start ( keyword . location . end_char )
1334
1334
statements . bind (
1335
1335
start_char ,
1336
1336
start_char - line_counts [ keyword . location . start_line - 1 ] . start ,
@@ -1355,9 +1355,10 @@ def on_elsif(predicate, statements, consequent)
1355
1355
beginning = find_token ( Kw , "elsif" )
1356
1356
ending = consequent || find_token ( Kw , "end" )
1357
1357
1358
+ start_char = find_next_statement_start ( predicate . location . end_char )
1358
1359
statements . bind (
1359
- predicate . location . end_char ,
1360
- predicate . location . end_column ,
1360
+ start_char ,
1361
+ start_char - line_counts [ predicate . location . start_line - 1 ] . start ,
1361
1362
ending . location . start_char ,
1362
1363
ending . location . start_column
1363
1364
)
@@ -1598,9 +1599,12 @@ def on_for(index, collection, statements)
1598
1599
tokens . delete ( keyword )
1599
1600
end
1600
1601
1602
+ start_char =
1603
+ find_next_statement_start ( ( keyword || collection ) . location . end_char )
1601
1604
statements . bind (
1602
- ( keyword || collection ) . location . end_char ,
1603
- ( keyword || collection ) . location . end_column ,
1605
+ start_char ,
1606
+ start_char -
1607
+ line_counts [ ( keyword || collection ) . location . end_line - 1 ] . start ,
1604
1608
ending . location . start_char ,
1605
1609
ending . location . start_column
1606
1610
)
@@ -1778,9 +1782,10 @@ def on_if(predicate, statements, consequent)
1778
1782
beginning = find_token ( Kw , "if" )
1779
1783
ending = consequent || find_token ( Kw , "end" )
1780
1784
1785
+ start_char = find_next_statement_start ( predicate . location . end_char )
1781
1786
statements . bind (
1782
- predicate . location . end_char ,
1783
- predicate . location . end_column ,
1787
+ start_char ,
1788
+ start_char - line_counts [ predicate . location . end_line - 1 ] . start ,
1784
1789
ending . location . start_char ,
1785
1790
ending . location . start_column
1786
1791
)
@@ -2024,9 +2029,10 @@ def on_lambda(params, statements)
2024
2029
closing = find_token ( Kw , "end" )
2025
2030
end
2026
2031
2032
+ start_char = find_next_statement_start ( opening . location . end_char )
2027
2033
statements . bind (
2028
- opening . location . end_char ,
2029
- opening . location . end_column ,
2034
+ start_char ,
2035
+ start_char - line_counts [ opening . location . end_line - 1 ] . start ,
2030
2036
closing . location . start_char ,
2031
2037
closing . location . start_column
2032
2038
)
@@ -3456,9 +3462,10 @@ def on_unless(predicate, statements, consequent)
3456
3462
beginning = find_token ( Kw , "unless" )
3457
3463
ending = consequent || find_token ( Kw , "end" )
3458
3464
3465
+ start_char = find_next_statement_start ( predicate . location . end_char )
3459
3466
statements . bind (
3460
- predicate . location . end_char ,
3461
- predicate . location . end_column ,
3467
+ start_char ,
3468
+ start_char - line_counts [ predicate . location . end_line - 1 ] . start ,
3462
3469
ending . location . start_char ,
3463
3470
ending . location . start_column
3464
3471
)
@@ -3498,9 +3505,10 @@ def on_until(predicate, statements)
3498
3505
end
3499
3506
3500
3507
# Update the Statements location information
3508
+ start_char = find_next_statement_start ( predicate . location . end_char )
3501
3509
statements . bind (
3502
- predicate . location . end_char ,
3503
- predicate . location . end_column ,
3510
+ start_char ,
3511
+ start_char - line_counts [ predicate . location . end_line - 1 ] . start ,
3504
3512
ending . location . start_char ,
3505
3513
ending . location . start_column
3506
3514
)
@@ -3633,9 +3641,10 @@ def on_while(predicate, statements)
3633
3641
end
3634
3642
3635
3643
# Update the Statements location information
3644
+ start_char = find_next_statement_start ( predicate . location . end_char )
3636
3645
statements . bind (
3637
- predicate . location . end_char ,
3638
- predicate . location . end_column ,
3646
+ start_char ,
3647
+ start_char - line_counts [ predicate . location . end_line - 1 ] . start ,
3639
3648
ending . location . start_char ,
3640
3649
ending . location . start_column
3641
3650
)
0 commit comments