Implement FLIP2 NODE locations
This commit is contained in:
parent
61c4907458
commit
24653430cd
Notes:
git
2025-01-04 11:27:58 +00:00
4
ast.c
4
ast.c
@ -820,6 +820,10 @@ node_locations(VALUE ast_value, const NODE *node)
|
|||||||
location_new(nd_code_loc(node)),
|
location_new(nd_code_loc(node)),
|
||||||
location_new(&RNODE_EVSTR(node)->opening_loc),
|
location_new(&RNODE_EVSTR(node)->opening_loc),
|
||||||
location_new(&RNODE_EVSTR(node)->closing_loc));
|
location_new(&RNODE_EVSTR(node)->closing_loc));
|
||||||
|
case NODE_FLIP2:
|
||||||
|
return rb_ary_new_from_args(2,
|
||||||
|
location_new(nd_code_loc(node)),
|
||||||
|
location_new(&RNODE_FLIP2(node)->operator_loc));
|
||||||
case NODE_LAMBDA:
|
case NODE_LAMBDA:
|
||||||
return rb_ary_new_from_args(4,
|
return rb_ary_new_from_args(4,
|
||||||
location_new(nd_code_loc(node)),
|
location_new(nd_code_loc(node)),
|
||||||
|
@ -1412,6 +1412,14 @@ dummy
|
|||||||
assert_locations(node.children[-1].children[1].locations, [[1, 0, 1, 5], [1, 1, 1, 2], nil])
|
assert_locations(node.children[-1].children[1].locations, [[1, 0, 1, 5], [1, 1, 1, 2], nil])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_flip2_locations
|
||||||
|
node = ast_parse("if 'a'..'z'; foo; end")
|
||||||
|
assert_locations(node.children[-1].children[0].locations, [[1, 3, 1, 11], [1, 6, 1, 8]])
|
||||||
|
|
||||||
|
node = ast_parse('if 1..5; foo; end')
|
||||||
|
assert_locations(node.children[-1].children[0].locations, [[1, 3, 1, 7], [1, 4, 1, 6]])
|
||||||
|
end
|
||||||
|
|
||||||
def test_lambda_locations
|
def test_lambda_locations
|
||||||
node = ast_parse("-> (a, b) { foo }")
|
node = ast_parse("-> (a, b) { foo }")
|
||||||
assert_locations(node.children[-1].locations, [[1, 0, 1, 17], [1, 0, 1, 2], [1, 10, 1, 11], [1, 16, 1, 17]])
|
assert_locations(node.children[-1].locations, [[1, 0, 1, 17], [1, 0, 1, 2], [1, 10, 1, 11], [1, 16, 1, 17]])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user