Skip to main content

GraphStore

Trait GraphStore 

Source
pub trait GraphStore: Send + Sync {
Show 13 methods // Required methods fn insert(&mut self, path: &str, graph: CodeGraph); fn symbols_in_file(&self, path: &str) -> Vec<Symbol>; fn definitions(&self, name: &str) -> Vec<Located<Symbol>>; fn references_to(&self, name: &str) -> Vec<Located<Reference>>; fn callers_of(&self, name: &str) -> Vec<String>; fn callees(&self, name: &str) -> Vec<String>; fn all_symbols(&self) -> Vec<Located<Symbol>>; fn all_references(&self) -> Vec<Located<Reference>>; // Provided methods fn impact(&self, name: &str) -> Vec<String> { ... } fn overview(&self, largest: usize) -> ViewOverview { ... } fn top(&self, ranking: Ranking, limit: usize) -> Page<RankedSymbol> { ... } fn list(&self, filter: &SymbolFilter, limit: usize) -> Page<Located<Symbol>> { ... } fn unreferenced( &self, filter: &SymbolFilter, exclude_tests: bool, limit: usize, ) -> Page<Located<Symbol>> { ... }
}
Expand description

Structural queries over an assembled view (a set of path-keyed slices).

Required Methods§

Source

fn insert(&mut self, path: &str, graph: CodeGraph)

Insert (or replace) the slice assembled at path. Re-inserting the same path overwrites — slices are content-addressed and write-if-absent, never appended, so this cannot duplicate a file’s symbols.

Source

fn symbols_in_file(&self, path: &str) -> Vec<Symbol>

Symbols defined in the slice at path.

Source

fn definitions(&self, name: &str) -> Vec<Located<Symbol>>

Definitions matching name, each with the path it was found under (there may be several — names are unresolved).

Source

fn references_to(&self, name: &str) -> Vec<Located<Reference>>

References whose target name is name, each with its path.

Source

fn callers_of(&self, name: &str) -> Vec<String>

Distinct enclosing-function names that reference name.

Source

fn callees(&self, name: &str) -> Vec<String>

Distinct names referenced from within name (the inverse of callers_of), sorted.

Source

fn all_symbols(&self) -> Vec<Located<Symbol>>

Every symbol in the view, each with its path (used for whole-graph operations like diffing).

Source

fn all_references(&self) -> Vec<Located<Reference>>

Every reference in the view, each with its path.

Provided Methods§

Source

fn impact(&self, name: &str) -> Vec<String>

The transitive closure of callers: every symbol that could be affected if name changes, reached by walking callers_of breadth-first. Runs server-side (never ships the whole graph); the seed name is excluded, and cycles terminate via a visited set. Returned sorted.

Source

fn overview(&self, largest: usize) -> ViewOverview

The aggregate shape of the whole view: counts, a breakdown by kind and by language, and the largest files by symbol count.

Answers “what is in this view” without the caller having to know a symbol name first. Like impact this runs server-side over the assembled graph; only the summary is returned.

Source

fn top(&self, ranking: Ranking, limit: usize) -> Page<RankedSymbol>

The top limit symbol names by ranking, descending.

Ranking::Definitions is the ambiguity report: any name scoring above 1 is defined in several places, so every name-matched traversal through it merges unrelated subgraphs.

Source

fn list(&self, filter: &SymbolFilter, limit: usize) -> Page<Located<Symbol>>

Symbols matching filter, in path order, bounded by limit.

The enumeration counterpart to definitions: answers “what is in this crate” rather than “where is this name”.

Source

fn unreferenced( &self, filter: &SymbolFilter, exclude_tests: bool, limit: usize, ) -> Page<Located<Symbol>>

Symbols with no inbound reference anywhere in the view — dead-code candidates, in path then line order.

With exclude_tests (the useful default) symbols inside a test scope are dropped: members of a mod tests / mod test block, by line range, and anything under a tests/ directory. On gonzalo itself that filter is the difference between 515 hits and 40 — without it the result is ~92% noise.

This is a heuristic, and its false positives are real. It inherits every limit of the name-matched extractor underneath:

  • A function used only as a value (map_err(be), and_then(f)) is a path expression, not a call, so higher-order usage is invisible.
  • Calls inside Rust macro arguments are now recorded (#216), but by a token-level heuristic: an identifier followed by a parenthesised token tree. A tuple-struct pattern such as Some(_) reads the same way, so macro-derived edges are slightly over-inclusive rather than missing.
  • Names are unresolved: an unused foo is hidden by any other foo that is used.
  • Conversely a reference from anywhere counts, including from tests and from the symbol itself, so recursive-only and test-only functions are not reported even though they may be dead.

Treat every result as a lead to confirm, never as proof.

Implementors§