diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-08 18:39:17 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-08 18:39:17 +0800 |
commit | c11314297d912569a90784c0000592930fb32694 (patch) | |
tree | 6c7c1d15b36971c68b75c2fd9ce86e25a2b4ef99 /server | |
parent | 1ebe865f30455bd2b32a576ce69fb86aa344b548 (diff) | |
download | lua-language-server-c11314297d912569a90784c0000592930fb32694.zip |
多次重定义不警告
Diffstat (limited to 'server')
-rw-r--r-- | server/src/matcher/compile.lua | 11 | ||||
-rw-r--r-- | server/src/matcher/diagnostics.lua | 20 |
2 files changed, 23 insertions, 8 deletions
diff --git a/server/src/matcher/compile.lua b/server/src/matcher/compile.lua index 43b68acf..7b29f188 100644 --- a/server/src/matcher/compile.lua +++ b/server/src/matcher/compile.lua @@ -73,7 +73,16 @@ function mt:createLocal(key, source, var) var = self:createVar('local', key, source) self:addInfo(var, 'local', source) end - var.redefinition = self.env.var[key] + local old = self.env.var[key] + if old then + local shadow = old.shadow + if not shadow then + shadow = { old } + old.shadow = shadow + end + var.shadow = shadow + shadow[#shadow+1] = var + end self.env.var[key] = var return var end diff --git a/server/src/matcher/diagnostics.lua b/server/src/matcher/diagnostics.lua index d53cb82a..2b66c490 100644 --- a/server/src/matcher/diagnostics.lua +++ b/server/src/matcher/diagnostics.lua @@ -101,17 +101,23 @@ local function searchRedefinition(results, uri, callback) then goto NEXT_VAR end - local shadow = var.redefinition + local shadow = var.shadow if not shadow then goto NEXT_VAR end - callback(var.source.start, var.source.finish, var.key, { - { - start = shadow.source.start, - finish = shadow.source.finish, - uri = uri, + -- 如果多次重定义,则不再警告 + if #shadow >= 4 then + goto NEXT_VAR + end + local related = {} + for i = 1, #shadow do + related[i] = { + start = shadow[i].source.start, + finish = shadow[i].source.finish, + uri = uri, } - }) + end + callback(var.source.start, var.source.finish, var.key, related) ::NEXT_VAR:: end end |