pub struct WatchSession { /* private fields */ }Expand description
Live watch-mode state (M6 brief D-W3): config, resolved options, the extraction
cache, the current walk result, and the built ProjectResolver —
run_cycle redoes the discovery+link+check pipeline
from these without ever touching notify.
Implementations§
Source§impl WatchSession
impl WatchSession
Sourcepub fn new(options: WatchSessionOptions) -> Result<Self, ConfigLoadError>
pub fn new(options: WatchSessionOptions) -> Result<Self, ConfigLoadError>
Load the config, resolve options, and perform the initial full pipeline run
(walk, extract, link, check) — last_diagnostics/last_has_error reflect
the project’s current state as soon as this returns. Fails only if the
initial config can’t be loaded (an explicit --config that doesn’t exist,
or a parse error): matching main.rs’s non-watch lint(), refusing to start
watch mode on a broken config is the right call. Once running, a bad config
edit is reported via CycleOutcome::config_error and the previous config is
kept — never fatal (M6 brief D-W1) — see WatchSession::run_cycle.
Sourcepub fn set_overlay(&mut self, path: PathBuf, content: String)
pub fn set_overlay(&mut self, path: PathBuf, content: String)
Set (or replace) the in-memory overlay content for path (L1, docs/PLAN-lsp.md
§3): overrides its on-disk content in extraction and diagnostic line/col
rendering until WatchSession::clear_overlay is called. This only mutates
overlay state — nothing is re-checked until the caller follows up with
run_cycle(&[ChangeKind::ContentEdit(path)]).
path must be the same path identity used everywhere else for this file (a
canonical path — the same one a ChangeKind::ContentEdit for it would carry,
and the same one the module graph keys its files by). This method does not
canonicalize path itself: canonicalizing here would fail for a file that no
longer exists on disk, and an overlay must still be settable for such a path
(an unsaved buffer whose file was deleted on disk) — the caller is expected to
have already resolved path to its canonical form while the file still
existed (e.g. at the time it was opened).
Sourcepub fn clear_overlay(&mut self, path: &Path) -> bool
pub fn clear_overlay(&mut self, path: &Path) -> bool
Clear the overlay for path, if any (see WatchSession::set_overlay for
the path-identity requirement), returning whether one existed. Disk content
becomes authoritative again for this file; nothing is re-checked until the
caller follows up with run_cycle(&[ChangeKind::ContentEdit(path)]).
Sourcepub fn last_diagnostics(&self) -> &[RenderedDiagnostic]
pub fn last_diagnostics(&self) -> &[RenderedDiagnostic]
The most recently computed diagnostics (from new() or the last
run_cycle call).
pub fn last_has_error(&self) -> bool
Sourcepub fn watch_targets(&self) -> WatchTargets
pub fn watch_targets(&self) -> WatchTargets
Where watch_loop should point notify right now (M6 brief D-W2):
recomputed on demand since roots/config_path/tsconfig_path can change
after a ConfigChanged/TsconfigChanged/Structural reload.
Sourcepub fn run_cycle(&mut self, changes: &[ChangeKind]) -> CycleOutcome
pub fn run_cycle(&mut self, changes: &[ChangeKind]) -> CycleOutcome
Advance the session by one debounced batch of changes (M6/M7 brief,
PLAN-v1.md §7):
ConfigChanged: reload the config; on success this also forces a full reload (severity/options/include/exclude may have changed the walk itself); on failure, keep the previous config and report the error viaCycleOutcome::config_error— watching continues either way.TsconfigChangedorStructural: re-walk the roots and build a freshProjectResolver(a resolver’s cache assumes a frozen filesystem layout), then a full recheck (WatchSession::full_recheck).- Otherwise (every change is a
ContentEdit, including the empty batch):WatchSession::run_fast_cycle— re-extract just the changed paths and patch the graph and diagnostics map in place, without a full-projectstat()sweep, resolve pass, graph rebuild, or check pass. Falls back to a full reload + recheck on its own rare escape hatches (see that method’s doc comment) — always correct, just not always fast.
CycleOutcome::extracted_files is the number of files that were actually
re-parsed (0 for a batch that touched nothing); rechecked_files is the size
of whatever was actually re-checked this cycle (every lint target on a full
recheck, just the dirty set on a fast cycle).
Auto Trait Implementations§
impl !Freeze for WatchSession
impl !RefUnwindSafe for WatchSession
impl !UnwindSafe for WatchSession
impl Send for WatchSession
impl Sync for WatchSession
impl Unpin for WatchSession
impl UnsafeUnpin for WatchSession
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 moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more