Skip to main content

Module add_parameter

Module add_parameter 

Source
Expand description

Add-parameter recipe: insert a new parameter into a function signature and update all call sites.

Algorithm:

  1. Parse file with tree-sitter; locate the function declaration named function_name.
  2. Find the parameter list node; determine insertion byte position.
  3. Build the parameter text for the definition (name + optional type annotation).
  4. Find all call sites via the facts index (find_callers). Falls back to text search if the index is unavailable, with a warning.
  5. At each call site: find the argument list; insert default_value at position.
  6. Return a RefactoringPlan with one PlannedEdit per affected file.

Language support: Rust, TypeScript/JavaScript, Python. Node kinds by language:

  • Rust: function_itemparameters, args in arguments
  • Python: function_definitionparameters, args in argument_list
  • JS/TS: function_declaration/function/method_definition/arrow_functionformal_parameters, args in arguments

Structs§

AddParameterOutcome
Outcome of a successful add-parameter plan.

Functions§

plan_add_parameter
Build an add-parameter plan without touching the filesystem.