summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-11-16 11:07:03 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-11-16 11:07:03 +0800
commit4e23000383857307e33ec255fe71e2e020413615 (patch)
tree53d689987cde76577b3a04da3283b24797daf130
parent6576326add050eb308249c69f9f5ee42d788d72f (diff)
downloadlua-language-server-4e23000383857307e33ec255fe71e2e020413615.zip
未使用的函数不检查全局函数(有可能导出给外部使用了)
-rw-r--r--script-beta/core/diagnostics/unused-function.lua5
-rw-r--r--test-beta/diagnostics/init.lua14
2 files changed, 9 insertions, 10 deletions
diff --git a/script-beta/core/diagnostics/unused-function.lua b/script-beta/core/diagnostics/unused-function.lua
index 2bf3084a..f0bca613 100644
--- a/script-beta/core/diagnostics/unused-function.lua
+++ b/script-beta/core/diagnostics/unused-function.lua
@@ -10,15 +10,14 @@ return function (uri, callback)
if not ast then
return
end
- -- 只检查局部函数与全局函数
+ -- 只检查局部函数
guide.eachSourceType(ast.ast, 'function', function (source)
local parent = source.parent
if not parent then
return
end
if parent.type ~= 'local'
- and parent.type ~= 'setlocal'
- and parent.type ~= 'setglobal' then
+ and parent.type ~= 'setlocal' then
return
end
local hasGet
diff --git a/test-beta/diagnostics/init.lua b/test-beta/diagnostics/init.lua
index e32ef275..579a132b 100644
--- a/test-beta/diagnostics/init.lua
+++ b/test-beta/diagnostics/init.lua
@@ -332,13 +332,13 @@ TEST [[
<!local function f() end!>
]]
-TEST [[
-F = <!function () end!>
-]]
-
-TEST [[
-<!function F() end!>
-]]
+--TEST [[
+--F = <!function () end!>
+--]]
+--
+--TEST [[
+--<!function F() end!>
+--]]
config.config.diagnostics.disable['unused-local'] = false
config.config.diagnostics.disable['unused-function'] = true