summaryrefslogtreecommitdiff
path: root/server/src/core
diff options
context:
space:
mode:
authorunknown <sumnekosun@intranet.123u.com>2019-04-02 17:09:56 +0800
committerunknown <sumnekosun@intranet.123u.com>2019-04-02 17:09:56 +0800
commitd283727cffff43312e5129801e265c2957d507d6 (patch)
tree93333303de1715e6c2754213d6721bdcfcf73a22 /server/src/core
parent43e0d5819011e069893ee9f05eba2fc90d1b4bf5 (diff)
downloadlua-language-server-d283727cffff43312e5129801e265c2957d507d6.zip
函数重新从全局查找
Diffstat (limited to 'server/src/core')
-rw-r--r--server/src/core/completion.lua11
-rw-r--r--server/src/core/diagnostics.lua11
-rw-r--r--server/src/core/hover/hover.lua5
-rw-r--r--server/src/core/signature.lua16
4 files changed, 29 insertions, 14 deletions
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)