mirror of
https://github.com/neovim/neovim.git
synced 2025-10-02 16:08:36 +00:00
tree-sitter: use "range" instead of "point_range" consistently in lua API
This commit is contained in:
@@ -62,8 +62,8 @@ static struct luaL_Reg node_meta[] = {
|
|||||||
{ "named_child_count", node_named_child_count },
|
{ "named_child_count", node_named_child_count },
|
||||||
{ "child", node_child },
|
{ "child", node_child },
|
||||||
{ "named_child", node_named_child },
|
{ "named_child", node_named_child },
|
||||||
{ "descendant_for_point_range", node_descendant_for_point_range },
|
{ "descendant_for_range", node_descendant_for_range },
|
||||||
{ "named_descendant_for_point_range", node_named_descendant_for_point_range },
|
{ "named_descendant_for_range", node_named_descendant_for_range },
|
||||||
{ "parent", node_parent },
|
{ "parent", node_parent },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
@@ -587,7 +587,7 @@ static int node_named_child(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int node_descendant_for_point_range(lua_State *L)
|
static int node_descendant_for_range(lua_State *L)
|
||||||
{
|
{
|
||||||
TSNode node;
|
TSNode node;
|
||||||
if (!node_check(L, &node)) {
|
if (!node_check(L, &node)) {
|
||||||
@@ -604,7 +604,7 @@ static int node_descendant_for_point_range(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int node_named_descendant_for_point_range(lua_State *L)
|
static int node_named_descendant_for_range(lua_State *L)
|
||||||
{
|
{
|
||||||
TSNode node;
|
TSNode node;
|
||||||
if (!node_check(L, &node)) {
|
if (!node_check(L, &node)) {
|
||||||
|
@@ -59,7 +59,7 @@ describe('tree-sitter API', function()
|
|||||||
eq("<node function_definition>", exec_lua("return tostring(child)"))
|
eq("<node function_definition>", exec_lua("return tostring(child)"))
|
||||||
eq({0,0,2,1}, exec_lua("return {child:range()}"))
|
eq({0,0,2,1}, exec_lua("return {child:range()}"))
|
||||||
|
|
||||||
exec_lua("descendant = root:descendant_for_point_range(1,2,1,12)")
|
exec_lua("descendant = root:descendant_for_range(1,2,1,12)")
|
||||||
eq("<node declaration>", exec_lua("return tostring(descendant)"))
|
eq("<node declaration>", exec_lua("return tostring(descendant)"))
|
||||||
eq({1,2,1,12}, exec_lua("return {descendant:range()}"))
|
eq({1,2,1,12}, exec_lua("return {descendant:range()}"))
|
||||||
eq("(declaration (primitive_type) (init_declarator (identifier) (number_literal)))", exec_lua("return descendant:sexpr()"))
|
eq("(declaration (primitive_type) (init_declarator (identifier) (number_literal)))", exec_lua("return descendant:sexpr()"))
|
||||||
@@ -68,7 +68,7 @@ describe('tree-sitter API', function()
|
|||||||
exec_lua([[
|
exec_lua([[
|
||||||
tree2 = parser:parse()
|
tree2 = parser:parse()
|
||||||
root2 = tree2:root()
|
root2 = tree2:root()
|
||||||
descendant2 = root2:descendant_for_point_range(1,2,1,13)
|
descendant2 = root2:descendant_for_range(1,2,1,13)
|
||||||
]])
|
]])
|
||||||
eq(false, exec_lua("return tree2 == tree1"))
|
eq(false, exec_lua("return tree2 == tree1"))
|
||||||
eq("<node declaration>", exec_lua("return tostring(descendant2)"))
|
eq("<node declaration>", exec_lua("return tostring(descendant2)"))
|
||||||
|
Reference in New Issue
Block a user