Class InheritanceDepthCalculator
java.lang.Object
org.ek9lang.compiler.phase5.InheritanceDepthCalculator
- All Implemented Interfaces:
ToIntFunction<ISymbol>
Calculates the Depth of Inheritance Tree (DIT) for aggregate symbols.
Based on Chidamber & Kemerer (1994) CK Metrics Suite.
DIT counts the number of ancestor classes from a class to the root of its inheritance tree. Higher DIT values indicate greater design complexity.
The implicit 'Any' base class is NOT counted as it is universal to all types.
For traits, depth is calculated through the trait hierarchy (via getTraits()) rather than getSuperAggregate(), since traits use composition not inheritance.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintapplyAsInt(ISymbol symbol) Calculate the inheritance depth for a symbol.
-
Constructor Details
-
InheritanceDepthCalculator
InheritanceDepthCalculator()
-
-
Method Details
-
applyAsInt
Calculate the inheritance depth for a symbol. Returns 0 for non-aggregate symbols or aggregates with no explicit super.- Specified by:
applyAsIntin interfaceToIntFunction<ISymbol>- Parameters:
symbol- The symbol to calculate depth for- Returns:
- The depth of inheritance tree (0 = no inheritance, 1 = extends one class, etc.)
-