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.
95 lines
3.6 KiB
C++
95 lines
3.6 KiB
C++
#pragma once
|
|
|
|
#include <Void/LanguageServer/Build/Providers.hpp>
|
|
|
|
#include <cstdint>
|
|
#include <expected>
|
|
#include <filesystem>
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
namespace vls {
|
|
|
|
namespace semantic {
|
|
class GccProfile;
|
|
}
|
|
|
|
struct WorkspaceLaunch {
|
|
std::optional<std::filesystem::path> root, build_root, producer_cwd;
|
|
std::optional<Void::LanguageServer::Workspace::PartialWorkspaceSettings> user_settings,
|
|
cli_settings;
|
|
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 {
|
|
std::filesystem::path executable;
|
|
Void::LanguageServer::Workspace::CompilerDriver family{
|
|
Void::LanguageServer::Workspace::CompilerDriver::unknown};
|
|
};
|
|
|
|
enum class SemanticContextIssue { unavailable, disabled, no_command, wrong_command, superseded };
|
|
|
|
struct SemanticContextError {
|
|
SemanticContextIssue issue;
|
|
std::string message;
|
|
};
|
|
|
|
struct SemanticLeaseData;
|
|
class SemanticContextLease {
|
|
public:
|
|
[[nodiscard]] const Void::LanguageServer::Build::Selection &selection() const;
|
|
[[nodiscard]] const Void::LanguageServer::Build::SelectionState &selection_state() const;
|
|
[[nodiscard]] const Void::LanguageServer::Build::DriverInput &driver() const;
|
|
[[nodiscard]] std::uint64_t configuration_generation() const;
|
|
[[nodiscard]] std::uint32_t worker_memory_limit_mib() const;
|
|
[[nodiscard]] const std::string &document_uri() const;
|
|
|
|
private:
|
|
friend class WorkspaceSession;
|
|
explicit SemanticContextLease(std::shared_ptr<const SemanticLeaseData> data);
|
|
std::shared_ptr<const SemanticLeaseData> data_;
|
|
};
|
|
|
|
class WorkspaceSession {
|
|
public:
|
|
// The optional test hook runs after observation and before the publication checks.
|
|
explicit WorkspaceSession(WorkspaceLaunch = {}, std::function<void()> before_publish = {});
|
|
~WorkspaceSession();
|
|
|
|
// The client settings object contains defaults and optional `workspaces`
|
|
// overrides keyed by a folder's admitted or canonical file URI.
|
|
[[nodiscard]] std::expected<void, std::string>
|
|
initialize(const Void::LanguageServer::Protocol::Json ¶ms);
|
|
[[nodiscard]] std::expected<void, std::string>
|
|
update_folders(const Void::LanguageServer::Protocol::Json *params);
|
|
[[nodiscard]] std::expected<void, std::string>
|
|
configure(const Void::LanguageServer::Protocol::Json *params);
|
|
[[nodiscard]] std::expected<Void::LanguageServer::Protocol::Json, std::string>
|
|
provider_status(const Void::LanguageServer::Protocol::Json *params);
|
|
|
|
// The caller explicitly selects the launcher driver. The lease retains the ordered
|
|
// original and checked command in selection()->selected, and its immutable generation.
|
|
[[nodiscard]] std::expected<SemanticContextLease, SemanticContextError>
|
|
acquire_semantic_context(std::string_view document_uri,
|
|
std::optional<std::string_view> workspace_uri,
|
|
const SemanticDriver &selected_driver);
|
|
[[nodiscard]] std::expected<void, SemanticContextError>
|
|
validate_semantic_context(const SemanticContextLease &lease);
|
|
|
|
// Invalidates launcher authority and in-flight observations for an admitted root.
|
|
void revoke_root_authority(const std::filesystem::path &root);
|
|
|
|
private:
|
|
struct State;
|
|
std::unique_ptr<State> state_;
|
|
};
|
|
|
|
} // namespace vls
|