Class InjectionPromoteToFacadeOrError

java.lang.Object
org.ek9lang.compiler.phase5.InjectionPromoteToFacadeOrError
All Implemented Interfaces:
BiConsumer<org.antlr.v4.runtime.tree.ParseTree, Map<String,Integer>>

final class InjectionPromoteToFacadeOrError extends Object implements BiConsumer<org.antlr.v4.runtime.tree.ParseTree, Map<String,Integer>>
Validates DI injection design quality across a construct's methods (E11041).

When the SAME component type is method-local-injected ('!') inside several methods of a construct, that dependency is central to the construct and should be declared ONCE as a field, with every method using the field, rather than re-injected (and re-resolved) per method.

Applies only to components and classes (aspects are classes) - the multi-method, field-capable constructs where "promote to a single field" is a real remedy. Services and traits are field-less (so the repetition is structural, not field-fixable - the same reason a CRUD service legitimately injects its repository in every operation), and functions/programs are single-callable. The per-type method tally is supplied by the listener from InjectionTypeCounter scopes.