pub struct CallGraph { /* private fields */ }Expand description
Worktree-scoped call graph with lazy per-file construction.
Files are parsed and analyzed on first access, then cached. The graph can resolve cross-file call edges using the import engine.
Implementations§
Source§impl CallGraph
impl CallGraph
Sourcepub fn project_root(&self) -> &Path
pub fn project_root(&self) -> &Path
Get the project root directory.
Sourcepub fn build_file(&mut self, path: &Path) -> Result<&FileCallData, AftError>
pub fn build_file(&mut self, path: &Path) -> Result<&FileCallData, AftError>
Get or build the call data for a file.
Sourcepub fn resolve_cross_file_edge(
&mut self,
full_callee: &str,
short_name: &str,
caller_file: &Path,
import_block: &ImportBlock,
) -> EdgeResolution
pub fn resolve_cross_file_edge( &mut self, full_callee: &str, short_name: &str, caller_file: &Path, import_block: &ImportBlock, ) -> EdgeResolution
Resolve a cross-file call edge.
Given a callee expression and the calling file’s import block, determines which file and symbol the call targets.
Sourcepub fn forward_tree(
&mut self,
file: &Path,
symbol: &str,
max_depth: usize,
) -> Result<CallTreeNode, AftError>
pub fn forward_tree( &mut self, file: &Path, symbol: &str, max_depth: usize, ) -> Result<CallTreeNode, AftError>
Depth-limited forward call tree traversal.
Starting from a (file, symbol) pair, recursively follows calls
up to max_depth levels. Uses a visited set for cycle detection.
Sourcepub fn project_files(&mut self) -> &[PathBuf]
pub fn project_files(&mut self) -> &[PathBuf]
Get all project files (lazily discovered).
Sourcepub fn callers_of(
&mut self,
file: &Path,
symbol: &str,
depth: usize,
) -> Result<CallersResult, AftError>
pub fn callers_of( &mut self, file: &Path, symbol: &str, depth: usize, ) -> Result<CallersResult, AftError>
Get callers of a symbol in a file, grouped by calling file.
Builds the reverse index on first call (scans all project files). Supports recursive depth expansion: depth=1 returns direct callers, depth=2 returns callers-of-callers, etc. depth=0 is treated as 1.
Sourcepub fn trace_to(
&mut self,
file: &Path,
symbol: &str,
max_depth: usize,
) -> Result<TraceToResult, AftError>
pub fn trace_to( &mut self, file: &Path, symbol: &str, max_depth: usize, ) -> Result<TraceToResult, AftError>
Trace backward from a symbol to all entry points.
Returns complete paths (top-down: entry point first, target last). Uses BFS backward through the reverse index, with per-path cycle detection and depth limiting.
Sourcepub fn impact(
&mut self,
file: &Path,
symbol: &str,
depth: usize,
) -> Result<ImpactResult, AftError>
pub fn impact( &mut self, file: &Path, symbol: &str, depth: usize, ) -> Result<ImpactResult, AftError>
Impact analysis: enriched callers query.
Returns all call sites affected by a change to the given symbol, annotated with each caller’s signature, entry point status, the source line at the call site, and extracted parameter names.
Sourcepub fn trace_data(
&mut self,
file: &Path,
symbol: &str,
expression: &str,
max_depth: usize,
) -> Result<TraceDataResult, AftError>
pub fn trace_data( &mut self, file: &Path, symbol: &str, expression: &str, max_depth: usize, ) -> Result<TraceDataResult, AftError>
Trace how an expression flows through variable assignments within a function body and across function boundaries via argument-to-parameter matching.
Algorithm:
- Parse the function body, find the expression text.
- Walk AST for assignments that reference the tracked name.
- When the tracked name appears as a call argument, resolve the callee, match argument position to parameter name, recurse.
- Destructuring, spread, and unresolved calls produce approximate hops.
Sourcepub fn invalidate_file(&mut self, path: &Path)
pub fn invalidate_file(&mut self, path: &Path)
Invalidate a file: remove its cached data and clear the reverse index.
Called by the file watcher when a file changes on disk. The reverse
index is rebuilt lazily on the next callers_of call.
Auto Trait Implementations§
impl Freeze for CallGraph
impl RefUnwindSafe for CallGraph
impl Send for CallGraph
impl Sync for CallGraph
impl Unpin for CallGraph
impl UnsafeUnpin for CallGraph
impl UnwindSafe for CallGraph
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