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. Every class here is held as an instance, never
called statically; the string-expression primitives the editors share are in
org.ek9lang.compiler.repair.expressions.
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.Parameters declared the way other languages declare them (wasParameterDeclarations.commaSeparated):-> a as Integer, b as String- several parameters on one->line.THE rendering of a+chain as one backtick String - shared by the rewrite tool (StringConcatRewriter) and the E11068 repair (ConcatenationInterpolation); hold one, do not re-derive the operand rules (wasStringConcatRewriter.renderChain).A+chain rendered as a backtick String, or the first operand that cannot be one: setrenderedwith the operand counts, orconflictKind/reasonnaming the refusal.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.A foreign spelling (wasForeignSyntax.trailingColon): a trailing:on a control line (if x:,else:,while x:) - Python's block colon; EK9 blocks are opened by indentation alone.A foreign spelling (wasForeignSyntax.blockComment): a C block comment (slash-star ...A foreign spelling (wasForeignSyntax.genericType):List<String>()/as List<String>/Dict<K, V>- EK9'sList() of String/List of String/Dict of (K, V).A foreign spelling (wasForeignSyntax.hashComment): a# notecomment line - EK9's// note.A foreign spelling (wasForeignSyntax.logicalOperators):a && b/a || b- EK9'sa and b/a or b.THE line or column of a diagnostic map as the keyed repairs read it: the int of aNumber, else -1.THE line or column of a diagnostic map read leniently: the int of aNumber, or of its text when that parses as one, else -1 (SourceRepairs' syntax layer andServiceDeclarationFormseach held this copy, identical).THE join of a source's lines back into its text - the inverse ofLinesOf(wasSourceLines.join).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.THE tab rule: a source with each LAYOUT tab replaced by two spaces (wasLayoutRepairs.replaceLayoutTabs).THE number of leading spaces of a line, for the repairs (wasSyntaxProbe.indentOfandSourceLines.indent, the second delegating to the first).THE split of a source into its lines for the text rules: a mutable list, keeping a trailing empty line so thatJoinedLinesgives the text back (wasSourceLines.split).THE line with its literals masked out, for a text rule searching for code (wasSourceLines.masked): the content of every String, backtick String and character literal replaced byMaskedLiterals.MASK, and a trailing//comment likewise - same length, so an index found in the mask is an index in the line.THE index of the nearest line afterindexwith content, or -1 (wasSourceLines.nextContent).THE rewrite of one line by a text rule, with its noteline N: 'was' -> 'now' - why.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.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.Parameters declared the way other languages declare them (wasParameterDeclarations.inParentheses):add(name as String)/label(first: String, last: String)- Java's parameter list on a DECLARATION line.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 index of the nearest line beforeindexwith content, or -1 (wasSourceLines.previousContent).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 quoting of a line for a repair's note: stripped, in single quotes (wasSourceLines.quoted).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.THE E02090 repair - a trait listed beside another listed trait that already has it (with trait of LoudSpeaker, SpeakerwhereLoudSpeaker with trait of Speaker) - which has ONE reading: delete the redundant name (Steve, 2026-10-11).The rewritten text and one note per rewrite;notesempty means nothing moved.THE service-form repair (Steve, 2026-10-11: one form each) - for every editing tool.The rewritten text and one note per rewrite;notesempty means nothing moved.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.THE slice of a source text a rule spans, by its tokens' start and stop character indices into that text; null when the rule has no tokens or the indices fall outside the text (wasStringConcatRewriter.sliceSource, shared by the rewrite andConcatChainRenderer).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`).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 parts of a text between its top-level commas - a comma inside brackets or a literal does not split - each stripped; one part when there is no such comma (wasSourceLines.topLevelParts).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.