pub struct Context { /* private fields */ }Expand description
Per-request handle to framework state (see ADR 0009).
The handle exposes connection-scoped capabilities — the established
Workspace (initialization metadata, roots, workspace folders, and the
read-only DocumentsView) and the Client — without exposing
protocol-owned queues or registries.
Implementations§
Source§impl Context
impl Context
Sourcepub fn request_id(&self) -> Option<&RequestId>
pub fn request_id(&self) -> Option<&RequestId>
The JSON-RPC request ID, or None while handling a notification.
Sourcepub fn documents(&self) -> DocumentsView
pub fn documents(&self) -> DocumentsView
The connection’s documents, as a read-only DocumentsView — the
same view Workspace::documents hands out.
The framework owns and mutates the documents; a handler reads the retained documents and converts positions through this view, and a registered document hook sees it already carrying the built-in mutation (ADR 0018).
Sourcepub fn client(&self) -> Client
pub fn client(&self) -> Client
A cheap clone of the typed handle for this connection’s LSP client.
Sourcepub fn workspace(&self) -> &Workspace
pub fn workspace(&self) -> &Workspace
The connection’s Workspace, established from InitializeParams
during the initialize transaction (ADR 0017, ADR 0018): the one
cheap, shared, read-only view of the initialization metadata, roots,
workspace folders, and documents every handler observes.
Sourcepub fn publish_diagnostics(
&self,
params: PublishDiagnosticsParams,
) -> Result<(), ClientError>
pub fn publish_diagnostics( &self, params: PublishDiagnosticsParams, ) -> Result<(), ClientError>
Push a textDocument/publishDiagnostics notification through the
connection’s typed Client (fire-and-forget); see
Client::publish_diagnostics for the exact semantics.
Serialization and enqueue failures are returned to the caller (the
client helper also reports them through tracing). A failed publish
never invalidates the handler that triggered it, so a handler that
treats publishing as best effort may simply drop the error.