Class InheritanceDepthCalculator

java.lang.Object
org.ek9lang.compiler.phase5.InheritanceDepthCalculator
All Implemented Interfaces:
ToIntFunction<ISymbol>

class InheritanceDepthCalculator extends Object implements 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 Details

    • InheritanceDepthCalculator

      InheritanceDepthCalculator()
  • Method Details

    • applyAsInt

      public int applyAsInt(ISymbol symbol)
      Calculate the inheritance depth for a symbol. Returns 0 for non-aggregate symbols or aggregates with no explicit super.
      Specified by:
      applyAsInt in interface ToIntFunction<ISymbol>
      Parameters:
      symbol - The symbol to calculate depth for
      Returns:
      The depth of inheritance tree (0 = no inheritance, 1 = extends one class, etc.)