Skip to main content

Module extract

Module extract 

Source
Expand description

Shared extraction utilities for extract_function (and future inline_symbol).

Provides:

  • detect_free_variables — classify identifier references in a byte range
  • detect_return_value — infer what the extracted function should return
  • generate_extracted_function — produce function text for TS/JS or Python

Structs§

FreeVariableResult
Classification result for free variables in a selected byte range.
ScopeConflict
A detected scope conflict when inlining a function body at a call site.

Enums§

ReturnKind
What the extracted function should return.

Functions§

detect_free_variables
Walk the AST for a byte range and classify every identifier reference.
detect_return_value
Detect what the extracted code range should return.
detect_scope_conflicts
Detect scope conflicts between the call site scope and the function body being inlined.
generate_call_site
Generate the call site text that replaces the extracted range.
generate_extracted_function
Generate the text for an extracted function.
substitute_params
Substitute parameter names with argument expressions in a function body.
validate_single_return
Validate that a function has at most one return statement (suitable for inlining).