Class MagicLiteralTracker
Thread-safe: designed to be used during parallel file processing where multiple PreIRListener instances (one per file) share a single MagicLiteralTracker.
Context exemptions: literals in constant declarations, list/dict literals, require/assert statements, constrain declarations, range expressions, string concatenation, and named arguments - the label documents the value, and the compiler checks it against the declared parameter (E06240/E06250), so it cannot lie.
A constructor call is NOT exempt (D4, Steve 2026-10-03): Person("Steve", "Limb") repeated is as
opaque as any call; label it (Person(firstName: "Steve", lastName: "Limb")) or name a shared value
as a constant. It was once exempt by the callee's name starting with an uppercase letter, which also
exempted any function so named.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final recordOne recorded occurrence of a literal. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) List<MagicLiteralTracker.LiteralRecord> getRecords(String moduleName) Get a snapshot copy of literal records for a specific module.(package private) static booleanCheck if a module is exempt from magic literal checking.(package private) voidprocessLiteral(EK9Parser.LiteralContext literal, String moduleName, String filePath, Set<org.antlr.v4.runtime.Token> reportedByTier1) Record a literal occurrence for a specific module, if not exempt.
-
Constructor Details
-
MagicLiteralTracker
MagicLiteralTracker()
-
-
Method Details
-
processLiteral
void processLiteral(EK9Parser.LiteralContext literal, String moduleName, String filePath, Set<org.antlr.v4.runtime.Token> reportedByTier1) Record a literal occurrence for a specific module, if not exempt.- Parameters:
literal- the literal parser contextmoduleName- the module containing the literalfilePath- the source file pathreportedByTier1- tokens already reported by Tier 1 (to avoid double-reporting)
-
getRecords
Get a snapshot copy of literal records for a specific module.- Parameters:
moduleName- the module to query- Returns:
- list of literal records (may be empty, never null)
-
isExempt
Check if a module is exempt from magic literal checking. Built-in modules (org.ek9.*) are exempt.
-