From 20b562e48b11df93a5926c919d793c1fe00aa018 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 10:25:35 +0800 Subject: =?UTF-8?q?hover=E6=97=B6=E5=B0=9D=E8=AF=95=E5=B0=86=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E5=8E=9F=E5=9E=8B=E5=85=A8=E9=83=A8=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=87=BA=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/core/hover/function.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'server/src/core/hover/function.lua') 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 -- cgit v1.2.3