ek9_inline_variable
Deletes a single-assignment local's declaration and substitutes its initialiser at every use site (including `${...}` holes); answers status, edits[] and conflicts[] (variable-reassigned, impure-initialiser-multi-use, ...).
When to use it
'Inline the local subtotal' is one call with file + symbol:'subtotal' - no line needed; 'inline both locals' is one call with symbols:['prefix','message']. Use it on a LOCAL whose name adds no clarity over its short initialiser, or one an earlier refactor extracted and no longer needs.
When not to use it
- Variable has ZERO references - nothing to inline; use
ek9_safe_deleteto remove it. - You want the OPPOSITE (lift an expression INTO a new local) — use
ek9_extract_variable. - Target is a FUNCTION, not a variable — use
ek9_inline_function. - Target is a field, parameter, module constant or `<- rtn` return variable — locals only; no inline tool exists for those.
Details
A call-free initialiser inlines at any number of uses; a call-bearing one only at a SINGLE use site (V1 refuses multi-use: impure-initialiser-multi-use). Other conflict kinds: variable-reassigned, multi-line-initialiser, variable-is-guard, variable-has-no-references; fields, parameters, return variables and lines not on a local declaration return status:error. Pairs with ek9_extract_method to collapse the destructuring locals a multiReturn container leaves at the call site.
Arguments
| Argument | Type | Required | What it is |
|---|---|---|---|
file | string | yes | Workspace-relative path to the .ek9 source file holding the local declaration. |
line | integer | 1-based line of the declaration or a reference - OMIT it and pass symbol:'<name>' to let the tool find the line (a model counting lines in a file miscounts); if you do count, use ek9_read_file(lineNumbers:true). | |
symbol | string | The identifier you mean (e.g. 'total'); the tool finds its declaration line in file. Pass line only to anchor one specific occurrence. | |
symbols | array of string | Several locals to inline as ONE change, in this order (e.g. ['prefix','message']) - all or none. Instead of symbol. |
It also takes the arguments every tool takes.
Recorded calls
Real calls, recorded against small projects and checked on every build - a changed answer fails it.
Two locals one change
Request
{
"file" : "task.ek9",
"symbols" : [ "prefix", "message" ]
}
Response
{
"conflicts" : [ ],
"edits" : [ {
"after" : " rtn: \"Hello, \" + name",
"before" : " prefix <- \"Hello, \"\n message <- prefix + name\n rtn: message",
"endLine" : 11,
"file" : "task.ek9",
"startLine" : 9,
"type" : "replace"
} ],
"meta" : {
"serverMs" : "<timing>"
},
"resolvedPath" : "<workspace-root>/task.ek9",
"risk" : {
"crossesModuleBoundary" : false,
"estimatedSeverity" : "trivial",
"fileCount" : 1,
"lineCount" : 3,
"touchesPublicApi" : false,
"touchesTests" : false
},
"status" : "applied",
"summary" : "Would inline 'prefix' (1 use) — remove declaration + substitute 1 line; Would inline 'message' (1 use) — remove declaration + substitute 1 line",
...
Cut short here: 4 more lines. The whole recorded call.
See also
- Show me in the IDE: Chapter 2: values, reshaped
- Show me in the IDE: Inline Variable
- Show me in the IDE: Inline Candidates