Class LayoutRepairs

java.lang.Object
org.ek9lang.compiler.repair.LayoutRepairs

final class LayoutRepairs extends Object
THE layout repairs - the faults in how a source is laid out rather than what it says, each with exactly one reading and none able to change which code runs. Formerly the formatter's SourcePreProcessor (and, for the shebang, a second copy in the MCP file writer).
  1. a leading byte-order mark (U+FEFF) - removed (the compiler rejects one);
  2. CRLF / CR line endings - LF (only in all(String): CRLF parses, so no diagnostic ever asks for it);
  3. a WRONG shebang (#!/usr/bin/env ek9) - replaced by #!ek9; a MISSING one - added;
  4. layout tabs - two spaces each; a tab inside a String, character or regex literal, or a comment, is content and is kept (the lexer decides which is which);
  5. an odd base indent (a file indented in threes) - re-levelled to two spaces per level.

There is deliberately NO keyword-typo correction: a Levenshtein guess rewrote valid identifiers (heads to head) and ek9 -ff saved the file (removed 2026-10-05). A misspelt keyword changes which code runs - see ParseSuggestions.

  • Field Details

  • Method Details

    • all

      static LayoutRepairs.Result all(String source)
      Every layout repair, line endings included - the ek9 -ff pre-pass.
    • withoutLineEndings

      static LayoutRepairs.Result withoutLineEndings(String source)
      Every layout repair except the line endings - for a caller whose text already failed to parse.
    • replaceLayoutTabs

      static String replaceLayoutTabs(String source)
      Replace each LAYOUT tab with two spaces. The EK9 lexer decides which tabs are layout: a tab it reads as part of an INDENT/DEDENT/NL (in the indentation, or between tokens) is one the compiler rejects, and is replaced here. A tab inside any other token - a String, a backtick String, a character or regex literal, a comment - is part of that token's text and is kept, because replacing it would change what the program does.