summaryrefslogtreecommitdiff
path: root/script-beta/core/diagnostics
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-10-22 14:22:36 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-10-22 14:22:36 +0800
commit2881d5d769033594dca45d659509fa0de3c746bf (patch)
tree1c5b22256cca22f159d64e6920982a12bd099fbb /script-beta/core/diagnostics
parent57dd96177c217611de4aced4efde94106ee389d3 (diff)
downloadlua-language-server-2881d5d769033594dca45d659509fa0de3c746bf.zip
暂存
Diffstat (limited to 'script-beta/core/diagnostics')
-rw-r--r--script-beta/core/diagnostics/duplicate-doc-class.lua46
-rw-r--r--script-beta/core/diagnostics/emmy-lua.lua3
-rw-r--r--script-beta/core/diagnostics/set-const.lua2
3 files changed, 48 insertions, 3 deletions
diff --git a/script-beta/core/diagnostics/duplicate-doc-class.lua b/script-beta/core/diagnostics/duplicate-doc-class.lua
new file mode 100644
index 00000000..8974d215
--- /dev/null
+++ b/script-beta/core/diagnostics/duplicate-doc-class.lua
@@ -0,0 +1,46 @@
+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.focs then
+ return
+ end
+
+ local cache = {}
+ for _, doc in ipairs(state.ast.docs) do
+ if doc.type == 'doc.class'
+ or doc.type == 'doc.alias' then
+ local name = guide.getName(doc)
+ if not cache[name] then
+ local docs = vm.getDocTypes(name)
+ cache[name] = {}
+ for _, otherDoc in ipairs(docs) do
+ if otherDoc.type == 'doc.class'
+ or otherDoc.type == 'doc.alias' then
+ cache[name][#cache[name]+1] = {
+ start = otherDoc.start,
+ finish = otherDoc.finish,
+ uri = guide.getUri(otherDoc),
+ }
+ end
+ end
+ end
+ if #cache[name] > 1 then
+ callback {
+ start = doc.start,
+ finish = doc.finish,
+ related = cache,
+ message = lang.script('DIAG_DUPLICATE_DOC_CLASS', name)
+ }
+ end
+ end
+ end
+end
diff --git a/script-beta/core/diagnostics/emmy-lua.lua b/script-beta/core/diagnostics/emmy-lua.lua
deleted file mode 100644
index b3d19c21..00000000
--- a/script-beta/core/diagnostics/emmy-lua.lua
+++ /dev/null
@@ -1,3 +0,0 @@
-return function ()
-
-end
diff --git a/script-beta/core/diagnostics/set-const.lua b/script-beta/core/diagnostics/set-const.lua
new file mode 100644
index 00000000..62a67b01
--- /dev/null
+++ b/script-beta/core/diagnostics/set-const.lua
@@ -0,0 +1,2 @@
+return function (uri, callback)
+end