Files
Language-Server/include/vls/semantic/Occurrences.hpp
T
faumaray b1c8a4a625 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.
2026-12-05 22:56:00 +03:00

56 lines
1.7 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 TypeRef {
std::string name, path;
Documents::Range range;
};
// A class observed as a call's result type and its direct bases.
struct ReflectedType {
TypeRef self;
std::vector<TypeRef> bases;
};
struct OccurrenceReport {
std::vector<Occurrence> occurrences;
std::vector<ReflectedType> types;
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