Class CouplingTracker
Uses a stack to handle nested constructs (e.g., inner classes). Built-in types from org.ek9.lang are excluded from the count as they are universal primitives that don't contribute to meaningful coupling.
Complexity: O(T) where T = total type references - linear, not N-squared.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) booleanisEmpty()Check if there are any scopes being tracked.(package private) doublePop the current scope and return the (delegation-weighted) coupling count.(package private) voidPush a new scope for tracking coupling of a construct.(package private) voidRecord that the current construct delegates a trait viaby— worth a 0.5 discount on its efferent coupling.(package private) voidrecordDependency(ISymbol type) Record a type dependency.
-
Constructor Details
-
CouplingTracker
CouplingTracker()
-
-
Method Details
-
pushScope
void pushScope()Push a new scope for tracking coupling of a construct. -
recordDependency
Record a type dependency. Unwraps generics and filters out built-in types.A field/param/return typed
Optional of domain::Addressarchitecturally couples todomain::Address, not to the built-inOptionalcontainer it is created inside. A naive outer-FQN read attributes the coupling toorg.ek9.langand the real target vanishes — the generics-hole that made E11015 evadable through any generic. So each reference is decomposed viaGenericTypeInfo: the generic template (empty for a plain type; the built-in container forList/Dict/Optional, filtered below; a userCache's own module for a user generic) plus every leaf concrete type argument, recursively. This is the SAME decomposition the MCP architecture tools measure with, so the enforced count and the measured count agree by construction.- Parameters:
type- the symbol representing the dependent type
-
recordDelegation
void recordDelegation()Record that the current construct delegates a trait viaby— worth a 0.5 discount on its efferent coupling. Safe to call when no scope is open (ignored). -
popAndGetCouplingCount
double popAndGetCouplingCount()Pop the current scope and return the (delegation-weighted) coupling count.- Returns:
- the fractional efferent coupling — whole unless the construct uses
bydelegation
-
isEmpty
boolean isEmpty()Check if there are any scopes being tracked.- Returns:
- true if no scopes are on the stack
-