From 07c2cec7341676e587fe73f7ecbd361c9eb9a5b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 27 Jun 2019 21:42:53 +0800 Subject: =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=AE=8C=E6=88=90=E6=94=AF=E6=8C=81e?= =?UTF-8?q?num.comment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/core/completion.lua | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'server/src') diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua index 37527ac2..ddbe7271 100644 --- a/server/src/core/completion.lua +++ b/server/src/core/completion.lua @@ -663,6 +663,17 @@ local function searchEnumAsLib(vm, source, word, callback, pos, args, lib) end end +local function buildEmmyEnumComment(option, data) + if not option or not option.comment then + return data + end + if not data then + data = {} + end + data.documentation = tostring(option.comment) + return data +end + local function searchEnumAsEmmyParams(vm, source, word, callback, pos, args, func) local select = #args + 1 for i, arg in ipairs(args) do @@ -677,18 +688,18 @@ local function searchEnumAsEmmyParams(vm, source, word, callback, pos, args, fun return end - param:eachEnum(function (str) + param:eachEnum(function (str, option) if matchKey(word, str) then local strSource = parser:ast(tostring(str), 'String') if strSource then if source.type == 'string' then local data = buildTextEdit(source.start, source.finish, strSource[1], source[2]) - callback(str, nil, CompletionItemKind.EnumMember, data) + callback(str, nil, CompletionItemKind.EnumMember, buildEmmyEnumComment(option, data)) else - callback(str, nil, CompletionItemKind.EnumMember) + callback(str, nil, CompletionItemKind.EnumMember, buildEmmyEnumComment(option)) end else - callback(str, nil, CompletionItemKind.EnumMember) + callback(str, nil, CompletionItemKind.EnumMember, buildEmmyEnumComment(option)) end end end) -- cgit v1.2.3