Class MetricLimitCheck
java.lang.Object
org.ek9lang.compiler.phase5.MetricLimitCheck
THE shared steps of every
Acceptable*OrError quality-metric check: find the symbol the metric belongs
to (one null policy), squirrel the measured integer (one encoding) and raise the error when it is over the limit.
Use these; do not re-derive a variant in a checker.
The null policy is an assertion, because a metric scope is pushed on entry for a construct that has a symbol.
A checker that must still pop a tracker for a symbol-less node (cohesion, coupling) does its own
getRecordedSymbol so that it can pop first - that is a stack-balance reason, not a second policy.
The message of each limit keeps its own wording, so it is supplied by the caller.
-
Method Summary
Modifier and TypeMethodDescription(package private) static voiderrorIfExceeds(ErrorListener errorListener, ISymbol symbol, int value, int max, ErrorListener.SemanticClassification code, Supplier<String> message) Raisecodeon the symbol's source token when the value is strictly above the maximum.(package private) static voidrecord(ISymbol symbol, CommonValues squirrelKey, int value) Squirrel an integer metric on the symbol as decimal text, throughSmallIntStrings.(package private) static ISymbolsymbolOf(SymbolsAndScopes symbolsAndScopes, org.antlr.v4.runtime.tree.ParseTree node) The symbol the metric is recorded against; asserted present (the node, not the symbol, is never null).
-
Method Details
-
symbolOf
static ISymbol symbolOf(SymbolsAndScopes symbolsAndScopes, org.antlr.v4.runtime.tree.ParseTree node) The symbol the metric is recorded against; asserted present (the node, not the symbol, is never null). -
record
Squirrel an integer metric on the symbol as decimal text, throughSmallIntStrings. -
errorIfExceeds
static void errorIfExceeds(ErrorListener errorListener, ISymbol symbol, int value, int max, ErrorListener.SemanticClassification code, Supplier<String> message) Raisecodeon the symbol's source token when the value is strictly above the maximum.
-