The stock observer reports targetKind inside each proven target span, the decoder carries it, and semantic tokens apply the legend's definition modifier instead of always declaring. The observer verifier validates the field and the definition span parser ignores it as envelope metadata. A real stdio session showed modifier 2 on the factory definitions.
61 lines
2.0 KiB
C++
61 lines
2.0 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;
|
|
// Uid of the reported class type of this call's result, when present.
|
|
std::uint32_t result_type_uid{};
|
|
// The resolved target is a definition (not merely a declaration).
|
|
bool target_is_definition{};
|
|
|
|
[[nodiscard]] bool has_definition() const noexcept { return definition_file != nullptr; }
|
|
};
|
|
|
|
struct TypeRef {
|
|
std::string name, path;
|
|
Documents::Range range;
|
|
std::uint32_t uid{};
|
|
};
|
|
// 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
|