Skip to main content

LspCore

Struct LspCore 

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

The headless LSP core state machine.

This struct contains all the state and logic for the language server, independent of the platform-specific event loop. Both native and WASM implementations use this core.

Implementations§

Source§

impl LspCore

Source

pub fn new() -> Self

Create a new LspCore instance.

Source

pub fn runtime_mut(&mut self) -> &mut QueryRuntime

Get a mutable reference to the query runtime.

This is useful for registering workspaces during initialization.

Source

pub fn is_initialized(&self) -> bool

Check if the server has been initialized.

Source

pub fn set_initialized(&mut self)

Mark the server as initialized.

Source

pub fn pending_files(&self) -> impl Iterator<Item = &TextFile>

Get pending files that need to be fetched.

Source

pub fn pending_globs(&self) -> impl Iterator<Item = (&str, &Glob)>

Get pending glob patterns that need to be expanded.

Source

pub fn open_document(&mut self, uri: &str, content: String)

Open a document and cache its content.

This should be called when a textDocument/didOpen notification is received.

Source

pub fn change_document(&mut self, uri: &str, content: String)

Update a document’s content.

This should be called when a textDocument/didChange notification is received.

Source

pub fn close_document(&mut self, uri: &str)

Close a document and clear its cached content.

This should be called when a textDocument/didClose notification is received.

Source

pub fn get_document(&self, uri: &str) -> Option<&String>

Get the cached content of a document.

Source

pub fn handle_request( &mut self, id: CoreRequestId, method: &str, params: Value, ) -> (Vec<LspOutput>, Vec<Effect>)

Handle an LSP request.

Returns outputs to send to the client and effects for the platform to perform.

Source

pub fn cancel_request(&mut self, id: &CoreRequestId)

Cancel a pending request.

Source

pub fn handle_notification( &mut self, method: &str, params: Value, ) -> (Vec<LspOutput>, Vec<Effect>)

Handle an LSP notification.

Returns outputs to send to the client and effects for the platform to perform.

Source

pub fn resolve_file( &mut self, file: TextFile, content: Result<String, String>, ) -> (Vec<LspOutput>, Vec<Effect>)

Resolve a file asset with its content.

Returns outputs (responses, notifications) and effects for any newly pending assets.

Source

pub fn resolve_glob( &mut self, id: &str, files: Vec<TextFile>, ) -> (Vec<LspOutput>, Vec<Effect>)

Resolve a glob pattern with matching files.

Returns outputs (responses, notifications) and effects for any newly pending assets.

Trait Implementations§

Source§

impl Default for LspCore

Source§

fn default() -> Self

Returns the “default value” for a 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> Same for T

Source§

type Output = T

Should always be Self
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