(lua) Recursive find of function instead of fixed
This commit is contained in:
@@ -1,14 +1,20 @@
|
|||||||
local common_function_extractor = function(node)
|
local common_function_extractor = function(node)
|
||||||
local tree = {
|
local tree = {
|
||||||
{
|
{
|
||||||
retrieve = "first",
|
retrieve = "first_recursive",
|
||||||
node_type = "parameters",
|
node_type = "function_definition",
|
||||||
subtree = {
|
subtree = {
|
||||||
{ retrieve = "all", node_type = "identifier", extract = true },
|
{
|
||||||
{ retrieve = "all", node_type = "spread", extract = true },
|
retrieve = "first",
|
||||||
|
node_type = "parameters",
|
||||||
|
subtree = {
|
||||||
|
{ retrieve = "all", node_type = "identifier", extract = true },
|
||||||
|
{ retrieve = "all", node_type = "spread", extract = true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ retrieve = "first", node_type = "return_statement", extract = true },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ retrieve = "first", node_type = "return_statement", extract = true },
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local nodes = neogen.utilities.nodes:matching_nodes_from(node, tree)
|
local nodes = neogen.utilities.nodes:matching_nodes_from(node, tree)
|
||||||
@@ -52,14 +58,12 @@ return {
|
|||||||
func = {
|
func = {
|
||||||
-- When the function is inside one of those
|
-- When the function is inside one of those
|
||||||
["local_variable_declaration|field|variable_declaration"] = {
|
["local_variable_declaration|field|variable_declaration"] = {
|
||||||
["2"] = {
|
["0"] = {
|
||||||
match = "function_definition",
|
|
||||||
|
|
||||||
extract = common_function_extractor,
|
extract = common_function_extractor,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
-- When the function is in the root tree
|
-- When the function is in the root tree
|
||||||
["function_definition|function|local_function"] = {
|
["function|local_function"] = {
|
||||||
["0"] = {
|
["0"] = {
|
||||||
|
|
||||||
extract = common_function_extractor,
|
extract = common_function_extractor,
|
||||||
|
|||||||
Reference in New Issue
Block a user