ek9_inline_function
Replaces every call to a FUNCTION or METHOD with its parameter-substituted body and deletes the declaration; answers status, edits[] (one REPLACE per call site + the DELETE) and conflicts[] (kind 'variable-clash' with {name, suggestedName}).
When to use it
'Inline the function formatLabel everywhere' is one call with symbol:'formatLabel' - no file or line needed. Use it on a trivial FUNCTION or METHOD ('Type.method') whose name no longer earns its abstraction.
When not to use it
- The function has ZERO call sites - just delete it with
ek9_safe_delete(inline returns conflict no-call-sites). - You want the OPPOSITE — factor a block OUT into a new function — use
ek9_extract_method. - The target is a LOCAL VARIABLE, not a function — use
ek9_inline_variable. - Operator/constructor/abstract (error), recursive (direct or mutual), or dispatcher/override/trait-dispatch targets — no inlinable expansion; refactor or keep the abstraction.
- A METHOD called on another object (obj.method()) or whose body reads 'this' or a field — conflicts receiver-qualified-callsite / this-or-field-capture; it needs its object.
Details
scope: all-call-sites (default; inline everywhere then delete decl) | single-call-site (requires callSiteFile/Line, callSiteColumn defaults to 1; decl kept). An expression-bodied function (name() <- rtn as T: EXPR) inlines at any call context; a multi-statement body inlines only where the call is the whole statement (bare, or RHS of <- / :=), its rtn mapping to the assignment target. A donor-local clash returns conflicts kind 'variable-clash' with clashes[] of {name, suggestedName} — rename via ek9_rename_symbol then re-run (the tool never auto-renames); recursion, dispatcher/override, this/field capture, named arguments and discarded return refuse cleanly as other conflict kinds, and anything subtler (e.g. an E08130 purity violation) surfaces as would-fail — never silent broken source.
Arguments
| Argument | Type | Required | What it is |
|---|---|---|---|
callSite | object | single-call-site only: {file, line} of the ONE call to inline - the function's name on that line is found for you; column (0-based, an IDE cursor) is optional. The flat callSiteFile / callSiteLine / callSiteColumn (1-based) are the IDE form of the same thing. | |
callSiteColumn | integer | IDE form - column (1-based) on the call name; the name is found on the line when omitted. | |
callSiteFile | string | IDE form of callSite.file - workspace-relative file of the target call. | |
callSiteLine | integer | IDE form of callSite.line - line (1-based) of the target call. | |
file | string | The EK9 source file - OPTIONAL when symbol is a construct name; required to anchor on a member or a use site. | |
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). | |
scope | string: all-call-sites | single-call-site | all-call-sites (default): inline every call (via the Phase-5 call graph, across files) and remove the declaration. single-call-site: inline just the call at callSite:{file, line} and keep the declaration. | |
symbol | string | A construct NAME alone ('Shape', 'sample.deps.core::Validator') - no file needed, the tool finds it workspace-wide; or, with file (+ line), the identifier you mean there. |
It also takes the arguments every tool takes.
See also
- Show me in the IDE: Inline Function