diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-06-28 10:25:35 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-06-28 10:25:35 +0800 |
commit | 20b562e48b11df93a5926c919d793c1fe00aa018 (patch) | |
tree | 3ff69ea8c062336ad6b856f17c7d2d147cae4a3e /server/src/core/hover/function.lua | |
parent | 3d7cb724b13e75a7e4dab9b6bcf24e1f1f1de2b0 (diff) | |
download | lua-language-server-20b562e48b11df93a5926c919d793c1fe00aa018.zip |
hover时尝试将函数原型全部显示出来
Diffstat (limited to 'server/src/core/hover/function.lua')
-rw-r--r-- | server/src/core/hover/function.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/server/src/core/hover/function.lua b/server/src/core/hover/function.lua index 52402f83..5976806c 100644 --- a/server/src/core/hover/function.lua +++ b/server/src/core/hover/function.lua @@ -1,3 +1,5 @@ +local emmyFunction = require 'core.hover.emmy_function' + local function buildValueArgs(func, object, select) if not func then return '', nil @@ -155,11 +157,25 @@ local function getComment(func) return func:getComment() end +local function getOverLoads(name, func, object, select) + local overloads = func and func:getEmmyOverLoads() + if not overloads then + return nil + end + local list = {} + for _, ol in ipairs(overloads) do + local hover = emmyFunction(name, ol, object, select) + list[#list+1] = hover.label + end + return table.concat(list, '\n') +end + return function (name, func, object, select) local args, argLabel = buildValueArgs(func, object, select) local returns = buildValueReturns(func) local enum = buildEnum(func) local comment = getComment(func) + local overloads = getOverLoads(name, func, object, select) local headLen = #('function %s('):format(name) local title = ('function %s(%s)%s'):format(name, args, returns) if argLabel then @@ -171,5 +187,6 @@ return function (name, func, object, select) description = comment, enum = enum, argLabel = argLabel, + overloads = overloads, } end |