@@ -51,7 +51,7 @@ use super::remove_unused_param::range_to_remove;
51
51
// }
52
52
// ```
53
53
pub ( crate ) fn extract_module ( acc : & mut Assists , ctx : & AssistContext ) -> Option < ( ) > {
54
- if ctx. frange . range . is_empty ( ) {
54
+ if ctx. has_empty_selection ( ) {
55
55
return None ;
56
56
}
57
57
@@ -66,7 +66,7 @@ pub(crate) fn extract_module(acc: &mut Assists, ctx: &AssistContext) -> Option<(
66
66
curr_parent_module = ast:: Module :: cast ( mod_syn_opt) ;
67
67
}
68
68
69
- let mut module = extract_target ( & node, ctx. frange . range ) ?;
69
+ let mut module = extract_target ( & node, ctx. selection_trimmed ( ) ) ?;
70
70
if module. body_items . len ( ) == 0 {
71
71
return None ;
72
72
}
@@ -119,7 +119,7 @@ pub(crate) fn extract_module(acc: &mut Assists, ctx: &AssistContext) -> Option<(
119
119
120
120
let mut usages_to_be_updated_for_curr_file = vec ! [ ] ;
121
121
for usages_to_be_updated_for_file in usages_to_be_processed {
122
- if usages_to_be_updated_for_file. 0 == ctx. frange . file_id {
122
+ if usages_to_be_updated_for_file. 0 == ctx. file_id ( ) {
123
123
usages_to_be_updated_for_curr_file = usages_to_be_updated_for_file. 1 ;
124
124
continue ;
125
125
}
@@ -129,7 +129,7 @@ pub(crate) fn extract_module(acc: &mut Assists, ctx: &AssistContext) -> Option<(
129
129
}
130
130
}
131
131
132
- builder. edit_file ( ctx. frange . file_id ) ;
132
+ builder. edit_file ( ctx. file_id ( ) ) ;
133
133
for usage_to_be_processed in usages_to_be_updated_for_curr_file {
134
134
builder. replace ( usage_to_be_processed. 0 , usage_to_be_processed. 1 )
135
135
}
@@ -426,11 +426,11 @@ impl Module {
426
426
ctx : & AssistContext ,
427
427
) -> Option < TextRange > {
428
428
//We only need to find in the current file
429
- let selection_range = ctx. frange . range ;
430
- let search_scope = SearchScope :: single_file ( ctx. frange . file_id ) ;
429
+ let selection_range = ctx. selection_trimmed ( ) ;
430
+ let curr_file_id = ctx. file_id ( ) ;
431
+ let search_scope = SearchScope :: single_file ( curr_file_id) ;
431
432
let usage_res = def. usages ( & ctx. sema ) . in_scope ( search_scope) . all ( ) ;
432
- let curr_file_id = ctx. frange . file_id ;
433
- let file = ctx. sema . parse ( ctx. frange . file_id ) ;
433
+ let file = ctx. sema . parse ( curr_file_id) ;
434
434
435
435
let mut exists_inside_sel = false ;
436
436
let mut exists_outside_sel = false ;
@@ -470,7 +470,7 @@ impl Module {
470
470
let use_stmt_opt: Option < ast:: Use > = usage_res. into_iter ( ) . find_map ( |x| {
471
471
let file_id = x. 0 ;
472
472
let mut use_opt: Option < ast:: Use > = None ;
473
- if file_id == ctx . frange . file_id {
473
+ if file_id == curr_file_id {
474
474
( & x. 1 ) . into_iter ( ) . for_each ( |x| {
475
475
let node_opt: Option < ast:: Use > = find_node_at_range ( file. syntax ( ) , x. range ) ;
476
476
if let Some ( node) = node_opt {
0 commit comments