Skip to main content

AppContext

Struct AppContext 

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

Shared application context threaded through all command handlers.

Holds the language provider, backup/checkpoint stores, configuration, and call graph engine. Constructed once at startup and passed by reference to dispatch.

Stores use RefCell for interior mutability — the binary is single-threaded (one request at a time on the stdin read loop) so runtime borrow checking is safe and never contended.

Implementations§

Source§

impl AppContext

Source

pub fn new(provider: Box<dyn LanguageProvider>, config: Config) -> Self

Source

pub fn provider(&self) -> &dyn LanguageProvider

Access the language provider.

Source

pub fn backup(&self) -> &RefCell<BackupStore>

Access the backup store.

Source

pub fn checkpoint(&self) -> &RefCell<CheckpointStore>

Access the checkpoint store.

Source

pub fn config(&self) -> Ref<'_, Config>

Access the configuration (shared borrow).

Source

pub fn config_mut(&self) -> RefMut<'_, Config>

Access the configuration (mutable borrow).

Source

pub fn callgraph(&self) -> &RefCell<Option<CallGraph>>

Access the call graph engine.

Source

pub fn watcher(&self) -> &RefCell<Option<RecommendedWatcher>>

Access the file watcher handle (kept alive to continue watching).

Source

pub fn watcher_rx(&self) -> &RefCell<Option<Receiver<Result<Event>>>>

Access the watcher event receiver.

Source

pub fn lsp(&self) -> RefMut<'_, LspManager>

Access the LSP manager.

Source

pub fn lsp_notify_file_changed(&self, file_path: &Path, content: &str)

Notify LSP servers that a file was written. Call this after write_format_validate in command handlers.

Source

pub fn lsp_notify_and_collect_diagnostics( &self, file_path: &Path, content: &str, timeout: Duration, ) -> Vec<StoredDiagnostic>

Notify LSP and optionally wait for diagnostics.

Call this after write_format_validate when the request has "diagnostics": true. Sends didChange to the server, waits briefly for publishDiagnostics, and returns any diagnostics for the file. If no server is running, returns empty immediately.

Source

pub fn lsp_post_write( &self, file_path: &Path, content: &str, params: &Value, ) -> Vec<StoredDiagnostic>

Post-write LSP hook: notify server and optionally collect diagnostics.

This is the single call site for all command handlers after write_format_validate. When diagnostics is true, it notifies the server, waits briefly, drains queued LSP notifications, and returns diagnostics for the file. When false, it just notifies (fire-and-forget).

Source

pub fn validate_path( &self, req_id: &str, path: &Path, ) -> Result<PathBuf, Response>

Validate that a file path falls within the configured project root.

When project_root is configured (normal plugin usage), this resolves the path and checks it starts with the root. Returns the canonicalized path on success, or an error response on violation.

When no project_root is configured (direct CLI usage), all paths pass through unrestricted for backward compatibility.

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.