summaryrefslogtreecommitdiff
path: root/server-beta/src/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-11-07 20:06:45 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-11-07 20:06:45 +0800
commita80d62baf3568e42ffa796509a2056dd9021c462 (patch)
treeebdbff6bda538d728e797e4c48ddb15c8e74db61 /server-beta/src/core
parent0f4da273013ed0b311debefb8824c47d8be7e58f (diff)
downloadlua-language-server-a80d62baf3568e42ffa796509a2056dd9021c462.zip
诊断测试完成
Diffstat (limited to 'server-beta/src/core')
-rw-r--r--server-beta/src/core/diagnostics/duplicate-method.lua3
-rw-r--r--server-beta/src/core/diagnostics/newfield-call.lua36
-rw-r--r--server-beta/src/core/diagnostics/set-const.lua3
3 files changed, 34 insertions, 8 deletions
diff --git a/server-beta/src/core/diagnostics/duplicate-method.lua b/server-beta/src/core/diagnostics/duplicate-method.lua
deleted file mode 100644
index b3d19c21..00000000
--- a/server-beta/src/core/diagnostics/duplicate-method.lua
+++ /dev/null
@@ -1,3 +0,0 @@
-return function ()
-
-end
diff --git a/server-beta/src/core/diagnostics/newfield-call.lua b/server-beta/src/core/diagnostics/newfield-call.lua
index b3d19c21..87ece955 100644
--- a/server-beta/src/core/diagnostics/newfield-call.lua
+++ b/server-beta/src/core/diagnostics/newfield-call.lua
@@ -1,3 +1,35 @@
-return function ()
-
+local files = require 'files'
+local guide = require 'parser.guide'
+local lang = require 'language'
+
+return function (uri, callback)
+ local ast = files.getAst(uri)
+ if not ast then
+ return
+ end
+
+ local lines = files.getLines(uri)
+ local text = files.getText(uri)
+
+ guide.eachSourceType(ast.ast, 'table', function (source)
+ for i = 1, #source do
+ local field = source[i]
+ if field.type == 'call' then
+ local func = field.node
+ local args = field.args
+ local funcLine = guide.positionOf(lines, func.finish)
+ local argsLine = guide.positionOf(lines, args.start)
+ if argsLine > funcLine then
+ callback {
+ start = field.start,
+ finish = field.finish,
+ message = lang.script('DIAG_PREFIELD_CALL'
+ , text:sub(func.start, func.finish)
+ , text:sub(args.start, args.finish)
+ )
+ }
+ end
+ end
+ end
+ end)
end
diff --git a/server-beta/src/core/diagnostics/set-const.lua b/server-beta/src/core/diagnostics/set-const.lua
deleted file mode 100644
index b3d19c21..00000000
--- a/server-beta/src/core/diagnostics/set-const.lua
+++ /dev/null
@@ -1,3 +0,0 @@
-return function ()
-
-end