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>

source

pub fn new(server: LS, receiver: Receiver<Value>) -> Self

The server should send responses to the channel at least during testing.

source

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.

source

pub fn remove_handler(&mut self, method_name: &str)

Removes the handler for the request/notification with the given method name.

source

pub fn enable_log_display(&mut self)

source

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.

source

pub fn wait_diagnostics(&mut self) -> Result<PublishDiagnosticsParams>

source

pub fn request<R: Request>(&mut self, params: R::Params) -> Result<R::Result>

Send a request to the server.

source

pub fn notify<N: Notification>(&mut self, params: N::Params) -> Result<()>

Send a notification to the server.

source

pub fn request_initialize(&mut self) -> Result<InitializeResult>

Send an initialize request to the server. This will set the server capabilities

source

pub fn notify_initialized(&mut self) -> Result<()>

Send an initialized notification to the server.

source

pub fn notify_exit(&mut self) -> Result<()>

Send an exit notification to the server.

source

pub fn notify_open(&mut self, file: &str) -> Result<()>

Send a textDocument/didOpen notification to the server.

source

pub fn notify_change( &mut self, uri: Url, change: TextDocumentContentChangeEvent ) -> Result<()>

Send a textDocument/didChange notification to the server.

source

pub fn notify_save(&mut self, uri: Url) -> Result<()>

Send a textDocument/didSave notification to the server.

source

pub fn notify_close(&mut self, uri: Url) -> Result<()>

Send a textDocument/didClose notification to the server.

source

pub fn request_shutdown(&mut self) -> Result<()>

Send a shutdown request to the server.

source

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.

source

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.

source

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.

source

pub fn request_hover( &mut self, uri: Url, line: u32, col: u32 ) -> Result<Option<Hover>>

Send a textDocument/hover request to the server.

source

pub fn request_references( &mut self, uri: Url, line: u32, col: u32 ) -> Result<Option<Vec<Location>>>

Send a textDocument/references request to the server.

source

pub fn request_goto_definition( &mut self, uri: Url, line: u32, col: u32 ) -> Result<Option<GotoDefinitionResponse>>

Send a textDocument/definition request to the server.

source

pub fn request_folding_range( &mut self, uri: Url ) -> Result<Option<Vec<FoldingRange>>>

Send a textDocument/foldingRange request to the server.

source

pub fn request_document_symbols( &mut self, uri: Url ) -> Result<Option<DocumentSymbolResponse>>

Send a textDocument/documentSymbol request to the server.

source

pub fn request_inlay_hint(&mut self, uri: Url) -> Result<Option<Vec<InlayHint>>>

Send a textDocument/inlayHint request to the server.

Auto Trait Implementations§

§

impl<LS> !RefUnwindSafe for FakeClient<LS>

§

impl<LS> !Send for FakeClient<LS>

§

impl<LS> !Sync for FakeClient<LS>

§

impl<LS> Unpin for FakeClient<LS>where LS: Unpin,

§

impl<LS> !UnwindSafe for FakeClient<LS>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.