@@ -302,8 +302,8 @@ def find_next_statement_start(position)
302302 def on_BEGIN(statements)
303303 lbrace = find_token(LBrace)
304304 rbrace = find_token(RBrace)
305- start_char = find_next_statement_start(lbrace.location.end_char)
306305
306+ start_char = find_next_statement_start(lbrace.location.end_char)
307307 statements.bind(
308308 start_char,
309309 start_char - line_counts[lbrace.location.start_line - 1].start,
@@ -340,8 +340,8 @@ def on_CHAR(value)
340340 def on_END(statements)
341341 lbrace = find_token(LBrace)
342342 rbrace = find_token(RBrace)
343- start_char = find_next_statement_start(lbrace.location.end_char)
344343
344+ start_char = find_next_statement_start(lbrace.location.end_char)
345345 statements.bind(
346346 start_char,
347347 start_char - line_counts[lbrace.location.start_line - 1].start,
@@ -831,8 +831,8 @@ def on_brace_block(block_var, statements)
831831 lbrace = find_token(LBrace)
832832 rbrace = find_token(RBrace)
833833 location = (block_var || lbrace).location
834- start_char = find_next_statement_start(location.end_char)
835834
835+ start_char = find_next_statement_start(location.end_char)
836836 statements.bind(
837837 start_char,
838838 start_char - line_counts[location.start_line - 1].start,
@@ -1329,8 +1329,8 @@ def on_else(statements)
13291329
13301330 node = tokens[index]
13311331 ending = node.value == "end" ? tokens.delete_at(index) : node
1332- start_char = find_next_statement_start(keyword.location.end_char)
13331332
1333+ start_char = find_next_statement_start(keyword.location.end_char)
13341334 statements.bind(
13351335 start_char,
13361336 start_char - line_counts[keyword.location.start_line - 1].start,
@@ -1355,9 +1355,10 @@ def on_elsif(predicate, statements, consequent)
13551355 beginning = find_token(Kw, "elsif")
13561356 ending = consequent || find_token(Kw, "end")
13571357
1358+ start_char = find_next_statement_start(predicate.location.end_char)
13581359 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 ,
13611362 ending.location.start_char,
13621363 ending.location.start_column
13631364 )
@@ -1598,9 +1599,12 @@ def on_for(index, collection, statements)
15981599 tokens.delete(keyword)
15991600 end
16001601
1602+ start_char =
1603+ find_next_statement_start((keyword || collection).location.end_char)
16011604 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,
16041608 ending.location.start_char,
16051609 ending.location.start_column
16061610 )
@@ -1778,9 +1782,10 @@ def on_if(predicate, statements, consequent)
17781782 beginning = find_token(Kw, "if")
17791783 ending = consequent || find_token(Kw, "end")
17801784
1785+ start_char = find_next_statement_start(predicate.location.end_char)
17811786 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 ,
17841789 ending.location.start_char,
17851790 ending.location.start_column
17861791 )
@@ -2024,9 +2029,10 @@ def on_lambda(params, statements)
20242029 closing = find_token(Kw, "end")
20252030 end
20262031
2032+ start_char = find_next_statement_start(opening.location.end_char)
20272033 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 ,
20302036 closing.location.start_char,
20312037 closing.location.start_column
20322038 )
@@ -3456,9 +3462,10 @@ def on_unless(predicate, statements, consequent)
34563462 beginning = find_token(Kw, "unless")
34573463 ending = consequent || find_token(Kw, "end")
34583464
3465+ start_char = find_next_statement_start(predicate.location.end_char)
34593466 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 ,
34623469 ending.location.start_char,
34633470 ending.location.start_column
34643471 )
@@ -3498,9 +3505,10 @@ def on_until(predicate, statements)
34983505 end
34993506
35003507 # Update the Statements location information
3508+ start_char = find_next_statement_start(predicate.location.end_char)
35013509 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 ,
35043512 ending.location.start_char,
35053513 ending.location.start_column
35063514 )
@@ -3633,9 +3641,10 @@ def on_while(predicate, statements)
36333641 end
36343642
36353643 # Update the Statements location information
3644+ start_char = find_next_statement_start(predicate.location.end_char)
36363645 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 ,
36393648 ending.location.start_char,
36403649 ending.location.start_column
36413650 )
0 commit comments