Class CommentFormatter

java.lang.Object
org.ek9lang.compiler.formatter.CommentFormatter

final class CommentFormatter extends Object
Pass 4 of the EK9 source formatter: Comment Interior Re-indentation.

After Passes 1-3, multi-line comments have a misalignment issue: the opening line (<?-, <!-, <!--) is correctly indented by Pass 1, but interior lines (content + closing marker) are preserved from the original source. This pass computes the delta between the opening and closing line indents and applies that delta to all interior lines.

The algorithm is idempotent: after first application, closing matches opening (delta = 0), so a second run produces no changes.

  • Constructor Details

    • CommentFormatter

      CommentFormatter()
  • Method Details

    • format

      String format(String source)
      Apply comment interior re-indentation to the given EK9 source.
      Parameters:
      source - The EK9 source code (already indented, reordered, and spaced).
      Returns:
      The source with comment interiors re-indented, or null if parsing fails.