Ingest the generic outline into the symbol index

Each open document's text outline is published as its own context
(outline:<uri>, provenance document-outline) on content change and
removed on close, so it never replaces compiler facts. workspace/symbol
no longer requires the occurrence observer, and documentSymbol skips
the outline's index copies. The generic stdio session now resolves a
workspace symbol with no compiler-specific artifact.
This commit is contained in:
faumaray committed 2026-12-06 01:49:14 +03:00
1 parent 103b38a291
commit 0b33a0cd99
3 files changed
+60 -1

No files matched your search

+16
View File
@@ -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:<uri>`, 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
+1 -1
View File
@@ -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)
+43
View File
@@ -117,9 +117,24 @@ struct PublishedDiagnostic {
std::vector<DiagnosticFix> 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<PublishedDiagnostic> published;
std::string outline_content;
std::size_t unlocated{};
};
@@ -172,6 +187,7 @@ struct Entry {
bool sent{}, had_findings{};
std::shared_ptr<const Receipt> receipt;
std::vector<PublishedDiagnostic> published;
std::string outline_content;
std::shared_ptr<const std::vector<Occurrence>> occurrences;
std::shared_ptr<const std::vector<ReflectedType>> 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<int>(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<PublishedDiagnostic> published;
std::string outline_content;
{
std::lock_guard lock{s.mutex};
const auto i = s.entries.find(identity->canonical_uri);