Skip to main content

CallGraph

Struct CallGraph 

Source
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

Source

pub fn new(project_root: PathBuf) -> Self

Create a new call graph for a project.

Source

pub fn project_root(&self) -> &Path

Get the project root directory.

Source

pub fn build_file(&mut self, path: &Path) -> Result<&FileCallData, AftError>

Get or build the call data for a file.

Source

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.

Source

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.

Source

pub fn project_files(&mut self) -> &[PathBuf]

Get all project files (lazily discovered).

Source

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.

Source

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.

Source

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.

Source

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:

  1. Parse the function body, find the expression text.
  2. Walk AST for assignments that reference the tracked name.
  3. When the tracked name appears as a call argument, resolve the callee, match argument position to parameter name, recurse.
  4. Destructuring, spread, and unresolved calls produce approximate hops.
Source

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§

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.