diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-11-05 19:31:38 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-11-05 19:31:38 +0800 |
commit | c844e46ae97f28ec928db6b701fdf5f2eea2664d (patch) | |
tree | 938d77a0aadb6a3975d146659302137f58d9babc /server-beta/src/core/diagnostics/newline-call.lua | |
parent | 5d4d2ccd06d56bb92219baf3825c5786efdf906c (diff) | |
download | lua-language-server-c844e46ae97f28ec928db6b701fdf5f2eea2664d.zip |
更新诊断实现
Diffstat (limited to 'server-beta/src/core/diagnostics/newline-call.lua')
-rw-r--r-- | server-beta/src/core/diagnostics/newline-call.lua | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/server-beta/src/core/diagnostics/newline-call.lua b/server-beta/src/core/diagnostics/newline-call.lua index b3d19c21..52b84197 100644 --- a/server-beta/src/core/diagnostics/newline-call.lua +++ b/server-beta/src/core/diagnostics/newline-call.lua @@ -1,3 +1,38 @@ -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) + + guide.eachSourceType(ast.ast, 'call', function (source) + local node = source.node + local args = source.args + if not args then + return + end + + -- 必须有其他人在继续使用当前对象 + if not source.next then + return + end + + local nodeRow = guide.positionOf(lines, node.start) + local argRow = guide.positionOf(lines, args.start) + if nodeRow == argRow then + return + end + + if #args == 1 then + callback { + start = args.start, + finish = args.finish, + message = lang.script.DIAG_PREVIOUS_CALL, + } + end + end) end |