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 ResponseHandler = std::function<void(const QByteArray &, QTextCodec *)>;
|
||||||
using ResponseHandlers = std::function<void(MessageId, const QByteArray &, QTextCodec *)>;
|
using ResponseHandlers = std::function<void(const MessageId &, const QByteArray &, QTextCodec *)>;
|
||||||
using MethodHandler = std::function<void(const QString, MessageId, const IContent *)>;
|
using MethodHandler = std::function<void(const QString &, const MessageId &, const IContent *)>;
|
||||||
|
|
||||||
inline uint qHash(const LanguageServerProtocol::MessageId &id)
|
inline uint qHash(const LanguageServerProtocol::MessageId &id)
|
||||||
{
|
{
|
||||||
|
@@ -85,8 +85,8 @@ void JsonRpcMessageHandler::registerMessageProvider(
|
|||||||
void JsonRpcMessageHandler::parseContent(const QByteArray &content,
|
void JsonRpcMessageHandler::parseContent(const QByteArray &content,
|
||||||
QTextCodec *codec,
|
QTextCodec *codec,
|
||||||
QString &parseError,
|
QString &parseError,
|
||||||
ResponseHandlers responseHandlers,
|
const ResponseHandlers &responseHandlers,
|
||||||
MethodHandler methodHandler)
|
const MethodHandler &methodHandler)
|
||||||
{
|
{
|
||||||
const QJsonObject &jsonObject = toJsonObject(content, codec, parseError);
|
const QJsonObject &jsonObject = toJsonObject(content, codec, parseError);
|
||||||
if (jsonObject.isEmpty())
|
if (jsonObject.isEmpty())
|
||||||
|
@@ -76,8 +76,8 @@ public:
|
|||||||
}
|
}
|
||||||
static QByteArray jsonRpcMimeType();
|
static QByteArray jsonRpcMimeType();
|
||||||
static void parseContent(const QByteArray &content, QTextCodec *codec, QString &errorMessage,
|
static void parseContent(const QByteArray &content, QTextCodec *codec, QString &errorMessage,
|
||||||
ResponseHandlers responseHandlers,
|
const ResponseHandlers &responseHandlers,
|
||||||
MethodHandler methodHandler);
|
const MethodHandler &methodHandler);
|
||||||
static QJsonObject toJsonObject(const QByteArray &content, QTextCodec *codec, QString &parseError);
|
static QJsonObject toJsonObject(const QByteArray &content, QTextCodec *codec, QString &parseError);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -938,10 +938,10 @@ void Client::handleMessage(const BaseMessage &message)
|
|||||||
if (auto handler = m_contentHandler[message.mimeType]) {
|
if (auto handler = m_contentHandler[message.mimeType]) {
|
||||||
QString parseError;
|
QString parseError;
|
||||||
handler(message.content, message.codec, 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->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);
|
this->handleMethod(method, id, content);
|
||||||
});
|
});
|
||||||
if (!parseError.isEmpty())
|
if (!parseError.isEmpty())
|
||||||
@@ -1072,7 +1072,7 @@ void Client::handleResponse(const MessageId &id, const QByteArray &content, QTex
|
|||||||
handler(content, codec);
|
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;
|
ErrorHierarchy error;
|
||||||
auto logError = [&](const JsonObject &content) {
|
auto logError = [&](const JsonObject &content) {
|
||||||
|
@@ -189,7 +189,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void handleResponse(const LanguageServerProtocol::MessageId &id, const QByteArray &content,
|
void handleResponse(const LanguageServerProtocol::MessageId &id, const QByteArray &content,
|
||||||
QTextCodec *codec);
|
QTextCodec *codec);
|
||||||
void handleMethod(const QString &method, LanguageServerProtocol::MessageId id,
|
void handleMethod(const QString &method, const LanguageServerProtocol::MessageId &id,
|
||||||
const LanguageServerProtocol::IContent *content);
|
const LanguageServerProtocol::IContent *content);
|
||||||
|
|
||||||
void handleDiagnostics(const LanguageServerProtocol::PublishDiagnosticsParams ¶ms);
|
void handleDiagnostics(const LanguageServerProtocol::PublishDiagnosticsParams ¶ms);
|
||||||
|
Reference in New Issue
Block a user