forked from qt-creator/qt-creator
LSP: Fix MarkedString fromJson
fromJsonValue<T>(...) (with T = MarkedString) always tried to convert the json value toObject() first. Which is wrong since it can be an object or a string. Fixes the broken hover text for the json language server. Change-Id: Id69b4270238bea7068936a7d2142f4f94918f96b Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -261,6 +261,12 @@ DocumentHighlightsResult::DocumentHighlightsResult(const QJsonValue &value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
MarkedString fromJsonValue<MarkedString>(const QJsonValue &value)
|
||||||
|
{
|
||||||
|
return MarkedString(value);
|
||||||
|
}
|
||||||
|
|
||||||
MarkedString::MarkedString(const QJsonValue &value)
|
MarkedString::MarkedString(const QJsonValue &value)
|
||||||
{
|
{
|
||||||
if (value.isObject())
|
if (value.isObject())
|
||||||
|
@@ -52,6 +52,9 @@ public:
|
|||||||
operator QJsonValue() const;
|
operator QJsonValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
LANGUAGESERVERPROTOCOL_EXPORT MarkedString fromJsonValue<MarkedString>(const QJsonValue &value);
|
||||||
|
|
||||||
class LANGUAGESERVERPROTOCOL_EXPORT HoverContent
|
class LANGUAGESERVERPROTOCOL_EXPORT HoverContent
|
||||||
: public std::variant<MarkedString, QList<MarkedString>, MarkupContent>
|
: public std::variant<MarkedString, QList<MarkedString>, MarkupContent>
|
||||||
{
|
{
|
||||||
|
@@ -68,7 +68,7 @@ public:
|
|||||||
if (value.isArray()) {
|
if (value.isArray()) {
|
||||||
QList<T> values;
|
QList<T> values;
|
||||||
values.reserve(value.toArray().count());
|
values.reserve(value.toArray().count());
|
||||||
for (auto arrayValue : value.toArray())
|
for (const auto &arrayValue : value.toArray())
|
||||||
values << fromJsonValue<T>(arrayValue);
|
values << fromJsonValue<T>(arrayValue);
|
||||||
*this = values;
|
*this = values;
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user