@@ -70,8 +70,8 @@ pub(crate) fn extract_function(acc: &mut Assists, ctx: &AssistContext<'_>) -> Op
7070 }
7171
7272 let node = ctx. covering_element ( ) ;
73- if node. kind ( ) == SyntaxKind :: L_CURLY || node . kind ( ) == SyntaxKind :: R_CURLY {
74- cov_mark:: hit!( extract_function_in_curly_bracket_is_not_applicable ) ;
73+ if matches ! ( node. kind( ) , T ! [ '{' ] | T ! [ '}' ] | T ! [ '(' ] | T ! [ ')' ] | T ! [ '[' ] | T ! [ ']' ] ) {
74+ cov_mark:: hit!( extract_function_in_braces_is_not_applicable ) ;
7575 return None ;
7676 }
7777
@@ -5808,13 +5808,37 @@ fn $0fun_name() -> ControlFlow<()> {
58085808
58095809 #[ test]
58105810 fn in_left_curly_is_not_applicable ( ) {
5811- cov_mark:: check!( extract_function_in_curly_bracket_is_not_applicable ) ;
5812- check_assist_not_applicable ( extract_function, r"fn foo() { $0}$0 " ) ;
5811+ cov_mark:: check!( extract_function_in_braces_is_not_applicable ) ;
5812+ check_assist_not_applicable ( extract_function, r"fn foo() { $0}$0" ) ;
58135813 }
58145814
58155815 #[ test]
58165816 fn in_right_curly_is_not_applicable ( ) {
5817- cov_mark:: check!( extract_function_in_curly_bracket_is_not_applicable) ;
5818- check_assist_not_applicable ( extract_function, r"fn foo() $0{$0 } " ) ;
5817+ cov_mark:: check!( extract_function_in_braces_is_not_applicable) ;
5818+ check_assist_not_applicable ( extract_function, r"fn foo() $0{$0 }" ) ;
5819+ }
5820+
5821+ #[ test]
5822+ fn in_left_paren_is_not_applicable ( ) {
5823+ cov_mark:: check!( extract_function_in_braces_is_not_applicable) ;
5824+ check_assist_not_applicable ( extract_function, r"fn foo( $0)$0 { }" ) ;
5825+ }
5826+
5827+ #[ test]
5828+ fn in_right_paren_is_not_applicable ( ) {
5829+ cov_mark:: check!( extract_function_in_braces_is_not_applicable) ;
5830+ check_assist_not_applicable ( extract_function, r"fn foo $0($0 ) { }" ) ;
5831+ }
5832+
5833+ #[ test]
5834+ fn in_left_brack_is_not_applicable ( ) {
5835+ cov_mark:: check!( extract_function_in_braces_is_not_applicable) ;
5836+ check_assist_not_applicable ( extract_function, r"fn foo(arr: &mut [i32$0]$0) {}" ) ;
5837+ }
5838+
5839+ #[ test]
5840+ fn in_right_brack_is_not_applicable ( ) {
5841+ cov_mark:: check!( extract_function_in_braces_is_not_applicable) ;
5842+ check_assist_not_applicable ( extract_function, r"fn foo(arr: &mut $0[$0i32]) {}" ) ;
58195843 }
58205844}
0 commit comments