diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-10-23 16:01:55 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-10-23 16:01:55 +0800 |
commit | 28a21f6f3988c0bb2022748e8f8daae236d80f5c (patch) | |
tree | 4fbc553648b5c64fdf7ec0f0304be1eed2a79088 /script-beta | |
parent | dd4a4a8ef8ccbceb475b8cb8d34cc580c5715c0c (diff) | |
download | lua-language-server-28a21f6f3988c0bb2022748e8f8daae236d80f5c.zip |
诊断未定义的docname
Diffstat (limited to 'script-beta')
-rw-r--r-- | script-beta/core/diagnostics/undefined-doc-name.lua | 43 | ||||
-rw-r--r-- | script-beta/proto/define.lua | 1 |
2 files changed, 44 insertions, 0 deletions
diff --git a/script-beta/core/diagnostics/undefined-doc-name.lua b/script-beta/core/diagnostics/undefined-doc-name.lua new file mode 100644 index 00000000..bf885f6f --- /dev/null +++ b/script-beta/core/diagnostics/undefined-doc-name.lua @@ -0,0 +1,43 @@ +local files = require 'files' +local guide = require 'parser.guide' +local lang = require 'language' +local define = require 'proto.define' +local vm = require 'vm' + +return function (uri, callback) + local state = files.getAst(uri) + if not state then + return + end + + if not state.ast.docs then + return + end + + local cache = {} + guide.eachSource(state.ast.docs, function (source) + if source.type:sub(-5) ~= '.name' then + return + end + local name = source[1] + if cache[name] == nil then + cache[name] = false + local docs = vm.getDocTypes(name) + for _, otherDoc in ipairs(docs) do + if otherDoc.type == 'doc.class.name' + or otherDoc.type == 'doc.alias.name' then + cache[name] = true + break + end + end + end + if not cache[name] then + callback { + start = source.start, + finish = source.finish, + related = cache, + message = lang.script('DIAG_UNDEFINED_DOC_NAME', name) + } + end + end) +end diff --git a/script-beta/proto/define.lua b/script-beta/proto/define.lua index 119314fb..fdb38c6f 100644 --- a/script-beta/proto/define.lua +++ b/script-beta/proto/define.lua @@ -131,6 +131,7 @@ m.DiagnosticDefaultSeverity = { ['redundant-value'] = 'Hint', ['duplicate-doc-class'] = 'Warning', + ['undefined-doc-name'] = 'Warning', } --- 诊断报告标签 |