From 82173c8de4b1283b6b54bd0def25b9c432614841 Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Thu, 21 Feb 2019 18:49:03 +0200 Subject: Move `non_trivia_sibling` to `ra_syntax::algo` --- crates/ra_ide_api_light/src/join_lines.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'crates/ra_ide_api_light/src') diff --git a/crates/ra_ide_api_light/src/join_lines.rs b/crates/ra_ide_api_light/src/join_lines.rs index 9a400199f..b5bcd62fb 100644 --- a/crates/ra_ide_api_light/src/join_lines.rs +++ b/crates/ra_ide_api_light/src/join_lines.rs @@ -2,8 +2,9 @@ use itertools::Itertools; use ra_syntax::{ SourceFile, TextRange, TextUnit, AstNode, SyntaxNode, SyntaxKind::{self, WHITESPACE, COMMA, R_CURLY, R_PAREN, R_BRACK}, - algo::find_covering_node, + algo::{find_covering_node, non_trivia_sibling}, ast, + Direction, }; use ra_fmt::{ compute_ws, extract_trivial_expression @@ -121,13 +122,8 @@ fn remove_newline( } fn has_comma_after(node: &SyntaxNode) -> bool { - let next = node.next_sibling(); - let nnext = node.next_sibling().and_then(|n| n.next_sibling()); - - match (next, nnext) { - // Whitespace followed by a comma is fine - (Some(ws), Some(comma)) if ws.kind() == WHITESPACE && comma.kind() == COMMA => true, - (Some(n), _) => n.kind() == COMMA, + match non_trivia_sibling(node, Direction::Next) { + Some(n) => n.kind() == COMMA, _ => false, } } -- cgit v1.2.3