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
impl AppContext
pub fn new(provider: Box<dyn LanguageProvider>, config: Config) -> Self
Sourcepub fn provider(&self) -> &dyn LanguageProvider
pub fn provider(&self) -> &dyn LanguageProvider
Access the language provider.
Sourcepub fn backup(&self) -> &RefCell<BackupStore>
pub fn backup(&self) -> &RefCell<BackupStore>
Access the backup store.
Sourcepub fn checkpoint(&self) -> &RefCell<CheckpointStore>
pub fn checkpoint(&self) -> &RefCell<CheckpointStore>
Access the checkpoint store.
Sourcepub fn config_mut(&self) -> RefMut<'_, Config>
pub fn config_mut(&self) -> RefMut<'_, Config>
Access the configuration (mutable borrow).
Sourcepub fn watcher(&self) -> &RefCell<Option<RecommendedWatcher>>
pub fn watcher(&self) -> &RefCell<Option<RecommendedWatcher>>
Access the file watcher handle (kept alive to continue watching).
Sourcepub fn watcher_rx(&self) -> &RefCell<Option<Receiver<Result<Event>>>>
pub fn watcher_rx(&self) -> &RefCell<Option<Receiver<Result<Event>>>>
Access the watcher event receiver.
Sourcepub fn lsp(&self) -> RefMut<'_, LspManager>
pub fn lsp(&self) -> RefMut<'_, LspManager>
Access the LSP manager.
Sourcepub fn lsp_notify_file_changed(&self, file_path: &Path, content: &str)
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.
Sourcepub fn lsp_notify_and_collect_diagnostics(
&self,
file_path: &Path,
content: &str,
timeout: Duration,
) -> Vec<StoredDiagnostic>
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.
Sourcepub fn lsp_post_write(
&self,
file_path: &Path,
content: &str,
params: &Value,
) -> Vec<StoredDiagnostic>
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).
Sourcepub fn validate_path(
&self,
req_id: &str,
path: &Path,
) -> Result<PathBuf, Response>
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§
impl !Freeze for AppContext
impl !RefUnwindSafe for AppContext
impl !Send for AppContext
impl !Sync for AppContext
impl Unpin for AppContext
impl UnsafeUnpin for AppContext
impl !UnwindSafe for AppContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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