diff --git a/docs/agent-workflow/VERIFICATION.md b/docs/agent-workflow/VERIFICATION.md index 04cbe84..07c2eb3 100644 --- a/docs/agent-workflow/VERIFICATION.md +++ b/docs/agent-workflow/VERIFICATION.md @@ -61,6 +61,22 @@ start coordinate only, so ranges are zero-width until an end is available. LSP adapters and index/rename/debugging integration remain open. `vbs test` passed all 17 native suites; CMake passed the reflection and trace suites. +## December 6 generic outline ingested into the symbol index + +Each open document's text outline is published as its own index context +(`outline:`, provenance `document-outline`) when its content changes and +removed when the document closes, so it never replaces the compiler facts for +the same document. `workspace/symbol` no longer requires the occurrence +observer, and `documentSymbol` skips the outline's index copies. + +In the D-032 session (plain compilation database, no observer): +``` +documentSymbol: [('main', 12)] +workspace/symbol: ['main'] error: None +hover error: -32601 +``` +All 18 native suites and all 18 CMake tests passed. + ## December 6 generic document outline `include/vls/features/Outline.hpp` adds a compiler-independent outline: a diff --git a/src/Server.cpp b/src/Server.cpp index bf8b13e..7e8c1bb 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -772,7 +772,7 @@ DispatchResult Server::handle(std::string_view body) { return reply(id, "result", std::move(navigation.result)); } if (*method == "workspace/symbol") { - if (!diagnostics_ || !diagnostics_->supports_occurrences()) + if (!diagnostics_) return error(id, -32601, "Method not found"); const auto *query = as_string(member(params, "query")); if (!query || query->size() > 256) diff --git a/src/semantic/EditorDiagnostics.cpp b/src/semantic/EditorDiagnostics.cpp index b608314..f4eee65 100644 --- a/src/semantic/EditorDiagnostics.cpp +++ b/src/semantic/EditorDiagnostics.cpp @@ -117,9 +117,24 @@ struct PublishedDiagnostic { std::vector fixes; }; +index::SymbolKind outline_kind(features::outline::Kind kind) { + switch (kind) { + case features::outline::Kind::namespace_: + return index::SymbolKind::namespace_; + case features::outline::Kind::function: + case features::outline::Kind::method: + return index::SymbolKind::function; + case features::outline::Kind::class_: + case features::outline::Kind::enum_: + return index::SymbolKind::type; + } + return index::SymbolKind::unknown; +} + struct EditorReport { Json::Array diagnostics, other_messages; std::vector published; + std::string outline_content; std::size_t unlocated{}; }; @@ -172,6 +187,7 @@ struct Entry { bool sent{}, had_findings{}; std::shared_ptr receipt; std::vector published; + std::string outline_content; std::shared_ptr> occurrences; std::shared_ptr> types; std::string occurrence_state{"disabled"}, occurrence_reason; @@ -774,6 +790,7 @@ void EditorDiagnostics::finish_update(bool workspace_changed) { else { s.retract(i->second, true); s.symbols.remove(i->first); + s.symbols.remove("outline:" + i->first); s.module_work.cancel(i->first); i = s.entries.erase(i); } @@ -787,6 +804,28 @@ void EditorDiagnostics::finish_update(bool workspace_changed) { entry.uri = id.display_uri; entry.version = overlay->version; entry.retry_delay = 1s; + // The generic outline is a separate context, so it never replaces the + // compiler facts for the same document and needs no observer. + if (entry.outline_content != overlay->content_hash.sha256_hex) { + index::ContextInput facts; + facts.context = "outline:" + id.canonical_uri; + facts.complete = true; + facts.sources.emplace_back(id.canonical_path.native(), + overlay->content_hash.sha256_hex); + facts.dependencies.push_back(id.canonical_path.native()); + for (const auto &symbol : features::outline::outline(overlay->text)) { + index::SymbolRecord record; + record.name = symbol.name; + record.kind = outline_kind(symbol.kind); + record.location = {id.canonical_path.native(), symbol.range.start.line, + symbol.range.start.character, symbol.range.end.line, + symbol.range.end.character}; + record.provenance = "document-outline"; + facts.records.push_back(std::move(record)); + } + if (s.symbols.publish(facts)) + entry.outline_content = overlay->content_hash.sha256_hex; + } if (workspace_changed) { s.retract(entry); entry.hints.clear(); @@ -1173,6 +1212,9 @@ Json EditorDiagnostics::document_symbols(std::string_view uri) const { } for (const auto &record : records.symbols) { const auto &location = record.location; + // The text outline above already represents its own index copies. + if (record.provenance == "document-outline") + continue; if (!seen.emplace(record.name, static_cast(record.kind), location.line, location.character) .second) @@ -1282,6 +1324,7 @@ Json EditorDiagnostics::code_actions(std::string_view uri, Documents::Range rang if (!identity || !identity->is_file_uri) return Json{nullptr}; std::vector published; + std::string outline_content; { std::lock_guard lock{s.mutex}; const auto i = s.entries.find(identity->canonical_uri);