@@ -5,6 +5,7 @@ local guide = require 'parser.guide'
5
5
local config = require ' config'
6
6
local define = require ' proto.define'
7
7
local await = require ' await'
8
+ local util = require ' utility'
8
9
9
10
local types = {' getglobal' , ' getfield' , ' getindex' , ' getmethod' }
10
11
--- @async
@@ -16,7 +17,6 @@ return function (uri, callback)
16
17
17
18
local dglobals = config .get (uri , ' Lua.diagnostics.globals' )
18
19
local rspecial = config .get (uri , ' Lua.runtime.special' )
19
- local cache = {}
20
20
21
21
guide .eachSourceTypes (ast .ast , types , function (src ) --- @async
22
22
if src .type == ' getglobal' then
@@ -34,28 +34,17 @@ return function (uri, callback)
34
34
35
35
await .delay ()
36
36
37
- if not vm .isDeprecated (src , true ) then
37
+ local deprecated = vm .getDeprecated (src , true )
38
+ if not deprecated then
38
39
return
39
40
end
40
41
41
42
await .delay ()
42
43
43
- local defs = vm .getDefs (src )
44
- local validVersions
45
- for _ , def in ipairs (defs ) do
46
- if def .bindDocs then
47
- for _ , doc in ipairs (def .bindDocs ) do
48
- if doc .type == ' doc.version' then
49
- validVersions = vm .getValidVersions (doc )
50
- break
51
- end
52
- end
53
- end
54
- end
55
-
56
44
local message = lang .script .DIAG_DEPRECATED
57
45
local versions
58
- if validVersions then
46
+ if deprecated .type == ' doc.version' then
47
+ local validVersions = vm .getValidVersions (deprecated )
59
48
versions = {}
60
49
for version , valid in pairs (validVersions ) do
61
50
if valid then
@@ -71,6 +60,11 @@ return function (uri, callback)
71
60
)
72
61
end
73
62
end
63
+ if deprecated .type == ' doc.deprecated' then
64
+ if deprecated .comment then
65
+ message = (' %s(%s)' ):format (message , util .trim (deprecated .comment .text ))
66
+ end
67
+ end
74
68
75
69
callback {
76
70
start = src .start ,
0 commit comments