diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-21 17:16:30 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-21 17:16:30 +0800 |
commit | aeac4c08a5a6ed1c832ca62aad0190e660887abe (patch) | |
tree | ce90e38b7cb4c3ebb244eed2382f5c58a7165b19 /server | |
parent | 6dca52b18108d11ab08a8b951eb98115c06b5640 (diff) | |
download | lua-language-server-aeac4c08a5a6ed1c832ca62aad0190e660887abe.zip |
因为自动配对括号,正常语法也要尝试参数提示
Diffstat (limited to 'server')
-rw-r--r-- | server/src/matcher/signature.lua | 10 | ||||
-rw-r--r-- | server/src/parser/ast.lua | 4 | ||||
-rw-r--r-- | server/src/parser/grammar.lua | 3 | ||||
-rw-r--r-- | server/test/signature/init.lua | 11 |
4 files changed, 19 insertions, 9 deletions
diff --git a/server/src/matcher/signature.lua b/server/src/matcher/signature.lua index 60316a5f..159fde80 100644 --- a/server/src/matcher/signature.lua +++ b/server/src/matcher/signature.lua @@ -20,7 +20,7 @@ end local function findDirtyCall(vm, pos) local results = {} for _, call in ipairs(vm.results.calls) do - if call.args.dirty and isContainPos(call.args, pos) then + if isContainPos(call.args, pos) then local n = findArgCount(call.args, pos) results[#results+1] = { func = call.func, @@ -45,8 +45,12 @@ return function (vm, pos) end local hovers = {} - for i, call in ipairs(calls) do - hovers[i] = hover(call.var, call.source, nil, call.select) + for _, call in ipairs(calls) do + hovers[#hovers+1] = hover(call.var, call.source, nil, call.select) + end + + if #hovers == 0 then + return nil end return hovers diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua index 0b3e369a..45a0cbee 100644 --- a/server/src/parser/ast.lua +++ b/server/src/parser/ast.lua @@ -119,10 +119,6 @@ local defs = { } return obj end, - DirtyCall = function (obj) - obj.dirty = true - return obj - end, Binary = function (...) local e1, op = ... if not op then diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua index d7464e5b..942c23fc 100644 --- a/server/src/parser/grammar.lua +++ b/server/src/parser/grammar.lua @@ -268,8 +268,7 @@ Suffix <- DOT MustName / Sp ({} Table {}) -> Call / Sp ({} String {}) -> Call / BL Exp -> Index BR - / Sp ({} PL ExpList PR {}) -> Call - / Sp ({} PL ExpList {}) -> Call -> DirtyCall + / Sp ({} PL ExpList PR? {}) -> Call DirtyExp <- Exp / DirtyName ExpList <- (COMMA DirtyExp)+ diff --git a/server/test/signature/init.lua b/server/test/signature/init.lua index 855ffa24..0c343384 100644 --- a/server/test/signature/init.lua +++ b/server/test/signature/init.lua @@ -33,3 +33,14 @@ x(@ label = "function x(a: any, b: any)", arg = 'a: any' } + +TEST [[ +local function x(a, b) +end + +x(@) +]] +{ + label = "function x(a: any, b: any)", + arg = 'a: any' +} |