@@ -328,41 +328,37 @@ fn find(pattern: &SsrPattern, code: &SyntaxNode) -> SsrMatches {
328
328
if placeholders. iter ( ) . any ( |n| n. 0 . as_str ( ) == pattern. text ( ) ) {
329
329
match_. binding . insert ( Var ( pattern. text ( ) . to_string ( ) ) , code. clone ( ) ) ;
330
330
Some ( match_)
331
+ } else if let ( Some ( pattern) , Some ( code) ) =
332
+ ( RecordLit :: cast ( pattern. clone ( ) ) , RecordLit :: cast ( code. clone ( ) ) )
333
+ {
334
+ check_record_lit ( pattern, code, placeholders, match_)
335
+ } else if let ( Some ( pattern) , Some ( code) ) =
336
+ ( CallExpr :: cast ( pattern. clone ( ) ) , MethodCallExpr :: cast ( code. clone ( ) ) )
337
+ {
338
+ check_call_and_method_call ( pattern, code, placeholders, match_)
339
+ } else if let ( Some ( pattern) , Some ( code) ) =
340
+ ( MethodCallExpr :: cast ( pattern. clone ( ) ) , CallExpr :: cast ( code. clone ( ) ) )
341
+ {
342
+ check_method_call_and_call ( pattern, code, placeholders, match_)
331
343
} else {
332
- if let ( Some ( pattern) , Some ( code) ) =
333
- ( RecordLit :: cast ( pattern. clone ( ) ) , RecordLit :: cast ( code. clone ( ) ) )
334
- {
335
- check_record_lit ( pattern, code, placeholders, match_)
336
- } else if let ( Some ( pattern) , Some ( code) ) =
337
- ( CallExpr :: cast ( pattern. clone ( ) ) , MethodCallExpr :: cast ( code. clone ( ) ) )
338
- {
339
- check_call_and_method_call ( pattern, code, placeholders, match_)
340
- } else if let ( Some ( pattern) , Some ( code) ) =
341
- ( MethodCallExpr :: cast ( pattern. clone ( ) ) , CallExpr :: cast ( code. clone ( ) ) )
342
- {
343
- check_method_call_and_call ( pattern, code, placeholders, match_)
344
- } else {
345
- let mut pattern_children = pattern
346
- . children_with_tokens ( )
347
- . filter ( |element| !element. kind ( ) . is_trivia ( ) ) ;
348
- let mut code_children = code
349
- . children_with_tokens ( )
350
- . filter ( |element| !element. kind ( ) . is_trivia ( ) ) ;
351
- let new_ignored_comments =
352
- code. children_with_tokens ( ) . filter_map ( |element| {
353
- element. as_token ( ) . and_then ( |token| Comment :: cast ( token. clone ( ) ) )
354
- } ) ;
355
- match_. ignored_comments . extend ( new_ignored_comments) ;
356
- pattern_children
357
- . by_ref ( )
358
- . zip ( code_children. by_ref ( ) )
359
- . fold ( Some ( match_) , |accum, ( a, b) | {
360
- accum. and_then ( |match_| check ( & a, & b, placeholders, match_) )
361
- } )
362
- . filter ( |_| {
363
- pattern_children. next ( ) . is_none ( ) && code_children. next ( ) . is_none ( )
364
- } )
365
- }
344
+ let mut pattern_children = pattern
345
+ . children_with_tokens ( )
346
+ . filter ( |element| !element. kind ( ) . is_trivia ( ) ) ;
347
+ let mut code_children =
348
+ code. children_with_tokens ( ) . filter ( |element| !element. kind ( ) . is_trivia ( ) ) ;
349
+ let new_ignored_comments = code. children_with_tokens ( ) . filter_map ( |element| {
350
+ element. as_token ( ) . and_then ( |token| Comment :: cast ( token. clone ( ) ) )
351
+ } ) ;
352
+ match_. ignored_comments . extend ( new_ignored_comments) ;
353
+ pattern_children
354
+ . by_ref ( )
355
+ . zip ( code_children. by_ref ( ) )
356
+ . fold ( Some ( match_) , |accum, ( a, b) | {
357
+ accum. and_then ( |match_| check ( & a, & b, placeholders, match_) )
358
+ } )
359
+ . filter ( |_| {
360
+ pattern_children. next ( ) . is_none ( ) && code_children. next ( ) . is_none ( )
361
+ } )
366
362
}
367
363
}
368
364
_ => None ,
0 commit comments