forked from qt-creator/qt-creator
Lua: add send message to LSP Client interface
Change-Id: I9fa1d85041e97b5b69ae139e14510027c6097344 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -318,6 +318,16 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sendMessage(const sol::table &message)
|
||||||
|
{
|
||||||
|
const QJsonValue messageValue = ::Lua::LuaEngine::toJson(message);
|
||||||
|
if (!messageValue.isObject())
|
||||||
|
throw sol::error("Message is not an object");
|
||||||
|
const LanguageServerProtocol::JsonRpcMessage jsonrpcmessage(messageValue.toObject());
|
||||||
|
for (Client *c : m_clients)
|
||||||
|
c->sendMessage(jsonrpcmessage);
|
||||||
|
}
|
||||||
|
|
||||||
void updateOptions()
|
void updateOptions()
|
||||||
{
|
{
|
||||||
if (m_cmdLineCallback) {
|
if (m_cmdLineCallback) {
|
||||||
@@ -472,6 +482,8 @@ static void registerLuaApi()
|
|||||||
[](LuaClientWrapper *c, const sol::function &f) { c->m_onInstanceStart = f; }),
|
[](LuaClientWrapper *c, const sol::function &f) { c->m_onInstanceStart = f; }),
|
||||||
"registerMessage",
|
"registerMessage",
|
||||||
&LuaClientWrapper::registerMessageCallback,
|
&LuaClientWrapper::registerMessageCallback,
|
||||||
|
"sendMessage",
|
||||||
|
&LuaClientWrapper::sendMessage,
|
||||||
"create",
|
"create",
|
||||||
[](const sol::table &options) -> std::shared_ptr<LuaClientWrapper> {
|
[](const sol::table &options) -> std::shared_ptr<LuaClientWrapper> {
|
||||||
auto luaClient = std::make_shared<LuaClientWrapper>(options);
|
auto luaClient = std::make_shared<LuaClientWrapper>(options);
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ lsp.Client = {}
|
|||||||
---Registers a message handler for the message named 'msg'
|
---Registers a message handler for the message named 'msg'
|
||||||
function lsp.Client:registerMessage(msg, callback) end
|
function lsp.Client:registerMessage(msg, callback) end
|
||||||
|
|
||||||
|
---@param msg table the message to send
|
||||||
|
---Sends a message to the language server
|
||||||
|
function lsp.Client:sendMessage(msg, callback) end
|
||||||
|
|
||||||
---Creates a new Language Client
|
---Creates a new Language Client
|
||||||
---@param options ClientOptions
|
---@param options ClientOptions
|
||||||
---@return Client
|
---@return Client
|
||||||
|
|||||||
Reference in New Issue
Block a user