From daee93fb17e8f206e63ab8573566762011a3f1cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 28 Jun 2019 15:01:16 +0800 Subject: =?UTF-8?q?=E4=BF=AE=E6=94=B9enum=E7=9A=84=E8=AF=AD=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/core/completion.lua | 15 ++++++++------- server/src/core/hover/function.lua | 12 ++++++------ 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'server/src/core') diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua index ddbe7271..6ab3c565 100644 --- a/server/src/core/completion.lua +++ b/server/src/core/completion.lua @@ -663,14 +663,14 @@ 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 +local function buildEmmyEnumComment(enum, data) + if not enum.comment then return data end if not data then data = {} end - data.documentation = tostring(option.comment) + data.documentation = tostring(enum.comment) return data end @@ -688,18 +688,19 @@ local function searchEnumAsEmmyParams(vm, source, word, callback, pos, args, fun return end - param:eachEnum(function (str, option) + param:eachEnum(function (enum) + local str = enum[1] 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, buildEmmyEnumComment(option, data)) + callback(str, nil, CompletionItemKind.EnumMember, buildEmmyEnumComment(enum, data)) else - callback(str, nil, CompletionItemKind.EnumMember, buildEmmyEnumComment(option)) + callback(str, nil, CompletionItemKind.EnumMember, buildEmmyEnumComment(enum)) end else - callback(str, nil, CompletionItemKind.EnumMember, buildEmmyEnumComment(option)) + callback(str, nil, CompletionItemKind.EnumMember, buildEmmyEnumComment(enum)) end end end) diff --git a/server/src/core/hover/function.lua b/server/src/core/hover/function.lua index b3bbb428..620eb054 100644 --- a/server/src/core/hover/function.lua +++ b/server/src/core/hover/function.lua @@ -129,18 +129,18 @@ local function buildEnum(func) local strs = {} for _, param in ipairs(params) do local first = true - param:eachEnum(function (enum, option) + param:eachEnum(function (enum) if first then first = false strs[#strs+1] = ('\n%s: %s'):format(param:getName(), param:getType()) end - if option and option.default then - strs[#strs+1] = ('\n |>%s'):format(enum) + if enum.default then + strs[#strs+1] = ('\n |>%s'):format(enum[1]) else - strs[#strs+1] = ('\n | %s'):format(enum) + strs[#strs+1] = ('\n | %s'):format(enum[1]) end - if option and option.comment then - strs[#strs+1] = ' -- ' .. option.comment + if enum.comment then + strs[#strs+1] = ' -- ' .. enum.comment end end) end -- cgit v1.2.3