Class StringConcatRewriter
java.lang.Object
org.ek9lang.compiler.repair.StringConcatRewriter
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
objectAccessExpressionchains of identifier / method-call- Plain
callexpressions (foo(),bar(x)) - A unary
-or$over one of the above ($totalrenders${$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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionrewrite(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.
-
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 workspacefilePath- absolute path of the target .ek9 sourcesourceText- on-disk source textstartLine- 1-based inclusivestartCol- 1-based inclusiveendLine- 1-based inclusiveendCol- 1-based inclusive
-