forked from qt-creator/qt-creator
LSP: fix hover request result
According to the protocol a hover request can also return a Null as a result. Reflect this in the protocol implementation and adapt usages. Change-Id: I14ce71639c64b6de00e9c1198617083c1a3de9eb Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -403,4 +403,19 @@ Utils::optional<QJsonValue> CodeLens::data() const
|
||||
return contains(dataKey) ? Utils::make_optional(value(dataKey)) : Utils::nullopt;
|
||||
}
|
||||
|
||||
HoverResult::HoverResult(const QJsonValue &value)
|
||||
{
|
||||
if (value.isObject())
|
||||
emplace<Hover>(Hover(value.toObject()));
|
||||
else
|
||||
emplace<std::nullptr_t>(nullptr);
|
||||
}
|
||||
|
||||
bool HoverResult::isValid() const
|
||||
{
|
||||
if (auto hover = Utils::get_if<Hover>(this))
|
||||
return hover->isValid();
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace LanguageServerProtocol
|
||||
|
||||
Reference in New Issue
Block a user