pub struct GraphBuilder { /* private fields */ }Expand description
Builder for incremental graph construction from extraction results.
Implementations§
Source§impl GraphBuilder
impl GraphBuilder
Sourcepub fn new(snapshot_id: SnapshotId) -> Self
pub fn new(snapshot_id: SnapshotId) -> Self
Creates a new GraphBuilder for the given snapshot.
Sourcepub fn add_file(&mut self, path: PathBuf, language: LangId) -> FileId
pub fn add_file(&mut self, path: PathBuf, language: LangId) -> FileId
Adds a file node to the graph.
If the file already exists (determined by path), returns the existing FileId.
Sourcepub fn add_symbol(&mut self, symbol: &Symbol) -> Result<NodeIndex, Error>
pub fn add_symbol(&mut self, symbol: &Symbol) -> Result<NodeIndex, Error>
Adds a symbol node and its ownership edge to the containing file.
The containing file must already exist in the builder. The symbol’s file path is resolved against registered files.
Returns the NodeIndex for the symbol node.
Sourcepub fn add_import(&mut self, from: FileId, to: PathBuf)
pub fn add_import(&mut self, from: FileId, to: PathBuf)
Adds an import edge from one file to another.
If the target file exists in the project, creates an import edge. If the target is external (not in the project), creates an ExternalNode placeholder and an import edge to it.
Sourcepub fn add_reference(&mut self, from: SymbolId, to: SymbolId, confidence: f32)
pub fn add_reference(&mut self, from: SymbolId, to: SymbolId, confidence: f32)
Adds a reference edge between two symbols with a confidence score.
Both symbols must exist in the builder. If a duplicate edge already exists, the confidence is merged via max (the stronger signal is preserved).
Sourcepub fn file_id_for_path(&self, path: &PathBuf) -> Option<FileId>
pub fn file_id_for_path(&self, path: &PathBuf) -> Option<FileId>
Returns the FileId for a given file path, if registered.
Sourcepub fn import_adjacency(&self) -> HashMap<FileId, Vec<FileId>>
pub fn import_adjacency(&self) -> HashMap<FileId, Vec<FileId>>
Builds and returns an adjacency map from FileId to the FileIds it imports.
Walks all Import edges in the graph to produce the relationship.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Returns the number of nodes in the graph so far.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Returns the number of edges in the graph so far.
Sourcepub fn external_count(&self) -> usize
pub fn external_count(&self) -> usize
Returns the number of external dependency nodes.
Sourcepub fn from_extractions<F>(
extractions: &[F],
root: &Path,
snapshot_id: SnapshotId,
diagnostics: &mut Vec<Diagnostic>,
) -> (CodeGraph, SccAnalysis)
pub fn from_extractions<F>( extractions: &[F], root: &Path, snapshot_id: SnapshotId, diagnostics: &mut Vec<Diagnostic>, ) -> (CodeGraph, SccAnalysis)
Assemble a complete CodeGraph + SCC from parallel extraction results.
Replaces the manual multi-step wiring in pipeline.rs. Handles:
- File and symbol node registration
- Import edge resolution (via language-specific resolvers)
- Cross-file reference resolution via FlattenedScopeCache
- SCC analysis
Errors during symbol addition are non-fatal and appended to diagnostics.
Sourcepub fn from_extractions_with_scope<F>(
extractions: &[F],
root: &Path,
snapshot_id: SnapshotId,
diagnostics: &mut Vec<Diagnostic>,
) -> (CodeGraph, SccAnalysis, FlattenedScopeCache)
pub fn from_extractions_with_scope<F>( extractions: &[F], root: &Path, snapshot_id: SnapshotId, diagnostics: &mut Vec<Diagnostic>, ) -> (CodeGraph, SccAnalysis, FlattenedScopeCache)
Build the graph, the SCC, the scope cache, and the resolved references.
Sourcepub fn from_extractions_detailed<F>(
extractions: &[F],
root: &Path,
snapshot_id: SnapshotId,
diagnostics: &mut Vec<Diagnostic>,
) -> AnalysisParts
pub fn from_extractions_detailed<F>( extractions: &[F], root: &Path, snapshot_id: SnapshotId, diagnostics: &mut Vec<Diagnostic>, ) -> AnalysisParts
Build everything one analysis pass produces from a set of extractions.
Stages: file and symbol node registration, import edge resolution, cross
file reference resolution with the flattened scope cache, client-call
edge injection, and SCC analysis. Errors during symbol addition are
non-fatal and appended to diagnostics. Both the one-shot and the
incremental entry point call this, so the analysis of a tree cannot
depend on which entry point produced it.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for GraphBuilder
impl RefUnwindSafe for GraphBuilder
impl Send for GraphBuilder
impl Sync for GraphBuilder
impl Unpin for GraphBuilder
impl UnsafeUnpin for GraphBuilder
impl UnwindSafe for GraphBuilder
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> 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