Package org.ek9lang.compiler.repair
package org.ek9lang.compiler.repair
THE automatic source repairs - one engine for every door (
ek9 -ff, ek9_format, the MCP editors,
ek9_write_file, ek9_edit_file, ek9_compile). Start at
SourceRepairs: its text layer needs only a parse, its diagnostic layer a
compile's diagnostics. A repair applies only where its shape has exactly one reading and the literal reading does
not compile; anything needing a choice is a suggestion. SyntaxProbe is THE
parse-only check the repairs (and the MCP pre-flights) share.
Lives in compiler-main because the command line cannot see compiler-services, and both can
see this.
-
ClassDescriptionTHE labelling of a call's positional arguments from the parameter names the compiler resolved - use this, do not split an argument list by hand anywhere else.The corrected text plus one note per call labelled;
notesempty means nothing moved.THE E11068 repair - a String built from three or more+parts - for every editing tool.The rewritten text and one note per rewrite;notesempty means nothing moved.E01086 - a baredefault operatorwith something after it in the body.Adefines <block>line (class, function, program, ...) at any indent but two.Main() @Test- an annotation written after the declaration it marks, Java-and-Kotlin style.THE E07901 repair - a double-quoted String holding${- for every editing tool.The rewritten text and one note per rewrite;notesempty means nothing moved.Spellings carried over from other languages that EK9 writes one way and parses no other way.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.The repaired text and one note per repair; notes empty means nothing changed.An operator declaration written in another order than the grammar's[override|default] operator <symbol> [as] [pure] [abstract](operatorDeclaration).THE correction of a custom operator'sas purein source text the Oracle is about to write - use this, do not re-derive the rule from a list of symbols.The corrected text plus one note per line changed;notesempty means nothing moved.THE move of a prefix or suffix operator to its own side of a simple operand -names$to$names,?storedtostored?- for every editing tool.The rewritten text and one note per rewrite;notesempty means nothing moved.Parameters declared the way other languages declare them, rewritten to EK9's one-per-line form.THE E06210 repair for a generic constructed with its parentheses AFTER the type arguments -List of String(),Dict of (String, Integer)(),echo of Integer()- which has ONE reading,List() of String(Steve, 2026-10-08, GENERIC CONSTRUCTION b).The rewritten text and one note per rewrite;notesempty means nothing moved.The parse failures that have MORE than one reading - so no rule rewrites them, but the caller is told the readings (the SUGGEST tier ofdocs/tooling/EK9_TOOLING_IMPROVEMENT_METHOD.md):a % b- EK9 hasmod(the result takes the divisor's sign) andrem(Java's%, the dividend's sign); which one is meant is the writer's to say;assert x, "message"- EK9'sasserttakes no message; dropping it loses what it said;$namein a backtick String -${name}interpolates,\$is a literal dollar; a misspelt keyword (esle,defins) - correcting it changes which code runs, and a word one edit from a keyword is just as often a name (heads,sorts); a block header with nothing indented under it - how far its body extends is a choice.The two?spellings besideQuestionMarkWithValue'sType?: valuethat never parse:<- rtn as String??- a declaration's?written twice (a tool rendering'<- rtn as T?'around aT?it was given, or a model doing the same): one?is meant.THE repair of a declaration written with a?AND a value -<- rtn as String?: String()becomes<- rtn as String: String()- for every editing tool.The rewritten text and one note per rewrite;notesempty means nothing moved.THE E50050 repair - a name declared a second time with<-- where the second<-has ONE reading, for every editing tool.A second declaration as the E50050 message names it - THE reading of that message for this repair and for the MCPRedeclarationHint: the name, the line declaring it again, the line that declared it first.The rewritten text and one note per rewrite;notesempty means nothing moved.Line-level helpers the text rules share: indentation, a line with its literals masked out, the top-level comma split.THE source repair engine - the one place an EK9 source is repaired automatically, for every door:ek9 -ffandek9_format(the TEXT layer), and the MCP editors,ek9_write_file,ek9_edit_fileandek9_compile(the DIAGNOSTIC layer).One diagnostic-layer pass: the repaired text and one note per repair; notes empty means nothing moved.The text layer's outcome.Outcome of aStringConcatRewritercall.One refusal condition.Editor primitive that rewrites a string-concatenation expression ("a" + var + "b") into the equivalent backtick interpolation (`a${var}b`).A+chain rendered as a backtick String, or the first operand that cannot be one: setrenderedwith the operand counts, orconflictKind/reasonnaming the refusal.Shared parse-tree primitives for selection-driven string-expression editors.Result ofStringExpressionClassifier.findEnclosingTextMethodDeclaration(ParseTree, int, int): the resolved text-type and method names ready to feed straight intoek9_edit_localized_textastextTypeName/methodName.THE parse-only check of a piece of EK9 text, for every repair: the syntax errors the ANTLR parser reports, no symbol phase run.A parse tree and the token stream it came from (HIDDEN-channel comments included).One syntax error.One text rule ofSourceRepairs: given a source's lines and the parse failure the parser stopped on, the rewrite that answers it - or null when this rule does not recognise the failure.A rule's rewrite: the new lines, and the note that says what was written and why.THE unbalanced trailing bracket -stdout.println(x)],stdout.println("few")} - for every caller: thestatements[]pre-pass, the MCP diagnostic repairs andek9 -ff.THE E01093 repair - a backtick String closed with a double quote,`${count} items"- for every editing tool.The rewritten text and one note per rewrite;notesempty means nothing moved.THE E08180 repair on a RETURN declaration -<- rtn as Stringwith neither a value nor?- for every editing tool.The rewritten text and one note per rewrite;notesempty means nothing moved.