@@ -8439,18 +8439,15 @@ impl<'a> ExtractedFunction<'a> {
8439
8439
fn location ( & self ) -> SrcSpan {
8440
8440
match & self . value {
8441
8441
ExtractedValue :: Expression ( expression) => expression. location ( ) ,
8442
- ExtractedValue :: Statements ( statements) => SrcSpan :: new (
8443
- statements. first ( ) . location ( ) . start ,
8444
- statements. last ( ) . location ( ) . end ,
8445
- ) ,
8442
+ ExtractedValue :: Statements ( location) => * location,
8446
8443
}
8447
8444
}
8448
8445
}
8449
8446
8450
8447
#[ derive( Debug ) ]
8451
8448
enum ExtractedValue < ' a > {
8452
8449
Expression ( & ' a TypedExpr ) ,
8453
- Statements ( Vec1 < & ' a TypedStatement > ) ,
8450
+ Statements ( SrcSpan ) ,
8454
8451
}
8455
8452
8456
8453
impl < ' a > ExtractFunction < ' a > {
@@ -8486,8 +8483,8 @@ impl<'a> ExtractFunction<'a> {
8486
8483
ExtractedValue :: Expression ( expression) => {
8487
8484
self . extract_expression ( expression, extracted. parameters , end)
8488
8485
}
8489
- ExtractedValue :: Statements ( statements ) => self . extract_statements (
8490
- statements ,
8486
+ ExtractedValue :: Statements ( location ) => self . extract_statements (
8487
+ location ,
8491
8488
extracted. parameters ,
8492
8489
extracted. returned_variables ,
8493
8490
end,
@@ -8599,16 +8596,11 @@ impl<'a> ExtractFunction<'a> {
8599
8596
8600
8597
fn extract_statements (
8601
8598
& mut self ,
8602
- statements : Vec1 < & TypedStatement > ,
8599
+ location : SrcSpan ,
8603
8600
parameters : Vec < ( EcoString , Arc < Type > ) > ,
8604
8601
returned_variables : Vec < ( EcoString , Arc < Type > ) > ,
8605
8602
function_end : u32 ,
8606
8603
) {
8607
- let first = statements. first ( ) ;
8608
- let last = statements. last ( ) ;
8609
-
8610
- let location = SrcSpan :: new ( first. location ( ) . start , last. location ( ) . end ) ;
8611
-
8612
8604
let code = code_at ( self . module , location) ;
8613
8605
8614
8606
let returns_anything = !returned_variables. is_empty ( ) ;
@@ -8720,20 +8712,18 @@ impl<'ast> ast::visit::Visit<'ast> for ExtractFunction<'ast> {
8720
8712
if within ( range, self . params . range ) {
8721
8713
match & mut self . extract {
8722
8714
None => {
8723
- self . extract = Some ( ExtractedFunction :: new ( ExtractedValue :: Statements ( vec1 ! [
8724
- statement,
8725
- ] ) ) ) ;
8715
+ self . extract = Some ( ExtractedFunction :: new ( ExtractedValue :: Statements (
8716
+ statement. location ( ) ,
8717
+ ) ) ) ;
8726
8718
}
8727
8719
Some ( ExtractedFunction {
8728
8720
value : ExtractedValue :: Expression ( _) ,
8729
8721
..
8730
8722
} ) => { }
8731
8723
Some ( ExtractedFunction {
8732
- value : ExtractedValue :: Statements ( statements ) ,
8724
+ value : ExtractedValue :: Statements ( location ) ,
8733
8725
..
8734
- } ) => {
8735
- statements. push ( statement) ;
8736
- }
8726
+ } ) => * location = location. merge ( & statement. location ( ) ) ,
8737
8727
}
8738
8728
}
8739
8729
ast:: visit:: visit_typed_statement ( self , statement) ;
0 commit comments