@@ -5,7 +5,7 @@ use hir::{Adt, HasSource, ModuleDef, Semantics};
5
5
use ide_db:: helpers:: { mod_path_to_ast, FamousDefs } ;
6
6
use ide_db:: RootDatabase ;
7
7
use itertools:: Itertools ;
8
- use syntax:: ast:: { self , AstNode , HasName , MatchArm , MatchArmList , MatchExpr , Pat , make } ;
8
+ use syntax:: ast:: { self , make , AstNode , HasName , MatchArm , MatchArmList , MatchExpr , Pat } ;
9
9
use syntax:: TextRange ;
10
10
11
11
use crate :: {
@@ -40,9 +40,9 @@ use crate::{
40
40
pub ( crate ) fn add_missing_match_arms ( acc : & mut Assists , ctx : & AssistContext ) -> Option < ( ) > {
41
41
let match_expr = ctx. find_node_at_offset_with_descend :: < ast:: MatchExpr > ( ) ?;
42
42
let match_arm_list = match_expr. match_arm_list ( ) ?;
43
- let target_range : TextRange ;
43
+ let target_range: TextRange ;
44
44
45
- if let None = trivial_match_arm_list_at_cursor ( & ctx, & match_expr, & match_arm_list) {
45
+ if let None = cursor_at_trivial_match_arm_list ( & ctx, & match_expr, & match_arm_list) {
46
46
target_range = TextRange :: new (
47
47
ctx. sema . original_range ( match_expr. syntax ( ) ) . range . start ( ) ,
48
48
ctx. sema . original_range ( match_arm_list. syntax ( ) ) . range . start ( ) ,
@@ -52,8 +52,7 @@ pub(crate) fn add_missing_match_arms(acc: &mut Assists, ctx: &AssistContext) ->
52
52
if !cursor_in_range {
53
53
return None ;
54
54
}
55
- }
56
- else {
55
+ } else {
57
56
target_range = ctx. sema . original_range ( match_expr. syntax ( ) ) . range ;
58
57
}
59
58
@@ -193,7 +192,11 @@ pub(crate) fn add_missing_match_arms(acc: &mut Assists, ctx: &AssistContext) ->
193
192
)
194
193
}
195
194
196
- fn trivial_match_arm_list_at_cursor ( ctx : & AssistContext , match_expr : & MatchExpr , match_arm_list : & MatchArmList ) -> Option < ( ) > {
195
+ fn cursor_at_trivial_match_arm_list (
196
+ ctx : & AssistContext ,
197
+ match_expr : & MatchExpr ,
198
+ match_arm_list : & MatchArmList ,
199
+ ) -> Option < ( ) > {
197
200
// match x { $0 }
198
201
if match_arm_list. arms ( ) . next ( ) == None {
199
202
return Some ( ( ) ) ;
@@ -204,7 +207,7 @@ fn trivial_match_arm_list_at_cursor(ctx: &AssistContext, match_expr : &MatchExpr
204
207
let arm = wild_pat. syntax ( ) . parent ( ) . and_then ( ast:: MatchArm :: cast) ?;
205
208
let arm_match_expr = arm. syntax ( ) . ancestors ( ) . nth ( 2 ) . and_then ( ast:: MatchExpr :: cast) ?;
206
209
if arm_match_expr == * match_expr {
207
- return Some ( ( ) )
210
+ return Some ( ( ) ) ;
208
211
}
209
212
210
213
None
@@ -975,7 +978,6 @@ fn main() {
975
978
) ;
976
979
}
977
980
978
-
979
981
#[ test]
980
982
fn wildcard_inside_expression_not_applicable ( ) {
981
983
check_assist_not_applicable (
0 commit comments