diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-09-29 16:44:43 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-09-29 16:44:43 +0800 |
commit | 734d9c6abeffaf8f70ef043a7a960fdd6cf16ca1 (patch) | |
tree | a25317a492f36a79323a7c15f775b38c09f92589 /server/src/core | |
parent | 41b4fe57bf46f5e67a8f41bde4ded038955e178d (diff) | |
download | lua-language-server-734d9c6abeffaf8f70ef043a7a960fdd6cf16ca1.zip |
new field call 的诊断
Diffstat (limited to 'server/src/core')
-rw-r--r-- | server/src/core/diagnostics.lua | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/server/src/core/diagnostics.lua b/server/src/core/diagnostics.lua index 8584897e..c99f6e87 100644 --- a/server/src/core/diagnostics.lua +++ b/server/src/core/diagnostics.lua @@ -251,6 +251,30 @@ function mt:searchNewLineCall(callback) end) end +function mt:searchNewFieldCall(callback) + local lines = self.lines + self.vm:eachSource(function (source) + if source.type ~= 'table' then + return + end + for i = 1, #source do + local field = source[i] + if field.type == 'simple' then + local callSource = field[#field] + local funcSource = field[#field-1] + local callLine = lines:rowcol(callSource.start) + local funcLine = lines:rowcol(funcSource.finish) + if callLine > funcLine then + callback(funcSource.start, callSource.finish + , lines.buf:sub(funcSource.start, funcSource.finish) + , lines.buf:sub(callSource.start, callSource.finish) + ) + end + end + end + end) +end + function mt:searchRedundantParameters(callback) self.vm:eachSource(function (source) local args = source:bindCall() @@ -911,6 +935,12 @@ return function (vm, lines, uri) message = lang.script.DIAG_PREVIOUS_CALL, } end) + -- 以字符串开始的field(可能被误解析为了上一行的call) + session:doDiagnostics(session.searchNewFieldCall, 'newfield-call', function (func, call) + return { + message = lang.script('DIAG_PREFIELD_CALL', func, call), + } + end) -- 调用函数时的参数数量是否超过函数的接收数量 session:doDiagnostics(session.searchRedundantParameters, 'redundant-parameter', function (max, passed) return { |