diff options
Diffstat (limited to 'script/core/diagnostics')
-rw-r--r-- | script/core/diagnostics/newline-call.lua | 12 | ||||
-rw-r--r-- | script/core/diagnostics/redundant-value.lua | 32 |
2 files changed, 23 insertions, 21 deletions
diff --git a/script/core/diagnostics/newline-call.lua b/script/core/diagnostics/newline-call.lua index b28310e3..dbb8c690 100644 --- a/script/core/diagnostics/newline-call.lua +++ b/script/core/diagnostics/newline-call.lua @@ -3,13 +3,13 @@ local guide = require 'parser.guide' local lang = require 'language' return function (uri, callback) - local ast = files.getState(uri) + local state = files.getState(uri) local text = files.getText(uri) - if not ast then + if not state then return end - guide.eachSourceType(ast.ast, 'call', function (source) + guide.eachSourceType(state.ast, 'call', function (source) local node = source.node local args = source.args if not args then @@ -20,8 +20,10 @@ return function (uri, callback) if not source.next then return end - if text:sub(args.start, args.start) ~= '(' - or text:sub(args.finish, args.finish) ~= ')' then + local startOffset = guide.positionToOffset(state, args.start) + 1 + local finishOffset = guide.positionToOffset(state, args.finish) + if text:sub(startOffset, startOffset) ~= '(' + or text:sub(finishOffset, finishOffset) ~= ')' then return end diff --git a/script/core/diagnostics/redundant-value.lua b/script/core/diagnostics/redundant-value.lua index d6cd97a7..4c913330 100644 --- a/script/core/diagnostics/redundant-value.lua +++ b/script/core/diagnostics/redundant-value.lua @@ -1,24 +1,24 @@ local files = require 'files' local define = require 'proto.define' local lang = require 'language' +local guide = require 'parser.guide' +local await = require 'await' -return function (uri, callback, code) - local ast = files.getState(uri) - if not ast then +return function (uri, callback) + local state = files.getState(uri) + if not state then return end - local diags = ast.diags[code] - if not diags then - return - end - - for _, info in ipairs(diags) do - callback { - start = info.start, - finish = info.finish, - tags = { define.DiagnosticTag.Unnecessary }, - message = lang.script('DIAG_OVER_MAX_VALUES', info.max, info.passed) - } - end + guide.eachSource(state.ast, function (src) + await.delay() + if src.redundant then + callback { + start = src.start, + finish = src.finish, + tags = { define.DiagnosticTag.Unnecessary }, + message = lang.script('DIAG_OVER_MAX_VALUES', src.redundant.max, src.redundant.passed) + } + end + end) end |