summaryrefslogtreecommitdiff
path: root/script/core/diagnostics/unused-local.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-07-01 16:59:35 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-07-01 16:59:35 +0800
commit342ff9af837cdbe0369e717585fcd36638d60002 (patch)
tree54b7b30a8b24e43e53666e3f754ea4e50d3a69ab /script/core/diagnostics/unused-local.lua
parent662532d837d88ec470206b24a1e73cef871f66b6 (diff)
downloadlua-language-server-342ff9af837cdbe0369e717585fcd36638d60002.zip
fix #1257 don't need to return if returns nil
Diffstat (limited to 'script/core/diagnostics/unused-local.lua')
-rw-r--r--script/core/diagnostics/unused-local.lua16
1 files changed, 12 insertions, 4 deletions
diff --git a/script/core/diagnostics/unused-local.lua b/script/core/diagnostics/unused-local.lua
index a637f427..8bff7dcb 100644
--- a/script/core/diagnostics/unused-local.lua
+++ b/script/core/diagnostics/unused-local.lua
@@ -63,16 +63,24 @@ local function isDocClass(source)
return false
end
+---@param func parser.object
+---@return boolean
+local function isEmptyFunction(func)
+ if #func > 0 then
+ return false
+ end
+ local startRow = guide.rowColOf(func.start)
+ local finishRow = guide.rowColOf(func.finish)
+ return finishRow - startRow <= 1
+end
+
---@param source parser.object
local function isDeclareFunctionParam(source)
if source.parent.type ~= 'funcargs' then
return false
end
local func = source.parent.parent
- if #func > 0 then
- return false
- end
- return true
+ return isEmptyFunction(func)
end
return function (uri, callback)