blob: a2bac8a46329003a0cd0f7460a4eb36c2d0f41e1 (
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
|
local files = require 'files'
local guide = require 'parser.guide'
local lang = require 'language'
local define = require 'proto.define'
return function (uri, callback)
local state = files.getAst(uri)
if not state then
return
end
local mark = {}
guide.eachSourceType(state.ast, 'break', function (source)
local list = source.parent
if mark[list] then
return
end
mark[list] = true
for i = #list, 1, -1 do
local src = list[i]
if src == source then
if i == #list then
return
end
callback {
start = list[i+1].start,
finish = list[#list].range or list[#list].finish,
tags = { define.DiagnosticTag.Unnecessary },
message = lang.script.DIAG_CODE_AFTER_BREAK,
}
end
end
end)
end
|