diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-10-25 18:21:40 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-10-25 18:21:40 +0800 |
commit | c848377b107594759492c6ba6566705c9821df32 (patch) | |
tree | 1adec8c9a1d1638bacd23d0658c1c62d6188b72c /script-beta/core | |
parent | 0e12a5a4ad223393a76827ffdd39d27ca3db4bd9 (diff) | |
download | lua-language-server-c848377b107594759492c6ba6566705c9821df32.zip |
更新诊断
Diffstat (limited to 'script-beta/core')
-rw-r--r-- | script-beta/core/diagnostics/duplicate-doc-field.lua | 34 | ||||
-rw-r--r-- | script-beta/core/diagnostics/undefined-doc-class.lua | 16 |
2 files changed, 50 insertions, 0 deletions
diff --git a/script-beta/core/diagnostics/duplicate-doc-field.lua b/script-beta/core/diagnostics/duplicate-doc-field.lua new file mode 100644 index 00000000..b621fd9e --- /dev/null +++ b/script-beta/core/diagnostics/duplicate-doc-field.lua @@ -0,0 +1,34 @@ +local files = require 'files' +local lang = require 'language' + +return function (uri, callback) + local state = files.getAst(uri) + if not state then + return + end + + if not state.ast.docs then + return + end + + local mark + for _, group in ipairs(state.ast.docs.groups) do + for _, doc in ipairs(group) do + if doc.type == 'doc.class' then + mark = {} + elseif doc.type == 'doc.field' then + if mark then + local name = doc.field[1] + if mark[name] then + callback { + start = doc.field.start, + finish = doc.field.finish, + message = lang.script('DIAG_DUPLICATE_DOC_FIELD', name), + } + end + mark[name] = true + end + end + end + end +end diff --git a/script-beta/core/diagnostics/undefined-doc-class.lua b/script-beta/core/diagnostics/undefined-doc-class.lua index bbfdceec..f3381039 100644 --- a/script-beta/core/diagnostics/undefined-doc-class.lua +++ b/script-beta/core/diagnostics/undefined-doc-class.lua @@ -4,6 +4,19 @@ local lang = require 'language' local define = require 'proto.define' local vm = require 'vm' +local builtin = { + ['any'] = true, + ['nil'] = true, + ['boolean'] = true, + ['number'] = true, + ['integer'] = true, + ['thread'] = true, + ['table'] = true, + ['file'] = true, + ['string'] = true, + ['function'] = true, +} + return function (uri, callback) local state = files.getAst(uri) if not state then @@ -22,6 +35,9 @@ return function (uri, callback) goto CONTINUE end local name = ext[1] + if builtin[name] then + goto CONTINUE + end local docs = vm.getDocTypes(name) if cache[name] == nil then cache[name] = false |