pub struct FakeClient<LS: LangServer> {
pub server: LS,
pub client_capas: ClientCapabilities,
pub server_capas: Option<ServerCapabilities>,
pub responses: Vec<Value>,
/* private fields */
}Fields§
§server: LS§client_capas: ClientCapabilities§server_capas: Option<ServerCapabilities>§responses: Vec<Value>Stores all messages received from the server.
Implementations§
Source§impl<LS: LangServer> FakeClient<LS>
impl<LS: LangServer> FakeClient<LS>
Sourcepub fn new(server: LS, receiver: Receiver<Value>) -> Self
pub fn new(server: LS, receiver: Receiver<Value>) -> Self
The server should send responses to the channel at least during testing.
pub fn with_capabilities( server: LS, receiver: Receiver<Value>, client_capas: ClientCapabilities, ) -> Self
Sourcepub fn add_handler(
&mut self,
method_name: impl Into<String>,
handler: impl Fn(&Value, &mut LS) -> Result<()> + 'static,
)
pub fn add_handler( &mut self, method_name: impl Into<String>, handler: impl Fn(&Value, &mut LS) -> Result<()> + 'static, )
Adds a handler for the request/notification with the given method name. When the client receives a request/notification for the specified method, it executes the handler.
Sourcepub fn remove_handler(&mut self, method_name: &str)
pub fn remove_handler(&mut self, method_name: &str)
Removes the handler for the request/notification with the given method name.
pub fn enable_log_display(&mut self)
Sourcepub fn wait_messages(&mut self, n: usize) -> Result<()>
pub fn wait_messages(&mut self, n: usize) -> Result<()>
Waits for n messages to be received.
When a request is received, the registered handler will be executed.
pub fn wait_diagnostics(&mut self) -> Result<PublishDiagnosticsParams>
Sourcepub fn wait_for<R>(&mut self) -> Result<R>where
R: Deserialize<'static>,
pub fn wait_for<R>(&mut self) -> Result<R>where
R: Deserialize<'static>,
Waits for a response to the request, where its id is expected to be that of req_id,
and req_id will be incremented if the response is successfully received.
When a request is received, the registered handler will be executed.
pub fn wait_with_timeout<R>(&mut self, timeout: Duration) -> Result<Option<R>>where
R: Deserialize<'static>,
Sourcepub fn request<R: Request>(&mut self, params: R::Params) -> Result<R::Result>
pub fn request<R: Request>(&mut self, params: R::Params) -> Result<R::Result>
Send a request to the server.
Sourcepub fn notify<N: Notification>(&mut self, params: N::Params) -> Result<()>
pub fn notify<N: Notification>(&mut self, params: N::Params) -> Result<()>
Send a notification to the server.
Sourcepub fn request_initialize(&mut self) -> Result<InitializeResult>
pub fn request_initialize(&mut self) -> Result<InitializeResult>
Send an initialize request to the server.
This will set the server capabilities
Sourcepub fn notify_initialized(&mut self) -> Result<()>
pub fn notify_initialized(&mut self) -> Result<()>
Send an initialized notification to the server.
Sourcepub fn notify_exit(&mut self) -> Result<()>
pub fn notify_exit(&mut self) -> Result<()>
Send an exit notification to the server.
Sourcepub fn notify_open(&mut self, file: &str) -> Result<()>
pub fn notify_open(&mut self, file: &str) -> Result<()>
Send a textDocument/didOpen notification to the server.
Sourcepub fn notify_change(
&mut self,
uri: Url,
change: TextDocumentContentChangeEvent,
) -> Result<()>
pub fn notify_change( &mut self, uri: Url, change: TextDocumentContentChangeEvent, ) -> Result<()>
Send a textDocument/didChange notification to the server.
Sourcepub fn notify_save(&mut self, uri: Url) -> Result<()>
pub fn notify_save(&mut self, uri: Url) -> Result<()>
Send a textDocument/didSave notification to the server.
Sourcepub fn notify_close(&mut self, uri: Url) -> Result<()>
pub fn notify_close(&mut self, uri: Url) -> Result<()>
Send a textDocument/didClose notification to the server.
Sourcepub fn request_shutdown(&mut self) -> Result<()>
pub fn request_shutdown(&mut self) -> Result<()>
Send a shutdown request to the server.
Sourcepub fn request_completion(
&mut self,
uri: Url,
line: u32,
col: u32,
character: &str,
) -> Result<Option<CompletionResponse>>
pub fn request_completion( &mut self, uri: Url, line: u32, col: u32, character: &str, ) -> Result<Option<CompletionResponse>>
Send a textDocument/completion request to the server.
Sourcepub fn request_completion_item_resolve(
&mut self,
completion_item: CompletionItem,
) -> Result<CompletionItem>
pub fn request_completion_item_resolve( &mut self, completion_item: CompletionItem, ) -> Result<CompletionItem>
Send a completionItem/resolve request to the server.
Sourcepub fn request_rename(
&mut self,
uri: Url,
line: u32,
col: u32,
new_name: &str,
) -> Result<Option<WorkspaceEdit>>
pub fn request_rename( &mut self, uri: Url, line: u32, col: u32, new_name: &str, ) -> Result<Option<WorkspaceEdit>>
Send a textDocument/rename request to the server.
Sourcepub fn request_signature_help(
&mut self,
uri: Url,
line: u32,
col: u32,
character: &str,
) -> Result<Option<SignatureHelp>>
pub fn request_signature_help( &mut self, uri: Url, line: u32, col: u32, character: &str, ) -> Result<Option<SignatureHelp>>
Send a textDocument/signatureHelp request to the server.
Sourcepub fn request_hover(
&mut self,
uri: Url,
line: u32,
col: u32,
) -> Result<Option<Hover>>
pub fn request_hover( &mut self, uri: Url, line: u32, col: u32, ) -> Result<Option<Hover>>
Send a textDocument/hover request to the server.
Sourcepub fn request_references(
&mut self,
uri: Url,
line: u32,
col: u32,
) -> Result<Option<Vec<Location>>>
pub fn request_references( &mut self, uri: Url, line: u32, col: u32, ) -> Result<Option<Vec<Location>>>
Send a textDocument/references request to the server.
Sourcepub fn request_goto_definition(
&mut self,
uri: Url,
line: u32,
col: u32,
) -> Result<Option<GotoDefinitionResponse>>
pub fn request_goto_definition( &mut self, uri: Url, line: u32, col: u32, ) -> Result<Option<GotoDefinitionResponse>>
Send a textDocument/definition request to the server.
Sourcepub fn request_folding_range(
&mut self,
uri: Url,
) -> Result<Option<Vec<FoldingRange>>>
pub fn request_folding_range( &mut self, uri: Url, ) -> Result<Option<Vec<FoldingRange>>>
Send a textDocument/foldingRange request to the server.
Sourcepub fn request_document_symbols(
&mut self,
uri: Url,
) -> Result<Option<DocumentSymbolResponse>>
pub fn request_document_symbols( &mut self, uri: Url, ) -> Result<Option<DocumentSymbolResponse>>
Send a textDocument/documentSymbol request to the server.
Sourcepub fn request_inlay_hint(&mut self, uri: Url) -> Result<Option<Vec<InlayHint>>>
pub fn request_inlay_hint(&mut self, uri: Url) -> Result<Option<Vec<InlayHint>>>
Send a textDocument/inlayHint request to the server.
Sourcepub fn request_code_action(
&mut self,
uri: Url,
line: u32,
col: u32,
) -> Result<Option<CodeActionResponse>>
pub fn request_code_action( &mut self, uri: Url, line: u32, col: u32, ) -> Result<Option<CodeActionResponse>>
Send a textDocument/codeAction request to the server.
pub fn request_code_action_resolve( &mut self, code_action: CodeAction, ) -> Result<CodeAction>
Sourcepub fn request_code_lens(&mut self, uri: Url) -> Result<Option<Vec<CodeLens>>>
pub fn request_code_lens(&mut self, uri: Url) -> Result<Option<Vec<CodeLens>>>
Send a textDocument/codeLens request to the server.
Sourcepub fn request_code_lens_resolve(
&mut self,
code_lens: CodeLens,
) -> Result<CodeLens>
pub fn request_code_lens_resolve( &mut self, code_lens: CodeLens, ) -> Result<CodeLens>
Send a codeLens/resolve request to the server.