summaryrefslogtreecommitdiff
path: root/script/vm/doc.lua
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/vm/doc.lua
parentcd6b80d6126a785c4407e118c13388db537d6bf3 (diff)
downloadlua-language-server-fa518d4f9522b38aca9478ac494e9523cca475f3.zip
fix #1057
Diffstat (limited to 'script/vm/doc.lua')
-rw-r--r--script/vm/doc.lua31
1 files changed, 21 insertions, 10 deletions
diff --git a/script/vm/doc.lua b/script/vm/doc.lua
index 1367bbc2..5a92a103 100644
--- a/script/vm/doc.lua
+++ b/script/vm/doc.lua
@@ -85,7 +85,8 @@ function vm.getValidVersions(doc)
return valids
end
-local function isDeprecated(value)
+---@return parser.object?
+local function getDeprecated(value)
if not value.bindDocs then
return false
end
@@ -94,13 +95,13 @@ local function isDeprecated(value)
end
for _, doc in ipairs(value.bindDocs) do
if doc.type == 'doc.deprecated' then
- value._deprecated = true
- return true
+ value._deprecated = doc
+ return doc
elseif doc.type == 'doc.version' then
local valids = vm.getValidVersions(doc)
if not valids[config.get(guide.getUri(value), 'Lua.runtime.version')] then
- value._deprecated = true
- return true
+ value._deprecated = doc
+ return doc
end
end
end
@@ -108,20 +109,30 @@ local function isDeprecated(value)
return false
end
-function vm.isDeprecated(value, deep)
+---@return parser.object?
+function vm.getDeprecated(value, deep)
if deep then
local defs = vm.getDefs(value)
if #defs == 0 then
return false
end
+ local deprecated = false
for _, def in ipairs(defs) do
- if not isDeprecated(def) then
- return false
+ if def.type == 'setglobal'
+ or def.type == 'setfield'
+ or def.type == 'setmethod'
+ or def.type == 'setindex'
+ or def.type == 'tablefield'
+ or def.type == 'tableindex' then
+ deprecated = getDeprecated(def)
+ if not deprecated then
+ return false
+ end
end
end
- return true
+ return deprecated
else
- return isDeprecated(value)
+ return getDeprecated(value)
end
end