nixos/lua-lsp/script/core/diagnostics/unknown-diag-code.lua

32 lines
905 B
Lua

local files = require 'files'
local lang = require 'language'
local diag = require 'proto.diagnostic'
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 diag.getDiagAndErrNameMap()[code] then
callback {
start = nameUnit.start,
finish = nameUnit.finish,
message = lang.script('DIAG_UNKNOWN_DIAG_CODE', code),
}
end
end
end
end
end
end