From 6fb028ef9e053076170ed03e46b9a4ab5d248e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 26 Jun 2019 18:09:32 +0800 Subject: =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=8F=90=E7=A4=BA=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=A4=9A=E5=8E=9F=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/core/signature.lua | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'server/src/core') diff --git a/server/src/core/signature.lua b/server/src/core/signature.lua index 92b44e32..62aa5b3c 100644 --- a/server/src/core/signature.lua +++ b/server/src/core/signature.lua @@ -47,15 +47,15 @@ local function getFunctionSource(call) return nil end -local function getHover(call, pos) +local function hovers(call, pos) local args = call:bindCall() if not args then - return + return nil end local value = call:findCallFunction() if not value then - return + return nil end local select = getSelect(args, pos) @@ -63,20 +63,29 @@ local function getHover(call, pos) local object = source:get 'object' local lib, fullkey = findLib(source) local name = fullkey or buildValueName(source) - local hover + local hovers = {} if lib then - hover = getFunctionHoverAsLib(name, lib, object, select) + hovers[#hovers+1] = getFunctionHoverAsLib(name, lib, object, select) else local emmy = value:getEmmy() if emmy and emmy.type == 'emmy.functionType' then - hover = getFunctionHoverAsEmmy(name, emmy, object, select) + hovers[#hovers+1] = getFunctionHoverAsEmmy(name, emmy, object, select) else - hover = getFunctionHover(name, value:getFunction(), object, select) + ---@type emmyFunction + local func = value:getFunction() + hovers[#hovers+1] = getFunctionHover(name, func, object, select) + local overLoads = func and func:getEmmyOverLoads() + if overLoads then + for _, ol in ipairs(overLoads) do + hovers[#hovers+1] = getFunctionHoverAsEmmy(name, ol, object, select) + end + end end end - if hover and hover.argLabel then - return hover + if #hovers == 0 then + return nil end + return hovers end local function isInFunctionOrTable(call, pos) @@ -109,12 +118,8 @@ return function (vm, pos) if isInFunctionOrTable(nearCall, pos) then return nil end - -- TODO 重构后改成显示多原型 - local hovers = { getHover(nearCall, pos) } - if #hovers == 0 then - return nil - end + local hovers = hovers(nearCall, pos) return hovers end -- cgit v1.2.3