summaryrefslogtreecommitdiff
path: root/server/src/method
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2019-04-22 14:52:14 +0800
committersumneko <sumneko@hotmail.com>2019-04-22 14:52:14 +0800
commitefa8bfce8228bc615e2870cbc4394bef0ab3cb9d (patch)
treec5c89bc67473c1525de1e1d912bab8517f59e7a9 /server/src/method
parentadb221773bbfffcec5e486a8e4f52e44d594508b (diff)
downloadlua-language-server-efa8bfce8228bc615e2870cbc4394bef0ab3cb9d.zip
全局值跳转等待编译完成(转到定义超时1秒,查找引用超时5秒)
Diffstat (limited to 'server/src/method')
-rw-r--r--server/src/method/initialize.lua1
-rw-r--r--server/src/method/textDocument/definition.lua28
-rw-r--r--server/src/method/textDocument/references.lua20
3 files changed, 17 insertions, 32 deletions
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