summaryrefslogtreecommitdiff
path: root/server/src/core/hover/function.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-06-26 20:52:59 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-06-26 20:52:59 +0800
commiteb4cc1e5915a2ac0fceaa4f6b08f7f0f762d3fb6 (patch)
tree82ef5a990f3b43b51d03785558398a97ba3aa46f /server/src/core/hover/function.lua
parentf92a71db462b2769eea194143f15ab090b665862 (diff)
downloadlua-language-server-eb4cc1e5915a2ac0fceaa4f6b08f7f0f762d3fb6.zip
用option来实现一些私有功能
Diffstat (limited to 'server/src/core/hover/function.lua')
-rw-r--r--server/src/core/hover/function.lua28
1 files changed, 26 insertions, 2 deletions
diff --git a/server/src/core/hover/function.lua b/server/src/core/hover/function.lua
index 5358cfaa..b0971308 100644
--- a/server/src/core/hover/function.lua
+++ b/server/src/core/hover/function.lua
@@ -4,6 +4,7 @@ local function buildValueArgs(func, object, select)
end
local names = {}
local values = {}
+ local options = {}
if func.argValues then
for i, value in ipairs(func.argValues) do
values[i] = value:getType()
@@ -15,6 +16,7 @@ local function buildValueArgs(func, object, select)
local param = func:findEmmyParamByName(arg:getName())
if param then
values[i] = param:getType()
+ options[i] = param:getOption()
end
end
end
@@ -30,11 +32,20 @@ local function buildValueArgs(func, object, select)
max = math.max(#names, #values)
end
for i = start, max do
+ local name = names[i]
+ local value = values[i] or 'any'
+ local option = options[i]
+ if option and option.optional then
+ if i > start then
+ strs[#strs+1] = ' ['
+ else
+ strs[#strs+1] = '['
+ end
+ end
if i > start then
strs[#strs+1] = ', '
end
- local name = names[i]
- local value = values[i] or 'any'
+
if i == select then
strs[#strs+1] = '@ARG'
end
@@ -46,6 +57,10 @@ local function buildValueArgs(func, object, select)
if i == select then
strs[#strs+1] = '@ARG'
end
+
+ if option and option.optional == 'self' then
+ strs[#strs+1] = ']'
+ end
end
if func:hasDots() then
if max > 0 then
@@ -53,6 +68,15 @@ local function buildValueArgs(func, object, select)
end
strs[#strs+1] = '...'
end
+
+ if options then
+ for _, option in pairs(options) do
+ if option.optional == 'after' then
+ strs[#strs+1] = ']'
+ end
+ end
+ end
+
local text = table.concat(strs)
local argLabel = {}
for i = 1, 2 do