aboutsummaryrefslogtreecommitdiff
path: root/test/client/session.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2024-01-15 19:49:08 +0000
committerLewis Russell <lewis6991@gmail.com>2024-01-17 10:10:17 +0000
commit26835d8d9cf1312d2851b191fe859c6f62d9d9d4 (patch)
treef2dd9bf5c2283a62a91c67372f2cebd454c6c0a2 /test/client/session.lua
parent5a16d08a6389596c89691b45b06121b4814a089f (diff)
downloadrneovim-26835d8d9cf1312d2851b191fe859c6f62d9d9d4.tar.gz
rneovim-26835d8d9cf1312d2851b191fe859c6f62d9d9d4.tar.bz2
rneovim-26835d8d9cf1312d2851b191fe859c6f62d9d9d4.zip
test: add type annotations
Diffstat (limited to 'test/client/session.lua')
-rw-r--r--test/client/session.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/client/session.lua b/test/client/session.lua
index 86b4ee7103..cf3d8c4f25 100644
--- a/test/client/session.lua
+++ b/test/client/session.lua
@@ -1,6 +1,12 @@
local uv = vim.uv
local MsgpackRpcStream = require('test.client.msgpack_rpc_stream')
+--- @class test.Session
+--- @field private _pending_messages string[]
+--- @field private _msgpack_rpc_stream test.MsgpackRpcStream
+--- @field private _prepare uv.uv_prepare_t
+--- @field private _timer uv.uv_timer_t
+--- @field private _is_running boolean
local Session = {}
Session.__index = Session
if package.loaded['jit'] then
@@ -26,7 +32,7 @@ end
local function coroutine_exec(func, ...)
local args = { ... }
- local on_complete
+ local on_complete --- @type function?
if #args > 0 and type(args[#args]) == 'function' then
-- completion callback
@@ -54,6 +60,8 @@ function Session.new(stream)
}, Session)
end
+--- @param timeout integer?
+--- @return string?
function Session:next_message(timeout)
local function on_request(method, args, response)
table.insert(self._pending_messages, { 'request', method, args, response })
@@ -86,6 +94,10 @@ function Session:notify(method, ...)
self._msgpack_rpc_stream:write(method, { ... })
end
+--- @param method string
+--- @param ... any
+--- @return boolean
+--- @return table
function Session:request(method, ...)
local args = { ... }
local err, result