Class StringConcatRewriter

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

public final class StringConcatRewriter extends Object
Editor primitive that rewrites a string-concatenation expression ("a" + var + "b") into the equivalent backtick interpolation (`a${var}b`). Selection-driven; single mode; produces a single replace edit.

Idempotent: when the selection is already a backtick literal or a single double-quoted literal, returns applied with meta.outcome = "already-in-target-form" and no edits.

Operand admissibility in V1 is restricted to:

  • String literals (become literal segments)
  • Plain identifier references
  • objectAccessExpression chains of identifier / method-call
  • Plain call expressions (foo(), bar(x))
  • A unary - or $ over one of the above ($total renders ${$total})

Everything else (ternary, logical operators, lambdas, ranges, list/dict literals, etc.) is refused with an escalation conflict. The grammar permits arbitrary expressions inside ${...} but tool policy is stricter — see docs/tooling/tools/ek9_rewrite_string_concat.md.

Each non-literal operand's type must define a _string() operator — this is the semantic admission gate, verified via MethodSymbolSearch against the recorded symbol type.

The chain's rendering is ConcatChainRenderer's, shared with the E11068 repair.

  • Constructor Details

    • StringConcatRewriter

      public StringConcatRewriter()
  • Method Details

    • rewrite

      public StringConcatRewriteOutcome rewrite(CompilableProgram program, Workspace workspace, String filePath, String sourceText, int startLine, int startCol, int endLine, int endCol)
      Rewrite the string-concat expression covered by the selection range.
      Parameters:
      program - current compiled program (read-only)
      workspace - current workspace
      filePath - absolute path of the target .ek9 source
      sourceText - on-disk source text
      startLine - 1-based inclusive
      startCol - 1-based inclusive
      endLine - 1-based inclusive
      endCol - 1-based inclusive