summaryrefslogtreecommitdiff
path: root/script/core/diagnostics/unknown-diag-code.lua
blob: 013a702bc197f6d020e9ac8782ed6357264b15b3 (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
26
27
28
29
30
31
local files   = require 'files'
local lang    = require 'language'
local define  = require 'proto.define'

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

    if not state.ast.docs then
        return
    end

    for _, doc in ipairs(state.ast.docs) do
        if doc.type == 'doc.diagnostic' then
            if doc.names then
                for _, nameUnit in ipairs(doc.names) do
                    local code = nameUnit[1]
                    if not define.DiagnosticDefaultSeverity[code] then
                        callback {
                            start   = nameUnit.start,
                            finish  = nameUnit.finish,
                            message = lang.script.DIAG_UNKNOWN_DIAG_CODE,
                        }
                    end
                end
            end
        end
    end
end