#pragma once #include #include #include #include #include #include #include #include #include namespace vls { namespace semantic { class GccProfile; } struct WorkspaceLaunch { std::optional root, build_root, producer_cwd; std::optional user_settings, cli_settings; std::shared_ptr diagnostics_profile{}; }; 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 data); std::shared_ptr data_; }; class WorkspaceSession { public: // The optional test hook runs after observation and before the publication checks. explicit WorkspaceSession(WorkspaceLaunch = {}, std::function 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 initialize(const Void::LanguageServer::Protocol::Json ¶ms); [[nodiscard]] std::expected update_folders(const Void::LanguageServer::Protocol::Json *params); [[nodiscard]] std::expected configure(const Void::LanguageServer::Protocol::Json *params); [[nodiscard]] std::expected 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 acquire_semantic_context(std::string_view document_uri, std::optional workspace_uri, const SemanticDriver &selected_driver); [[nodiscard]] std::expected 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_; }; } // namespace vls