Serve reference code lenses and the showReferences command

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.
This commit is contained in:
faumaray committed 2026-12-05 17:50:38 +03:00
1 parent ec86a79a1a
commit 0bf5873069
12 files changed
+279 -5

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
#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
@@ -60,6 +60,8 @@ class EditorDiagnostics {
selection_ranges(std::string_view uri, std::span<const Documents::Position>) const;
// Foldable brace blocks, comments, regions and include groups.
[[nodiscard]] Void::LanguageServer::Protocol::Json folding_ranges(std::string_view uri) const;
// Reference-count lenses for the records the index holds for one document.
[[nodiscard]] Void::LanguageServer::Protocol::Json code_lenses(std::string_view uri) const;
// Quick fixes suggested by the compiler for diagnostics overlapping the
// requested range. Only fixes proven in the owner snapshot are offered.
[[nodiscard]] Void::LanguageServer::Protocol::Json code_actions(std::string_view uri,