summaryrefslogtreecommitdiff
path: root/script-beta
diff options
context:
space:
mode:
Diffstat (limited to 'script-beta')
-rw-r--r--script-beta/core/diagnostics/duplicate-doc-field.lua34
-rw-r--r--script-beta/core/diagnostics/undefined-doc-class.lua16
-rw-r--r--script-beta/parser/luadoc.lua2
-rw-r--r--script-beta/proto/define.lua1
4 files changed, 53 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
diff --git a/script-beta/parser/luadoc.lua b/script-beta/parser/luadoc.lua
index 9c9ea113..c55484cf 100644
--- a/script-beta/parser/luadoc.lua
+++ b/script-beta/parser/luadoc.lua
@@ -720,6 +720,7 @@ local function bindDocs(state)
if not isNextLine(lns, binded, doc) then
bindDoc(state, lns, binded)
binded = {}
+ state.ast.docs.groups[#state.ast.docs.groups+1] = binded
end
binded[#binded+1] = doc
end
@@ -735,6 +736,7 @@ return function (_, state)
ast.docs = {
type = 'doc',
parent = ast,
+ groups = {},
}
pushError = state.pushError
diff --git a/script-beta/proto/define.lua b/script-beta/proto/define.lua
index f69660cf..92403518 100644
--- a/script-beta/proto/define.lua
+++ b/script-beta/proto/define.lua
@@ -137,6 +137,7 @@ m.DiagnosticDefaultSeverity = {
['undefined-doc-param'] = 'Warning',
['duplicate-doc-param'] = 'Warning',
['doc-field-no-class'] = 'Warning',
+ ['duplicate-doc-field'] = 'Warning',
}
--- 诊断报告标签