diff options
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 |