A bounded call-hierarchy core maps resolved call sites to the innermost compiler-proven definition containing them in the same file, falling back to an explicitly file-level caller instead of a guessed function. Registered vls_feature_tests cases cover grouping, deduplication, exact-target matching and bounds. Server wiring remains.
64 lines
1.8 KiB
C++
64 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <compare>
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <optional>
|
|
#include <span>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace vls::features::call_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;
|
|
};
|
|
|
|
// A compiler-proven function definition.
|
|
struct Definition {
|
|
std::string name;
|
|
std::string path;
|
|
Range range;
|
|
auto operator<=>(const Definition &) const = default;
|
|
};
|
|
|
|
// One resolved call site.
|
|
struct Call {
|
|
std::string callee;
|
|
std::optional<Definition> callee_definition;
|
|
std::string path;
|
|
Range range;
|
|
};
|
|
|
|
struct Incoming {
|
|
std::string name;
|
|
std::string path;
|
|
Range range; // the caller definition, or the call itself when unknown
|
|
std::vector<Range> from_ranges;
|
|
// True when an enclosing compiler-proven definition named the caller;
|
|
// false means the caller is reported at file level.
|
|
bool resolved_definition{};
|
|
auto operator<=>(const Incoming &) const = default;
|
|
};
|
|
|
|
struct Limits {
|
|
std::size_t callers{256};
|
|
std::size_t ranges{512};
|
|
std::size_t nameBytes{256};
|
|
};
|
|
|
|
// Incoming calls of TARGET: every resolved call to it, grouped by the
|
|
// innermost known definition containing the call site in that file. When no
|
|
// definition contains it, the caller is reported at file level with the call
|
|
// range, never as a guessed function.
|
|
[[nodiscard]] std::vector<Incoming> incoming(std::span<const Call>,
|
|
std::span<const Definition> known,
|
|
const Definition &target, const Limits & = Limits{});
|
|
|
|
} // namespace vls::features::call_hierarchy
|