diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-03-19 15:15:18 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-03-19 15:15:18 +0800 |
commit | 4087a9774bbfbad2652725684b812ed1eca43bde (patch) | |
tree | 8c40c3787ffa721c50c27f2dc788f62b9de64549 /server/src/core/diagnostics.lua | |
parent | 8662a6394eaaa1f0514578299627f7c4ec9808bf (diff) | |
download | lua-language-server-4087a9774bbfbad2652725684b812ed1eca43bde.zip |
区分重载_ENV的特殊情况
Diffstat (limited to 'server/src/core/diagnostics.lua')
-rw-r--r-- | server/src/core/diagnostics.lua | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/server/src/core/diagnostics.lua b/server/src/core/diagnostics.lua index def54a35..7ebe297a 100644 --- a/server/src/core/diagnostics.lua +++ b/server/src/core/diagnostics.lua @@ -40,15 +40,14 @@ end function mt:searchUndefinedGlobal(callback) local definedGlobal = {} - local definedValue = {} for name in pairs(config.config.diagnostics.globals) do definedGlobal[name] = true end local envValue = self.vm.env:getValue() envValue:eachInfo(function (info) if info.type == 'set child' then - local value = info[2] - definedValue[value] = true + local name = info[1] + definedGlobal[name] = true end end) self.vm:eachSource(function (source) @@ -59,14 +58,24 @@ function mt:searchUndefinedGlobal(callback) if name == '' then return end - if definedGlobal[name] then - return - end local value = source:bindValue() if not value then return end - if definedValue[value] then + if not value:isGlobal() then + -- 上文重载了 _ENV 的情况 + local ok = value:eachInfo(function (info) + if info.type == 'set' then + return true + end + end) + if ok then + return + end + callback(source.start, source.finish, name) + return + end + if definedGlobal[name] then return end if type(name) ~= 'string' then |