Skip to main content

CodeGraph

Trait CodeGraph 

Source
pub trait CodeGraph: Send + Sync {
    // Required methods
    fn neighborhood(&self, symbol: &str) -> Option<Neighborhood>;
    fn resolve_in_file(&self, file: &str, name: &str) -> Option<SymbolRef>;
    fn symbol_names(&self) -> Vec<String>;

    // Provided method
    fn neighborhood_all(&self, symbol: &str) -> Vec<Neighborhood> { ... }
}
Expand description

Read-only view over the code graph. Implementations must be Send + Sync so they can be shared across async task boundaries.

Required Methods§

Source

fn neighborhood(&self, symbol: &str) -> Option<Neighborhood>

Returns the neighborhood of the first symbol matching symbol, or None if the symbol is not in the index.

Prefer CodeGraph::neighborhood_all when the same name may be defined in more than one place: this method collapses those to one arbitrary match.

Source

fn resolve_in_file(&self, file: &str, name: &str) -> Option<SymbolRef>

Returns the first symbol named name defined in file, or None.

Source

fn symbol_names(&self) -> Vec<String>

Returns the names of every symbol currently in the index.

Provided Methods§

Source

fn neighborhood_all(&self, symbol: &str) -> Vec<Neighborhood>

Returns the neighborhood of every symbol matching symbol, one per definition site, in a deterministic order (by file, then line).

This is the multi-result form that avoids the single-winner collapse of CodeGraph::neighborhood. The default implementation returns at most the single CodeGraph::neighborhood result so existing implementations keep compiling; the concrete rinne-graph store overrides it to return all.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§