summaryrefslogtreecommitdiff
path: root/script-beta/core/diagnostics
diff options
context:
space:
mode:
Diffstat (limited to 'script-beta/core/diagnostics')
-rw-r--r--script-beta/core/diagnostics/duplicate-doc-field.lua34
-rw-r--r--script-beta/core/diagnostics/undefined-doc-class.lua16
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