Class ConfusinglySimilarNamesOrError
java.lang.Object
org.ek9lang.compiler.phase5.ConfusinglySimilarNamesOrError
- All Implemented Interfaces:
Consumer<org.antlr.v4.runtime.tree.ParseTree>
final class ConfusinglySimilarNamesOrError
extends Object
implements Consumer<org.antlr.v4.runtime.tree.ParseTree>
Detects confusingly similar variable, parameter, and field names within the same scope.
Confusingly similar names are a known comprehension hazard (Aman et al., Empirical Software Engineering 2023, found about 0.86% of compound-name pairs confusingly similar; Wong et al., arXiv 2025). This check flags pairs where:
- the names are ONE EDIT apart -
WeightedNameDistance<= 2, where a character inserted, removed or changed ANYWHERE costs 2 (at the start and the end too), two ADJACENT characters swapped (title/titel) cost 2 - but not the first two (latitude/altitudeis two changes) - and a change of case costs 1 - or they differ ONLY in case (userID/userid), however many letters (Steve, 2026-10-11) - Both have the same type (type system won't catch misuse)
- Developer controls both names (not inherited/trait methods)
The pairs compared: locals with locals, parameters with parameters, parameters and locals with the enclosing type's properties, and - on the type itself - its own properties with each other.
Intentionally skips:
- Exact param=field match (common constructor pattern)
- Different types (type system catches misuse)
- Loop variables (i, j, k are conventional)
-
Constructor Summary
ConstructorsConstructorDescriptionConfusinglySimilarNamesOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener) -
Method Summary
-
Constructor Details
-
ConfusinglySimilarNamesOrError
ConfusinglySimilarNamesOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener)
-
-
Method Details
-
accept
-