pub struct CodeGraph {
pub nodes: HashMap<SymbolId, SymbolNode>,
pub edges_out: HashMap<SymbolId, Vec<Edge>>,
pub edges_in: HashMap<SymbolId, Vec<Edge>>,
pub file_symbols: HashMap<PathBuf, Vec<SymbolId>>,
pub file_mtimes: HashMap<PathBuf, u64>,
}Expand description
Cross-file code knowledge graph indexing symbol relationships.
Fields§
§nodes: HashMap<SymbolId, SymbolNode>§edges_out: HashMap<SymbolId, Vec<Edge>>§edges_in: HashMap<SymbolId, Vec<Edge>>§file_symbols: HashMap<PathBuf, Vec<SymbolId>>§file_mtimes: HashMap<PathBuf, u64>Implementations§
Source§impl CodeGraph
impl CodeGraph
Sourcepub fn make_id(file: &PathBuf, name: &str, start_line: usize) -> SymbolId
pub fn make_id(file: &PathBuf, name: &str, start_line: usize) -> SymbolId
Deterministic symbol ID from file path, name, and start line.
Sourcepub fn add_symbol(&mut self, node: SymbolNode)
pub fn add_symbol(&mut self, node: SymbolNode)
Add a symbol node to the graph.
Sourcepub fn add_edge(&mut self, from: SymbolId, edge: Edge)
pub fn add_edge(&mut self, from: SymbolId, edge: Edge)
Add a directed edge from from to the target in edge.
Sourcepub fn node(&self, id: SymbolId) -> Option<&SymbolNode>
pub fn node(&self, id: SymbolId) -> Option<&SymbolNode>
Look up a node by ID.
Sourcepub fn symbols_in_file(&self, file: &PathBuf) -> Option<&Vec<SymbolId>>
pub fn symbols_in_file(&self, file: &PathBuf) -> Option<&Vec<SymbolId>>
Get all symbol IDs in a file.
Sourcepub fn callees(&self, id: SymbolId) -> Option<&Vec<Edge>>
pub fn callees(&self, id: SymbolId) -> Option<&Vec<Edge>>
Get outgoing edges (callees / targets) from a symbol.
Sourcepub fn callers(&self, id: SymbolId) -> Option<&Vec<Edge>>
pub fn callers(&self, id: SymbolId) -> Option<&Vec<Edge>>
Get incoming edges (callers / sources) to a symbol.
Sourcepub fn remove_file(&mut self, file: &PathBuf)
pub fn remove_file(&mut self, file: &PathBuf)
Remove all symbols belonging to a file and clean up associated edges.
Sourcepub fn find_by_name(&self, name: &str) -> Vec<&SymbolNode>
pub fn find_by_name(&self, name: &str) -> Vec<&SymbolNode>
Find symbols by name (exact match).
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Total number of symbol nodes.
Sourcepub fn file_count(&self) -> usize
pub fn file_count(&self) -> usize
Total number of indexed files.
Sourcepub fn trace_callers(
&self,
id: SymbolId,
max_depth: usize,
) -> Vec<(SymbolId, usize)>
pub fn trace_callers( &self, id: SymbolId, max_depth: usize, ) -> Vec<(SymbolId, usize)>
BFS reverse traversal — find all transitive callers up to max_depth.
Sourcepub fn trace_callees(
&self,
id: SymbolId,
max_depth: usize,
) -> Vec<(SymbolId, usize)>
pub fn trace_callees( &self, id: SymbolId, max_depth: usize, ) -> Vec<(SymbolId, usize)>
BFS forward traversal — find all transitive callees up to max_depth.
Sourcepub fn shortest_path(
&self,
from: SymbolId,
to: SymbolId,
) -> Option<Vec<SymbolId>>
pub fn shortest_path( &self, from: SymbolId, to: SymbolId, ) -> Option<Vec<SymbolId>>
BFS shortest path from from to to, max 10 hops.
Returns the ordered path [from, ..., to] or None.
Sourcepub fn file_dependents(&self, file: &Path, max_depth: usize) -> Vec<PathBuf>
pub fn file_dependents(&self, file: &Path, max_depth: usize) -> Vec<PathBuf>
Find all files that depend on (call into) symbols in the given file.
Sourcepub fn file_dependency_summary(&self, filename: &str) -> Option<String>
pub fn file_dependency_summary(&self, filename: &str) -> Option<String>
Generate a dependency summary for a file: what it uses, what uses it.
Sourcepub fn call_chain_summary(&self, fn_name: &str) -> Option<String>
pub fn call_chain_summary(&self, fn_name: &str) -> Option<String>
Generate a call chain summary for a function. Skips struct/enum/trait nodes (they don’t have call edges). If multiple functions match, picks the one with the most callees.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for CodeGraph
impl<'de> Deserialize<'de> for CodeGraph
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for CodeGraph
impl RefUnwindSafe for CodeGraph
impl Send for CodeGraph
impl Sync for CodeGraph
impl Unpin for CodeGraph
impl UnsafeUnpin for CodeGraph
impl UnwindSafe for CodeGraph
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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