summaryrefslogtreecommitdiff
path: root/script/core/diagnostics/redundant-value.lua
blob: 6f60303b98fa7302291be0587011d2585e7ef387 (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
25
local files  = require 'files'
local define = require 'proto.define'
local lang   = require 'language'
local guide  = require 'parser.guide'
local await  = require 'await'

---@async
return function (uri, callback)
    local state = files.getState(uri)
    if not state then
        return
    end

    guide.eachSource(state.ast, function (src) ---@async
        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