diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-03-04 14:14:30 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-03-04 14:14:30 +0800 |
commit | 6364d0aad94bae584c6b5574621ba340e4673378 (patch) | |
tree | ca46a98c3ce5774aef5e4953b9d3b3151e650550 /server/src/core/diagnostics.lua | |
parent | bcec4c1f25f0cac07a56e4fcfe98fe1477d97f29 (diff) | |
download | lua-language-server-6364d0aad94bae584c6b5574621ba340e4673378.zip |
换行call
Diffstat (limited to 'server/src/core/diagnostics.lua')
-rw-r--r-- | server/src/core/diagnostics.lua | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/server/src/core/diagnostics.lua b/server/src/core/diagnostics.lua index 47542fa5..613e31c0 100644 --- a/server/src/core/diagnostics.lua +++ b/server/src/core/diagnostics.lua @@ -103,7 +103,7 @@ end local function isInString(vm, start, finish) for _, source in ipairs(vm.sources) do - if source:getType() == 'string' and isContainPos(source, start, finish) then + if source.type == 'string' and isContainPos(source, start, finish) then return true end end @@ -178,22 +178,25 @@ function mt:searchRedefinition(callback) end function mt:searchNewLineCall(callback) - local results = self.results local lines = self.lines - for _, call in ipairs(results.calls) do - if not call.nextObj then - goto NEXT_CALL - end - if not call.lastObj.start then - goto NEXT_CALL + self.vm:eachSource(function (source) + if source.type ~= 'simple' then + return end - local callline = lines:rowcol(call.args.start) - local lastline = lines:rowcol(call.lastObj.finish) - if callline > lastline then - callback(call.args.start, call.args.finish) + for i = 1, #source - 1 do + local callSource = source[i] + local funcSource = source[i-1] + if callSource.type ~= 'call' then + goto CONTINUE + end + local callLine = lines:rowcol(callSource.start) + local funcLine = lines:rowcol(funcSource.finish) + if callLine > funcLine then + callback(callSource.start, callSource.finish) + end + :: CONTINUE :: end - ::NEXT_CALL:: - end + end) end function mt:searchRedundantParameters(callback) @@ -280,12 +283,12 @@ return function (vm, lines, uri) } end) -- 以括号开始的一行(可能被误解析为了上一行的call) - --session:doDiagnostics(session.searchNewLineCall, 'newline-call', function () - -- return { - -- level = DiagnosticSeverity.Information, - -- message = lang.script.DIAG_PREVIOUS_CALL, - -- } - --end) + session:doDiagnostics(session.searchNewLineCall, 'newline-call', function () + return { + level = DiagnosticSeverity.Information, + message = lang.script.DIAG_PREVIOUS_CALL, + } + end) -- 调用函数时的参数数量是否超过函数的接收数量 --session:doDiagnostics(session.searchRedundantParameters, --'remainder-parameters', function (max, passed) -- return { |