Skip to main content

LspSupervisorHandle

Struct LspSupervisorHandle 

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

Editor-facing handle to the LSP subsystem. Cheap to clone (every field is Arc-shaped internally); the App holds one instance and shares it with helpers that need to read or mutate supervisor state.

Reads are wait-free. Self::servers_for, Self::running_actors, Self::configs, and the count helpers all go through ArcSwap::load. The UI thread can call them on the keystroke / render path without ever blocking.

Writes are mailbox-routed. Self::open_buffer, Self::attach_handle, Self::shutdown, and Self::flush_all are async (await processing); the fire-and-forget variants (Self::close_buffer, Self::flush, Self::record_edit) send the cmd and return immediately, with the effect observable on the next snapshot publish.

Implementations§

Source§

impl LspSupervisorHandle

Source

pub fn snapshot(&self) -> Arc<SupervisorSnapshot> ⓘ

One wait-free ArcSwap::load_full returning the current snapshot. Callers that need many fields project from the returned Arc; one-off readers should prefer the projection helpers below to avoid retaining the snapshot across awaits.

Source

pub fn servers_for(&self, uri: &Uri) -> Vec<ServerHandle>

Every server attached to uri. Empty when the URI is not open or no config matched its path. Cheap clone.

Source

pub fn running_actors(&self) -> Vec<(ActorKey, ServerHandle)>

Snapshot of every running actor’s (key, handle) pair.

Source

pub fn all_running_handles(&self) -> Vec<ServerHandle>

Snapshot of every running actor’s ServerHandle. Used by workspace-scoped LSP requests (e.g. workspace/symbol) that fan out across every server, not just servers attached to one buffer.

Source

pub fn buffer_count_for(&self, key: &ActorKey) -> usize

Number of buffers currently attached to the actor at key. Used by :lsp-server-log for the picker margin.

Source

pub fn configs(&self) -> Vec<Arc<ServerConfig>>

Curated config registry (preference-ordered). Cheap clone.

Source

pub fn has_server_for_path(&self, path: &Path) -> bool

True iff at least one configured server’s file_patterns matches path. M.5.2 uses this from the App’s MajorEntered hook to decide whether to auto-activate lsp-mode on the buffer.

Source

pub fn attached_buffer_count(&self) -> usize

Number of currently-attached buffers.

Source

pub fn running_actor_count(&self) -> usize

Number of currently-running actors.

Source

pub fn logger(&self) -> &LspLogger

Borrow the shared logger. Cloning is cheap (LspLogger wraps an Arc internally) but most callers just want a borrow to call .log(...).

Source

pub fn diagnostics(&self) -> &DiagnosticsLayer

Borrow the shared diagnostics layer.

Source

pub async fn open_buffer( &self, path: PathBuf, text: String, ) -> LspResult<Vec<ServerHandle>>

Open a buffer. Returns the list of attached ServerHandles; empty if no config matched the path. May spawn new actors (each one pays the LSP initialize handshake cost). The supervisor task runs the open; awaiting here parks the caller while it does, but does NOT block any other read of the supervisor.

Source

pub async fn attach_handle( &self, uri: Uri, workspace_root: PathBuf, server_id: String, language_id: String, text: String, handle: ServerHandle, ) -> LspResult<()>

Attach a buffer to a pre-built handle (tests + custom transports).

Source

pub fn close_buffer(&self, uri: Uri)

Close a buffer. Fire-and-forget: the supervisor task processes the cmd asynchronously, fires didClose per attached server, and publishes a fresh snapshot. Tests that need to assert post-close state should call Self::close_buffer_ack.

Source

pub async fn close_buffer_ack(&self, uri: Uri) -> LspResult<()>

Close a buffer + await acknowledgement. Used by tests + shutdown paths that need to observe the next snapshot.

Source

pub fn flush(&self, uri: Uri)

Force-flush queued changes for uri. Fire-and-forget.

Source

pub async fn flush_all(&self) -> LspResult<()>

Force-flush every URI; awaits the supervisor task’s ack.

Source

pub fn record_edit(&self, uri: Uri, edit: Edit)

Drive an edit through the supervisor (test / admin path; production edits ride the event-bus fan-in).

Source

pub async fn restart_server( &self, server_id: String, ) -> LspResult<RestartReport>

4.4.d: force-restart every actor with id server_id. Subject to the per-server-id restart-history backoff: more than MAX_RESTARTS inside RESTART_WINDOW returns an error; the caller surfaces the cooldown message via set_message.

Source

pub async fn shutdown(&self) -> LspResult<()>

Editor exit: close every buffer, drop fan-ins, shut down every actor. Awaits the supervisor task’s final ack.

Trait Implementations§

Source§

impl Clone for LspSupervisorHandle

Source§

fn clone(&self) -> LspSupervisorHandle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LspSupervisorHandle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LspSupervisorHandle

Placeholder handle for Editor::default() / headless test scaffolding. The receiver is dropped immediately, so any cmd sent through this handle silently no-ops (the caller’s reply oneshot drops without being completed, which LspSupervisor::send_with_reply reports as a “supervisor gone” error). Real construction goes through LspSupervisor::spawn. Production code overwrites this in boot.rs before any cmd flows.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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