summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-07 02:14:49 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-07 02:14:49 +0800
commit3e2948e1480659d7c29f9d701e378330c08b238f (patch)
tree897356bf814adf07642409741b1b55f5cb02a3f2 /script/core
parent55b423dbeabb6f04dc5429b362c7cb1f770dac93 (diff)
downloadlua-language-server-3e2948e1480659d7c29f9d701e378330c08b238f.zip
update
Diffstat (limited to 'script/core')
-rw-r--r--script/core/hover/description.lua26
1 files changed, 13 insertions, 13 deletions
diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua
index 49e8d2bc..cf6f0113 100644
--- a/script/core/hover/description.lua
+++ b/script/core/hover/description.lua
@@ -6,6 +6,7 @@ local lang = require 'language'
local util = require 'utility'
local guide = require 'parser.guide'
local rpath = require 'workspace.require-path'
+local infer = require 'vm.infer'
local function collectRequire(mode, literal, uri)
local result, searchers
@@ -152,29 +153,28 @@ local function tryDocModule(source)
end
local function buildEnumChunk(docType, name)
- local enums = vm.getDocEnums(docType)
- if not enums or #enums == 0 then
- return
- end
+ local enums = {}
local types = {}
+ local lines = {}
for _, tp in ipairs(docType.types) do
- if tp.type ~= 'doc.string'
- and tp.type ~= 'doc.integer' then
- types[#types+1] = tp[1]
+ types[#types+1] = infer.getInfer(tp):view()
+ if tp.type == 'doc.type.string'
+ or tp.type == 'doc.type.integer' then
+ enums[#enums+1] = tp
end
- end
- local lines = {}
- for _, typeUnit in ipairs(docType.types) do
- local comment = tryDocClassComment(typeUnit)
+ local comment = tryDocClassComment(tp)
if comment then
for line in util.eachLine(comment) do
lines[#lines+1] = ('-- %s'):format(line)
end
end
end
- lines[#lines+1] = ('%s: %s'):format(name, table.concat(types, '|'))
+ if #enums == 0 then
+ return
+ end
+ lines[#lines+1] = ('%s:'):format(name)
for _, enum in ipairs(enums) do
- local enumDes = (' %s %s'):format(
+ local enumDes = (' %s %q'):format(
(enum.default and '->')
or (enum.additional and '+>')
or ' |',