Implement the VLS roadmap on the native VBS build
Native VBS and CMake builds of the server and every registered suite: protocol and document sync, VBS/compdb providers, stock GCC diagnostics (including in-process default profile preparation), the stock occurrence observer and hover/definition, the bounded Scheduler, C++ module graph, scan and artifact cache with real CMI production, the context-aware symbol index with schema-2 snapshot migration, navigation and guarded rename, reflection provenance with splice-origin extraction, index-backed completion and signature help, live GCC worker control with a registered DAP suite, and the Neovim and VS Code clients. VoidLibrary follows main. The private GCC 16.2.0 frontend is reproduced from the versioned patches and verified stepping reflection/template code with projected values 17/34 and 41/82.
This commit is contained in:
1 parent
ca04975d54
commit
da8003f6d4
310 files changed
+47552
-480
No files matched your search
@@ -0,0 +1,158 @@
|
||||
#pragma once
|
||||
|
||||
#include <compare>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace vls::index {
|
||||
|
||||
// Zero-based LSP-style character coordinates within one physical line.
|
||||
struct Location {
|
||||
std::string path;
|
||||
std::uint32_t line{}, character{};
|
||||
std::uint32_t endLine{}, endCharacter{};
|
||||
auto operator<=>(const Location &) const = default;
|
||||
};
|
||||
|
||||
enum class SymbolKind { unknown, function, type, variable, field, namespace_, module };
|
||||
|
||||
struct SymbolRecord {
|
||||
std::string name;
|
||||
SymbolKind kind{SymbolKind::unknown};
|
||||
Location location; // declaration or definition
|
||||
std::optional<Location> definition;
|
||||
std::vector<Location> references;
|
||||
std::string provenance;
|
||||
auto operator<=>(const SymbolRecord &) const = default;
|
||||
};
|
||||
|
||||
struct Limits {
|
||||
std::size_t contexts{64};
|
||||
std::size_t records{65536};
|
||||
std::size_t recordsPerContext{16384};
|
||||
std::size_t referencesPerRecord{256};
|
||||
std::size_t nameBytes{256};
|
||||
std::size_t pathBytes{4096};
|
||||
std::size_t snapshotBytes{32 * 1024 * 1024};
|
||||
};
|
||||
|
||||
struct ContextInput {
|
||||
std::string context; // Build::ContextKey alternative
|
||||
std::vector<std::string> dependencies;
|
||||
// Path and content identity of every source this context consumed.
|
||||
std::vector<std::pair<std::string, std::string>> sources;
|
||||
std::vector<SymbolRecord> records;
|
||||
bool complete{true};
|
||||
std::string reason;
|
||||
};
|
||||
|
||||
struct Coverage {
|
||||
bool indexed{}; // at least one context or overlay was considered
|
||||
bool complete{};
|
||||
std::vector<std::string> incomplete; // context names, sorted
|
||||
auto operator<=>(const Coverage &) const = default;
|
||||
};
|
||||
|
||||
struct Query {
|
||||
std::string name;
|
||||
bool substring{};
|
||||
std::optional<std::string> context;
|
||||
std::size_t limit{100};
|
||||
};
|
||||
|
||||
struct Result {
|
||||
std::vector<SymbolRecord> symbols;
|
||||
Coverage coverage;
|
||||
bool truncated{};
|
||||
};
|
||||
|
||||
// Immutable published snapshot. Readers keep it alive across later publications
|
||||
// and evictions.
|
||||
class Generation {
|
||||
public:
|
||||
[[nodiscard]] std::uint64_t number() const noexcept { return number_; }
|
||||
[[nodiscard]] const std::vector<SymbolRecord> &symbols() const noexcept { return records_; }
|
||||
[[nodiscard]] const std::vector<std::pair<std::string, Coverage>> &contexts() const noexcept {
|
||||
return contexts_;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class SymbolIndex;
|
||||
Generation(std::uint64_t number, std::vector<SymbolRecord> records,
|
||||
std::vector<std::pair<std::string, Coverage>> contexts)
|
||||
: number_(number), records_(std::move(records)), contexts_(std::move(contexts)) {}
|
||||
std::uint64_t number_;
|
||||
std::vector<SymbolRecord> records_;
|
||||
std::vector<std::pair<std::string, Coverage>> contexts_;
|
||||
};
|
||||
|
||||
// Context-aware, bounded symbol index. Committed records belong to explicit
|
||||
// analysis contexts; unsaved document overlays shadow committed records for
|
||||
// the same path and are reconciled on save/close. A changed, deleted or
|
||||
// renamed source marks dependent contexts incomplete without discarding the
|
||||
// last-good records (degraded navigation, never an authoritative rename).
|
||||
class SymbolIndex {
|
||||
public:
|
||||
explicit SymbolIndex(Limits = Limits{});
|
||||
~SymbolIndex();
|
||||
SymbolIndex(const SymbolIndex &) = delete;
|
||||
SymbolIndex &operator=(const SymbolIndex &) = delete;
|
||||
|
||||
// Atomically replaces one context and publishes a new generation.
|
||||
[[nodiscard]] bool publish(const ContextInput &);
|
||||
[[nodiscard]] bool remove(std::string_view context);
|
||||
|
||||
// Unsaved document records. The newest overlay for a path shadows the
|
||||
// committed records of that path until it is cleared.
|
||||
[[nodiscard]] bool set_overlay(std::string path, std::string content,
|
||||
std::vector<SymbolRecord> records);
|
||||
[[nodiscard]] bool clear_overlay(std::string_view path);
|
||||
|
||||
// A new content (or absence) invalidates every context that consumed the
|
||||
// path. Matching content is a no-op.
|
||||
[[nodiscard]] std::size_t invalidate(std::string_view path,
|
||||
const std::optional<std::string> &content);
|
||||
|
||||
[[nodiscard]] Result find(const Query &) const;
|
||||
[[nodiscard]] Coverage coverage() const;
|
||||
[[nodiscard]] std::shared_ptr<const Generation> current() const;
|
||||
[[nodiscard]] std::uint64_t generation() const;
|
||||
[[nodiscard]] std::size_t records() const;
|
||||
[[nodiscard]] const Limits &limits() const noexcept;
|
||||
|
||||
// Versioned persistence. restore() classifies the snapshot; incompatible or
|
||||
// corrupt bytes are quarantined and the index rebuilds into a new generation.
|
||||
enum class LoadStatus { loaded, missing, incompatible, corrupt, oversized };
|
||||
struct LoadResult {
|
||||
LoadStatus status{LoadStatus::missing};
|
||||
std::uint64_t generation{};
|
||||
std::optional<std::filesystem::path> quarantine;
|
||||
// True when a schema-1 snapshot was accepted and upgraded in memory.
|
||||
bool migrated{};
|
||||
};
|
||||
// Writes the versioned snapshot (schema 2 with a canonical payload digest).
|
||||
// restore() also accepts schema 1 and reports the upgrade as migrated.
|
||||
[[nodiscard]] bool save(const std::filesystem::path &) const;
|
||||
[[nodiscard]] std::expected<LoadResult, std::string> restore(const std::filesystem::path &);
|
||||
// True only when a compatible snapshot was loaded.
|
||||
[[nodiscard]] bool load(const std::filesystem::path &);
|
||||
// Generation-directory backend: each save keeps the previous generation for
|
||||
// crash recovery, CURRENT selects the newest, and a legacy index.json is
|
||||
// migrated on the first restore.
|
||||
[[nodiscard]] bool save_generation(const std::filesystem::path &);
|
||||
[[nodiscard]] std::expected<LoadResult, std::string>
|
||||
restore_generation(const std::filesystem::path &);
|
||||
|
||||
private:
|
||||
struct State;
|
||||
std::shared_ptr<State> state_;
|
||||
};
|
||||
|
||||
} // namespace vls::index
|
||||
Reference in new issue
Block a user