Class DefinesPlacement

java.lang.Object
org.ek9lang.compiler.repair.DefinesPlacement
All Implemented Interfaces:
TextRule

final class DefinesPlacement extends Object implements TextRule
A defines <block> line (class, function, program, ...) at any indent but two. Only defines module sits at column 0; every other defines opens a block of that module and sits at exactly two spaces - the grammar admits no other place, so moving it there is the only reading. Measured: 48 harness events (22 at column 0), nearly all from multi-line edit_file replacements.

The block's content moves WITH the header when it was written relative to it (header at 0, content at 2), and stays when it already sits at 4 - the depth it belongs at. Content at any other depth leaves the rule out.

  • Constructor Details

    • DefinesPlacement

      DefinesPlacement()
  • Method Details

    • apply

      public TextRule.Rewrite apply(List<String> lines, SyntaxProbe.SyntaxError failure)
      Description copied from interface: TextRule
      The rewrite of lines answering failure, or null.
      Specified by:
      apply in interface TextRule
      Parameters:
      lines - the source's lines (never modified by a rule - a rewrite carries its own copy)
      failure - the first syntax error, as the parser reported it