diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-06-17 16:02:39 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-06-17 16:02:39 +0800 |
commit | 1bcadf492c4ccc19d137ffac80b0e9ca181a9ad7 (patch) | |
tree | db21c17b1b6f18d3fb60920a5d0783aaf50e8d0a /script/core | |
parent | cbb4bea9cabfa3073b39e067ea2114946c1d1690 (diff) | |
parent | 6fbe324f7130c94046ce14eee2235b663b47eafc (diff) | |
download | lua-language-server-1bcadf492c4ccc19d137ffac80b0e9ca181a9ad7.zip |
Merge branch 'master' into type-check
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 |