A bounded core builds one lens per document position with its proven reference count. EditorDiagnostics counts index records by name and definition and serves textDocument/codeLens; workspace/executeCommand implements vls.showReferences via the navigation binding. Registered feature tests cover titles, arguments, deduplication and bounds. A real stdio session showed the one-reference lens at the fnv1a64 call and resolved it to the source location.
48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <compare>
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <span>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace vls::features::code_lens {
|
|
|
|
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 outline symbol with its proven reference count.
|
|
struct Entry {
|
|
std::string name;
|
|
std::string path;
|
|
Range range;
|
|
std::size_t references{};
|
|
};
|
|
|
|
struct Lens {
|
|
Range range;
|
|
std::string title;
|
|
std::vector<std::string> arguments;
|
|
auto operator<=>(const Lens &) const = default;
|
|
};
|
|
|
|
struct Limits {
|
|
std::size_t lenses{512};
|
|
std::size_t nameBytes{256};
|
|
std::size_t titleBytes{128};
|
|
};
|
|
|
|
// One lens per unique (path, range), titled with the reference count and
|
|
// carrying {path, line, character} arguments so a client can resolve it through
|
|
// workspace/executeCommand. Entries are ordered by position and bounded.
|
|
[[nodiscard]] std::vector<Lens> build(std::span<const Entry>, const Limits & = Limits{});
|
|
|
|
} // namespace vls::features::code_lens
|