Serve document symbols and highlights over LSP
SymbolIndex::find_by_path exposes one document's records with the same overlay shadowing and coverage as find. EditorDiagnostics maps them to textDocument/documentSymbol, and a bounded same-file highlight core (vls/features/DocumentSymbols.hpp) backs textDocument/documentHighlight from verified occurrence facts with the ambiguous-binding rule. Both are advertised and exercised over a real stdio session with the stock observer. Record the LSP parity matrix.
This commit is contained in:
1 parent
da8003f6d4
commit
8ca3dcbf74
16 files changed
+366
-8
No files matched your search
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <compare>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace vls::features::documents {
|
||||
|
||||
struct Position {
|
||||
std::uint32_t line{}, character{};
|
||||
auto operator<=>(const Position &) const = default;
|
||||
};
|
||||
|
||||
struct Range {
|
||||
Position start, end;
|
||||
auto operator<=>(const Range &) const = default;
|
||||
};
|
||||
|
||||
struct Location {
|
||||
std::string path;
|
||||
Range range;
|
||||
auto operator<=>(const Location &) const = default;
|
||||
};
|
||||
|
||||
// Semantic identity of one binding, joined by definition like navigation.
|
||||
struct Binding {
|
||||
std::string name;
|
||||
std::optional<Location> definition;
|
||||
auto operator<=>(const Binding &) const = default;
|
||||
};
|
||||
|
||||
struct Use {
|
||||
Binding binding;
|
||||
std::string path;
|
||||
Range range;
|
||||
};
|
||||
|
||||
// Ranges of every proven use of the binding at the position, restricted to
|
||||
// the same file, deduplicated and bounded. An empty result means no unique
|
||||
// binding covers the position.
|
||||
[[nodiscard]] std::vector<Range> highlights(std::span<const Use>, std::string_view path, Position,
|
||||
std::size_t limit = 512);
|
||||
|
||||
} // namespace vls::features::documents
|
||||
@@ -121,6 +121,9 @@ class SymbolIndex {
|
||||
const std::optional<std::string> &content);
|
||||
|
||||
[[nodiscard]] Result find(const Query &) const;
|
||||
// Records whose use location is in PATH, with the same overlay shadowing,
|
||||
// deduplication and coverage reporting as find().
|
||||
[[nodiscard]] Result find_by_path(std::string_view path, std::size_t limit = 4096) const;
|
||||
[[nodiscard]] Coverage coverage() const;
|
||||
[[nodiscard]] std::shared_ptr<const Generation> current() const;
|
||||
[[nodiscard]] std::uint64_t generation() const;
|
||||
|
||||
@@ -37,6 +37,11 @@ class EditorDiagnostics {
|
||||
// without details rather than details for a different entity.
|
||||
[[nodiscard]] Void::LanguageServer::Protocol::Json
|
||||
completion_resolve(const Void::LanguageServer::Protocol::Json &item) const;
|
||||
// Outline of the records the index holds for one document path.
|
||||
[[nodiscard]] Void::LanguageServer::Protocol::Json document_symbols(std::string_view uri) const;
|
||||
// Same-binding uses within the document, or an empty list.
|
||||
[[nodiscard]] Void::LanguageServer::Protocol::Json
|
||||
document_highlights(std::string_view uri, Documents::Position position) const;
|
||||
|
||||
struct NavigationReply {
|
||||
Void::LanguageServer::Protocol::Json result;
|
||||
|
||||
Reference in new issue
Block a user