pub struct Client { /* private fields */ }Expand description
Handle for communicating with the language client.
This type provides a very cheap implementation of Clone so API consumers can cheaply clone
and pass it around as needed.
It also implements [tower::Service] in order to remain independent from the underlying
transport and to facilitate further abstraction with middleware.
Implementations§
Source§impl Client
impl Client
Sourcepub fn register_capability(
&self,
registrations: Vec<Registration>,
) -> Result<()>
pub fn register_capability( &self, registrations: Vec<Registration>, ) -> Result<()>
Registers a new capability with the client.
This corresponds to the client/registerCapability request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err with JSON-RPC error code -32002 (read more).
Sourcepub fn unregister_capability(
&self,
unregisterations: Vec<Unregistration>,
) -> Result<()>
pub fn unregister_capability( &self, unregisterations: Vec<Unregistration>, ) -> Result<()>
Unregisters a capability with the client.
This corresponds to the client/unregisterCapability request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err with JSON-RPC error code -32002 (read more).
Sourcepub fn show_message<M: Display>(&self, typ: MessageType, message: M)
pub fn show_message<M: Display>(&self, typ: MessageType, message: M)
Notifies the client to display a particular message in the user interface.
This corresponds to the window/showMessage notification.
Sourcepub fn show_message_request<M: Display>(
&self,
typ: MessageType,
message: M,
actions: Option<Vec<MessageActionItem>>,
) -> Result<Option<MessageActionItem>>
pub fn show_message_request<M: Display>( &self, typ: MessageType, message: M, actions: Option<Vec<MessageActionItem>>, ) -> Result<Option<MessageActionItem>>
Requests the client to display a particular message in the user interface.
Unlike the show_message notification, this request can also pass a list of actions and
wait for an answer from the client.
This corresponds to the window/showMessageRequest request.
Sourcepub fn log_message<M: Display>(&self, typ: MessageType, message: M)
pub fn log_message<M: Display>(&self, typ: MessageType, message: M)
Notifies the client to log a particular message.
This corresponds to the window/logMessage notification.
Sourcepub fn show_document(&self, params: ShowDocumentParams) -> Result<bool>
pub fn show_document(&self, params: ShowDocumentParams) -> Result<bool>
Asks the client to display a particular resource referenced by a URI in the user interface.
Returns Ok(true) if the document was successfully shown, or Ok(false) otherwise.
This corresponds to the window/showDocument request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err with JSON-RPC error code -32002 (read more).
§Compatibility
This request was introduced in specification version 3.16.0.
Sourcepub fn telemetry_event<U: Serialize>(&self, data: U)
pub fn telemetry_event<U: Serialize>(&self, data: U)
Notifies the client to log a telemetry event.
This corresponds to the telemetry/event notification.
Sourcepub fn code_lens_refresh(&self) -> Result<()>
pub fn code_lens_refresh(&self) -> Result<()>
Asks the client to refresh the code lenses currently shown in editors. As a result, the client should ask the server to recompute the code lenses for these editors.
This is useful if a server detects a configuration change which requires a re-calculation of all code lenses.
Note that the client still has the freedom to delay the re-calculation of the code lenses if for example an editor is currently not visible.
This corresponds to the workspace/codeLens/refresh request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err with JSON-RPC error code -32002 (read more).
§Compatibility
This request was introduced in specification version 3.16.0.
Sourcepub fn semantic_tokens_refresh(&self) -> Result<()>
pub fn semantic_tokens_refresh(&self) -> Result<()>
Asks the client to refresh the editors for which this server provides semantic tokens. As a result, the client should ask the server to recompute the semantic tokens for these editors.
This is useful if a server detects a project-wide configuration change which requires a re-calculation of all semantic tokens. Note that the client still has the freedom to delay the re-calculation of the semantic tokens if for example an editor is currently not visible.
This corresponds to the workspace/semanticTokens/refresh request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err with JSON-RPC error code -32002 (read more).
§Compatibility
This request was introduced in specification version 3.16.0.
Sourcepub fn inline_value_refresh(&self) -> Result<()>
pub fn inline_value_refresh(&self) -> Result<()>
Asks the client to refresh the inline values currently shown in editors. As a result, the client should ask the server to recompute the inline values for these editors.
This is useful if a server detects a configuration change which requires a re-calculation of all inline values. Note that the client still has the freedom to delay the re-calculation of the inline values if for example an editor is currently not visible.
This corresponds to the workspace/inlineValue/refresh request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err with JSON-RPC error code -32002 (read more).
§Compatibility
This request was introduced in specification version 3.17.0.
Sourcepub fn inlay_hint_refresh(&self) -> Result<()>
pub fn inlay_hint_refresh(&self) -> Result<()>
Asks the client to refresh the inlay hints currently shown in editors. As a result, the client should ask the server to recompute the inlay hints for these editors.
This is useful if a server detects a configuration change which requires a re-calculation of all inlay hints. Note that the client still has the freedom to delay the re-calculation of the inlay hints if for example an editor is currently not visible.
This corresponds to the workspace/inlayHint/refresh request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err with JSON-RPC error code -32002 (read more).
§Compatibility
This request was introduced in specification version 3.17.0.
Sourcepub fn workspace_diagnostic_refresh(&self) -> Result<()>
pub fn workspace_diagnostic_refresh(&self) -> Result<()>
Asks the client to refresh all needed document and workspace diagnostics.
This is useful if a server detects a project wide configuration change which requires a re-calculation of all diagnostics.
This corresponds to the workspace/diagnostic/refresh request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err with JSON-RPC error code -32002 (read more).
§Compatibility
This request was introduced in specification version 3.17.0.
Sourcepub fn publish_diagnostics(
&self,
uri: Url,
diags: Vec<Diagnostic>,
version: Option<i32>,
)
pub fn publish_diagnostics( &self, uri: Url, diags: Vec<Diagnostic>, version: Option<i32>, )
Submits validation diagnostics for an open file with the given URI.
This corresponds to the textDocument/publishDiagnostics notification.
§Initialization
This notification will only be sent if the server is initialized.
Sourcepub fn configuration(&self, items: Vec<ConfigurationItem>) -> Result<Vec<Value>>
pub fn configuration(&self, items: Vec<ConfigurationItem>) -> Result<Vec<Value>>
Fetches configuration settings from the client.
The request can fetch several configuration settings in one roundtrip. The order of the
returned configuration settings correspond to the order of the passed
ConfigurationItems (e.g. the first item in the response is the result for the first
configuration item in the params).
This corresponds to the workspace/configuration request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err with JSON-RPC error code -32002 (read more).
§Compatibility
This request was introduced in specification version 3.6.0.
Sourcepub fn workspace_folders(&self) -> Result<Option<Vec<WorkspaceFolder>>>
pub fn workspace_folders(&self) -> Result<Option<Vec<WorkspaceFolder>>>
Fetches the current open list of workspace folders.
Returns None if only a single file is open in the tool. Returns an empty Vec if a
workspace is open but no folders are configured.
This corresponds to the workspace/workspaceFolders request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err with JSON-RPC error code -32002 (read more).
§Compatibility
This request was introduced in specification version 3.6.0.
Sourcepub fn apply_edit(
&self,
edit: WorkspaceEdit,
) -> Result<ApplyWorkspaceEditResponse>
pub fn apply_edit( &self, edit: WorkspaceEdit, ) -> Result<ApplyWorkspaceEditResponse>
Requests a workspace resource be edited on the client side and returns whether the edit was applied.
This corresponds to the workspace/applyEdit request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err with JSON-RPC error code -32002 (read more).
Sourcepub fn send_notification<N>(&self, params: N::Params)where
N: Notification,
pub fn send_notification<N>(&self, params: N::Params)where
N: Notification,
Sends a custom notification to the client.
§Initialization
This notification will only be sent if the server is initialized.