fix(c/cpp) Do not show multiple returns (#32)

This commit is contained in:
danymat
2022-01-07 18:00:10 +01:00
parent ff0e8eaf83
commit 72a82df7f2

View File

@@ -73,16 +73,19 @@ local c_function_extractor = function(node)
res = vim.tbl_deep_extend("keep", res, subres) res = vim.tbl_deep_extend("keep", res, subres)
end end
--- Checks if we have a return statement.
--- If so, return { true } as we don't need to properly know the content of the node for the template
--- @return table?
local has_return_statement = function() local has_return_statement = function()
if res.return_statement then if res.return_statement then
-- function implementation -- function implementation
return res.return_statement return res.return_statement
elseif res.function_declarator and (res.primitive_type or res.type_identifier) then elseif res.function_declarator and (res.primitive_type or res.type_identifier) then
if res.type_identifier then if res.type_identifier then
return res.type_identifier return { true }
elseif res.primitive_type[1] ~= "void" or res.pointer_declarator then elseif res.primitive_type[1] ~= "void" or res.pointer_declarator then
-- function prototype -- function prototype
return res.primitive_type return { true }
end end
end end
-- not found -- not found