Class VisualErrorFormatter

java.lang.Object
org.ek9lang.compiler.common.VisualErrorFormatter
All Implemented Interfaces:
Function<VisualErrorData, String>

public final class VisualErrorFormatter extends Object implements Function<VisualErrorData, String>
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. Hold an instance.

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: ek9 -h E02010
  • Constructor Details

    • VisualErrorFormatter

      public VisualErrorFormatter()
  • Method Details

    • apply

      public String apply(VisualErrorData data)
      Format an error with visual source display.
      Specified by:
      apply in interface Function<VisualErrorData, String>
      Parameters:
      data - All the error data needed for visual formatting
      Returns:
      The formatted visual error string