LSP: Simplify content parsing

JsonRpcMessageHandler::toJsonObject can be expensive for huge
json objects like the clangd ast responses for big c++ files. Avoid
calling this function in Request::responseHandler. We already generate a
JsonRpcMessage in JsonRpcMessageHandler::parseContent to get the id of
the response so pass this around.

While at it also pass around references instead of pointers to simplify
the memory handling of generated messages.

Change-Id: I9a3c7e85428fc064d1ea1197d897739725265192
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2022-04-11 07:28:29 +02:00
parent bc30523293
commit 42fc527fec
6 changed files with 94 additions and 123 deletions

View File

@@ -61,17 +61,6 @@ LanguageClientManager::LanguageClientManager(QObject *parent)
{
using namespace Core;
using namespace ProjectExplorer;
JsonRpcMessageHandler::registerMessageProvider<PublishDiagnosticsNotification>();
JsonRpcMessageHandler::registerMessageProvider<ApplyWorkspaceEditRequest>();
JsonRpcMessageHandler::registerMessageProvider<LogMessageNotification>();
JsonRpcMessageHandler::registerMessageProvider<ShowMessageRequest>();
JsonRpcMessageHandler::registerMessageProvider<ShowMessageNotification>();
JsonRpcMessageHandler::registerMessageProvider<WorkSpaceFolderRequest>();
JsonRpcMessageHandler::registerMessageProvider<RegisterCapabilityRequest>();
JsonRpcMessageHandler::registerMessageProvider<UnregisterCapabilityRequest>();
JsonRpcMessageHandler::registerMessageProvider<WorkDoneProgressCreateRequest>();
JsonRpcMessageHandler::registerMessageProvider<ProgressNotification>();
JsonRpcMessageHandler::registerMessageProvider<SemanticTokensRefreshRequest>();
connect(EditorManager::instance(), &EditorManager::editorOpened,
this, &LanguageClientManager::editorOpened);
connect(EditorManager::instance(), &EditorManager::documentOpened,