Occurrences carry their result type uid, decoded types are retained per editor entry, and a bounded core selects direct bases and inverse subtypes. The server advertises typeHierarchyProvider and serves prepareTypeHierarchy, supertypes and subtypes. Registered feature tests cover the selection; a real stdio session prepared DerivedA and returned Base as supertype and DerivedA/DerivedB as subtypes of Base.
59 lines
1.8 KiB
C++
59 lines
1.8 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{};
|
|
|
|
[[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
|