diff options
Diffstat (limited to 'src/plugins')
16 files changed, 90 insertions, 105 deletions
diff --git a/src/plugins/clangcodemodel/clangdast.cpp b/src/plugins/clangcodemodel/clangdast.cpp index 9e46c603b21..88a9416c72c 100644 --- a/src/plugins/clangcodemodel/clangdast.cpp +++ b/src/plugins/clangcodemodel/clangdast.cpp @@ -26,7 +26,6 @@ #include "clangdast.h" #include <languageclient/client.h> -#include <languageserverprotocol/icontent.h> #include <languageserverprotocol/jsonkeys.h> #include <languageserverprotocol/lsptypes.h> #include <utils/filepath.h> @@ -403,7 +402,7 @@ MessageId requestAst(Client *client, const FilePath &filePath, const Range range const auto result = response.result(); handler(result ? *result : ClangdAstNode(), reqId); }); - client->sendContent(request, Client::SendDocUpdates::Ignore); + client->sendMessage(request, Client::SendDocUpdates::Ignore); return request.id(); } diff --git a/src/plugins/clangcodemodel/clangdclient.cpp b/src/plugins/clangcodemodel/clangdclient.cpp index ef045b5da41..aa149ba4ddb 100644 --- a/src/plugins/clangcodemodel/clangdclient.cpp +++ b/src/plugins/clangcodemodel/clangdclient.cpp @@ -1271,13 +1271,13 @@ void ClangdClient::openExtraFile(const Utils::FilePath &filePath, const QString item.setUri(DocumentUri::fromFilePath(filePath)); item.setText(!content.isEmpty() ? content : QString::fromUtf8(cxxFile.readAll())); item.setVersion(0); - sendContent(DidOpenTextDocumentNotification(DidOpenTextDocumentParams(item)), + sendMessage(DidOpenTextDocumentNotification(DidOpenTextDocumentParams(item)), SendDocUpdates::Ignore); } void ClangdClient::closeExtraFile(const Utils::FilePath &filePath) { - sendContent(DidCloseTextDocumentNotification(DidCloseTextDocumentParams( + sendMessage(DidCloseTextDocumentNotification(DidCloseTextDocumentParams( TextDocumentIdentifier{DocumentUri::fromFilePath(filePath)})), SendDocUpdates::Ignore); } @@ -1321,7 +1321,7 @@ void ClangdClient::findUsages(TextDocument *document, const QTextCursor &cursor, return; d->findUsages(doc.data(), adjustedCursor, sd.name(), replacement, categorize); }); - sendContent(symReq); + sendMessage(symReq); } void ClangdClient::handleDiagnostics(const PublishDiagnosticsParams ¶ms) @@ -1612,7 +1612,7 @@ void ClangdClient::updateParserConfig(const Utils::FilePath &filePath, addCompilationDb(settings, cdbChanges); DidChangeConfigurationParams configChangeParams; configChangeParams.setSettings(settings); - sendContent(DidChangeConfigurationNotification(configChangeParams)); + sendMessage(DidChangeConfigurationNotification(configChangeParams)); } void ClangdClient::switchIssuePaneEntries(const Utils::FilePath &filePath) @@ -1914,7 +1914,7 @@ void ClangdClient::switchHeaderSource(const Utils::FilePath &filePath, bool inNe CppEditor::openEditor(filePath, inNextSplit); } }); - sendContent(req); + sendMessage(req); } void ClangdClient::findLocalUsages(TextDocument *document, const QTextCursor &cursor, @@ -2103,7 +2103,7 @@ void ClangdClient::gatherHelpItemForTooltip(const HoverRequest::Response &hoverR // with mainOverload = true, such information would get ignored anyway. d->setHelpItemForTooltip(id, fqn, HelpItem::Function, isFunction ? type : "()"); }); - sendContent(symReq, SendDocUpdates::Ignore); + sendMessage(symReq, SendDocUpdates::Ignore); return; } if ((node.role() == "expression" && node.kind() == "DeclRef") @@ -2216,7 +2216,7 @@ void ClangdClient::Private::sendGotoImplementationRequest(const Utils::Link &lin followSymbolData->pendingGotoImplRequests.removeOne(reqId); handleGotoImplementationResult(response); }); - q->sendContent(req, SendDocUpdates::Ignore); + q->sendMessage(req, SendDocUpdates::Ignore); followSymbolData->pendingGotoImplRequests << req.id(); qCDebug(clangdLog) << "sending go to implementation request" << link.targetLine; } @@ -2303,7 +2303,7 @@ void ClangdClient::Private::handleGotoImplementationResult( }); followSymbolData->pendingSymbolInfoRequests << symReq.id(); qCDebug(clangdLog) << "sending symbol info request"; - q->sendContent(symReq, SendDocUpdates::Ignore); + q->sendMessage(symReq, SendDocUpdates::Ignore); if (link == followSymbolData->defLink) continue; @@ -2337,7 +2337,7 @@ void ClangdClient::Private::handleGotoImplementationResult( followSymbolData->pendingGotoDefRequests << defReq.id(); qCDebug(clangdLog) << "sending additional go to definition request" << link.targetFilePath << link.targetLine; - q->sendContent(defReq, SendDocUpdates::Ignore); + q->sendMessage(defReq, SendDocUpdates::Ignore); } const Utils::FilePath defLinkFilePath = followSymbolData->defLink.targetFilePath; @@ -4094,7 +4094,7 @@ void MemoryUsageWidget::getMemoryTree() }); qCDebug(clangdLog) << "sending memory usage request"; m_currentRequest = request.id(); - m_client->sendContent(request, ClangdClient::SendDocUpdates::Ignore); + m_client->sendMessage(request, ClangdClient::SendDocUpdates::Ignore); } } // namespace Internal diff --git a/src/plugins/languageclient/client.cpp b/src/plugins/languageclient/client.cpp index d4cc2e09761..6d9fbdb61e7 100644 --- a/src/plugins/languageclient/client.cpp +++ b/src/plugins/languageclient/client.cpp @@ -90,7 +90,7 @@ public: { using Interface = BaseClientInterface; interface->moveToThread(&m_thread); - connect(interface, &Interface::contentReceived, this, &InterfaceController::contentReceived); + connect(interface, &Interface::messageReceived, this, &InterfaceController::messageReceived); connect(interface, &Interface::error, this, &InterfaceController::error); connect(interface, &Interface::finished, this, &InterfaceController::finished); connect(interface, &Interface::started, this, &InterfaceController::started); @@ -107,9 +107,9 @@ public: { QMetaObject::invokeMethod(m_interface, &BaseClientInterface::start); } - void sendContent(const JsonRpcMessage message) + void sendMessage(const JsonRpcMessage &message) { - QMetaObject::invokeMethod(m_interface, [=]() { m_interface->sendContent(message); }); + QMetaObject::invokeMethod(m_interface, [=]() { m_interface->sendMessage(message); }); } void resetBuffer() { @@ -117,7 +117,7 @@ public: } signals: - void contentReceived(const JsonRpcMessage &message); + void messageReceived(const JsonRpcMessage &message); void started(); void error(const QString &message); void finished(); @@ -152,7 +152,7 @@ Client::Client(BaseClientInterface *clientInterface) this, &Client::projectClosed); QTC_ASSERT(clientInterface, return); - connect(m_clientInterface, &InterfaceController::contentReceived, this, &Client::handleContent); + connect(m_clientInterface, &InterfaceController::messageReceived, this, &Client::handleMessage); connect(m_clientInterface, &InterfaceController::error, this, &Client::setError); connect(m_clientInterface, &InterfaceController::finished, this, &Client::finished); connect(m_clientInterface, &InterfaceController::started, this, [this]() { @@ -209,8 +209,8 @@ Client::~Client() m_documentHighlightsTimer.clear(); updateEditorToolBar(m_openedDocument.keys()); // do not handle messages while shutting down - disconnect(m_clientInterface, &InterfaceController::contentReceived, - this, &Client::handleContent); + disconnect(m_clientInterface, &InterfaceController::messageReceived, + this, &Client::handleMessage); delete m_diagnosticManager; delete m_clientInterface; } @@ -377,7 +377,7 @@ void Client::initialize() m_responseHandlers[responseHandler->id] = responseHandler->callback; // directly send content now otherwise the state check of sendContent would fail - sendContentNow(initRequest); + sendMessageNow(initRequest); m_state = InitializeRequested; } @@ -389,7 +389,7 @@ void Client::shutdown() shutdown.setResponseCallback([this](const ShutdownRequest::Response &shutdownResponse){ shutDownCallback(shutdownResponse); }); - sendContent(shutdown); + sendMessage(shutdown); m_state = ShutdownRequested; m_shutdownTimer.start(); } @@ -469,7 +469,7 @@ void Client::openDocument(TextEditor::TextDocument *document) if (!m_documentVersions.contains(filePath)) m_documentVersions[filePath] = 0; item.setVersion(m_documentVersions[filePath]); - sendContent(DidOpenTextDocumentNotification(DidOpenTextDocumentParams(item))); + sendMessage(DidOpenTextDocumentNotification(DidOpenTextDocumentParams(item))); handleDocumentOpened(document); const Client *currentClient = LanguageClientManager::clientForDocument(document); @@ -482,24 +482,24 @@ void Client::openDocument(TextEditor::TextDocument *document) } } -void Client::sendContent(const IContent &content, SendDocUpdates sendUpdates) +void Client::sendMessage(const JsonRpcMessage &message, SendDocUpdates sendUpdates) { QTC_ASSERT(m_clientInterface, return); QTC_ASSERT(m_state == Initialized, return); if (sendUpdates == SendDocUpdates::Send) sendPostponedDocumentUpdates(Schedule::Delayed); - if (Utils::optional<ResponseHandler> responseHandler = content.responseHandler()) + if (Utils::optional<ResponseHandler> responseHandler = message.responseHandler()) m_responseHandlers[responseHandler->id] = responseHandler->callback; QString error; - if (!QTC_GUARD(content.isValid(&error))) + if (!QTC_GUARD(message.isValid(&error))) Core::MessageManager::writeFlashing(error); - sendContentNow(content); + sendMessageNow(message); } void Client::cancelRequest(const MessageId &id) { m_responseHandlers.remove(id); - sendContent(CancelRequest(CancelParameter(id)), SendDocUpdates::Ignore); + sendMessage(CancelRequest(CancelParameter(id)), SendDocUpdates::Ignore); } void Client::closeDocument(TextEditor::TextDocument *document) @@ -511,7 +511,7 @@ void Client::closeDocument(TextEditor::TextDocument *document) handleDocumentClosed(document); if (m_state == Initialized) { DidCloseTextDocumentParams params(TextDocumentIdentifier{uri}); - sendContent(DidCloseTextDocumentNotification(params)); + sendMessage(DidCloseTextDocumentNotification(params)); } } } @@ -652,7 +652,7 @@ void Client::requestDocumentHighlightsNow(TextEditor::TextEditorWidget *widget) widget->setExtraSelections(id, selections); }); m_highlightRequests[widget] = request.id(); - sendContent(request); + sendMessage(request); } void Client::activateDocument(TextEditor::TextDocument *document) @@ -722,16 +722,16 @@ void Client::documentContentsSaved(TextEditor::TextDocument *document) { if (!m_openedDocument.contains(document)) return; - bool sendMessage = true; + bool send = true; bool includeText = false; const QString method(DidSaveTextDocumentNotification::methodName); if (Utils::optional<bool> registered = m_dynamicCapabilities.isRegistered(method)) { - sendMessage = *registered; - if (sendMessage) { + send = *registered; + if (send) { const TextDocumentSaveRegistrationOptions option( m_dynamicCapabilities.option(method).toObject()); if (option.isValid()) { - sendMessage = option.filterApplies(document->filePath(), + send = option.filterApplies(document->filePath(), Utils::mimeTypeForName(document->mimeType())); includeText = option.includeText().value_or(includeText); } @@ -743,13 +743,13 @@ void Client::documentContentsSaved(TextEditor::TextDocument *document) includeText = saveOptions->includeText().value_or(includeText); } } - if (!sendMessage) + if (!send) return; DidSaveTextDocumentParams params( TextDocumentIdentifier(DocumentUri::fromFilePath(document->filePath()))); if (includeText) params.setText(document->plainText()); - sendContent(DidSaveTextDocumentNotification(params)); + sendMessage(DidSaveTextDocumentNotification(params)); } void Client::documentWillSave(Core::IDocument *document) @@ -758,27 +758,27 @@ void Client::documentWillSave(Core::IDocument *document) auto textDocument = qobject_cast<TextEditor::TextDocument *>(document); if (!m_openedDocument.contains(textDocument)) return; - bool sendMessage = false; + bool send = false; const QString method(WillSaveTextDocumentNotification::methodName); if (Utils::optional<bool> registered = m_dynamicCapabilities.isRegistered(method)) { - sendMessage = *registered; - if (sendMessage) { + send = *registered; + if (send) { const TextDocumentRegistrationOptions option(m_dynamicCapabilities.option(method)); if (option.isValid()) { - sendMessage = option.filterApplies(filePath, + send = option.filterApplies(filePath, Utils::mimeTypeForName(document->mimeType())); } } } else if (Utils::optional<ServerCapabilities::TextDocumentSync> _sync = m_serverCapabilities.textDocumentSync()) { if (auto options = Utils::get_if<TextDocumentSyncOptions>(&*_sync)) - sendMessage = options->willSave().value_or(sendMessage); + send = options->willSave().value_or(send); } - if (!sendMessage) + if (!send) return; const WillSaveTextDocumentParams params( TextDocumentIdentifier(DocumentUri::fromFilePath(filePath))); - sendContent(WillSaveTextDocumentNotification(params)); + sendMessage(WillSaveTextDocumentNotification(params)); } void Client::documentContentsChanged(TextEditor::TextDocument *document, @@ -996,7 +996,7 @@ void Client::requestCodeActions(const CodeActionRequest &request) return; } - sendContent(request); + sendMessage(request); } void Client::handleCodeActionResponse(const CodeActionRequest::Response &response, @@ -1025,7 +1025,7 @@ void Client::executeCommand(const Command &command) .isRegistered(ExecuteCommandRequest::methodName) .value_or(serverSupportsExecuteCommand); if (serverSupportsExecuteCommand) - sendContent(ExecuteCommandRequest(ExecuteCommandParams(command))); + sendMessage(ExecuteCommandRequest(ExecuteCommandParams(command))); } ProjectExplorer::Project *Client::project() const @@ -1059,7 +1059,7 @@ void Client::projectOpened(ProjectExplorer::Project *project) DidChangeWorkspaceFoldersParams params; params.setEvent(event); DidChangeWorkspaceFoldersNotification change(params); - sendContent(change); + sendMessage(change); } void Client::projectClosed(ProjectExplorer::Project *project) @@ -1071,7 +1071,7 @@ void Client::projectClosed(ProjectExplorer::Project *project) DidChangeWorkspaceFoldersParams params; params.setEvent(event); DidChangeWorkspaceFoldersNotification change(params); - sendContent(change); + sendMessage(change); } if (project == m_project) { if (m_state == Initialized) { @@ -1091,7 +1091,7 @@ void Client::updateConfiguration(const QJsonValue &configuration) DidChangeConfigurationParams params; params.setSettings(configuration); DidChangeConfigurationNotification notification(params); - sendContent(notification); + sendMessage(notification); } } @@ -1265,7 +1265,7 @@ void Client::setProgressTitleForToken(const LanguageServerProtocol::ProgressToke m_progressManager.setTitleForToken(token, message); } -void Client::handleContent(const LanguageServerProtocol::JsonRpcMessage &message) +void Client::handleMessage(const LanguageServerProtocol::JsonRpcMessage &message) { LanguageClientManager::logJsonRpcMessage(LspLogMessage::ServerMessage, name(), message); const MessageId id(message.toJsonObject().value(idKey)); @@ -1383,7 +1383,7 @@ void Client::sendPostponedDocumentUpdates(Schedule semanticTokensSchedule) m_documentsToUpdate.clear(); for (const DocumentUpdate &update : updates) { - sendContent(update.notification, SendDocUpdates::Ignore); + sendMessage(update.notification, SendDocUpdates::Ignore); emit documentUpdated(update.document); if (currentWidget && currentWidget->textDocument() == update.document) @@ -1404,10 +1404,10 @@ void Client::sendPostponedDocumentUpdates(Schedule semanticTokensSchedule) } } -void Client::handleResponse(const MessageId &id, const IContent &content) +void Client::handleResponse(const MessageId &id, const JsonRpcMessage &message) { if (auto handler = m_responseHandlers[id]) - handler(content); + handler(message); } template<typename T> @@ -1419,12 +1419,7 @@ static ResponseError<T> createInvalidParamsError(const QString &message) return error; } -template<typename T> -static T asJsonContent(const IContent &content) { - return T(static_cast<const JsonRpcMessage &>(content).toJsonObject()); -} - -void Client::handleMethod(const QString &method, const MessageId &id, const IContent &content) +void Client::handleMethod(const QString &method, const MessageId &id, const JsonRpcMessage &message) { auto invalidParamsErrorMessage = [&](const JsonObject ¶ms) { return tr("Invalid parameter in \"%1\":\n%2") @@ -1443,10 +1438,10 @@ void Client::handleMethod(const QString &method, const MessageId &id, const ICon bool responseSend = false; auto sendResponse = - [&](const IContent &response) { + [&](const JsonRpcMessage &response) { responseSend = true; if (reachable()) { - sendContent(response); + sendMessage(response); } else { qCDebug(LOGLSPCLIENT) << QString("Dropped response to request %1 id %2 for unreachable server %3") @@ -1455,28 +1450,28 @@ void Client::handleMethod(const QString &method, const MessageId &id, const ICon }; if (method == PublishDiagnosticsNotification::methodName) { - auto params = asJsonContent<PublishDiagnosticsNotification>(content).params().value_or( + auto params = PublishDiagnosticsNotification(message.toJsonObject()).params().value_or( PublishDiagnosticsParams()); if (params.isValid()) handleDiagnostics(params); else log(invalidParamsErrorMessage(params)); } else if (method == LogMessageNotification::methodName) { - auto params = asJsonContent<LogMessageNotification>(content).params().value_or( + auto params = LogMessageNotification(message.toJsonObject()).params().value_or( LogMessageParams()); if (params.isValid()) log(params); else log(invalidParamsErrorMessage(params)); } else if (method == ShowMessageNotification::methodName) { - auto params = asJsonContent<ShowMessageNotification>(content).params().value_or( + auto params = ShowMessageNotification(message.toJsonObject()).params().value_or( ShowMessageParams()); if (params.isValid()) log(params); else log(invalidParamsErrorMessage(params)); } else if (method == ShowMessageRequest::methodName) { - auto request = asJsonContent<ShowMessageRequest>(content); + auto request = ShowMessageRequest(message.toJsonObject()); ShowMessageRequest::Response response(id); auto params = request.params().value_or(ShowMessageRequestParams()); if (params.isValid()) { @@ -1488,7 +1483,7 @@ void Client::handleMethod(const QString &method, const MessageId &id, const ICon } sendResponse(response); } else if (method == RegisterCapabilityRequest::methodName) { - auto params = asJsonContent<RegisterCapabilityRequest>(content).params().value_or( + auto params = RegisterCapabilityRequest(message.toJsonObject()).params().value_or( RegistrationParams()); if (params.isValid()) { registerCapabilities(params.registrations()); @@ -1501,7 +1496,7 @@ void Client::handleMethod(const QString &method, const MessageId &id, const ICon sendResponse(response); } } else if (method == UnregisterCapabilityRequest::methodName) { - auto params = asJsonContent<UnregisterCapabilityRequest>(content).params().value_or( + auto params = UnregisterCapabilityRequest(message.toJsonObject()).params().value_or( UnregistrationParams()); if (params.isValid()) { unregisterCapabilities(params.unregistrations()); @@ -1515,7 +1510,7 @@ void Client::handleMethod(const QString &method, const MessageId &id, const ICon } } else if (method == ApplyWorkspaceEditRequest::methodName) { ApplyWorkspaceEditRequest::Response response(id); - auto params = asJsonContent<ApplyWorkspaceEditRequest>(content).params().value_or( + auto params = ApplyWorkspaceEditRequest(message.toJsonObject()).params().value_or( ApplyWorkspaceEditParams()); if (params.isValid()) { ApplyWorkspaceEditResult result; @@ -1549,7 +1544,7 @@ void Client::handleMethod(const QString &method, const MessageId &id, const ICon sendResponse(createDefaultResponse()); } else if (method == ProgressNotification::methodName) { if (Utils::optional<ProgressParams> params - = asJsonContent<ProgressNotification>(content).params()) { + = ProgressNotification(message.toJsonObject()).params()) { if (!params->isValid()) log(invalidParamsErrorMessage(*params)); m_progressManager.handleProgress(*params); @@ -1583,14 +1578,10 @@ void Client::handleDiagnostics(const PublishDiagnosticsParams ¶ms) } } -void Client::sendContentNow(const IContent &content) +void Client::sendMessageNow(const JsonRpcMessage &message) { - if (content.mimeType() == JsonRpcMessage::jsonRpcMimeType()) { - LanguageClientManager::logJsonRpcMessage(LspLogMessage::ClientMessage, - name(), - static_cast<const JsonRpcMessage &>(content)); - m_clientInterface->sendContent(static_cast<const JsonRpcMessage &>(content)); - } + LanguageClientManager::logJsonRpcMessage(LspLogMessage::ClientMessage, name(), message); + m_clientInterface->sendMessage(message); } bool Client::documentUpdatePostponed(const Utils::FilePath &fileName) const @@ -1676,7 +1667,7 @@ void Client::initializeCallback(const InitializeRequest::Response &initResponse) qCDebug(LOGLSPCLIENT) << "language server " << m_displayName << " initialized"; m_state = Initialized; - sendContent(InitializeNotification(InitializedParams())); + sendMessage(InitializeNotification(InitializedParams())); Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> documentSymbolProvider = capabilities().documentSymbolProvider(); if (documentSymbolProvider.has_value()) { @@ -1707,7 +1698,7 @@ void Client::shutDownCallback(const ShutdownRequest::Response &shutdownResponse) if (optional<ShutdownRequest::Response::Error> error = shutdownResponse.error()) log(*error); // directly send content now otherwise the state check of sendContent would fail - sendContentNow(ExitNotification()); + sendMessageNow(ExitNotification()); qCDebug(LOGLSPCLIENT) << "language server " << m_displayName << " shutdown"; m_state = Shutdown; m_shutdownTimer.start(); diff --git a/src/plugins/languageclient/client.h b/src/plugins/languageclient/client.h index 977835aa0a1..80a6f3144f0 100644 --- a/src/plugins/languageclient/client.h +++ b/src/plugins/languageclient/client.h @@ -101,7 +101,7 @@ public: QString name() const; enum class SendDocUpdates { Send, Ignore }; - void sendContent(const LanguageServerProtocol::IContent &content, + void sendMessage(const LanguageServerProtocol::JsonRpcMessage &message, SendDocUpdates sendUpdates = SendDocUpdates::Send); void cancelRequest(const LanguageServerProtocol::MessageId &id); @@ -226,17 +226,17 @@ protected: void setError(const QString &message); void setProgressTitleForToken(const LanguageServerProtocol::ProgressToken &token, const QString &message); - void handleContent(const LanguageServerProtocol::JsonRpcMessage &message); + void handleMessage(const LanguageServerProtocol::JsonRpcMessage &message); virtual void handleDiagnostics(const LanguageServerProtocol::PublishDiagnosticsParams ¶ms); virtual DiagnosticManager *createDiagnosticManager(); private: - void sendContentNow(const LanguageServerProtocol::IContent &content); + void sendMessageNow(const LanguageServerProtocol::JsonRpcMessage &message); void handleResponse(const LanguageServerProtocol::MessageId &id, - const LanguageServerProtocol::IContent &content); + const LanguageServerProtocol::JsonRpcMessage &message); void handleMethod(const QString &method, const LanguageServerProtocol::MessageId &id, - const LanguageServerProtocol::IContent &content); + const LanguageServerProtocol::JsonRpcMessage &message); void initializeCallback(const LanguageServerProtocol::InitializeRequest::Response &initResponse); void shutDownCallback(const LanguageServerProtocol::ShutdownRequest::Response &shutdownResponse); @@ -268,10 +268,6 @@ private: virtual QTextCursor adjustedCursorForHighlighting(const QTextCursor &cursor, TextEditor::TextDocument *doc); - using ContentHandler = std::function<void(const QByteArray &, QTextCodec *, QString &, - LanguageServerProtocol::ResponseHandlers, - LanguageServerProtocol::MethodHandler)>; - State m_state = Uninitialized; QHash<LanguageServerProtocol::MessageId, LanguageServerProtocol::ResponseHandler::Callback> m_responseHandlers; diff --git a/src/plugins/languageclient/documentsymbolcache.cpp b/src/plugins/languageclient/documentsymbolcache.cpp index 916fa8d688f..5b12870f104 100644 --- a/src/plugins/languageclient/documentsymbolcache.cpp +++ b/src/plugins/languageclient/documentsymbolcache.cpp @@ -106,7 +106,7 @@ void DocumentSymbolCache::requestSymbolsImpl() self->handleResponse(uri, response); }); m_runningRequests[uri] = request.id(); - m_client->sendContent(request); + m_client->sendMessage(request); } m_compressedUris.clear(); } diff --git a/src/plugins/languageclient/languageclientcompletionassist.cpp b/src/plugins/languageclient/languageclientcompletionassist.cpp index 7024445aa06..39b1bd9e306 100644 --- a/src/plugins/languageclient/languageclientcompletionassist.cpp +++ b/src/plugins/languageclient/languageclientcompletionassist.cpp @@ -371,7 +371,7 @@ IAssistProposal *LanguageClientCompletionAssistProcessor::perform(const AssistIn completionRequest.setResponseCallback([this](auto response) { this->handleCompletionResponse(response); }); - m_client->sendContent(completionRequest); + m_client->sendMessage(completionRequest); m_client->addAssistProcessor(this); m_currentRequest = completionRequest.id(); m_document = interface->textDocument(); diff --git a/src/plugins/languageclient/languageclientformatter.cpp b/src/plugins/languageclient/languageclientformatter.cpp index cfb4fd4fac2..0649f5dbf67 100644 --- a/src/plugins/languageclient/languageclientformatter.cpp +++ b/src/plugins/languageclient/languageclientformatter.cpp @@ -108,7 +108,7 @@ QFutureWatcher<ChangeSet> *LanguageClientFormatter::format( handleResponse(response); }); m_currentRequest = request.id(); - m_client->sendContent(request); + m_client->sendMessage(request); // ignore first contents changed, because this function is called inside a begin/endEdit block m_ignoreCancel = true; m_progress.reportStarted(); diff --git a/src/plugins/languageclient/languageclientformatter.h b/src/plugins/languageclient/languageclientformatter.h index 795246b2837..4a15196c615 100644 --- a/src/plugins/languageclient/languageclientformatter.h +++ b/src/plugins/languageclient/languageclientformatter.h @@ -25,7 +25,6 @@ #pragma once -#include <languageserverprotocol/icontent.h> #include <languageserverprotocol/languagefeatures.h> #include <texteditor/formatter.h> diff --git a/src/plugins/languageclient/languageclientfunctionhint.cpp b/src/plugins/languageclient/languageclientfunctionhint.cpp index aa7a62af4dc..319aad22338 100644 --- a/src/plugins/languageclient/languageclientfunctionhint.cpp +++ b/src/plugins/languageclient/languageclientfunctionhint.cpp @@ -96,7 +96,7 @@ IAssistProposal *FunctionHintProcessor::perform(const AssistInterface *interface SignatureHelpRequest request((TextDocumentPositionParams(TextDocumentIdentifier(uri), Position(cursor)))); request.setResponseCallback([this](auto response) { this->handleSignatureResponse(response); }); m_client->addAssistProcessor(this); - m_client->sendContent(request); + m_client->sendMessage(request); m_currentRequest = request.id(); return nullptr; } diff --git a/src/plugins/languageclient/languageclienthoverhandler.cpp b/src/plugins/languageclient/languageclienthoverhandler.cpp index 2eca331daaa..5f601a55c86 100644 --- a/src/plugins/languageclient/languageclienthoverhandler.cpp +++ b/src/plugins/languageclient/languageclienthoverhandler.cpp @@ -121,7 +121,7 @@ void HoverHandler::identifyMatch(TextEditor::TextEditorWidget *editorWidget, m_currentRequest = request.id(); request.setResponseCallback( [this](const HoverRequest::Response &response) { handleResponse(response); }); - m_client->sendContent(request); + m_client->sendMessage(request); } void HoverHandler::handleResponse(const HoverRequest::Response &response) diff --git a/src/plugins/languageclient/languageclientinterface.cpp b/src/plugins/languageclient/languageclientinterface.cpp index b9d806a3501..3595bc00da6 100644 --- a/src/plugins/languageclient/languageclientinterface.cpp +++ b/src/plugins/languageclient/languageclientinterface.cpp @@ -46,11 +46,11 @@ BaseClientInterface::~BaseClientInterface() m_buffer.close(); } -void BaseClientInterface::sendContent(const IContent &content) +void BaseClientInterface::sendMessage(const JsonRpcMessage message) { - const BaseMessage message = content.toBaseMessage(); - sendData(message.header()); - sendData(message.content); + const BaseMessage baseMessage = message.toBaseMessage(); + sendData(baseMessage.header()); + sendData(baseMessage.content); } void BaseClientInterface::resetBuffer() @@ -91,7 +91,7 @@ void BaseClientInterface::parseData(const QByteArray &data) void BaseClientInterface::parseCurrentMessage() { if (m_currentMessage.mimeType == JsonRpcMessage::jsonRpcMimeType()) { - emit contentReceived(JsonRpcMessage(m_currentMessage)); + emit messageReceived(JsonRpcMessage(m_currentMessage)); } else { emit error(tr("Cannot handle mimetype of message %1") .arg(QString::fromUtf8(m_currentMessage.mimeType))); diff --git a/src/plugins/languageclient/languageclientinterface.h b/src/plugins/languageclient/languageclientinterface.h index 4cb21722801..75a7fbb1db1 100644 --- a/src/plugins/languageclient/languageclientinterface.h +++ b/src/plugins/languageclient/languageclientinterface.h @@ -45,13 +45,13 @@ public: ~BaseClientInterface() override; - void sendContent(const LanguageServerProtocol::IContent &content); + void sendMessage(const LanguageServerProtocol::JsonRpcMessage message); void start() { startImpl(); } void resetBuffer(); signals: - void contentReceived(const LanguageServerProtocol::JsonRpcMessage message); + void messageReceived(const LanguageServerProtocol::JsonRpcMessage message); void finished(); void error(const QString &message); void started(); diff --git a/src/plugins/languageclient/languageclientsymbolsupport.cpp b/src/plugins/languageclient/languageclientsymbolsupport.cpp index 447577d6a83..42af56db325 100644 --- a/src/plugins/languageclient/languageclientsymbolsupport.cpp +++ b/src/plugins/languageclient/languageclientsymbolsupport.cpp @@ -69,7 +69,7 @@ static void sendTextDocumentPositionParamsRequest(Client *client, sendMessage = Utils::get<bool>(*provider); } if (sendMessage) - client->sendContent(request); + client->sendMessage(request); } static void handleGotoDefinitionResponse(const GotoDefinitionRequest::Response &response, @@ -313,7 +313,7 @@ void SymbolSupport::requestPrepareRename(const TextDocumentPositionParams ¶m } } }); - m_client->sendContent(request); + m_client->sendMessage(request); } void SymbolSupport::requestRename(const TextDocumentPositionParams &positionParams, @@ -326,7 +326,7 @@ void SymbolSupport::requestRename(const TextDocumentPositionParams &positionPara request.setResponseCallback([this, search](const RenameRequest::Response &response) { handleRenameResponse(search, response); }); - m_client->sendContent(request); + m_client->sendMessage(request); search->setTextToReplace(newName); search->popup(); } diff --git a/src/plugins/languageclient/locatorfilter.cpp b/src/plugins/languageclient/locatorfilter.cpp index 6474ef9ef26..50ee2e37ccf 100644 --- a/src/plugins/languageclient/locatorfilter.cpp +++ b/src/plugins/languageclient/locatorfilter.cpp @@ -288,7 +288,7 @@ void WorkspaceLocatorFilter::prepareSearch(const QString &entry, handleResponse(client, response); }); m_pendingRequests[client] = request.id(); - client->sendContent(request); + client->sendMessage(request); } } diff --git a/src/plugins/languageclient/semantichighlightsupport.cpp b/src/plugins/languageclient/semantichighlightsupport.cpp index 883b604885d..41c538be502 100644 --- a/src/plugins/languageclient/semantichighlightsupport.cpp +++ b/src/plugins/languageclient/semantichighlightsupport.cpp @@ -116,7 +116,7 @@ void SemanticTokenSupport::reloadSemanticTokensImpl(TextDocument *textDocument, request.setResponseCallback(responseCallback); qCDebug(LOGLSPHIGHLIGHT) << "Requesting all tokens for" << filePath << "with version" << m_client->documentVersion(filePath); - m_client->sendContent(request); + m_client->sendMessage(request); } } @@ -161,7 +161,7 @@ void SemanticTokenSupport::updateSemanticTokensImpl(TextDocument *textDocument, }); qCDebug(LOGLSPHIGHLIGHT) << "Requesting delta for" << filePath << "with version" << documentVersion; - m_client->sendContent(request); + m_client->sendMessage(request); return; } } diff --git a/src/plugins/python/pythonlanguageclient.cpp b/src/plugins/python/pythonlanguageclient.cpp index 887911e8054..b65e4b9372c 100644 --- a/src/plugins/python/pythonlanguageclient.cpp +++ b/src/plugins/python/pythonlanguageclient.cpp @@ -471,7 +471,7 @@ public: DidChangeWorkspaceFoldersParams params; params.setEvent(event); DidChangeWorkspaceFoldersNotification change(params); - sendContent(change); + sendMessage(change); extraWorkspaceDirs.append(workspacePath); } } |