summaryrefslogtreecommitdiff
path: root/script-beta/core/diagnostics/redundant-value.lua
blob: be4834483f5d534b0ee7aef48c51db758f8c9796 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
local files  = require 'files'
local define = require 'proto.define'
local lang   = require 'language'

return function (uri, callback, code)
    local ast = files.getAst(uri)
    if not ast 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
end