Report full function extents from the stock observer

The observer emits an optional extent inside each proven definition
span from the body's last statement finish (the C++ frontend does not
set function_end_locus). The occurrence decoder binds it to the same
snapshot through the negotiated encoding and rejects malformed
extents; call hierarchy attributes nested calls to the enclosing
extent. A real stdio session reported both inner calls as outgoing
from outer, and the observer and occurrence corpora still pass.
This commit is contained in:
faumaray committed 2026-12-05 17:28:59 +03:00
1 parent a098e45dc9
commit ec86a79a1a
11 files changed
+239 -11

No files matched your search

+17 -1
View File
@@ -61,7 +61,9 @@ def compile(compiler, observer, work, main, flags=()):
def read_span(span, name, label):
check(isinstance(span, dict) and set(span) == {"path", "line", "startByte", "endByte"},
check(isinstance(span, dict)
and set(span) in ({"path", "line", "startByte", "endByte"},
{"path", "line", "startByte", "endByte", "extent"}),
f"invalid {label} span {span!r}")
check(all(type(span[key]) is int for key in ("line", "startByte", "endByte")),
f"non-integer {label} span {span!r}")
@@ -76,6 +78,20 @@ def read_span(span, name, label):
f"{label} {name!r} does not occupy {span}: {raw!r}")
raw[:start - 1].decode("utf-8")
raw[:end - 1].decode("utf-8")
if "extent" in span:
extent = span["extent"]
check(isinstance(extent, dict)
and set(extent) == {"startLine", "startByte", "endLine", "endByte"}
and all(type(value) is int for value in extent.values()),
f"invalid {label} extent {extent!r}")
check(extent["startLine"] == span["line"] and extent["startByte"] == start
and (extent["endLine"], extent["endByte"]) >= (extent["startLine"], start),
f"{label} extent does not start at its span: {extent} vs {span}")
check(1 <= extent["endLine"] <= len(lines),
f"{label} extent line outside {path}: {extent}")
last = lines[extent["endLine"] - 1]
check(1 <= extent["endByte"] <= len(last) + 1,
f"{label} extent bytes outside line: {extent}")
return (path, span["line"], start, end)