blob: 21f7e83a0f02db6aa04fd4249226c30189e8edbc (
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.getState(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
|