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.

  • Class
    Description
    THE 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; notes empty means nothing moved.
    Parameters declared the way other languages declare them (was ParameterDeclarations.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 (was StringConcatRewriter.renderChain).
    A + chain rendered as a backtick String, or the first operand that cannot be one: set rendered with the operand counts, or conflictKind/reason naming 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; notes empty means nothing moved.
    E01086 - a bare default operator with something after it in the body.
    A defines <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; notes empty means nothing moved.
    A foreign spelling (was ForeignSyntax.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 (was ForeignSyntax.blockComment): a C block comment (slash-star ...
    A foreign spelling (was ForeignSyntax.genericType): List<String>() / as List<String> / Dict<K, V> - EK9's List() of String / List of String / Dict of (K, V).
    A foreign spelling (was ForeignSyntax.hashComment): a # note comment line - EK9's // note.
    A foreign spelling (was ForeignSyntax.logicalOperators): a && b / a || b - EK9's a and b / a or b.
    THE line or column of a diagnostic map as the keyed repairs read it: the int of a Number, else -1.
    THE line or column of a diagnostic map read leniently: the int of a Number, or of its text when that parses as one, else -1 (SourceRepairs' syntax layer and ServiceDeclarationForms each held this copy, identical).
    THE join of a source's lines back into its text - the inverse of LinesOf (was SourceLines.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 (was LayoutRepairs.replaceLayoutTabs).
    THE number of leading spaces of a line, for the repairs (was SyntaxProbe.indentOf and SourceLines.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 that JoinedLines gives the text back (was SourceLines.split).
    THE line with its literals masked out, for a text rule searching for code (was SourceLines.masked): the content of every String, backtick String and character literal replaced by MaskedLiterals.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 after index with content, or -1 (was SourceLines.nextContent).
    THE rewrite of one line by a text rule, with its note line 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's as pure in 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; notes empty means nothing moved.
    THE move of a prefix or suffix operator to its own side of a simple operand - names$ to $names, ?stored to stored? - for every editing tool.
    The rewritten text and one note per rewrite; notes empty 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; notes empty means nothing moved.
    Parameters declared the way other languages declare them (was ParameterDeclarations.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 of docs/tooling/EK9_TOOLING_IMPROVEMENT_METHOD.md): a % b - EK9 has mod (the result takes the divisor's sign) and rem (Java's %, the dividend's sign); which one is meant is the writer's to say; assert x, "message" - EK9's assert takes no message; dropping it loses what it said; $name in 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 before index with content, or -1 (was SourceLines.previousContent).
    The two ? spellings beside QuestionMarkWithValue's Type?: value that never parse: <- rtn as String?? - a declaration's ? written twice (a tool rendering '<- rtn as T?' around a T? 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; notes empty means nothing moved.
    THE quoting of a line for a repair's note: stripped, in single quotes (was SourceLines.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 MCP RedeclarationHint: the name, the line declaring it again, the line that declared it first.
    The rewritten text and one note per rewrite; notes empty means nothing moved.
    THE E02090 repair - a trait listed beside another listed trait that already has it (with trait of LoudSpeaker, Speaker where LoudSpeaker with trait of Speaker) - which has ONE reading: delete the redundant name (Steve, 2026-10-11).
    The rewritten text and one note per rewrite; notes empty 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; notes empty means nothing moved.
    THE source repair engine - the one place an EK9 source is repaired automatically, for every door: ek9 -ff and ek9_format (the TEXT layer), and the MCP editors, ek9_write_file, ek9_edit_file and ek9_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 (was StringConcatRewriter.sliceSource, shared by the rewrite and ConcatChainRenderer).
    Outcome of a StringConcatRewriter call.
    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 of SourceRepairs: 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 (was SourceLines.topLevelParts).
    THE unbalanced trailing bracket - stdout.println(x)], stdout.println("few")} - for every caller: the statements[] pre-pass, the MCP diagnostic repairs and ek9 -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; notes empty means nothing moved.
    THE E08180 repair on a RETURN declaration - <- rtn as String with neither a value nor ? - for every editing tool.
    The rewritten text and one note per rewrite; notes empty means nothing moved.