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 lsp_child_registry(&self) -> LspChildRegistry
pub fn lsp_child_registry(&self) -> LspChildRegistry
Clone the LSP child registry handle. Used by main.rs to give the signal handler thread a way to SIGKILL LSP children on shutdown.
pub fn stdout_writer(&self) -> SharedStdoutWriter
pub fn set_progress_sender(&self, sender: Option<ProgressSender>)
pub fn emit_progress(&self, frame: ProgressFrame)
Sourcepub fn progress_sender_handle(&self) -> Option<ProgressSender>
pub fn progress_sender_handle(&self) -> Option<ProgressSender>
Get a clone of the current progress sender for use from background
threads. Returns None when the main loop hasn’t installed one (tests,
CLI without push frames).
Used by configure’s deferred file-walk thread to push warnings after
configure has already returned, so configure latency stays sub-100 ms
even on huge directories.
pub fn bash_background(&self) -> &BgTaskRegistry
pub fn drain_bg_completions(&self) -> Vec<BgCompletion>
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 search_index(&self) -> &RefCell<Option<SearchIndex>>
pub fn search_index(&self) -> &RefCell<Option<SearchIndex>>
Access the search index.
Sourcepub fn search_index_rx(&self) -> &RefCell<Option<Receiver<SearchIndex>>>
pub fn search_index_rx(&self) -> &RefCell<Option<Receiver<SearchIndex>>>
Access the search-index build receiver.
Sourcepub fn symbol_cache(&self) -> SharedSymbolCache
pub fn symbol_cache(&self) -> SharedSymbolCache
Access the shared symbol cache.
Sourcepub fn reset_symbol_cache(&self) -> u64
pub fn reset_symbol_cache(&self) -> u64
Clear the shared symbol cache and return the new active generation.
Sourcepub fn semantic_index(&self) -> &RefCell<Option<SemanticIndex>>
pub fn semantic_index(&self) -> &RefCell<Option<SemanticIndex>>
Access the semantic search index.
Sourcepub fn semantic_index_rx(
&self,
) -> &RefCell<Option<Receiver<SemanticIndexEvent>>>
pub fn semantic_index_rx( &self, ) -> &RefCell<Option<Receiver<SemanticIndexEvent>>>
Access the semantic-index build receiver.
pub fn semantic_index_status(&self) -> &RefCell<SemanticIndexStatus>
Sourcepub fn semantic_embedding_model(&self) -> &RefCell<Option<EmbeddingModel>>
pub fn semantic_embedding_model(&self) -> &RefCell<Option<EmbeddingModel>>
Access the cached semantic embedding model.
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,
) -> PostEditWaitOutcome
pub fn lsp_notify_and_collect_diagnostics( &self, file_path: &Path, content: &str, timeout: Duration, ) -> PostEditWaitOutcome
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.
v0.17.3: this is the version-aware path. Pre-edit cached diagnostics
are NEVER returned — only entries whose version matches the
post-edit document version (or, for unversioned servers, whose
epoch advanced past the pre-edit snapshot).
pub fn lsp_notify_watched_config_file( &self, file_path: &Path, change_type: FileChangeType, )
Sourcepub fn lsp_post_multi_file_write(
&self,
file_path: &Path,
content: &str,
file_paths: &[PathBuf],
params: &Value,
) -> Option<PostEditWaitOutcome>
pub fn lsp_post_multi_file_write( &self, file_path: &Path, content: &str, file_paths: &[PathBuf], params: &Value, ) -> Option<PostEditWaitOutcome>
Post-write LSP hook for multi-file edits. When the patch includes
config-file edits, notify active workspace servers via
workspace/didChangeWatchedFiles before sending the per-document
didOpen/didChange for the current file.
Sourcepub fn lsp_post_write(
&self,
file_path: &Path,
content: &str,
params: &Value,
) -> Option<PostEditWaitOutcome>
pub fn lsp_post_write( &self, file_path: &Path, content: &str, params: &Value, ) -> Option<PostEditWaitOutcome>
Post-write LSP hook: notify server and optionally collect diagnostics.
This is the single call site for all command handlers after write_format_validate.
Behavior:
- When
diagnostics: trueis inparams, notifies the server, waits until matching diagnostics arrive or the timeout expires, and returnsSome(outcome)with the verified-fresh diagnostics + per-server status. - When
diagnostics: false(or absent), just notifies (fire-and-forget) and returnsNone. Callers must NOT wrap this inSome(...); theNoneis what tells the response builder to omit the LSP fields entirely (preserves the no-diagnostics-requested response shape).
v0.17.3: default wait_ms raised from 1500 to 3000 because real-world
tsserver re-analysis on monorepo files routinely takes 2-5s. Still
capped at 10000ms.
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.
Sourcepub fn lsp_server_count(&self) -> usize
pub fn lsp_server_count(&self) -> usize
Count active LSP server instances.
Sourcepub fn symbol_cache_stats(&self) -> Value
pub fn symbol_cache_stats(&self) -> Value
Symbol cache statistics from the language provider.
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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