Struct farmfe_core::module::module_graph::ModuleGraph
source · pub struct ModuleGraph {
pub entries: HashMap<ModuleId, String>,
/* private fields */
}Fields§
§entries: HashMap<ModuleId, String>entry modules of this module graph. (Entry Module Id, Entry Name)
Implementations§
source§impl ModuleGraph
impl ModuleGraph
pub fn new() -> Self
sourcepub fn get_dep_by_source_optional(
&self,
module_id: &ModuleId,
source: &str
) -> Option<ModuleId>
pub fn get_dep_by_source_optional( &self, module_id: &ModuleId, source: &str ) -> Option<ModuleId>
Get the dep module of the specified module which imports the dep module using the specified source.
Used to get module by (module, source) pair, for example, for module a:
import b from './b';
we can get module b by (module a, "./b").
Panic if the dep does not exist or the source is not correct
pub fn get_dep_by_source(&self, module_id: &ModuleId, source: &str) -> ModuleId
pub fn module(&self, module_id: &ModuleId) -> Option<&Module>
pub fn module_mut(&mut self, module_id: &ModuleId) -> Option<&mut Module>
pub fn modules(&self) -> Vec<&Module>
pub fn modules_mut(&mut self) -> Vec<&mut Module>
pub fn has_module(&self, module_id: &ModuleId) -> bool
pub fn update_module(&mut self, module: Module)
pub fn module_ids_by_file(&self, module_id: &ModuleId) -> Vec<ModuleId>
pub fn add_module(&mut self, module: Module)
pub fn remove_module(&mut self, module_id: &ModuleId) -> Module
pub fn add_edge_item( &mut self, from: &ModuleId, to: &ModuleId, edge_info: ModuleGraphEdgeDataItem ) -> Result<()>
pub fn add_edge( &mut self, from: &ModuleId, to: &ModuleId, edge_info: ModuleGraphEdge ) -> Result<()>
pub fn remove_edge(&mut self, from: &ModuleId, to: &ModuleId) -> Result<()>
pub fn has_edge(&self, from: &ModuleId, to: &ModuleId) -> bool
pub fn edge_info( &self, from: &ModuleId, to: &ModuleId ) -> Option<&ModuleGraphEdge>
pub fn edge_count(&self) -> usize
sourcepub fn dependencies(
&self,
module_id: &ModuleId
) -> Vec<(ModuleId, &ModuleGraphEdge)>
pub fn dependencies( &self, module_id: &ModuleId ) -> Vec<(ModuleId, &ModuleGraphEdge)>
get dependencies of the specific module, sorted by the order of the edge.
for example, for module a:
import c from './c';
import b from './b';
return ['module c', 'module b'], ensure the order of original imports.
sourcepub fn dependencies_ids(&self, module_id: &ModuleId) -> Vec<ModuleId>
pub fn dependencies_ids(&self, module_id: &ModuleId) -> Vec<ModuleId>
Same as dependencies, but only return the module id.
sourcepub fn dependents(
&self,
module_id: &ModuleId
) -> Vec<(ModuleId, &ModuleGraphEdge)>
pub fn dependents( &self, module_id: &ModuleId ) -> Vec<(ModuleId, &ModuleGraphEdge)>
get dependent of the specific module. don’t ensure the result’s order.
pub fn dependents_ids(&self, module_id: &ModuleId) -> Vec<ModuleId>
sourcepub fn toposort(&self) -> (Vec<ModuleId>, Vec<Vec<ModuleId>>)
pub fn toposort(&self) -> (Vec<ModuleId>, Vec<Vec<ModuleId>>)
sort the module graph topologically using post order dfs, note this topo sort also keeps the original import order. return (topologically sorted modules, cyclic modules stack)
Unsupported Situation: if the two entries shares the same dependencies but the import order is not the same, may cause one entry don’t keep original import order, this may bring problems in css as css depends on the order.
pub fn update_execution_order_for_modules(&mut self)
pub fn internal_graph(&self) -> &StableDiGraph<Module, ModuleGraphEdge>
pub fn dfs(&self, entry: &ModuleId, op: &mut dyn FnMut(&ModuleId))
pub fn dfs_breakable( &self, entries: Vec<ModuleId>, op: &mut dyn FnMut(Option<&ModuleId>, &ModuleId) -> bool )
pub fn bfs(&self, entry: &ModuleId, op: &mut dyn FnMut(&ModuleId))
pub fn take_edge_and_module( &mut self, from: &ModuleId, to: &ModuleId ) -> (ModuleGraphEdge, Module)
pub fn take_module(&mut self, module_id: &ModuleId) -> Module
pub fn replace_module(&mut self, module: Module)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ModuleGraph
impl !RefUnwindSafe for ModuleGraph
impl Send for ModuleGraph
impl Sync for ModuleGraph
impl Unpin for ModuleGraph
impl !UnwindSafe for ModuleGraph
Blanket Implementations§
source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata
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<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.