diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-03-29 10:16:33 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-03-29 10:16:33 +0800 |
commit | 9c2843279fb04b75169057c3d81a93ce87ebcf34 (patch) | |
tree | 228de57591f59de8349ca849f2200affefe77b7c /server | |
parent | 51fdb8bbd4a78703ca0dd95a68d09e8a188407c3 (diff) | |
download | lua-language-server-9c2843279fb04b75169057c3d81a93ce87ebcf34.zip |
在函数内或表内则不再提示参数
Diffstat (limited to 'server')
-rw-r--r-- | server/src/core/signature.lua | 21 | ||||
-rw-r--r-- | server/test/signature/init.lua | 11 |
2 files changed, 32 insertions, 0 deletions
diff --git a/server/src/core/signature.lua b/server/src/core/signature.lua index 1e629308..ca20f054 100644 --- a/server/src/core/signature.lua +++ b/server/src/core/signature.lua @@ -67,6 +67,22 @@ local function getHover(call, pos) end end +local function isInFunctionOrTable(call, pos) + local func, args = call:bindCall() + if not func then + return false + end + local select = getSelect(args, pos) + local arg = args[select] + if not arg then + return false + end + if arg.type == 'function' or arg.type == 'table' then + return true + end + return false +end + return function (vm, pos) local source = findSource(vm, pos) or findSource(vm, pos-1) if not source or source.type == 'string' then @@ -77,6 +93,11 @@ return function (vm, pos) return nil end + local nearCall = calls[1] + if isInFunctionOrTable(nearCall, pos) then + return nil + end + local hovers = {} for _, call in ipairs(calls) do hovers[#hovers+1] = getHover(call, pos) diff --git a/server/test/signature/init.lua b/server/test/signature/init.lua index cf335f05..3e83b5ba 100644 --- a/server/test/signature/init.lua +++ b/server/test/signature/init.lua @@ -13,6 +13,7 @@ function TEST(script) assert(vm) local hovers = core.signature(vm, pos) if hovers then + assert(expect) local hover = hovers[#hovers] local label = hover.label:gsub('^[\r\n]*(.-)[\r\n]*$', '%1'):gsub('\r\n', '\n') @@ -106,3 +107,13 @@ end f(1, 'string@') ]] (nil) + +TEST [[ +pcall(function () @ end) +]] +(nil) + +TEST [[ +table.unpack {@} +]] +(nil) |