diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-21 16:55:26 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-21 16:55:26 +0000 |
commit | 5100aeac429919d1758908efb2f9cbe0d02c7510 (patch) | |
tree | 5921ac7c9d20fa729a3d97d8e6a81f87431f57e3 /crates/ra_syntax/src | |
parent | 55da8e786d2cac3cb6332f80c1ee715fbcbdee0d (diff) | |
parent | 82173c8de4b1283b6b54bd0def25b9c432614841 (diff) |
Merge #876
876: Fix join_lines not adding a comma after join_single_expr_block with match arm r=matklad a=vipentti
Fixes #868
Co-authored-by: Ville Penttinen <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/algo.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/crates/ra_syntax/src/algo.rs b/crates/ra_syntax/src/algo.rs index e8cf0d4b5..e2b4f0388 100644 --- a/crates/ra_syntax/src/algo.rs +++ b/crates/ra_syntax/src/algo.rs | |||
@@ -2,7 +2,7 @@ pub mod visit; | |||
2 | 2 | ||
3 | use rowan::TransparentNewType; | 3 | use rowan::TransparentNewType; |
4 | 4 | ||
5 | use crate::{SyntaxNode, TextRange, TextUnit, AstNode}; | 5 | use crate::{SyntaxNode, TextRange, TextUnit, AstNode, Direction}; |
6 | 6 | ||
7 | pub use rowan::LeafAtOffset; | 7 | pub use rowan::LeafAtOffset; |
8 | 8 | ||
@@ -29,6 +29,11 @@ pub fn find_node_at_offset<N: AstNode>(syntax: &SyntaxNode, offset: TextUnit) -> | |||
29 | find_leaf_at_offset(syntax, offset).find_map(|leaf| leaf.ancestors().find_map(N::cast)) | 29 | find_leaf_at_offset(syntax, offset).find_map(|leaf| leaf.ancestors().find_map(N::cast)) |
30 | } | 30 | } |
31 | 31 | ||
32 | /// Finds the first sibling in the given direction which is not `trivia` | ||
33 | pub fn non_trivia_sibling(node: &SyntaxNode, direction: Direction) -> Option<&SyntaxNode> { | ||
34 | node.siblings(direction).skip(1).find(|node| !node.kind().is_trivia()) | ||
35 | } | ||
36 | |||
32 | pub fn find_covering_node(root: &SyntaxNode, range: TextRange) -> &SyntaxNode { | 37 | pub fn find_covering_node(root: &SyntaxNode, range: TextRange) -> &SyntaxNode { |
33 | SyntaxNode::from_repr(root.0.covering_node(range)) | 38 | SyntaxNode::from_repr(root.0.covering_node(range)) |
34 | } | 39 | } |