Skip to main content

Module inline_function

Module inline_function 

Source
Expand description

Inline-function recipe: replace a single-use function’s call site with its body.

Steps:

  1. Locate the function definition at the given position (line:col may point to the function name in the definition or in a call site)
  2. Find all call sites of this function within the same file (name-match)
  3. Verify the function is called exactly once (or --force to override)
  4. Substitute arguments for parameters throughout the body
  5. Replace the call expression with the inlined body
  6. Remove the function definition

Supported languages: JavaScript, TypeScript (function declarations, arrow-function const bindings). Python (def) and Rust (fn) are structurally similar but less tested.

Conservative: aborts rather than generating broken code.

  • Multiple return statements → error
  • Non-trivial control flow → error
  • Grammar unavailable → error

Structs§

InlineFunctionOutcome
Outcome details for a planned inline-function operation.

Functions§

plan_inline_function
Build an inline-function plan without touching the filesystem.