summaryrefslogtreecommitdiff
path: root/script/core/diagnostics/unused-local.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-06-27 01:16:01 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-06-27 01:16:01 +0800
commit24f2bab098c176acdd58a5dc82ec037b2ded8eeb (patch)
tree1d58183a931aa69e3231de6fcec5b85f19b06224 /script/core/diagnostics/unused-local.lua
parent92b2a185af2d31dd353ef8a7d57469ee9d584cb7 (diff)
downloadlua-language-server-24f2bab098c176acdd58a5dc82ec037b2ded8eeb.zip
disable `unused-local` for empty function
Diffstat (limited to 'script/core/diagnostics/unused-local.lua')
-rw-r--r--script/core/diagnostics/unused-local.lua18
1 files changed, 8 insertions, 10 deletions
diff --git a/script/core/diagnostics/unused-local.lua b/script/core/diagnostics/unused-local.lua
index d12ceb2b..a637f427 100644
--- a/script/core/diagnostics/unused-local.lua
+++ b/script/core/diagnostics/unused-local.lua
@@ -63,18 +63,16 @@ local function isDocClass(source)
return false
end
-local function isDocParam(source)
- if not source.bindDocs then
+---@param source parser.object
+local function isDeclareFunctionParam(source)
+ if source.parent.type ~= 'funcargs' then
return false
end
- for _, doc in ipairs(source.bindDocs) do
- if doc.type == 'doc.param' then
- if doc.param[1] == source[1] then
- return true
- end
- end
+ local func = source.parent.parent
+ if #func > 0 then
+ return false
end
- return false
+ return true
end
return function (uri, callback)
@@ -94,7 +92,7 @@ return function (uri, callback)
if isDocClass(source) then
return
end
- if vm.isMetaFile(uri) and isDocParam(source) then
+ if isDeclareFunctionParam(source) then
return
end
local data = hasGet(source)