From aeac4c08a5a6ed1c832ca62aad0190e660887abe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 21 Dec 2018 17:16:30 +0800 Subject: =?UTF-8?q?=E5=9B=A0=E4=B8=BA=E8=87=AA=E5=8A=A8=E9=85=8D=E5=AF=B9?= =?UTF-8?q?=E6=8B=AC=E5=8F=B7=EF=BC=8C=E6=AD=A3=E5=B8=B8=E8=AF=AD=E6=B3=95?= =?UTF-8?q?=E4=B9=9F=E8=A6=81=E5=B0=9D=E8=AF=95=E5=8F=82=E6=95=B0=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/matcher/signature.lua | 10 +++++++--- server/src/parser/ast.lua | 4 ---- server/src/parser/grammar.lua | 3 +-- server/test/signature/init.lua | 11 +++++++++++ 4 files changed, 19 insertions(+), 9 deletions(-) (limited to 'server') 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' +} -- cgit v1.2.3