LSP: fix compile with Qt 6.2

Change-Id: Ia0b83166c9b859add450ae36001f3fa30cfb4b55
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Mathias Hasselmann <mathias@taschenorakel.de>
This commit is contained in:
David Schulz
2024-01-12 12:59:27 +01:00
parent f114df2bd3
commit 83d2b82eb9
8 changed files with 35 additions and 29 deletions

View File

@@ -3,22 +3,10 @@
#pragma once
#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
#include <QLatin1StringView>
#else
#include <QLatin1String>
#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"};

View File

@@ -10,8 +10,27 @@
#include <QDebug>
#include <QJsonObject>
#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
#include <QLatin1StringView>
#else
#include <QLatin1String>
#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<char>::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);

View File

@@ -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);

View File

@@ -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<CompletionItemCapbilities> completionItemCaps = completionItem()) {
completionItemCaps->setSnippetSupport(false);
setCompletionItem(*completionItemCaps);

View File

@@ -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"};
};

View File

@@ -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))
{

View File

@@ -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;

View File

@@ -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;