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:
faumaray committed 2026-12-05 14:21:26 +03:00
1 parent da8003f6d4
commit 8ca3dcbf74
16 files changed
+366 -8

No files matched your search

+16 -2
View File
@@ -260,9 +260,13 @@ DispatchResult Server::handle(std::string_view body) {
Json{Json::Object{
{"workspaceFolders", Json{Json::Object{{"supported", Json{true}},
{"changeNotifications", Json{true}}}}}}}}};
if (diagnostics_) {
capabilities.emplace("documentSymbolProvider", Json{true});
}
if (diagnostics_ && diagnostics_->supports_occurrences()) {
capabilities.emplace("hoverProvider", Json{true});
capabilities.emplace("definitionProvider", Json{true});
capabilities.emplace("documentHighlightProvider", Json{true});
}
if (diagnostics_)
capabilities.emplace("completionProvider",
@@ -301,7 +305,7 @@ DispatchResult Server::handle(std::string_view body) {
: Json{Json::Object{{"state", Json{std::string{"disabled"}}}}});
}
if (*method == "textDocument/hover" || *method == "textDocument/definition" ||
*method == "textDocument/signatureHelp") {
*method == "textDocument/signatureHelp" || *method == "textDocument/documentHighlight") {
if (!diagnostics_ || !diagnostics_->supports_occurrences())
return error(id, -32601, "Method not found");
const auto *uri = as_string(member(member(params, "textDocument"), "uri"));
@@ -321,7 +325,9 @@ DispatchResult Server::handle(std::string_view body) {
auto result = *method == "textDocument/hover" ? diagnostics_->hover(*uri, selected)
: *method == "textDocument/definition"
? diagnostics_->definition(*uri, selected)
: diagnostics_->signature_help(*uri, selected);
: *method == "textDocument/signatureHelp"
? diagnostics_->signature_help(*uri, selected)
: diagnostics_->document_highlights(*uri, selected);
return reply(id, "result", std::move(result));
}
if (*method == "completionItem/resolve") {
@@ -331,6 +337,14 @@ DispatchResult Server::handle(std::string_view body) {
return error(id, -32602, "Expected a completion item");
return reply(id, "result", diagnostics_->completion_resolve(*params));
}
if (*method == "textDocument/documentSymbol") {
if (!diagnostics_)
return error(id, -32601, "Method not found");
const auto *uri = as_string(member(member(params, "textDocument"), "uri"));
if (!uri || !Void::LanguageServer::Documents::client_uri_key(*uri))
return error(id, -32602, "Expected textDocument.uri");
return reply(id, "result", diagnostics_->document_symbols(*uri));
}
if (*method == "textDocument/completion") {
if (!diagnostics_)
return error(id, -32601, "Method not found");