Interface TextRule

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface interface TextRule
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 applies only where its shape has exactly ONE plausible reading and the literal reading does not parse (so the rewrite cannot change which code runs: the original never ran). The engine keeps a rewrite only when the parse then gets further than before; a rule never needs to re-check that itself.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    A rule's rewrite: the new lines, and the note that says what was written and why.
  • Method Summary

    Modifier and Type
    Method
    Description
    The rewrite of lines answering failure, or null.
  • Method Details

    • apply

      The rewrite of lines answering failure, or null.
      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