Class Ek9SourceFormatter
java.lang.Object
org.ek9lang.compiler.formatter.Ek9SourceFormatter
Orchestrates the EK9 source code formatting pipeline.
Implements a multi-pass approach:
- Pass 1: Canonical indentation (2-space, from INDENT/DEDENT tokens)
- Pass 2: Structural reordering (reference sorting, block ordering, overload colocation)
- Pass 3: Token spacing (operator spacing, canonical whitespace)
- Pass 4: Line splitting (long line breaking for params, streams, expressions)
- Pass 5: Comment formatting (doc comment indentation and wrapping)
For unparseable files, a Tier 2 pipeline (force mode) attempts error-guided iterative refinement to achieve a parseable state before applying the Tier 1 pipeline.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionforceFormat(String source) Force-format the given EK9 source code.Format the given EK9 source code using the Tier 1 pipeline.
-
Constructor Details
-
Ek9SourceFormatter
public Ek9SourceFormatter()
-
-
Method Details
-
format
Format the given EK9 source code using the Tier 1 pipeline. The input must be parseable. If not, returns a failure result.- Parameters:
source- The EK9 source code to format.- Returns:
- The formatting result containing the formatted output or error information.
-
forceFormat
Force-format the given EK9 source code. Attempts Tier 2 error-guided refinement for unparseable files, then applies the Tier 1 pipeline if successful.- Parameters:
source- The EK9 source code to format (may be unparseable).- Returns:
- The formatting result containing the formatted output or error information.
-