Skip to main content

detect_return_value

Function detect_return_value 

Source
pub fn detect_return_value(
    source: &str,
    tree: &Tree,
    start_byte: usize,
    end_byte: usize,
    enclosing_fn_end_byte: Option<usize>,
    lang: LangId,
) -> ReturnKind
Expand description

Detect what the extracted code range should return.

  1. If there’s an explicit return statement in the range, use its expression.
  2. If a variable declared in-range is referenced after the range (but within the enclosing function), that variable becomes the return value.
  3. Otherwise, void.