@@ -3,11 +3,10 @@ use std::convert::TryFrom;
33use ide_assists:: utils:: extract_trivial_expression;
44use itertools:: Itertools ;
55use syntax:: {
6- algo:: non_trivia_sibling,
76 ast:: { self , AstNode , AstToken , IsString } ,
8- Direction , NodeOrToken , SourceFile , SyntaxElement ,
7+ NodeOrToken , SourceFile , SyntaxElement ,
98 SyntaxKind :: { self , USE_TREE , WHITESPACE } ,
10- SyntaxNode , SyntaxToken , TextRange , TextSize , T ,
9+ SyntaxToken , TextRange , TextSize , T ,
1110} ;
1211
1312use text_edit:: { TextEdit , TextEditBuilder } ;
@@ -204,13 +203,6 @@ fn remove_newline(
204203 edit. replace ( token. text_range ( ) , compute_ws ( prev. kind ( ) , next. kind ( ) ) . to_string ( ) ) ;
205204}
206205
207- fn has_comma_after ( node : & SyntaxNode ) -> bool {
208- match non_trivia_sibling ( node. clone ( ) . into ( ) , Direction :: Next ) {
209- Some ( n) => n. kind ( ) == T ! [ , ] ,
210- _ => false ,
211- }
212- }
213-
214206fn join_single_expr_block ( edit : & mut TextEditBuilder , token : & SyntaxToken ) -> Option < ( ) > {
215207 let block_expr = ast:: BlockExpr :: cast ( token. parent ( ) ?) ?;
216208 if !block_expr. is_standalone ( ) {
@@ -223,7 +215,7 @@ fn join_single_expr_block(edit: &mut TextEditBuilder, token: &SyntaxToken) -> Op
223215
224216 // Match block needs to have a comma after the block
225217 if let Some ( match_arm) = block_expr. syntax ( ) . parent ( ) . and_then ( ast:: MatchArm :: cast) {
226- if ! has_comma_after ( match_arm. syntax ( ) ) {
218+ if match_arm. comma_token ( ) . is_none ( ) {
227219 buf. push ( ',' ) ;
228220 }
229221 }
0 commit comments