diff --git a/src/libs/languageserverprotocol/lsptypes.cpp b/src/libs/languageserverprotocol/lsptypes.cpp index 6b2975fbe51..ddd9b0e66c0 100644 --- a/src/libs/languageserverprotocol/lsptypes.cpp +++ b/src/libs/languageserverprotocol/lsptypes.cpp @@ -419,16 +419,16 @@ DocumentChange::DocumentChange(const QJsonValue &value) { const QString kind = value["kind"].toString(); if (kind == "create") - emplace(value); + emplace(value); else if (kind == "rename") - emplace(value); + emplace(value); else if (kind == "delete") - emplace(value); + emplace(value); else emplace(value); } -using DocumentChangeBase = std::variant; +using DocumentChangeBase = std::variant; bool DocumentChange::isValid() const { @@ -440,49 +440,49 @@ DocumentChange::operator const QJsonValue () const return std::visit([](const auto &v) { return QJsonValue(v); }, DocumentChangeBase(*this)); } -CreateFile::CreateFile() +CreateFileOperation::CreateFileOperation() { insert(kindKey, "create"); } -QString CreateFile::message(const DocumentUri::PathMapper &mapToHostPath) const +QString CreateFileOperation::message(const DocumentUri::PathMapper &mapToHostPath) const { return Tr::tr("Create %1").arg(uri().toFilePath(mapToHostPath).toUserOutput()); } -bool LanguageServerProtocol::CreateFile::isValid() const +bool LanguageServerProtocol::CreateFileOperation::isValid() const { return contains(uriKey) && value(kindKey) == "create"; } -RenameFile::RenameFile() +RenameFileOperation::RenameFileOperation() { insert(kindKey, "rename"); } -QString RenameFile::message(const DocumentUri::PathMapper &mapToHostPath) const +QString RenameFileOperation::message(const DocumentUri::PathMapper &mapToHostPath) const { return Tr::tr("Rename %1 to %2") .arg(oldUri().toFilePath(mapToHostPath).toUserOutput(), newUri().toFilePath(mapToHostPath).toUserOutput()); } -bool RenameFile::isValid() const +bool RenameFileOperation::isValid() const { return contains(oldUriKey) && contains(newUriKey) && value(kindKey) == "rename"; } -DeleteFile::DeleteFile() +DeleteFileOperation::DeleteFileOperation() { insert(kindKey, "delete"); } -QString DeleteFile::message(const DocumentUri::PathMapper &mapToHostPath) const +QString DeleteFileOperation::message(const DocumentUri::PathMapper &mapToHostPath) const { return Tr::tr("Delete %1").arg(uri().toFilePath(mapToHostPath).toUserOutput()); } -bool DeleteFile::isValid() const +bool DeleteFileOperation::isValid() const { return contains(uriKey) && value(kindKey) == "delete"; } diff --git a/src/libs/languageserverprotocol/lsptypes.h b/src/libs/languageserverprotocol/lsptypes.h index 135b4c124a2..ae19f36145b 100644 --- a/src/libs/languageserverprotocol/lsptypes.h +++ b/src/libs/languageserverprotocol/lsptypes.h @@ -299,11 +299,11 @@ public: void clearIgnoreIfExists() { remove(ignoreIfExistsKey); } }; -class LANGUAGESERVERPROTOCOL_EXPORT CreateFile : public JsonObject +class LANGUAGESERVERPROTOCOL_EXPORT CreateFileOperation : public JsonObject { public: using JsonObject::JsonObject; - CreateFile(); + CreateFileOperation(); DocumentUri uri() const { return DocumentUri::fromProtocol(typedValue(uriKey)); } void setUri(const DocumentUri &uri) { insert(uriKey, uri); } @@ -318,11 +318,11 @@ public: bool isValid() const override; }; -class LANGUAGESERVERPROTOCOL_EXPORT RenameFile : public JsonObject +class LANGUAGESERVERPROTOCOL_EXPORT RenameFileOperation : public JsonObject { public: using JsonObject::JsonObject; - RenameFile(); + RenameFileOperation(); DocumentUri oldUri() const { return DocumentUri::fromProtocol(typedValue(oldUriKey)); } void setOldUri(const DocumentUri &oldUri) { insert(oldUriKey, oldUri); } @@ -354,11 +354,11 @@ public: void clearIgnoreIfNotExists() { remove(ignoreIfNotExistsKey); } }; -class LANGUAGESERVERPROTOCOL_EXPORT DeleteFile : public JsonObject +class LANGUAGESERVERPROTOCOL_EXPORT DeleteFileOperation : public JsonObject { public: using JsonObject::JsonObject; - DeleteFile(); + DeleteFileOperation(); DocumentUri uri() const { return DocumentUri::fromProtocol(typedValue(uriKey)); } void setUri(const DocumentUri &uri) { insert(uriKey, uri); } @@ -374,7 +374,7 @@ public: }; class LANGUAGESERVERPROTOCOL_EXPORT DocumentChange - : public std::variant + : public std::variant { public: using variant::variant; diff --git a/src/plugins/languageclient/languageclientsymbolsupport.cpp b/src/plugins/languageclient/languageclientsymbolsupport.cpp index 8ba9507a640..13dddd38e23 100644 --- a/src/plugins/languageclient/languageclientsymbolsupport.cpp +++ b/src/plugins/languageclient/languageclientsymbolsupport.cpp @@ -556,18 +556,18 @@ Utils::SearchResultItems generateReplaceItems(const WorkspaceEdit &edits, } else { Utils::SearchResultItem item; - if (std::holds_alternative(documentChange)) { - auto op = std::get(documentChange); + if (std::holds_alternative(documentChange)) { + auto op = std::get(documentChange); item.setLineText(op.message(pathMapper)); item.setFilePath(op.uri().toFilePath(pathMapper)); item.setUserData(QVariant(op)); - } else if (std::holds_alternative(documentChange)) { - auto op = std::get(documentChange); + } else if (std::holds_alternative(documentChange)) { + auto op = std::get(documentChange); item.setLineText(op.message(pathMapper)); item.setFilePath(op.oldUri().toFilePath(pathMapper)); item.setUserData(QVariant(op)); - } else if (std::holds_alternative(documentChange)) { - auto op = std::get(documentChange); + } else if (std::holds_alternative(documentChange)) { + auto op = std::get(documentChange); item.setLineText(op.message(pathMapper)); item.setFilePath(op.uri().toFilePath(pathMapper)); item.setUserData(QVariant(op)); @@ -693,11 +693,11 @@ void SymbolSupport::applyRename(const Utils::SearchResultItems &checkedItems, const QJsonObject jsonObject = item.userData().toJsonObject(); if (const TextEdit edit(jsonObject); edit.isValid()) editsForDocuments[filePath] << edit; - else if (const LanguageServerProtocol::CreateFile createFile(jsonObject); createFile.isValid()) + else if (const CreateFileOperation createFile(jsonObject); createFile.isValid()) changes << createFile; - else if (const RenameFile renameFile(jsonObject); renameFile.isValid()) + else if (const RenameFileOperation renameFile(jsonObject); renameFile.isValid()) changes << renameFile; - else if (const LanguageServerProtocol::DeleteFile deleteFile(jsonObject); deleteFile.isValid()) + else if (const DeleteFileOperation deleteFile(jsonObject); deleteFile.isValid()) changes << deleteFile; } diff --git a/src/plugins/languageclient/languageclientutils.cpp b/src/plugins/languageclient/languageclientutils.cpp index 2df9331d2bf..8fc032f06d6 100644 --- a/src/plugins/languageclient/languageclientutils.cpp +++ b/src/plugins/languageclient/languageclientutils.cpp @@ -351,8 +351,8 @@ bool applyDocumentChange(const Client *client, const DocumentChange &change) if (std::holds_alternative(change)) { return applyTextDocumentEdit(client, std::get(change)); - } else if (std::holds_alternative(change)) { - const auto createOperation = std::get(change); + } else if (std::holds_alternative(change)) { + const auto createOperation = std::get(change); const FilePath filePath = createOperation.uri().toFilePath(client->hostPathMapper()); if (filePath.exists()) { if (const std::optional options = createOperation.options()) { @@ -365,8 +365,8 @@ bool applyDocumentChange(const Client *client, const DocumentChange &change) } } return filePath.ensureExistingFile(); - } else if (std::holds_alternative(change)) { - const RenameFile renameOperation = std::get(change); + } else if (std::holds_alternative(change)) { + const RenameFileOperation renameOperation = std::get(change); const FilePath oldPath = renameOperation.oldUri().toFilePath(client->hostPathMapper()); if (!oldPath.exists()) return false; @@ -384,8 +384,8 @@ bool applyDocumentChange(const Client *client, const DocumentChange &change) } } return oldPath.renameFile(newPath); - } else if (std::holds_alternative(change)) { - const auto deleteOperation = std::get(change); + } else if (std::holds_alternative(change)) { + const auto deleteOperation = std::get(change); const FilePath filePath = deleteOperation.uri().toFilePath(client->hostPathMapper()); if (const std::optional options = deleteOperation.options()) { if (!filePath.exists())