summaryrefslogtreecommitdiff
path: root/script/core/diagnostics/redundant-value.lua
blob: 4c91333050ef16fc9c11429e0f74f014cfacfae8 (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'
local guide  = require 'parser.guide'
local await  = require 'await'

return function (uri, callback)
    local state = files.getState(uri)
    if not state then
        return
    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