Skip to main content

extraction_target

Function extraction_target 

Source
fn extraction_target(
    node: &SyntaxNode,
    selection_range: TextRange,
) -> Option<FunctionBody>
Expand description

Try to guess what user wants to extract

We have basically have two cases:

  • We want whole node, like loop {}, 2 + 2, { let n = 1; } exprs. Then we can use ast::Expr
  • We want a few statements for a block. E.g.
    fn foo() -> i32 {
      let m = 1;
      $0
      let n = 2;
      let k = 3;
      k + n
      $0
    }