summaryrefslogtreecommitdiff
path: root/script/core/diagnostics
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-16 21:50:29 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-16 21:50:29 +0800
commitfa518d4f9522b38aca9478ac494e9523cca475f3 (patch)
treeb82261ecb612e15c9fa9a8381839898dbab3149a /script/core/diagnostics
parentcd6b80d6126a785c4407e118c13388db537d6bf3 (diff)
downloadlua-language-server-fa518d4f9522b38aca9478ac494e9523cca475f3.zip
fix #1057
Diffstat (limited to 'script/core/diagnostics')
-rw-r--r--script/core/diagnostics/deprecated.lua26
1 files changed, 10 insertions, 16 deletions
diff --git a/script/core/diagnostics/deprecated.lua b/script/core/diagnostics/deprecated.lua
index a5d623d2..27920c43 100644
--- a/script/core/diagnostics/deprecated.lua
+++ b/script/core/diagnostics/deprecated.lua
@@ -5,6 +5,7 @@ local guide = require 'parser.guide'
local config = require 'config'
local define = require 'proto.define'
local await = require 'await'
+local util = require 'utility'
local types = {'getglobal', 'getfield', 'getindex', 'getmethod'}
---@async
@@ -16,7 +17,6 @@ return function (uri, callback)
local dglobals = config.get(uri, 'Lua.diagnostics.globals')
local rspecial = config.get(uri, 'Lua.runtime.special')
- local cache = {}
guide.eachSourceTypes(ast.ast, types, function (src) ---@async
if src.type == 'getglobal' then
@@ -34,28 +34,17 @@ return function (uri, callback)
await.delay()
- if not vm.isDeprecated(src, true) then
+ local deprecated = vm.getDeprecated(src, true)
+ if not deprecated then
return
end
await.delay()
- local defs = vm.getDefs(src)
- local validVersions
- for _, def in ipairs(defs) do
- if def.bindDocs then
- for _, doc in ipairs(def.bindDocs) do
- if doc.type == 'doc.version' then
- validVersions = vm.getValidVersions(doc)
- break
- end
- end
- end
- end
-
local message = lang.script.DIAG_DEPRECATED
local versions
- if validVersions then
+ if deprecated.type == 'doc.version' then
+ local validVersions = vm.getValidVersions(deprecated)
versions = {}
for version, valid in pairs(validVersions) do
if valid then
@@ -71,6 +60,11 @@ return function (uri, callback)
)
end
end
+ if deprecated.type == 'doc.deprecated' then
+ if deprecated.comment then
+ message = ('%s(%s)'):format(message, util.trim(deprecated.comment.text))
+ end
+ end
callback {
start = src.start,