summaryrefslogtreecommitdiff
path: root/script/core/diagnostics/unknown-diag-code.lua
blob: 45d3b6db0fdde7f1bae12122b22522080e643091 (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.getAst(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