forked from qt-creator/qt-creator
LanguageClient: pass id as a const ref when handling client messages
Change-Id: I7ab6a7517d4dd0fe66f601661e7b3f6a7afb338b Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -90,8 +90,8 @@ public:
|
||||
};
|
||||
|
||||
using ResponseHandler = std::function<void(const QByteArray &, QTextCodec *)>;
|
||||
using ResponseHandlers = std::function<void(MessageId, const QByteArray &, QTextCodec *)>;
|
||||
using MethodHandler = std::function<void(const QString, MessageId, const IContent *)>;
|
||||
using ResponseHandlers = std::function<void(const MessageId &, const QByteArray &, QTextCodec *)>;
|
||||
using MethodHandler = std::function<void(const QString &, const MessageId &, const IContent *)>;
|
||||
|
||||
inline uint qHash(const LanguageServerProtocol::MessageId &id)
|
||||
{
|
||||
|
@@ -85,8 +85,8 @@ void JsonRpcMessageHandler::registerMessageProvider(
|
||||
void JsonRpcMessageHandler::parseContent(const QByteArray &content,
|
||||
QTextCodec *codec,
|
||||
QString &parseError,
|
||||
ResponseHandlers responseHandlers,
|
||||
MethodHandler methodHandler)
|
||||
const ResponseHandlers &responseHandlers,
|
||||
const MethodHandler &methodHandler)
|
||||
{
|
||||
const QJsonObject &jsonObject = toJsonObject(content, codec, parseError);
|
||||
if (jsonObject.isEmpty())
|
||||
|
@@ -76,8 +76,8 @@ public:
|
||||
}
|
||||
static QByteArray jsonRpcMimeType();
|
||||
static void parseContent(const QByteArray &content, QTextCodec *codec, QString &errorMessage,
|
||||
ResponseHandlers responseHandlers,
|
||||
MethodHandler methodHandler);
|
||||
const ResponseHandlers &responseHandlers,
|
||||
const MethodHandler &methodHandler);
|
||||
static QJsonObject toJsonObject(const QByteArray &content, QTextCodec *codec, QString &parseError);
|
||||
|
||||
private:
|
||||
|
@@ -938,10 +938,10 @@ void Client::handleMessage(const BaseMessage &message)
|
||||
if (auto handler = m_contentHandler[message.mimeType]) {
|
||||
QString parseError;
|
||||
handler(message.content, message.codec, parseError,
|
||||
[this](MessageId id, const QByteArray &content, QTextCodec *codec){
|
||||
[this](const MessageId &id, const QByteArray &content, QTextCodec *codec){
|
||||
this->handleResponse(id, content, codec);
|
||||
},
|
||||
[this](const QString &method, MessageId id, const IContent *content){
|
||||
[this](const QString &method, const MessageId &id, const IContent *content){
|
||||
this->handleMethod(method, id, content);
|
||||
});
|
||||
if (!parseError.isEmpty())
|
||||
@@ -1072,7 +1072,7 @@ void Client::handleResponse(const MessageId &id, const QByteArray &content, QTex
|
||||
handler(content, codec);
|
||||
}
|
||||
|
||||
void Client::handleMethod(const QString &method, MessageId id, const IContent *content)
|
||||
void Client::handleMethod(const QString &method, const MessageId &id, const IContent *content)
|
||||
{
|
||||
ErrorHierarchy error;
|
||||
auto logError = [&](const JsonObject &content) {
|
||||
|
@@ -189,7 +189,7 @@ protected:
|
||||
private:
|
||||
void handleResponse(const LanguageServerProtocol::MessageId &id, const QByteArray &content,
|
||||
QTextCodec *codec);
|
||||
void handleMethod(const QString &method, LanguageServerProtocol::MessageId id,
|
||||
void handleMethod(const QString &method, const LanguageServerProtocol::MessageId &id,
|
||||
const LanguageServerProtocol::IContent *content);
|
||||
|
||||
void handleDiagnostics(const LanguageServerProtocol::PublishDiagnosticsParams ¶ms);
|
||||
|
Reference in New Issue
Block a user