Skip to main content

LspClient

Struct LspClient 

Source
pub struct LspClient { /* private fields */ }
Expand description

LSP client over stdio transport (JSON-RPC 2.0).

Implementations§

Source§

impl LspClient

Source

pub fn start(config: &LspServerConfig, root_dir: &Path) -> Result<Self>

Start an LSP server process and perform the initialize handshake.

Source

pub fn open_file( &mut self, rel_path: &str, content: &str, language_id: &str, ) -> Result<()>

Open a file in the language server (required before definition queries).

Source

pub fn close_file(&mut self, rel_path: &str) -> Result<()>

Close a file in the language server.

Source

pub fn progress_token_summary(&self) -> String

Wait for the language server to finish indexing the project.

Uses the LSP $/progress notification protocol:

  1. Server sends window/workDoneProgress/create to register a progress token
  2. Server sends $/progress with kind: "begin" when work starts
  3. Server sends $/progress with kind: "report" for updates
  4. Server sends $/progress with kind: "end" when work completes

We wait until all active progress tokens have reached “end”. Fallback: if no progress notifications arrive within initial_wait, we assume the server either doesn’t support progress or finished instantly. Get a summary of progress tokens for debugging

Source

pub fn wait_until_ready(&mut self, max_wait: Duration) -> Result<()>

Source

pub fn get_definition( &mut self, rel_path: &str, line: u32, character: u32, ) -> Result<Option<LspLocation>>

Get definition location for a symbol at the given position. Returns None if no definition found or definition is outside project.

Source

pub fn get_references( &mut self, rel_path: &str, line: u32, character: u32, include_declaration: bool, ) -> Result<Vec<LspLocation>>

Find all references to the symbol at the given position. Returns locations of all call sites / usages within the project. include_declaration controls whether the definition itself is included.

Source

pub fn get_implementations( &mut self, rel_path: &str, line: u32, character: u32, ) -> Result<Vec<LspLocation>>

Find all implementations of a trait method or interface method at the given position. Returns locations of all concrete implementations within the project.

Source

pub fn shutdown(self) -> Result<()>

Graceful shutdown of the language server.

Trait Implementations§

Source§

impl Drop for LspClient

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more