forked from qt-creator/qt-creator
LSP: Use 8-bit keys in Json wrapper
Sufficient, smaller, faster. Change-Id: I0d740785109538e04fc674c11d578ded8d2815fb Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -18,8 +18,8 @@ using namespace Utils;
|
||||
|
||||
namespace ClangCodeModel::Internal {
|
||||
|
||||
static constexpr char16_t roleKey[] = u"role";
|
||||
static constexpr char16_t arcanaKey[] = u"arcana";
|
||||
static constexpr char roleKey[] = "role";
|
||||
static constexpr char arcanaKey[] = "arcana";
|
||||
|
||||
QString ClangdAstNode::role() const { return typedValue<QString>(roleKey); }
|
||||
QString ClangdAstNode::kind() const { return typedValue<QString>(kindKey); }
|
||||
|
||||
@@ -99,7 +99,7 @@ class SymbolDetails : public JsonObject
|
||||
public:
|
||||
using JsonObject::JsonObject;
|
||||
|
||||
static constexpr char16_t usrKey[] = u"usr";
|
||||
static constexpr char usrKey[] = "usr";
|
||||
|
||||
// the unqualified name of the symbol
|
||||
QString name() const { return typedValue<QString>(nameKey); }
|
||||
@@ -226,15 +226,15 @@ class DiagnosticsCapabilities : public JsonObject
|
||||
{
|
||||
public:
|
||||
using JsonObject::JsonObject;
|
||||
void enableCategorySupport() { insert(u"categorySupport", true); }
|
||||
void enableCodeActionsInline() {insert(u"codeActionsInline", true);}
|
||||
void enableCategorySupport() { insert("categorySupport", true); }
|
||||
void enableCodeActionsInline() {insert("codeActionsInline", true);}
|
||||
};
|
||||
|
||||
class InactiveRegionsCapabilities : public JsonObject
|
||||
{
|
||||
public:
|
||||
using JsonObject::JsonObject;
|
||||
void enableInactiveRegionsSupport() { insert(u"inactiveRegions", true); }
|
||||
void enableInactiveRegionsSupport() { insert("inactiveRegions", true); }
|
||||
};
|
||||
|
||||
class ClangdTextDocumentClientCapabilities : public TextDocumentClientCapabilities
|
||||
@@ -243,9 +243,9 @@ public:
|
||||
using TextDocumentClientCapabilities::TextDocumentClientCapabilities;
|
||||
|
||||
void setPublishDiagnostics(const DiagnosticsCapabilities &caps)
|
||||
{ insert(u"publishDiagnostics", caps); }
|
||||
{ insert("publishDiagnostics", caps); }
|
||||
void setInactiveRegionsCapabilities(const InactiveRegionsCapabilities &caps)
|
||||
{ insert(u"inactiveRegionsCapabilities", caps); }
|
||||
{ insert("inactiveRegionsCapabilities", caps); }
|
||||
};
|
||||
|
||||
static qint64 getRevision(const TextDocument *doc)
|
||||
@@ -1572,7 +1572,7 @@ void ClangdClient::Private::handleSemanticTokens(TextDocument *doc,
|
||||
|
||||
std::optional<QList<CodeAction> > ClangdDiagnostic::codeActions() const
|
||||
{
|
||||
auto actions = optionalArray<LanguageServerProtocol::CodeAction>(u"codeActions");
|
||||
auto actions = optionalArray<LanguageServerProtocol::CodeAction>("codeActions");
|
||||
if (!actions)
|
||||
return actions;
|
||||
static const QStringList badCodeActions{
|
||||
@@ -1589,7 +1589,7 @@ std::optional<QList<CodeAction> > ClangdDiagnostic::codeActions() const
|
||||
|
||||
QString ClangdDiagnostic::category() const
|
||||
{
|
||||
return typedValue<QString>(u"category");
|
||||
return typedValue<QString>("category");
|
||||
}
|
||||
|
||||
MessageId ClangdClient::Private::getAndHandleAst(const TextDocOrFile &doc,
|
||||
|
||||
@@ -635,7 +635,7 @@ IAssistProposal *ClangdFunctionHintProcessor::perform()
|
||||
ClangdCompletionCapabilities::ClangdCompletionCapabilities(const JsonObject &object)
|
||||
: TextDocumentClientCapabilities::CompletionCapabilities(object)
|
||||
{
|
||||
insert(u"editsNearCursor", true); // For dot-to-arrow correction.
|
||||
insert("editsNearCursor", true); // For dot-to-arrow correction.
|
||||
if (std::optional<CompletionItemCapbilities> completionItemCaps = completionItem()) {
|
||||
completionItemCaps->setSnippetSupport(false);
|
||||
setCompletionItem(*completionItemCaps);
|
||||
|
||||
@@ -27,10 +27,10 @@ public:
|
||||
using JsonObject::JsonObject;
|
||||
|
||||
// number of bytes used, including child components
|
||||
qint64 total() const { return qint64(typedValue<double>(totalKey())); }
|
||||
qint64 total() const { return qint64(typedValue<double>(totalKey)); }
|
||||
|
||||
// number of bytes used, excluding child components
|
||||
qint64 self() const { return qint64(typedValue<double>(selfKey())); }
|
||||
qint64 self() const { return qint64(typedValue<double>(selfKey)); }
|
||||
|
||||
// named child components
|
||||
using NamedComponent = std::pair<MemoryTree, QString>;
|
||||
@@ -39,16 +39,15 @@ public:
|
||||
QList<NamedComponent> components;
|
||||
const auto obj = operator const QJsonObject &();
|
||||
for (auto it = obj.begin(); it != obj.end(); ++it) {
|
||||
if (it.key() == totalKey() || it.key() == selfKey())
|
||||
if (it.key() == QLatin1String(totalKey) || it.key() == QLatin1String(selfKey))
|
||||
continue;
|
||||
components.push_back({MemoryTree(it.value()), it.key()});
|
||||
}
|
||||
return components;
|
||||
}
|
||||
|
||||
private:
|
||||
static QString totalKey() { return QLatin1String("_total"); }
|
||||
static QString selfKey() { return QLatin1String("_self"); }
|
||||
static constexpr char totalKey[] = "_total";
|
||||
static constexpr char selfKey[] = "_self";
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -967,8 +967,8 @@ class InactiveRegionsParams : public JsonObject
|
||||
public:
|
||||
using JsonObject::JsonObject;
|
||||
|
||||
DocumentUri uri() const { return TextDocumentIdentifier(value(u"textDocument")).uri(); }
|
||||
QList<Range> inactiveRegions() const { return array<Range>(u"regions"); }
|
||||
DocumentUri uri() const { return TextDocumentIdentifier(value("textDocument")).uri(); }
|
||||
QList<Range> inactiveRegions() const { return array<Range>("regions"); }
|
||||
};
|
||||
|
||||
class InactiveRegionsNotification : public Notification<InactiveRegionsParams>
|
||||
|
||||
Reference in New Issue
Block a user