pub struct ModuleGraph { /* private fields */ }Expand description
Module dependency graph
Implementations§
Source§impl ModuleGraph
impl ModuleGraph
Sourcepub fn add_module(&mut self, path: &Path) -> ModuleId
pub fn add_module(&mut self, path: &Path) -> ModuleId
Add or get a module by path
Sourcepub fn add_external_module(
&mut self,
specifier: &str,
resolved: &ResolvedModule,
) -> ModuleId
pub fn add_external_module( &mut self, specifier: &str, resolved: &ResolvedModule, ) -> ModuleId
Add an external module
Sourcepub fn get_module(&self, id: ModuleId) -> Option<&ModuleInfo>
pub fn get_module(&self, id: ModuleId) -> Option<&ModuleInfo>
Get a module by ID
Sourcepub fn get_module_mut(&mut self, id: ModuleId) -> Option<&mut ModuleInfo>
pub fn get_module_mut(&mut self, id: ModuleId) -> Option<&mut ModuleInfo>
Get a mutable module by ID
Sourcepub fn get_module_by_path(&self, path: &Path) -> Option<&ModuleInfo>
pub fn get_module_by_path(&self, path: &Path) -> Option<&ModuleInfo>
Get a module by path
Sourcepub fn get_module_id(&self, path: &Path) -> Option<ModuleId>
pub fn get_module_id(&self, path: &Path) -> Option<ModuleId>
Get module ID by path
Sourcepub fn add_entry_point(&mut self, module_id: ModuleId)
pub fn add_entry_point(&mut self, module_id: ModuleId)
Add an entry point
Sourcepub fn add_dependency(&mut self, edge: DependencyEdge)
pub fn add_dependency(&mut self, edge: DependencyEdge)
Add a dependency edge
Sourcepub fn add_simple_dependency(
&mut self,
from: ModuleId,
to: ModuleId,
specifier: &str,
)
pub fn add_simple_dependency( &mut self, from: ModuleId, to: ModuleId, specifier: &str, )
Add a dependency between two modules
Sourcepub fn detect_circular_dependencies(&mut self) -> &[CircularDependency]
pub fn detect_circular_dependencies(&mut self) -> &[CircularDependency]
Detect circular dependencies using Tarjan’s algorithm
Sourcepub fn topological_sort(&self) -> Result<Vec<ModuleId>, CircularDependencyError>
pub fn topological_sort(&self) -> Result<Vec<ModuleId>, CircularDependencyError>
Get topological sort of modules (for build ordering)
Returns modules in dependency order: modules with no dependencies come first, followed by modules that depend only on already-listed modules. This is the correct order for building/processing modules.
Sourcepub fn get_dependents(&self, id: ModuleId) -> FxHashSet<ModuleId>
pub fn get_dependents(&self, id: ModuleId) -> FxHashSet<ModuleId>
Get all modules that depend on a given module (transitive)
Sourcepub fn get_dependencies(&self, id: ModuleId) -> FxHashSet<ModuleId>
pub fn get_dependencies(&self, id: ModuleId) -> FxHashSet<ModuleId>
Get all dependencies of a module (transitive)
Sourcepub fn depends_on(&self, from: ModuleId, to: ModuleId) -> bool
pub fn depends_on(&self, from: ModuleId, to: ModuleId) -> bool
Check if a module depends on another (directly or transitively)
Sourcepub fn stats(&self) -> ModuleGraphStats
pub fn stats(&self) -> ModuleGraphStats
Get statistics about the module graph
Sourcepub fn modules(&self) -> impl Iterator<Item = &ModuleInfo>
pub fn modules(&self) -> impl Iterator<Item = &ModuleInfo>
Get all modules in the graph
Sourcepub fn edges(&self) -> &[DependencyEdge]
pub fn edges(&self) -> &[DependencyEdge]
Get all edges
Sourcepub fn entry_points(&self) -> &[ModuleId]
pub fn entry_points(&self) -> &[ModuleId]
Get entry points
Sourcepub fn circular_deps(&self) -> &[CircularDependency]
pub fn circular_deps(&self) -> &[CircularDependency]
Get circular dependencies
Trait Implementations§
Source§impl Debug for ModuleGraph
impl Debug for ModuleGraph
Auto Trait Implementations§
impl Freeze for ModuleGraph
impl RefUnwindSafe for ModuleGraph
impl Send for ModuleGraph
impl Sync for ModuleGraph
impl Unpin for ModuleGraph
impl UnsafeUnpin for ModuleGraph
impl UnwindSafe for ModuleGraph
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