Class VisualErrorFormatter
java.lang.Object
org.ek9lang.compiler.common.VisualErrorFormatter
Formats compiler errors in a visual style similar to Rust/Elm compilers.
Displays the source code line with underline markers pointing to the error location.
Supports colors and Unicode symbols when terminal capabilities are detected.
Example output (with colors/symbols):
❌ error[E02010]: Property/Field duplicated
──▶ example.ek9:12:7
│
12 │ prop3 <- String()
│ ^^^^^ property already exists in parent type
│
├─ 💡 Did you mean: 'prop2'?
└─ 🔗 See: https://ek9.io/errors.html#E02010
-
Method Summary
Modifier and TypeMethodDescriptionstatic Stringformat(String classification, String errorCode, String fileName, int lineNumber, int position, int tokenLength, String sourceLine, String errorMessage, String detailMessage) Format an error with visual source display.static Stringformat(String classification, String errorCode, String fileName, int lineNumber, int position, int tokenLength, String sourceLine, String errorMessage, String detailMessage, MatchResults fuzzyResults) Format an error with visual source display and fuzzy match suggestions.
-
Method Details
-
format
public static String format(String classification, String errorCode, String fileName, int lineNumber, int position, int tokenLength, String sourceLine, String errorMessage, String detailMessage) Format an error with visual source display.- Parameters:
classification- The error classification (Error, Warning, etc.)errorCode- The error code (e.g., "E02010")fileName- The source file namelineNumber- The 1-based line numberposition- The 0-based character position on the linetokenLength- The length of the offending tokensourceLine- The actual source code line contenterrorMessage- The primary error messagedetailMessage- Additional detail message (can be null)- Returns:
- The formatted visual error string
-
format
public static String format(String classification, String errorCode, String fileName, int lineNumber, int position, int tokenLength, String sourceLine, String errorMessage, String detailMessage, MatchResults fuzzyResults) Format an error with visual source display and fuzzy match suggestions.- Parameters:
classification- The error classification (Error, Warning, etc.)errorCode- The error code (e.g., "E02010")fileName- The source file namelineNumber- The 1-based line numberposition- The 0-based character position on the linetokenLength- The length of the offending tokensourceLine- The actual source code line contenterrorMessage- The primary error messagedetailMessage- Additional detail message (can be null)fuzzyResults- Fuzzy match suggestions (can be null)- Returns:
- The formatted visual error string
-