Report class and base facts from the stock observer

For each call whose result is a class type, the observer records the
class name span and its direct bases (bounded, deduplicated by uid).
The corpus verifier validates the new types array, and the occurrence
decoder binds each reference to its captured snapshot through the
negotiated encoding, rejecting uncaptured or malformed entries. A
registered decoder case covers the new field. LSP type-hierarchy
handlers remain open.
This commit is contained in:
faumaray committed 2026-12-05 22:56:00 +03:00
1 parent 3344a9f170
commit b1c8a4a625
6 files changed
+240 -4

No files matched your search

+23
View File
@@ -207,3 +207,26 @@ VOID_TEST(Occurrences, binds_a_multiline_definition_extent) {
expect(
!decode(report(occurrence("f", "int", span_json(path, call), bad)), entries).has_value());
}
namespace {
std::string ref_only(const Span &value, std::uint32_t uid, std::string_view name) {
const auto span = span_json(path, value);
return "{\"uid\":" + std::to_string(uid) + ",\"name\":\"" + std::string{name} + "\"," +
span.substr(1);
}
std::string typed_report(std::string_view types) {
return R"({"schema":1,"nonce":")" + std::string{nonce} +
R"(","complete":true,"partial":false,"reason":"","occurrences":[],"types":)" +
std::string{types} + "}";
}
} // namespace
VOID_TEST(Occurrences, type_entry_without_bases_decodes) {
auto entries = capture(std::string{source});
const auto declaration = span(source, "f", 0);
const auto types = R"([{"self":)" + ref_only(declaration, 10, "f") + R"(,"bases":[]}])";
auto decoded = decode(typed_report(types), entries);
require(decoded.has_value());
require(decoded->types.size() == 1);
expect(decoded->types[0].bases.empty());
}