Struct molc::FakeClient
source · 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.
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 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_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.