diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-06-17 20:19:17 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-06-17 20:19:17 +0800 |
commit | f05a68d38a0915fae1303a86229f4f4c9fd96ecb (patch) | |
tree | e409fa0e28ccdc1afed49489e80cb5bce2bacea8 /script/core | |
parent | 9978771a0f377c6f7663324e96e40f985fb99eb4 (diff) | |
download | lua-language-server-f05a68d38a0915fae1303a86229f4f4c9fd96ecb.zip |
improve
Diffstat (limited to 'script/core')
-rw-r--r-- | script/core/diagnostics/undefined-global.lua | 15 | ||||
-rw-r--r-- | script/core/noder.lua | 15 |
2 files changed, 14 insertions, 16 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)) diff --git a/script/core/noder.lua b/script/core/noder.lua index 4c454d66..a7f71d3e 100644 --- a/script/core/noder.lua +++ b/script/core/noder.lua @@ -179,6 +179,9 @@ local function getKey(source) end local function checkMode(source) + if guide.isGlobal(source) then + return 'g:' + end if source.type == 'table' then return 't:' end @@ -254,9 +257,6 @@ local function checkMode(source) end return id end - if guide.isGlobal(source) then - return 'g:' - end if source.type == 'getlocal' or source.type == 'setlocal' then source = source.node @@ -302,15 +302,10 @@ local function getID(source) if not node then break end - current = node - if current.special == '_G' then - for i = index, 2, -1 do - if IDList[i] == '"_G"' then - IDList[i] = nil - end - end + if guide.isGlobal(current) then break end + current = node ::CONTINUE:: end if index == 0 then |