summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/proto/proto.lua6
-rw-r--r--script/provider/completion.lua2
-rw-r--r--script/workspace/workspace.lua3
-rw-r--r--test.lua13
-rw-r--r--test/tclient/lclient.lua33
-rw-r--r--test/tclient/tests/single-mode.lua6
6 files changed, 41 insertions, 22 deletions
diff --git a/script/proto/proto.lua b/script/proto/proto.lua
index 2b9a6963..b29d44b0 100644
--- a/script/proto/proto.lua
+++ b/script/proto/proto.lua
@@ -137,6 +137,9 @@ function m.doMethod(proto)
logRecieve(proto)
local method, optional = m.getMethodName(proto)
local abil = m.ability[method]
+ if proto.id then
+ m.holdon[proto.id] = proto
+ end
if not abil then
if not optional then
log.warn('Recieved unknown proto: ' .. method)
@@ -146,9 +149,6 @@ function m.doMethod(proto)
end
return
end
- if proto.id then
- m.holdon[proto.id] = proto
- end
await.call(function () ---@async
--log.debug('Start method:', method)
if proto.id then
diff --git a/script/provider/completion.lua b/script/provider/completion.lua
index 9bcccc66..3c0c82d7 100644
--- a/script/provider/completion.lua
+++ b/script/provider/completion.lua
@@ -30,6 +30,7 @@ local function enable(uri)
end
nonil.enable()
if not client.info.capabilities.textDocument.completion.dynamicRegistration then
+ nonil.disable()
return
end
nonil.disable()
@@ -55,6 +56,7 @@ local function disable(uri)
end
nonil.enable()
if not client.info.capabilities.textDocument.completion.dynamicRegistration then
+ nonil.disable()
return
end
nonil.disable()
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua
index c11d3e78..c537d78b 100644
--- a/script/workspace/workspace.lua
+++ b/script/workspace/workspace.lua
@@ -385,9 +385,6 @@ function m.reload(scp)
if not m.inited then
return
end
- if TEST then
- return
- end
---@async
await.call(function ()
m.awaitReload(scp)
diff --git a/test.lua b/test.lua
index 3acab926..61b5d766 100644
--- a/test.lua
+++ b/test.lua
@@ -82,17 +82,18 @@ end
local function main()
require 'utility'.enableCloseFunction()
- require 'core.searcher'.debugMode = true
- require 'language' 'zh-cn'
require 'library'.init()
- loadDocMetas()
- --test 'tclient'
+ test 'tclient'
--config.Lua.intelliSense.searchDepth = 5
--loadDocMetas()
--test 'full';do return end
-
+ require 'workspace.workspace'.reset()
+ require 'files'.reset()
+ require 'workspace.scope'.reset()
+ require 'language' 'zh-cn'
+ loadDocMetas()
require 'bee.platform'.OS = 'Windows'
testAll()
require 'bee.platform'.OS = 'Linux'
@@ -102,7 +103,7 @@ local function main()
--test 'tclient'
- --test 'full'
+ test 'full'
print('测试完成')
end
diff --git a/test/tclient/lclient.lua b/test/tclient/lclient.lua
index 50f13946..4273d88c 100644
--- a/test/tclient/lclient.lua
+++ b/test/tclient/lclient.lua
@@ -49,6 +49,8 @@ function mt:start(callback)
finished = true
end)
+ local jumpedTime = 0
+
while true do
if finished then
break
@@ -64,6 +66,10 @@ function mt:start(callback)
goto CONTINUE
end
timer.timeJump(1.0)
+ jumpedTime = jumpedTime + 1.0
+ if jumpedTime > 2 * 60 * 60 then
+ error('two hours later ...')
+ end
::CONTINUE::
end
@@ -111,10 +117,14 @@ function mt:update()
for _, out in ipairs(outs) do
if out.method then
local callback = self._methods[out.method]
- proto.doResponse {
- id = out.id,
- params = callback(out.params),
- }
+ if callback then
+ proto.doResponse {
+ id = out.id,
+ params = callback(out.params),
+ }
+ elseif out.method:sub(1, 2) ~= '$/' then
+ error('Unknown method: ' .. out.method)
+ end
else
local callback = self._waiting[out.id]
self._waiting[out.id] = nil
@@ -124,8 +134,19 @@ function mt:update()
return true
end
-function mt:register(name, callback)
- self._methods[name] = callback
+function mt:register(method, callback)
+ self._methods[method] = callback
+end
+
+function mt:registerFakers()
+ for _, method in ipairs {
+ 'workspace/configuration',
+ 'textDocument/publishDiagnostics',
+ } do
+ self:register(method, function ()
+ return nil
+ end)
+ end
end
---@return languageClient
diff --git a/test/tclient/tests/single-mode.lua b/test/tclient/tests/single-mode.lua
index e0773a7e..897eee31 100644
--- a/test/tclient/tests/single-mode.lua
+++ b/test/tclient/tests/single-mode.lua
@@ -5,9 +5,7 @@ local util = require 'utility'
---@async
lclient():start(function (client)
- client:register('workspace/configuration', function ()
- return nil
- end)
+ client:registerFakers()
client:awaitRequest('initialize', {
clientInfo = {
@@ -33,7 +31,7 @@ print(x)
ws.awaitReady()
- local locations = client:awaitRequest('textDocument.definition', {
+ local locations = client:awaitRequest('textDocument/definition', {
textDocument = { uri = 'test://single-file.lua' },
position = { line = 1, character = 7 },
})