From d283727cffff43312e5129801e265c2957d507d6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 2 Apr 2019 17:09:56 +0800 Subject: =?UTF-8?q?=E5=87=BD=E6=95=B0=E9=87=8D=E6=96=B0=E4=BB=8E=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E6=9F=A5=E6=89=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/core/completion.lua | 11 ++++++++--- server/src/core/diagnostics.lua | 11 +++++++---- server/src/core/hover/hover.lua | 5 +++-- server/src/core/signature.lua | 16 +++++++++++----- 4 files changed, 29 insertions(+), 14 deletions(-) (limited to 'server/src/core') diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua index 027f7faa..112e6408 100644 --- a/server/src/core/completion.lua +++ b/server/src/core/completion.lua @@ -400,12 +400,17 @@ local function searchCallArg(vm, source, word, callback, pos) return a.start > b.start end) local call = results[1] - local func, args = call:bindCall() - if not func then + local args = call:bindCall() + if not args then return end - local lib = func:getLib() + local value = call:findCallFunction() + if not value then + return + end + + local lib = value:getLib() if not lib then return end diff --git a/server/src/core/diagnostics.lua b/server/src/core/diagnostics.lua index 71995167..7337dd7b 100644 --- a/server/src/core/diagnostics.lua +++ b/server/src/core/diagnostics.lua @@ -203,14 +203,17 @@ end function mt:searchRedundantParameters(callback) self.vm:eachSource(function (source) - local call, args = source:bindCall() - if not call then + local args = source:bindCall() + if not args then return end - local func = call:getFunction() - if not func then + + local value = source:findCallFunction() + if not value then return end + + local func = value:getFunction() -- 参数中有 ... ,不用再检查了 if func:hasDots() then return diff --git a/server/src/core/hover/hover.lua b/server/src/core/hover/hover.lua index f09bfce4..dfaeed35 100644 --- a/server/src/core/hover/hover.lua +++ b/server/src/core/hover/hover.lua @@ -177,7 +177,7 @@ end local function hoverAsValue(source, lsp, select) local lib, fullkey = findLib(source) - local value = source:bindValue() + local value = source:findValue() local name = fullkey or buildValueName(source) local hover @@ -186,7 +186,8 @@ local function hoverAsValue(source, lsp, select) if lib then hover = getFunctionHoverAsLib(name, lib, object, select) else - hover = getFunctionHover(name, value:getFunction(), object, select) + local func = value:getFunction() + hover = getFunctionHover(name, func, object, select) end else hover = getValueHover(source, name, value, lib) diff --git a/server/src/core/signature.lua b/server/src/core/signature.lua index 23dba97a..5dcce85f 100644 --- a/server/src/core/signature.lua +++ b/server/src/core/signature.lua @@ -47,10 +47,16 @@ local function getFunctionSource(call) end local function getHover(call, pos) - local func, args = call:bindCall() - if not func then + local args = call:bindCall() + if not args then + return + end + + local value = call:findCallFunction() + if not value then return end + local select = getSelect(args, pos) local source = getFunctionSource(call) local object = source:get 'object' @@ -60,7 +66,7 @@ local function getHover(call, pos) if lib then hover = getFunctionHoverAsLib(name, lib, object, select) else - hover = getFunctionHover(name, func:getFunction(), object, select) + hover = getFunctionHover(name, value:getFunction(), object, select) end if hover and hover.argLabel then return hover @@ -68,8 +74,8 @@ local function getHover(call, pos) end local function isInFunctionOrTable(call, pos) - local func, args = call:bindCall() - if not func then + local args = call:bindCall() + if not args then return false end local select = getSelect(args, pos) -- cgit v1.2.3