summaryrefslogtreecommitdiff
path: root/script-beta/core/hover/label.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-11-02 10:50:58 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-11-02 10:50:58 +0800
commit2ca7cad6ead1b12cd899dd7ecac6b8442f499046 (patch)
tree54fc3b37dabec086697620e0d456c279cfbe4c98 /script-beta/core/hover/label.lua
parent9af004f6987221ea92f77118c18996d8d43ee672 (diff)
downloadlua-language-server-2ca7cad6ead1b12cd899dd7ecac6b8442f499046.zip
alias 的 hover
Diffstat (limited to 'script-beta/core/hover/label.lua')
-rw-r--r--script-beta/core/hover/label.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/script-beta/core/hover/label.lua b/script-beta/core/hover/label.lua
index 6ce8ef8e..b96421b1 100644
--- a/script-beta/core/hover/label.lua
+++ b/script-beta/core/hover/label.lua
@@ -29,6 +29,19 @@ local function asDocFunction(source)
return table.concat(lines, '\n')
end
+local function asDocTypeName(source)
+ for _, doc in ipairs(vm.getDocTypes(source[1])) do
+ if doc.type == 'doc.class.name' then
+ return 'class ' .. source[1]
+ end
+ if doc.type == 'doc.alias.name' then
+ local extends = doc.parent.extends
+ -- TODO
+ return '展开为 ' .. vm.getInferType(extends)
+ end
+ end
+end
+
local function asValue(source, title)
local name = buildName(source)
local infers = vm.getInfers(source, 'deep')
@@ -175,5 +188,7 @@ return function (source, oop)
return asLibrary(source)
elseif source.type == 'doc.type.function' then
return asDocFunction(source)
+ elseif source.type == 'doc.type.name' then
+ return asDocTypeName(source)
end
end