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

+21
View File
@@ -186,3 +186,24 @@ VOID_TEST(Occurrences, rejects_a_malformed_envelope) {
require(!decode(extra, entries).has_value());
require(!decode("{\"schema\":1}", entries).has_value());
}
VOID_TEST(Occurrences, binds_a_multiline_definition_extent) {
auto entries = capture(std::string{source});
const auto call = span(source, "f", 1), declaration = span(source, "f", 0);
const auto definition = span_json(path, declaration);
const auto with_extent = definition.substr(0, definition.size() - 1) +
R"(,"extent":{"startLine":1,"startByte":5,"endLine":1,"endByte":21}})";
auto decoded =
decode(report(occurrence("f", "int", span_json(path, call), with_extent)), entries);
require(decoded.has_value());
require(decoded->occurrences.size() == 1);
const auto &fact = decoded->occurrences.front();
require(fact.extent.has_value());
expect(fact.extent->start.line == 0 && fact.extent->start.character == 4);
expect(fact.extent->end.line == 0 && fact.extent->end.character == 20);
// A malformed extent rejects the report rather than being dropped.
const auto bad = definition.substr(0, definition.size() - 1) +
R"(,"extent":{"startLine":2,"startByte":5,"endLine":1,"endByte":21}})";
expect(
!decode(report(occurrence("f", "int", span_json(path, call), bad)), entries).has_value());
}