From efa8bfce8228bc615e2870cbc4394bef0ab3cb9d Mon Sep 17 00:00:00 2001 From: sumneko Date: Mon, 22 Apr 2019 14:52:14 +0800 Subject: =?UTF-8?q?=E5=85=A8=E5=B1=80=E5=80=BC=E8=B7=B3=E8=BD=AC=E7=AD=89?= =?UTF-8?q?=E5=BE=85=E7=BC=96=E8=AF=91=E5=AE=8C=E6=88=90=EF=BC=88=E8=BD=AC?= =?UTF-8?q?=E5=88=B0=E5=AE=9A=E4=B9=89=E8=B6=85=E6=97=B61=E7=A7=92?= =?UTF-8?q?=EF=BC=8C=E6=9F=A5=E6=89=BE=E5=BC=95=E7=94=A8=E8=B6=85=E6=97=B6?= =?UTF-8?q?5=E7=A7=92=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/method/initialize.lua | 1 - server/src/method/textDocument/definition.lua | 28 +++++++++------------------ server/src/method/textDocument/references.lua | 20 ++++++++----------- 3 files changed, 17 insertions(+), 32 deletions(-) (limited to 'server/src/method') diff --git a/server/src/method/initialize.lua b/server/src/method/initialize.lua index 82ff9640..5478e744 100644 --- a/server/src/method/initialize.lua +++ b/server/src/method/initialize.lua @@ -13,7 +13,6 @@ return function (lsp) capabilities = { hoverProvider = true, definitionProvider = true, - implementationProvider = true, referencesProvider = true, renameProvider = true, documentSymbolProvider = true, diff --git a/server/src/method/textDocument/definition.lua b/server/src/method/textDocument/definition.lua index fe8d38a5..50076c1c 100644 --- a/server/src/method/textDocument/definition.lua +++ b/server/src/method/textDocument/definition.lua @@ -26,9 +26,9 @@ local function findResult(lsp, params) checkWorkSpaceComplete(lsp, source) - local positions = core.definition(vm, source, lsp) + local positions, isGlobal = core.definition(vm, source, lsp) if not positions then - return nil + return nil, isGlobal end local locations = {} @@ -70,10 +70,10 @@ local function findResult(lsp, params) end if #locations == 0 then - return nil + return nil, isGlobal end - return locations + return locations, isGlobal end local LastTask @@ -83,27 +83,17 @@ return function (lsp, params) LastTask:remove() LastTask = nil end - local result = findResult(lsp, params) - if result then - return result - end return function (response) - local count = 0 + local clock = os.clock() LastTask = ac.loop(0.1, function () - local result = findResult(lsp, params) - if result then - response(result) - LastTask:remove() - LastTask = nil - return - end - count = count + 1 - if lsp:isWaitingCompile() and count < 10 then + local result, isGlobal = findResult(lsp, params) + if isGlobal and lsp:isWaitingCompile() and os.clock() - clock < 1 then return end - response(nil) + response(result) LastTask:remove() LastTask = nil end) + LastTask:onTimer() end end diff --git a/server/src/method/textDocument/references.lua b/server/src/method/textDocument/references.lua index d969e919..397b1491 100644 --- a/server/src/method/textDocument/references.lua +++ b/server/src/method/textDocument/references.lua @@ -4,7 +4,7 @@ local LastTask local function findReferences(lsp, uri, position, declarat) local vm = lsp:getVM(uri) - local positions = core.references(vm, position, declarat) + local positions, isGlobal = core.references(vm, position, declarat) if not positions then return nil end @@ -48,10 +48,10 @@ local function findReferences(lsp, uri, position, declarat) end if #locations == 0 then - return nil + return nil, isGlobal end - return locations + return locations, isGlobal end return function (lsp, params) @@ -71,20 +71,16 @@ return function (lsp, params) local position = lines:positionAsChar(params.position.line + 1, params.position.character) return function (response) + local clock = os.clock() LastTask = ac.loop(0.1, function (t) - local positions = findReferences(lsp, uri, position, declarat) - if positions then - response(positions) - t:remove() - LastTask = nil - return - end - if lsp:isWaitingCompile() then + local positions, isGlobal = findReferences(lsp, uri, position, declarat) + if isGlobal and lsp:isWaitingCompile() and os.clock() - clock < 5 then return end - response(nil) + response(positions) t:remove() LastTask = nil end) + LastTask:onTimer() end end -- cgit v1.2.3