summaryrefslogtreecommitdiff
path: root/server/src/core/hover
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-08-27 21:36:43 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-08-27 21:36:43 +0800
commitf3ef253b0c5ced3727e96df88fa16886f03325ec (patch)
treedd416f67f75b00e85a7acb515efecfcfde419e30 /server/src/core/hover
parent7d041b4d7507190141eaac05501d479b77aa8771 (diff)
downloadlua-language-server-f3ef253b0c5ced3727e96df88fa16886f03325ec.zip
调用片段支持枚举
Diffstat (limited to 'server/src/core/hover')
-rw-r--r--server/src/core/hover/emmy_function.lua8
-rw-r--r--server/src/core/hover/function.lua9
-rw-r--r--server/src/core/hover/lib_function.lua8
3 files changed, 19 insertions, 6 deletions
diff --git a/server/src/core/hover/emmy_function.lua b/server/src/core/hover/emmy_function.lua
index e38e54a4..36fd4e90 100644
--- a/server/src/core/hover/emmy_function.lua
+++ b/server/src/core/hover/emmy_function.lua
@@ -89,6 +89,7 @@ local function buildEnum(lib)
::NEXT_ENUM::
end
local strs = {}
+ local raw = {}
for name, enums in pairs(container) do
local tp
if type(enums.type) == 'table' then
@@ -96,6 +97,7 @@ local function buildEnum(lib)
else
tp = enums.type
end
+ raw[name] = {}
strs[#strs+1] = ('\n%s: %s'):format(name, tp or 'any')
for _, enum in ipairs(enums) do
if enum.default then
@@ -108,18 +110,19 @@ local function buildEnum(lib)
else
strs[#strs+1] = ('%q'):format(enum.enum)
end
+ raw[name][#raw[name]+1] = strs[#strs]
if enum.description then
strs[#strs+1] = ' -- ' .. enum.description
end
end
end
- return table.concat(strs)
+ return table.concat(strs), raw
end
return function (name, emmy, object, select)
local argStr, argLabel, args = buildEmmyArgs(emmy, object, select)
local returns = buildEmmyReturns(emmy)
- local enum = buildEnum(emmy)
+ local enum, rawEnum = buildEnum(emmy)
local tip = emmy.description
local headLen = #('function %s('):format(name)
local title = ('function %s(%s)%s'):format(name, argStr, returns)
@@ -131,6 +134,7 @@ return function (name, emmy, object, select)
label = title,
description = tip,
enum = enum,
+ rawEnum = rawEnum,
argLabel = argLabel,
args = args,
}
diff --git a/server/src/core/hover/function.lua b/server/src/core/hover/function.lua
index eab1ff59..6f8f325c 100644
--- a/server/src/core/hover/function.lua
+++ b/server/src/core/hover/function.lua
@@ -159,8 +159,11 @@ local function buildEnum(func)
return nil
end
local strs = {}
+ local raw = {}
for _, param in ipairs(params) do
local first = true
+ local name = param:getName()
+ raw[name] = {}
param:eachEnum(function (enum)
if first then
first = false
@@ -174,12 +177,13 @@ local function buildEnum(func)
if enum.comment then
strs[#strs+1] = ' -- ' .. enum.comment
end
+ raw[name][#raw[name]+1] = enum[1]
end)
end
if #strs == 0 then
return nil
end
- return table.concat(strs)
+ return table.concat(strs), raw
end
local function getComment(func)
@@ -219,7 +223,7 @@ end
return function (name, func, object, select)
local argStr, argLabel, args = buildValueArgs(func, object, select)
local returns = buildValueReturns(func)
- local enum = buildEnum(func)
+ local enum, rawEnum = buildEnum(func)
local comment = getComment(func)
local overloads = getOverLoads(name, func, object, select)
local headLen = #('function %s('):format(name)
@@ -232,6 +236,7 @@ return function (name, func, object, select)
label = title,
description = comment,
enum = enum,
+ rawEnum = rawEnum,
argLabel = argLabel,
overloads = overloads,
args = args,
diff --git a/server/src/core/hover/lib_function.lua b/server/src/core/hover/lib_function.lua
index 75e70064..57ba1417 100644
--- a/server/src/core/hover/lib_function.lua
+++ b/server/src/core/hover/lib_function.lua
@@ -149,6 +149,7 @@ local function buildEnum(lib)
::NEXT_ENUM::
end
local strs = {}
+ local raw = {}
for name, enums in pairs(container) do
local tp
if type(enums.type) == 'table' then
@@ -157,6 +158,7 @@ local function buildEnum(lib)
tp = enums.type
end
strs[#strs+1] = ('\n%s: %s'):format(name, tp or 'any')
+ raw[name] = {}
for _, enum in ipairs(enums) do
if enum.default then
strs[#strs+1] = '\n -> '
@@ -168,12 +170,13 @@ local function buildEnum(lib)
else
strs[#strs+1] = tostring(enum.enum)
end
+ raw[name][#raw[name]+1] = strs[#strs]
if enum.description then
strs[#strs+1] = ' -- ' .. enum.description
end
end
end
- return table.concat(strs)
+ return table.concat(strs), raw
end
local function buildDoc(lib)
@@ -198,7 +201,7 @@ end
return function (name, lib, object, select)
local argStr, argLabel, args = buildLibArgs(lib, object, select)
local returns = buildLibReturns(lib)
- local enum = buildEnum(lib)
+ local enum, rawEnum = buildEnum(lib)
local tip = lib.description
local doc = buildDoc(lib)
local headLen = #('function %s('):format(name)
@@ -211,6 +214,7 @@ return function (name, lib, object, select)
label = title,
description = tip,
enum = enum,
+ rawEnum = rawEnum,
argLabel = argLabel,
doc = doc,
args = args,