pub struct InheritanceGraph { /* private fields */ }Implementations§
Source§impl InheritanceGraph
impl InheritanceGraph
pub fn new() -> Self
Sourcepub fn add_inheritance(&self, child: SymbolId, parents: &[SymbolId])
pub fn add_inheritance(&self, child: SymbolId, parents: &[SymbolId])
Register a class or interface and its direct parents.
§Arguments
child- TheSymbolIdof the class/interface being definedparents- List ofSymbolIdsthis type extends or implements
Sourcepub fn is_derived_from(&self, child: SymbolId, ancestor: SymbolId) -> bool
pub fn is_derived_from(&self, child: SymbolId, ancestor: SymbolId) -> bool
Checks if child is a subtype of ancestor nominally.
This is an O(1) operation after the first lazy computation.
Returns true if child extends or implements ancestor (transitively).
Sourcepub fn get_resolution_order(&self, symbol_id: SymbolId) -> Vec<SymbolId>
pub fn get_resolution_order(&self, symbol_id: SymbolId) -> Vec<SymbolId>
Gets the Method Resolution Order (MRO) for a symbol.
Returns a list of SymbolIds in the order they should be searched for members.
Implements a depth-first, left-to-right traversal (standard for TS/JS).
Sourcepub fn find_common_ancestor(&self, a: SymbolId, b: SymbolId) -> Option<SymbolId>
pub fn find_common_ancestor(&self, a: SymbolId, b: SymbolId) -> Option<SymbolId>
Finds the Least Upper Bound (common ancestor) of two symbols.
Returns the most specific symbol that both A and B inherit from. In cases of multiple inheritance (interfaces), this might return one of several valid candidates.
Sourcepub fn detects_cycle(&self, child: SymbolId, parent: SymbolId) -> bool
pub fn detects_cycle(&self, child: SymbolId, parent: SymbolId) -> bool
Detects if adding an edge would create a cycle.
Sourcepub fn get_parents(&self, symbol_id: SymbolId) -> Vec<SymbolId>
pub fn get_parents(&self, symbol_id: SymbolId) -> Vec<SymbolId>
Get the direct parents of a symbol (for cycle detection).