@@ -3,11 +3,10 @@ use std::convert::TryFrom;
3
3
use ide_assists:: utils:: extract_trivial_expression;
4
4
use itertools:: Itertools ;
5
5
use syntax:: {
6
- algo:: non_trivia_sibling,
7
6
ast:: { self , AstNode , AstToken , IsString } ,
8
- Direction , NodeOrToken , SourceFile , SyntaxElement ,
7
+ NodeOrToken , SourceFile , SyntaxElement ,
9
8
SyntaxKind :: { self , USE_TREE , WHITESPACE } ,
10
- SyntaxNode , SyntaxToken , TextRange , TextSize , T ,
9
+ SyntaxToken , TextRange , TextSize , T ,
11
10
} ;
12
11
13
12
use text_edit:: { TextEdit , TextEditBuilder } ;
@@ -204,13 +203,6 @@ fn remove_newline(
204
203
edit. replace ( token. text_range ( ) , compute_ws ( prev. kind ( ) , next. kind ( ) ) . to_string ( ) ) ;
205
204
}
206
205
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
-
214
206
fn join_single_expr_block ( edit : & mut TextEditBuilder , token : & SyntaxToken ) -> Option < ( ) > {
215
207
let block_expr = ast:: BlockExpr :: cast ( token. parent ( ) ?) ?;
216
208
if !block_expr. is_standalone ( ) {
@@ -223,7 +215,7 @@ fn join_single_expr_block(edit: &mut TextEditBuilder, token: &SyntaxToken) -> Op
223
215
224
216
// Match block needs to have a comma after the block
225
217
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 ( ) {
227
219
buf. push ( ',' ) ;
228
220
}
229
221
}
0 commit comments