From 48f8f4dd6504f441d96110ca4b13eb196b0925eb Mon Sep 17 00:00:00 2001 From: Daniel Mathiot Date: Thu, 26 Aug 2021 11:03:41 +0200 Subject: [PATCH] (lua) Full specs for type annotations --- lua/neogen/configurations/lua.lua | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lua/neogen/configurations/lua.lua b/lua/neogen/configurations/lua.lua index 31649ce..1ec443e 100644 --- a/lua/neogen/configurations/lua.lua +++ b/lua/neogen/configurations/lua.lua @@ -21,13 +21,14 @@ local common_function_extractor = function(node) } end -local get_identifier_from_var = function (node) +local extract_from_var = function (node) local tree = { { retrieve = "first", node_type = "variable_declarator", subtree = { { retrieve = "first", node_type = "identifier", extract = true }, + { retrieve = "first", node_type = "field_expression", extract = true }, }, }, } @@ -66,7 +67,7 @@ return { ["local_variable_declaration|variable_declaration"] = { ["0"] = { extract = function(node) - local res = get_identifier_from_var(node) + local res = extract_from_var(node) return { class_name = res.identifier, } @@ -78,10 +79,16 @@ return { ["local_variable_declaration|variable_declaration"] = { ["0"] = { extract = function(node) - local res = get_identifier_from_var(node) - return { - type = res.identifier, - } + result = {} + local res = extract_from_var(node) + result.type = {} + if res.identifier then + vim.list_extend(result.type, res.identifier) + end + if res.field_expression then + vim.list_extend(result.type, res.field_expression) + end + return result end, }, },