summaryrefslogtreecommitdiff
path: root/script/core/diagnostics/undefined-global.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-06-17 20:19:17 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-06-17 20:19:17 +0800
commitf05a68d38a0915fae1303a86229f4f4c9fd96ecb (patch)
treee409fa0e28ccdc1afed49489e80cb5bce2bacea8 /script/core/diagnostics/undefined-global.lua
parent9978771a0f377c6f7663324e96e40f985fb99eb4 (diff)
downloadlua-language-server-f05a68d38a0915fae1303a86229f4f4c9fd96ecb.zip
improve
Diffstat (limited to 'script/core/diagnostics/undefined-global.lua')
-rw-r--r--script/core/diagnostics/undefined-global.lua15
1 files changed, 9 insertions, 6 deletions
diff --git a/script/core/diagnostics/undefined-global.lua b/script/core/diagnostics/undefined-global.lua
index 549a1922..c53029ba 100644
--- a/script/core/diagnostics/undefined-global.lua
+++ b/script/core/diagnostics/undefined-global.lua
@@ -1,8 +1,10 @@
-local files = require 'files'
-local vm = require 'vm'
-local lang = require 'language'
-local config = require 'config'
-local guide = require 'parser.guide'
+local files = require 'files'
+local vm = require 'vm'
+local lang = require 'language'
+local config = require 'config'
+local guide = require 'parser.guide'
+local noder = require 'core.noder'
+local collector = require 'core.collector'
local requireLike = {
['include'] = true,
@@ -33,7 +35,8 @@ return function (uri, callback)
if node.tag ~= '_ENV' then
return
end
- if #vm.getDefs(src) == 0 then
+ local id = 'def:' .. noder.getID(src)
+ if not collector.has(id) then
local message = lang.script('DIAG_UNDEF_GLOBAL', key)
if requireLike[key:lower()] then
message = ('%s(%s)'):format(message, lang.script('DIAG_REQUIRE_LIKE', key))