blob: e154080c78149174fe005d1535819dbce4efd717 (
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 guide = require 'parser.guide'
local lang = require 'language'
return function (uri, callback)
local state = files.getState(uri)
if not state then
return
end
local function check(source)
local node = source.node
if node.tag == '_ENV' then
return
end
if not node.value or node.value.type == 'nil' then
callback {
start = source.start,
finish = source.finish,
uri = uri,
message = lang.script.DIAG_GLOBAL_IN_NIL_ENV,
related = {
{
start = node.start,
finish = node.finish,
uri = uri,
}
}
}
end
end
guide.eachSourceType(state.ast, 'getglobal', check)
guide.eachSourceType(state.ast, 'setglobal', check)
end
|