summaryrefslogtreecommitdiff
path: root/script-beta/core/hover/description.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-11-16 15:42:57 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-11-16 15:42:57 +0800
commitdd0d670b21868181ff07b7a97f3d51f21e4c4aec (patch)
treef231f31eb19e83e94d422bf2c2742a1fb58f6176 /script-beta/core/hover/description.lua
parent42a8bb0a11264fc4aa0d06615e8943e068a657a4 (diff)
downloadlua-language-server-dd0d670b21868181ff07b7a97f3d51f21e4c4aec.zip
additional 类型的 enum
Diffstat (limited to 'script-beta/core/hover/description.lua')
-rw-r--r--script-beta/core/hover/description.lua20
1 files changed, 17 insertions, 3 deletions
diff --git a/script-beta/core/hover/description.lua b/script-beta/core/hover/description.lua
index 7ba1ca52..39cfb07b 100644
--- a/script-beta/core/hover/description.lua
+++ b/script-beta/core/hover/description.lua
@@ -210,7 +210,9 @@ local function buildEnumChunk(docType, name)
lines[#lines+1] = ('%s: %s'):format(name, table.concat(types))
for _, enum in ipairs(enums) do
lines[#lines+1] = (' %s %s%s'):format(
- enum.default and '->' or ' |',
+ (enum.default and '->')
+ or (enum.additional and '+>')
+ or ' |',
enum[1],
enum.comment and (' -- %s'):format(enum.comment) or ''
)
@@ -219,17 +221,29 @@ local function buildEnumChunk(docType, name)
end
local function getBindEnums(source)
+ local mark = {}
local chunks = {}
local returnIndex = 0
for _, doc in ipairs(source.bindDocs) do
if doc.type == 'doc.param' then
- chunks[#chunks+1] = buildEnumChunk(doc.extends, doc.param[1])
+ local name = doc.param[1]
+ if mark[name] then
+ goto CONTINUE
+ end
+ mark[name] = true
+ chunks[#chunks+1] = buildEnumChunk(doc.extends, name)
elseif doc.type == 'doc.return' then
for _, rtn in ipairs(doc.returns) do
returnIndex = returnIndex + 1
- chunks[#chunks+1] = buildEnumChunk(rtn, rtn.name and rtn.name[1] or ('(return %d)'):format(returnIndex))
+ local name = rtn.name and rtn.name[1] or ('(return %d)'):format(returnIndex)
+ if mark[name] then
+ goto CONTINUE
+ end
+ mark[name] = true
+ chunks[#chunks+1] = buildEnumChunk(rtn, name)
end
end
+ ::CONTINUE::
end
if #chunks == 0 then
return nil