diff --git a/src/libs/languageserverprotocol/jsonkeys.h b/src/libs/languageserverprotocol/jsonkeys.h index e5b07c064c0..f9ef7b4bedb 100644 --- a/src/libs/languageserverprotocol/jsonkeys.h +++ b/src/libs/languageserverprotocol/jsonkeys.h @@ -3,22 +3,10 @@ #pragma once -#include - -#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) -#include -#else -#include -#endif +#include "jsonobject.h" namespace LanguageServerProtocol { -#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) -using Key = QLatin1StringView; -#else -using Key = QLatin1String; -#endif - constexpr Key actionsKey{"actions"}; constexpr Key activeParameterKey{"activeParameter"}; constexpr Key activeParameterSupportKey{"activeParameterSupport"}; diff --git a/src/libs/languageserverprotocol/jsonobject.h b/src/libs/languageserverprotocol/jsonobject.h index 6c5f7510b79..178e74e5ad7 100644 --- a/src/libs/languageserverprotocol/jsonobject.h +++ b/src/libs/languageserverprotocol/jsonobject.h @@ -10,8 +10,27 @@ #include #include +#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) +#include +#else +#include +#endif + namespace LanguageServerProtocol { +#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) +using Key = QLatin1StringView; +#else +class Key : public QLatin1String +{ +public: + using QLatin1String::QLatin1String; + constexpr inline explicit Key(const char *s) noexcept + : QLatin1String(s, std::char_traits::length(s)) + {} +}; +#endif + class LANGUAGESERVERPROTOCOL_EXPORT JsonObject { public: @@ -43,11 +62,6 @@ public: const_iterator end() const { return m_jsonObject.end(); } protected: -#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) - using Key = QLatin1StringView; -#else - using Key = QLatin1String; -#endif iterator insert(const Key key, const JsonObject &value); iterator insert(const Key key, const QJsonValue &value); diff --git a/src/plugins/clangcodemodel/clangdclient.cpp b/src/plugins/clangcodemodel/clangdclient.cpp index 7ed88a63d10..e5e5142370d 100644 --- a/src/plugins/clangcodemodel/clangdclient.cpp +++ b/src/plugins/clangcodemodel/clangdclient.cpp @@ -88,6 +88,8 @@ using namespace Utils; namespace ClangCodeModel { namespace Internal { +using Key = LanguageServerProtocol::Key; + Q_LOGGING_CATEGORY(clangdLog, "qtc.clangcodemodel.clangd", QtWarningMsg); Q_LOGGING_CATEGORY(clangdLogAst, "qtc.clangcodemodel.clangd.ast", QtWarningMsg); static Q_LOGGING_CATEGORY(clangdLogServer, "qtc.clangcodemodel.clangd.server", QtWarningMsg); diff --git a/src/plugins/clangcodemodel/clangdcompletion.cpp b/src/plugins/clangcodemodel/clangdcompletion.cpp index c10c48685fc..a10ba815df3 100644 --- a/src/plugins/clangcodemodel/clangdcompletion.cpp +++ b/src/plugins/clangcodemodel/clangdcompletion.cpp @@ -624,7 +624,7 @@ IAssistProposal *ClangdFunctionHintProcessor::perform() ClangdCompletionCapabilities::ClangdCompletionCapabilities(const JsonObject &object) : TextDocumentClientCapabilities::CompletionCapabilities(object) { - insert(Key{"editsNearCursor"}, true); // For dot-to-arrow correction. + insert(LanguageServerProtocol::Key{"editsNearCursor"}, true); // For dot-to-arrow correction. if (std::optional completionItemCaps = completionItem()) { completionItemCaps->setSnippetSupport(false); setCompletionItem(*completionItemCaps); diff --git a/src/plugins/clangcodemodel/clangdmemoryusagewidget.cpp b/src/plugins/clangcodemodel/clangdmemoryusagewidget.cpp index c38986155a7..6c1df596afb 100644 --- a/src/plugins/clangcodemodel/clangdmemoryusagewidget.cpp +++ b/src/plugins/clangcodemodel/clangdmemoryusagewidget.cpp @@ -46,8 +46,8 @@ public: return components; } - static constexpr Key totalKey{"_total"}; - static constexpr Key selfKey{"_self"}; + static constexpr LanguageServerProtocol::Key totalKey{"_total"}; + static constexpr LanguageServerProtocol::Key selfKey{"_self"}; }; diff --git a/src/plugins/coco/cocolanguageclient.cpp b/src/plugins/coco/cocolanguageclient.cpp index 8b517729c01..1ef02a071e5 100644 --- a/src/plugins/coco/cocolanguageclient.cpp +++ b/src/plugins/coco/cocolanguageclient.cpp @@ -26,6 +26,8 @@ using namespace Core; namespace Coco { +using Key = LanguageServerProtocol::Key; + CocoLanguageClient::CocoLanguageClient(const FilePath &coco, const FilePath &csmes) : Client(clientInterface(coco, csmes)) { diff --git a/src/plugins/copilot/requests/checkstatus.h b/src/plugins/copilot/requests/checkstatus.h index 6f58f760241..4bd0026ca45 100644 --- a/src/plugins/copilot/requests/checkstatus.h +++ b/src/plugins/copilot/requests/checkstatus.h @@ -10,8 +10,8 @@ namespace Copilot { class CheckStatusParams : public LanguageServerProtocol::JsonObject { - static constexpr Key optionsKey{"options"}; - static constexpr Key localChecksOnlyKey{"options"}; + static constexpr LanguageServerProtocol::Key optionsKey{"options"}; + static constexpr LanguageServerProtocol::Key localChecksOnlyKey{"options"}; public: using JsonObject::JsonObject; @@ -30,8 +30,8 @@ public: class CheckStatusResponse : public LanguageServerProtocol::JsonObject { - static constexpr Key userKey{"user"}; - static constexpr Key statusKey{"status"}; + static constexpr LanguageServerProtocol::Key userKey{"user"}; + static constexpr LanguageServerProtocol::Key statusKey{"status"}; public: using JsonObject::JsonObject; diff --git a/src/plugins/copilot/requests/getcompletions.h b/src/plugins/copilot/requests/getcompletions.h index ea42560725d..3630c086cd1 100644 --- a/src/plugins/copilot/requests/getcompletions.h +++ b/src/plugins/copilot/requests/getcompletions.h @@ -11,8 +11,8 @@ namespace Copilot { class Completion : public LanguageServerProtocol::JsonObject { - static constexpr Key displayTextKey{"displayText"}; - static constexpr Key uuidKey{"uuid"}; + static constexpr LanguageServerProtocol::Key displayTextKey{"displayText"}; + static constexpr LanguageServerProtocol::Key uuidKey{"uuid"}; public: using JsonObject::JsonObject; @@ -41,7 +41,7 @@ public: class GetCompletionParams : public LanguageServerProtocol::JsonObject { public: - static constexpr Key docKey{"doc"}; + static constexpr LanguageServerProtocol::Key docKey{"doc"}; GetCompletionParams(const LanguageServerProtocol::TextDocumentIdentifier &document, int version, @@ -95,7 +95,7 @@ public: class GetCompletionResponse : public LanguageServerProtocol::JsonObject { - static constexpr Key completionKey{"completions"}; + static constexpr LanguageServerProtocol::Key completionKey{"completions"}; public: using JsonObject::JsonObject;