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:
David Schulz
2022-05-16 13:31:10 +02:00
parent 2b8d96465a
commit 52770b746e
4 changed files with 71 additions and 36 deletions

View File

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