forked from qt-creator/qt-creator
LSP: Require an id for a response
The id is the essential part of a response. Make the protocol implementation more stable by requiring this id in the Response constructor. Change-Id: I18908c8441be1ddd890058f3dd09fc8cda3b868c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -232,6 +232,7 @@ template <typename Result, typename ErrorDataType>
|
|||||||
class Response : public JsonRpcMessage
|
class Response : public JsonRpcMessage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
explicit Response(const MessageId &id) { setId(id); }
|
||||||
using JsonRpcMessage::JsonRpcMessage;
|
using JsonRpcMessage::JsonRpcMessage;
|
||||||
|
|
||||||
MessageId id() const
|
MessageId id() const
|
||||||
|
@@ -784,8 +784,7 @@ void Client::showMessageBox(const ShowMessageRequestParams &message, const Messa
|
|||||||
}
|
}
|
||||||
box->setModal(true);
|
box->setModal(true);
|
||||||
connect(box, &QMessageBox::finished, this, [=]{
|
connect(box, &QMessageBox::finished, this, [=]{
|
||||||
ShowMessageRequest::Response response;
|
ShowMessageRequest::Response response(id);
|
||||||
response.setId(id);
|
|
||||||
const MessageActionItem &item = itemForButton.value(box->clickedButton());
|
const MessageActionItem &item = itemForButton.value(box->clickedButton());
|
||||||
response.setResult(item.isValid(nullptr) ? LanguageClientValue<MessageActionItem>(item)
|
response.setResult(item.isValid(nullptr) ? LanguageClientValue<MessageActionItem>(item)
|
||||||
: LanguageClientValue<MessageActionItem>());
|
: LanguageClientValue<MessageActionItem>());
|
||||||
@@ -847,8 +846,7 @@ void Client::handleMethod(const QString &method, MessageId id, const IContent *c
|
|||||||
if (paramsValid) {
|
if (paramsValid) {
|
||||||
showMessageBox(params, request->id());
|
showMessageBox(params, request->id());
|
||||||
} else {
|
} else {
|
||||||
ShowMessageRequest::Response response;
|
ShowMessageRequest::Response response(request->id());
|
||||||
response.setId(request->id());
|
|
||||||
ResponseError<std::nullptr_t> error;
|
ResponseError<std::nullptr_t> error;
|
||||||
const QString errorMessage =
|
const QString errorMessage =
|
||||||
QString("Could not parse ShowMessageRequest parameter of '%1': \"%2\"")
|
QString("Could not parse ShowMessageRequest parameter of '%1': \"%2\"")
|
||||||
@@ -874,8 +872,7 @@ void Client::handleMethod(const QString &method, MessageId id, const IContent *c
|
|||||||
if (paramsValid)
|
if (paramsValid)
|
||||||
applyWorkspaceEdit(params.edit());
|
applyWorkspaceEdit(params.edit());
|
||||||
} else if (id.isValid(&error)) {
|
} else if (id.isValid(&error)) {
|
||||||
Response<JsonObject, JsonObject> response;
|
Response<JsonObject, JsonObject> response(id);
|
||||||
response.setId(id);
|
|
||||||
ResponseError<JsonObject> error;
|
ResponseError<JsonObject> error;
|
||||||
error.setCode(ResponseError<JsonObject>::MethodNotFound);
|
error.setCode(ResponseError<JsonObject>::MethodNotFound);
|
||||||
response.setError(error);
|
response.setError(error);
|
||||||
|
Reference in New Issue
Block a user