LanguageClient: Restructure request response handling

Instead of working on a Client member IContent now returns an optional
response handler that consists of an id, a name and a callback.

Change-Id: I5ca7dd4eaa7ae37f333f99c9fe60339db03ebf2c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2020-10-29 12:38:05 +01:00
parent 558532b45f
commit f440dfe43a
4 changed files with 23 additions and 11 deletions

View File

@@ -245,7 +245,9 @@ void Client::initialize()
initializeCallback(initResponse);
});
// directly send data otherwise the state check would fail;
initRequest.registerResponseHandler(&m_responseHandlers);
if (Utils::optional<ResponseHandler> responseHandler = initRequest.responseHandler())
m_responseHandlers[responseHandler->id] = responseHandler->callback;
LanguageClientManager::logBaseMessage(LspLogMessage::ClientMessage,
name(),
initRequest.toBaseMessage());
@@ -321,7 +323,8 @@ void Client::sendContent(const IContent &content)
QTC_ASSERT(m_clientInterface, return);
QTC_ASSERT(m_state == Initialized, return);
sendPostponedDocumentUpdates();
content.registerResponseHandler(&m_responseHandlers);
if (Utils::optional<ResponseHandler> responseHandler = content.responseHandler())
m_responseHandlers[responseHandler->id] = responseHandler->callback;
QString error;
if (!QTC_GUARD(content.isValid(&error)))
Core::MessageManager::write(error);