Class SourceRepairs
ek9 -ff
and ek9_format (the TEXT layer), and the MCP editors, ek9_write_file, ek9_edit_file and
ek9_compile (the DIAGNOSTIC layer). Use this; never add a private fixer to a tool - two fixers for one
slip behave differently, and they did (2026-10-05 parse-failure report: tabs, indentation and the shebang were
each handled two or three ways, one of them wrong).
Text layer (repairText(String)): needs no compile. The LayoutRepairs first (byte-order mark,
line endings, shebang, layout tabs, odd base indent), then a LOOP: parse, take the first syntax error, offer it to
each TextRule; a rewrite is kept only if the parse then gets further than before (it removes its own
error and adds none ahead of it). Up to 32 passes. What stays unparseable is reported
with the ParseSuggestions for it.
Diagnostic layer (repairAgainst(String, List)): one PASS over a compile's diagnostics (the §1.1 maps - line
1-based, column 0-based, errorCode, message). The compiler stops at the first phase that fails, so the caller
LOOPS: repair, re-verify, repair what the re-verify revealed (the MCP's AppliedRepairs.repairUntilClean).
Each repair is keyed on the diagnostic that proves it; the text rules answer the first SYNTAX diagnostic when the
keyed repairs had nothing to say.
The tier rule (docs/tooling/EK9_TOOLING_IMPROVEMENT_METHOD.md §2): a rule APPLIES only where its
shape has exactly one reading and the literal reading does not compile; anything needing a choice is a
SUGGESTION. Nothing here renames: a misspelt keyword is a suggestion, never a rewrite. Every applied repair is
reported - corrected[] in an MCP response, the ek9 -ff report on the command line.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOne diagnostic-layer pass: the repaired text and one note per repair; notes empty means nothing moved.static final recordThe text layer's outcome. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe most text-layer passes; each is one parse. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringThe layout repairs alone (LayoutRepairs) - what the canonical indenter applies before giving up on a source that does not parse.static StringlayoutTabsReplaced(String text) textwith every LAYOUT tab replaced by two spaces - a tab inside a String, character or regex literal, or a comment, is kept (the lexer decides).static booleanTrue whenrepairAgainst(String, List)might changetext- the cheap gate before a probe compile: the text does not parse, or it holds a shape one of the keyed repairs answers.static SourceRepairs.RepairedTHE diagnostic layer, one pass - see the class javadoc.static SourceRepairs.RepairedrepairAgainst(String text, List<Map<String, Object>> diagnostics, Predicate<DoubleQuotedInterpolation.Result> keepInterpolation) AsrepairAgainst(String, List), with a veto over the double-quoted interpolation repair (E07901): a caller that cannot re-verify the whole repair as one -ek9_write_filewrites with no line receipts - checks that every name the interpolation introduces resolves, and refuses it otherwise.static SourceRepairs.TextResultrepairText(String source) THE text layer - see the class javadoc.suggestionsFor(String text) The suggestions for the first syntax error intext; empty when it parses.
-
Field Details
-
MAX_TEXT_PASSES
public static final int MAX_TEXT_PASSESThe most text-layer passes; each is one parse.- See Also:
-
-
Method Details
-
repairText
THE text layer - see the class javadoc. -
layout
The layout repairs alone (LayoutRepairs) - what the canonical indenter applies before giving up on a source that does not parse. -
layoutTabsReplaced
-
suggestionsFor
-
repairAgainst
-
repairAgainst
public static SourceRepairs.Repaired repairAgainst(String text, List<Map<String, Object>> diagnostics, Predicate<DoubleQuotedInterpolation.Result> keepInterpolation) AsrepairAgainst(String, List), with a veto over the double-quoted interpolation repair (E07901): a caller that cannot re-verify the whole repair as one -ek9_write_filewrites with no line receipts - checks that every name the interpolation introduces resolves, and refuses it otherwise. -
mayApply
True whenrepairAgainst(String, List)might changetext- the cheap gate before a probe compile: the text does not parse, or it holds a shape one of the keyed repairs answers.
-