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.
46 lines
1.5 KiB
C++
46 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <vls/semantic/Diagnostics.hpp>
|
|
#include <vls/semantic/SourceCatalog.hpp>
|
|
|
|
#include <expected>
|
|
#include <span>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
namespace vls::semantic {
|
|
|
|
// A compiler-owned direct-call fact. Byte spans from the stock observer are
|
|
// already converted to the captured snapshot's negotiated character positions.
|
|
struct Occurrence {
|
|
std::string name, type, canonical_type, signature;
|
|
DiagnosticSnapshot use_file;
|
|
Documents::Range use;
|
|
DiagnosticSnapshot definition_file;
|
|
Documents::Range definition;
|
|
// Whole definition extent when the compiler reported one (function body
|
|
// included). Call hierarchy uses it to attribute nested calls.
|
|
std::optional<Documents::Range> extent;
|
|
|
|
[[nodiscard]] bool has_definition() const noexcept { return definition_file != nullptr; }
|
|
};
|
|
|
|
struct OccurrenceReport {
|
|
std::vector<Occurrence> occurrences;
|
|
bool complete{};
|
|
bool partial{};
|
|
std::string reason;
|
|
};
|
|
|
|
enum class OccurrenceError { invalid_report, wrong_nonce };
|
|
|
|
// Decode a stock-observer report against the exact capture that was compiled.
|
|
// Unknown paths, byte spans that do not match the captured bytes, duplicates
|
|
// and malformed envelopes reject the whole report.
|
|
[[nodiscard]] std::expected<OccurrenceReport, OccurrenceError>
|
|
decode_occurrences(std::string_view report, std::string_view nonce,
|
|
std::span<const CapturedSource> capture);
|
|
|
|
} // namespace vls::semantic
|