diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-08-06 15:55:11 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-08-06 15:55:11 +0800 |
commit | 842f98c6045f337ae30df559b451b65295f99f86 (patch) | |
tree | bb75fa33cc4e82d1e76253a9d141a9a293e403e4 /server/src | |
parent | f87c508bf3a45465c01241a0502041be9b693c08 (diff) | |
download | lua-language-server-842f98c6045f337ae30df559b451b65295f99f86.zip |
修正一些bug
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/constant/DiagnosticDefaultSeverity.lua | 2 | ||||
-rw-r--r-- | server/src/core/diagnostics.lua | 34 |
2 files changed, 21 insertions, 15 deletions
diff --git a/server/src/constant/DiagnosticDefaultSeverity.lua b/server/src/constant/DiagnosticDefaultSeverity.lua index 6edfb04b..77877434 100644 --- a/server/src/constant/DiagnosticDefaultSeverity.lua +++ b/server/src/constant/DiagnosticDefaultSeverity.lua @@ -11,7 +11,7 @@ return { ['lowercase-global'] = 'Information', ['undefined-env-child'] = 'Information', ['duplicate-index'] = 'Warning', - ['duplicate-field'] = 'Warning', + ['duplicate-method'] = 'Warning', ['empty-block'] = 'Information', ['redundant-value'] = 'Information', ['emmy-lua'] = 'Warning', diff --git a/server/src/core/diagnostics.lua b/server/src/core/diagnostics.lua index c136945a..1d636e07 100644 --- a/server/src/core/diagnostics.lua +++ b/server/src/core/diagnostics.lua @@ -385,8 +385,10 @@ function mt:searchDuplicateIndex(callback) end) end -function mt:searchDuplicateField(callback) +function mt:searchDuplicateMethod(callback) + local uri = self.uri local mark = {} + local map = {} self.vm:eachSource(function (source) local parent = source:get 'parent' if not parent then @@ -399,9 +401,6 @@ function mt:searchDuplicateField(callback) local relates = {} parent:eachInfo(function (info, src) local k = info[1] - if source == src then - return - end if info.type ~= 'set child' then return end @@ -411,23 +410,30 @@ function mt:searchDuplicateField(callback) if src.start == 0 then return end + if not src:get 'object' then + return + end + if map[src] then + return + end if not relates[k] then - relates[k] = {} + relates[k] = map[src] or { + name = k, + } end + map[src] = relates[k] relates[k][#relates[k]+1] = { start = src.start, finish = src.finish, uri = src.uri } end) - for name, relate in pairs(relates) do - if #relate > 1 then - for _, data in ipairs(relate) do - callback(data.start, data.finish, name, relate) - end - end - end end) + for src, relate in pairs(map) do + if #relate > 1 and src.uri == uri then + callback(src.start, src.finish, relate.name, relate) + end + end end function mt:searchEmptyBlock(callback) @@ -870,8 +876,8 @@ return function (vm, lines, uri) related = related, } end) - -- 往表里面塞重复的field - session:doDiagnostics(session.searchDuplicateField, 'duplicate-field', function (key, related) + -- 往表里面塞重复的method + session:doDiagnostics(session.searchDuplicateMethod, 'duplicate-method', function (key, related) return { message = lang.script('DIAG_DUPLICATE_FIELD', key), related = related, |