blob: 5815f9c37e8864a78defedde083c28a7af5533b7 (
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
|
local files = require 'files'
local guide = require 'parser.guide'
local searcher = require 'searcher'
local lang = require 'language'
return function (uri, callback)
local ast = files.getAst(uri)
if not ast then
return
end
-- 再遍历一次 getglobal ,找出 _ENV 被重载的情况
guide.eachSourceType(ast.ast, 'getglobal', function (source)
-- 单独验证自己是否在重载过的 _ENV 中有定义
if source.node.tag == '_ENV' then
return
end
local setInENV
searcher.eachRef(source, function (info)
if info.mode == 'set' then
setInENV = true
end
end)
if setInENV then
return
end
local key = source[1]
callback {
start = source.start,
finish = source.finish,
message = lang.script('DIAG_UNDEF_ENV_CHILD', key),
}
end)
end
|