callHierarchy/outgoingCalls groups calls attributed to the prepared function's innermost enclosing definition by callee, with registered core tests for grouping, innermost attribution, unresolved-callee omission and bounds. Real stdio evidence shows the observer reports only the declarator span, so body calls cannot be attributed without guessing; the matrix records that limitation.
78 lines
2.4 KiB
C++
78 lines
2.4 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{});
|
|
|
|
struct Outgoing {
|
|
Definition to;
|
|
std::vector<Range> from_ranges;
|
|
auto operator<=>(const Outgoing &) const = default;
|
|
};
|
|
|
|
// Calls made inside CALLER, grouped by their resolved callee definition.
|
|
// A call is attributed to the innermost known definition containing it in the
|
|
// same file, so calls inside nested functions are not reported for CALLER.
|
|
// Calls without a resolved callee are omitted: an item must point somewhere.
|
|
[[nodiscard]] std::vector<Outgoing> outgoing(std::span<const Call>,
|
|
std::span<const Definition> known,
|
|
const Definition &caller, const Limits & = Limits{});
|
|
|
|
} // namespace vls::features::call_hierarchy
|