blob: 98fdfd0885312442aed1e497f9fcac5234c53204 (
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
37
38
39
|
local files = require 'files'
local guide = require 'parser.guide'
local vm = require 'vm'
local lang = require 'language'
return function (uri, callback)
local state = files.getState(uri)
if not state then
return
end
guide.eachSourceType(state.ast, 'getlocal', function (src)
local checkNil
local nxt = src.next
if nxt then
if nxt.type == 'getfield'
or nxt.type == 'getmethod'
or nxt.type == 'getindex'
or nxt.type == 'call' then
checkNil = true
end
end
local call = src.parent
if call and call.type == 'call' and call.node == src then
checkNil = true
end
if not checkNil then
return
end
local node = vm.compileNode(src)
if node:hasFalsy() then
callback {
start = src.start,
finish = src.finish,
message = lang.script('DIAG_NEED_CHECK_NIL'),
}
end
end)
end
|