Consume a compiler-agnostic completion index

Under D-032, completion can now merge candidates from a documented,
versioned index file produced by any external tool. The bounded core
parses and selects the innermost covering scope, the server puts its
items ahead of index-backed ones and takes isIncomplete from the
scope's complete flag, and registered feature tests cover parsing,
selection and bounds. A real stdio session returned the provided
items first with isIncomplete false inside the scope and true outside.
This commit is contained in:
faumaray committed 2026-12-06 02:10:16 +03:00
1 parent 236c3c5718
commit 4a029152e9
13 files changed
+336 -11

No files matched your search

+2
View File
@@ -3,6 +3,7 @@
#include <Void/LanguageServer/Documents/DocumentStore.hpp>
#include <vls/Framing.hpp>
#include <vls/WorkspaceSession.hpp>
#include <vls/features/CompletionSource.hpp>
#include <vls/reflection/Provenance.hpp>
#include <functional>
@@ -37,6 +38,7 @@ class Server {
WorkspaceSession workspace_;
std::unique_ptr<semantic::EditorDiagnostics> diagnostics_;
std::shared_ptr<const reflection::Snapshot> reflection_;
std::vector<features::completion_source::Scope> completion_scopes_;
};
// Thin transport loop shared by the executable and stream-failure unit tests.
+2
View File
@@ -24,6 +24,8 @@ struct WorkspaceLaunch {
std::shared_ptr<const semantic::GccProfile> diagnostics_profile{};
// Versioned reflection provenance snapshot served as read-only hover.
std::optional<std::filesystem::path> reflection_snapshot;
// A compiler-agnostic completion index produced outside VLS.
std::optional<std::filesystem::path> completion_index;
};
struct SemanticDriver {
+59
View File
@@ -0,0 +1,59 @@
#pragma once
#include <compare>
#include <cstddef>
#include <cstdint>
#include <expected>
#include <optional>
#include <string>
#include <string_view>
#include <vector>
namespace vls::features::completion_source {
// Positions are LSP positions in the document's negotiated encoding, so any
// producer can write them without knowing VLS internals.
struct Position {
std::uint32_t line{}, character{};
auto operator<=>(const Position &) const = default;
};
struct Provided {
std::string label;
std::int64_t kind{1};
std::string detail;
std::string insert_text;
auto operator<=>(const Provided &) const = default;
};
// One compiler-produced completion point: a position range with the
// candidates visible there. COMPLETE means the producer proved the list is
// exhaustive for the range (visibility proof is the producer's claim, carried
// through unchanged).
struct Scope {
std::string path;
Position start, end;
bool complete{};
std::vector<Provided> items;
};
struct Limits {
std::size_t scopes{1024};
std::size_t items{4096};
std::size_t itemsPerScope{256};
std::size_t pathBytes{4096};
std::size_t textBytes{1024};
std::size_t fileBytes{8 * 1024 * 1024};
};
// Parses the versioned completion index:
// {"schema":1,"scopes":[{"path":...,"startLine":..,"startCharacter":..,
// "endLine":..,"endCharacter":..,"complete":bool,
// "items":[{"label":..,"kind":int?,"detail":?,"insertText":?}]}]}
[[nodiscard]] std::expected<std::vector<Scope>, std::string> parse(std::string_view bytes,
const Limits & = Limits{});
// The innermost scope covering the position, or null.
[[nodiscard]] const Scope *at(const std::vector<Scope> &, std::string_view path, Position);
} // namespace vls::features::completion_source