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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
local files = require 'files'
local guide = require 'parser.guide'
local lang = require 'language'
local define = require 'proto.define'
local vm = require 'vm'
local builtin = {
['any'] = true,
['nil'] = true,
['boolean'] = true,
['number'] = true,
['integer'] = true,
['thread'] = true,
['table'] = true,
['file'] = true,
['string'] = true,
['userdata'] = true,
['function'] = true,
}
return function (uri, callback)
local state = files.getAst(uri)
if not state then
return
end
if not state.ast.docs then
return
end
local cache = {}
for _, doc in ipairs(state.ast.docs) do
if doc.type == 'doc.class' then
local ext = doc.extends
if not ext then
goto CONTINUE
end
local name = ext[1]
if builtin[name] then
goto CONTINUE
end
local docs = vm.getDocTypes(name)
if cache[name] == nil then
cache[name] = false
for _, otherDoc in ipairs(docs) do
if otherDoc.type == 'doc.class.name' then
cache[name] = true
break
end
end
end
if not cache[name] then
callback {
start = ext.start,
finish = ext.finish,
related = cache,
message = lang.script('DIAG_UNDEFINED_DOC_CLASS', name)
}
end
end
::CONTINUE::
end
end
|