summaryrefslogtreecommitdiff
path: root/script/vm/function.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-06-28 21:06:53 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-06-28 21:06:53 +0800
commit08b9dd387a9b912c68749018b7dfe3c1df7094d5 (patch)
tree46c81598c214b10643f3d8083bb7b64b9e2ba21c /script/vm/function.lua
parent9ad317f2a1eb8dc5715103c8c62e0fcff88a482b (diff)
downloadlua-language-server-08b9dd387a9b912c68749018b7dfe3c1df7094d5.zip
cleanup
Diffstat (limited to 'script/vm/function.lua')
-rw-r--r--script/vm/function.lua22
1 files changed, 15 insertions, 7 deletions
diff --git a/script/vm/function.lua b/script/vm/function.lua
index d94e7561..5723fbc6 100644
--- a/script/vm/function.lua
+++ b/script/vm/function.lua
@@ -18,7 +18,7 @@ end
---@param func parser.object
---@return integer min
----@return integer max
+---@return number max
function vm.countParamsOfFunction(func)
local min = 0
local max = 0
@@ -60,7 +60,7 @@ end
---@param node vm.node
---@return integer min
----@return integer max
+---@return number max
function vm.countParamsOfNode(node)
local min, max
for n in node:eachObject() do
@@ -82,15 +82,21 @@ end
---@param func parser.object
---@param mark? table
---@return integer min
----@return integer max
+---@return number max
function vm.countReturnsOfFunction(func, mark)
if func.type == 'function' then
- local min, max
+ ---@type integer?
+ local min
+ ---@type number?
+ local max
local hasDocReturn
if func.bindDocs then
local lastReturn
local n = 0
- local dmin, dmax
+ ---@type integer?
+ local dmin
+ ---@type number?
+ local dmax
for _, doc in ipairs(func.bindDocs) do
if doc.type == 'doc.return' then
hasDocReturn = true
@@ -139,10 +145,12 @@ end
---@param func parser.object
---@param mark? table
---@return integer min
----@return integer max
+---@return number max
function vm.countReturnsOfCall(func, args, mark)
local funcs = vm.getMatchedFunctions(func, args)
+ ---@type integer?
local min
+ ---@type number?
local max
for _, f in ipairs(funcs) do
local rmin, rmax = vm.countReturnsOfFunction(f, mark)
@@ -159,7 +167,7 @@ end
---@param list parser.object[]?
---@param mark? table
---@return integer min
----@return integer max
+---@return number max
function vm.countList(list, mark)
if not list then
return 0, 0