diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-06-17 15:51:03 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-06-17 15:51:03 +0800 |
commit | 05b8cf4e0f92798c08aceb74891de5fb025ae1fb (patch) | |
tree | da88629bee5a0e964ad8fc559df539559fbcccb9 /script/core | |
parent | 6a9e89ad342ec169842ea7a225d0e149155b4c46 (diff) | |
download | lua-language-server-05b8cf4e0f92798c08aceb74891de5fb025ae1fb.zip |
fix #1223 count returns of `doc.type.function`
Diffstat (limited to 'script/core')
-rw-r--r-- | script/core/diagnostics/missing-parameter.lua | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/script/core/diagnostics/missing-parameter.lua b/script/core/diagnostics/missing-parameter.lua index a475673f..9844046f 100644 --- a/script/core/diagnostics/missing-parameter.lua +++ b/script/core/diagnostics/missing-parameter.lua @@ -5,7 +5,7 @@ local lang = require 'language' ---@param source parser.object ---@return integer -local function countReturns(source) +local function countReturnsOfFunction(source) local n = 0 local docs = source.bindDocs @@ -33,14 +33,25 @@ local function countReturns(source) return n end +---@param source parser.object +---@return integer +local function countReturnsOfDocFunction(source) + return #source.returns +end + local function countMaxReturns(source) local hasFounded local n = 0 for _, def in ipairs(vm.getDefs(source)) do - if def.type == 'doc.type.function' - or def.type == 'function' then + if def.type == 'function' then + hasFounded = true + local rets = countReturnsOfFunction(def) + if rets > n then + n = rets + end + elseif def.type == 'doc.type.function' then hasFounded = true - local rets = countReturns(def) + local rets = countReturnsOfDocFunction(def) if rets > n then n = rets end |