mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
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 <villem.penttinen@gmail.com>
This commit is contained in:
commit
5100aeac42
4 changed files with 143 additions and 10 deletions
|
@ -2,7 +2,7 @@ pub mod visit;
|
|||
|
||||
use rowan::TransparentNewType;
|
||||
|
||||
use crate::{SyntaxNode, TextRange, TextUnit, AstNode};
|
||||
use crate::{SyntaxNode, TextRange, TextUnit, AstNode, Direction};
|
||||
|
||||
pub use rowan::LeafAtOffset;
|
||||
|
||||
|
@ -29,6 +29,11 @@ pub fn find_node_at_offset<N: AstNode>(syntax: &SyntaxNode, offset: TextUnit) ->
|
|||
find_leaf_at_offset(syntax, offset).find_map(|leaf| leaf.ancestors().find_map(N::cast))
|
||||
}
|
||||
|
||||
/// Finds the first sibling in the given direction which is not `trivia`
|
||||
pub fn non_trivia_sibling(node: &SyntaxNode, direction: Direction) -> Option<&SyntaxNode> {
|
||||
node.siblings(direction).skip(1).find(|node| !node.kind().is_trivia())
|
||||
}
|
||||
|
||||
pub fn find_covering_node(root: &SyntaxNode, range: TextRange) -> &SyntaxNode {
|
||||
SyntaxNode::from_repr(root.0.covering_node(range))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue