Class ServiceDeclarationForms

java.lang.Object
org.ek9lang.compiler.repair.ServiceDeclarationForms

public final class ServiceDeclarationForms extends Object
THE service-form repair (Steve, 2026-10-11: one form each) - for every editing tool. Use this; do not re-derive it. Three slips, each with ONE reading, each keyed on the diagnostic that proves it:
  • E07671 'for' missing before ':/items' - Items :/items open becomes Items for :/items open, byId() as GET :/{id} becomes byId() as GET for :/{id}.
  • E07671 'as' missing before 'GET' - byId() GET for :/{id} becomes byId() as GET for :/{id}.
  • E07670 '+' (use '+=') - a service operator + becomes operator += (POST, a mutating add to the collection), and operator - becomes operator -= (DELETE).

Each rewrite stays within its line. The compiler keeps only the first error on a line, so a line missing both words is repaired over two passes of the caller's loop.

  • Method Details

    • mayApply

      public static boolean mayApply(String text)
      True when text may hold one of the three slips.
    • repair

      public static ServiceDeclarationForms.Result repair(String text, List<Map<String,Object>> diagnostics)
      One pass: every slip a diagnostic proves, right to left on each line so earlier columns stay put.
    • inserted

      static String inserted(String source, String keyword, String token, int column)
      source with keyword and a space inserted before token: at column when the token starts there, else at its one whole-word occurrence on the line; null when neither holds.