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:
1 parent
3344a9f170
commit
b1c8a4a625
6 files changed
+240
-4
No files matched your search
@@ -101,10 +101,25 @@ def analyze(work, nonce, admitted, complete=True, partial=None):
|
||||
data = report_path.read_bytes()
|
||||
check(0 < len(data) <= MAX_REPORT, "report size out of bounds")
|
||||
report = strict_json(data)
|
||||
check(set(report) == {"schema", "nonce", "complete", "partial", "reason", "occurrences"},
|
||||
check(set(report) == {"schema", "nonce", "complete", "partial", "reason", "occurrences",
|
||||
"types"},
|
||||
f"unexpected report keys {sorted(report)}")
|
||||
check(type(report["schema"]) is int and report["schema"] == 1, "wrong schema")
|
||||
check(report["nonce"] == nonce and HEX.fullmatch(report["nonce"]) is not None, "wrong nonce")
|
||||
check(isinstance(report["types"], list) and len(report["types"]) <= 256,
|
||||
"types is not a bounded list")
|
||||
for entry in report["types"]:
|
||||
check(isinstance(entry, dict) and set(entry) == {"self", "bases"},
|
||||
f"invalid type entry {entry!r}")
|
||||
for reference in [entry["self"], *entry["bases"]]:
|
||||
check(isinstance(reference, dict)
|
||||
and set(reference) == {"uid", "name", "path", "line", "startByte", "endByte"}
|
||||
and type(reference["uid"]) is int and reference["uid"] > 0,
|
||||
f"invalid type reference {reference!r}")
|
||||
read_span({key: reference[key]
|
||||
for key in ("path", "line", "startByte", "endByte")},
|
||||
reference["name"], "type")
|
||||
check(len(entry["bases"]) <= 16, "too many bases")
|
||||
check(type(report["complete"]) is bool and type(report["partial"]) is bool,
|
||||
"non-boolean status")
|
||||
check(isinstance(report["reason"], str), "reason is not a string")
|
||||
|
||||
Reference in new issue
Block a user