blob: 34d55ee28aaf1899ac557e2fda068535767be3fe (
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
32
33
34
35
36
|
local files = require 'files'
local codeFormat = require 'code_format'
local converter = require 'proto.converter'
local log = require 'log'
local pformatting = require 'provider.formatting'
---@async
return function(uri, callback)
local text = files.getText(uri)
if not text then
return
end
pformatting.updateConfig(uri)
local status, diagnosticInfos = codeFormat.diagnose_file(uri, text)
if not status then
if diagnosticInfos ~= nil then
log.error(diagnosticInfos)
end
return
end
if diagnosticInfos then
for _, diagnosticInfo in ipairs(diagnosticInfos) do
callback {
start = converter.unpackPosition(uri, diagnosticInfo.range.start),
finish = converter.unpackPosition(uri, diagnosticInfo.range["end"]),
message = diagnosticInfo.message
}
end
end
end
|