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

+46 -3
View File
@@ -189,7 +189,7 @@ decode_occurrences(std::string_view report, std::string_view nonce,
if (!parsed)
return std::unexpected{OccurrenceError::invalid_report};
const auto *root = P::as_object(&*parsed);
if (!root || root->size() != 6)
if (!root)
return std::unexpected{OccurrenceError::invalid_report};
const auto schema = integer(P::find_member(*root, "schema"));
const auto *nonce_text = P::as_string(P::find_member(*root, "nonce"));
@@ -197,14 +197,57 @@ decode_occurrences(std::string_view report, std::string_view nonce,
const auto partial = P::as_bool(P::find_member(*root, "partial"));
const auto *reason = P::as_string(P::find_member(*root, "reason"));
const auto *items = P::as_array(P::find_member(*root, "occurrences"));
const auto *types = P::as_array(P::find_member(*root, "types"));
if (!schema || *schema != 1 || !nonce_text || !complete || !partial || !reason ||
!plain(*reason, max_reason) || !items || items->size() > max_occurrences)
!plain(*reason, max_reason) || !items || items->size() > max_occurrences ||
(root->size() != 6 && root->size() != 7) || (root->size() == 7 && !types) ||
(types && types->size() > max_occurrences))
return std::unexpected{OccurrenceError::invalid_report};
if (*nonce_text != nonce)
return std::unexpected{OccurrenceError::wrong_nonce};
OccurrenceReport result{{}, *complete, *partial, *reason};
OccurrenceReport result{{}, {}, *complete, *partial, *reason};
if (!*complete)
return result;
if (types)
for (const auto &item : *types) {
const auto *fields = P::as_object(&item);
const auto *self = fields ? P::find_member(*fields, "self") : nullptr;
const auto *bases = fields ? P::as_array(P::find_member(*fields, "bases")) : nullptr;
if (!fields || fields->size() != 2 || !bases || bases->size() > 16)
return std::unexpected{OccurrenceError::invalid_report};
const auto read = [&](const Json *value) -> std::optional<TypeRef> {
const auto *fields = value ? P::as_object(value) : nullptr;
if (!fields || fields->size() != 6 || !integer(P::find_member(*fields, "uid")) ||
!P::as_string(P::find_member(*fields, "name")))
return std::nullopt;
Json::Object trimmed;
for (const auto *key : {"path", "line", "startByte", "endByte"}) {
const auto *field = P::find_member(*fields, key);
if (!field)
return std::nullopt;
trimmed.emplace(key, *field);
}
const Json holder{std::move(trimmed)};
const auto raw = span(&holder);
if (!raw || !captured(capture, raw->path))
return std::nullopt;
auto bound = bind_span(*raw, {}, capture);
if (!bound)
return std::nullopt;
return TypeRef{std::string{raw->path}, raw->path, bound->second};
};
auto parsed_self = read(self);
if (!parsed_self)
return std::unexpected{OccurrenceError::invalid_report};
ReflectedType type{std::move(*parsed_self), {}};
for (const auto &base : *bases) {
auto parsed_base = read(&base);
if (!parsed_base)
return std::unexpected{OccurrenceError::invalid_report};
type.bases.push_back(std::move(*parsed_base));
}
result.types.push_back(std::move(type));
}
std::set<std::tuple<const void *, std::uint32_t, std::uint32_t>> uses;
for (const auto &item : *items) {
const auto *fields = P::as_object(&item);