diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-11-15 23:47:39 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-11-15 23:47:39 +0800 |
commit | f4fcddfa8805848b7ce7c58188cca711fc429c3b (patch) | |
tree | 8e8b1947a40d274e7237dddab30c195bfb0ad1ae /server-beta/src/core | |
parent | 2862282e18315a6474001a994e385fee132753a6 (diff) | |
download | lua-language-server-f4fcddfa8805848b7ce7c58188cca711fc429c3b.zip |
诊断:未使用的函数 只检查局部函数与全局函数
Diffstat (limited to 'server-beta/src/core')
-rw-r--r-- | server-beta/src/core/diagnostics/unused-function.lua | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/server-beta/src/core/diagnostics/unused-function.lua b/server-beta/src/core/diagnostics/unused-function.lua index eb6b8f7f..ca3a751d 100644 --- a/server-beta/src/core/diagnostics/unused-function.lua +++ b/server-beta/src/core/diagnostics/unused-function.lua @@ -10,7 +10,17 @@ 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 + return + end local hasSet local hasGet = searcher.eachRef(source, function (info) if info.mode == 'get' then |