Serve type hierarchy from observer class facts

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.
This commit is contained in:
faumaray committed 2026-12-05 23:36:05 +03:00
1 parent b1c8a4a625
commit 86b9923532
14 files changed
+357 -15

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
#pragma once
#include <compare>
#include <cstddef>
#include <cstdint>
#include <span>
#include <string>
#include <vector>
namespace vls::features::type_hierarchy {
struct Position {
std::uint32_t line{}, character{};
auto operator<=>(const Position &) const = default;
};
struct Range {
Position start, end;
auto operator<=>(const Range &) const = default;
};
// One compiler-proven type name occurrence.
struct TypeRef {
std::uint32_t uid{};
std::string name;
std::string path;
Range range;
auto operator<=>(const TypeRef &) const = default;
};
struct Type {
TypeRef self;
std::vector<TypeRef> bases;
};
struct Limits {
std::size_t items{256};
};
// Direct bases of TARGET, deduplicated by identity and bounded.
[[nodiscard]] std::vector<TypeRef> supertypes(std::span<const Type>, const TypeRef &target,
const Limits & = Limits{});
// Types whose direct bases contain TARGET, deduplicated by identity and bounded.
[[nodiscard]] std::vector<TypeRef> subtypes(std::span<const Type>, const TypeRef &target,
const Limits & = Limits{});
} // namespace vls::features::type_hierarchy