From d402974aa0af6de290245a9d2a69a5d56c4fa610 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 18 Jul 2019 19:23:05 +0300 Subject: migrate ra_syntax to the new rowan API --- crates/ra_syntax/src/algo.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/ra_syntax/src/algo.rs') diff --git a/crates/ra_syntax/src/algo.rs b/crates/ra_syntax/src/algo.rs index fad8da132..e2de5e0e3 100644 --- a/crates/ra_syntax/src/algo.rs +++ b/crates/ra_syntax/src/algo.rs @@ -9,8 +9,8 @@ pub use rowan::TokenAtOffset; pub fn find_token_at_offset(node: &SyntaxNode, offset: TextUnit) -> TokenAtOffset { match node.0.token_at_offset(offset) { TokenAtOffset::None => TokenAtOffset::None, - TokenAtOffset::Single(n) => TokenAtOffset::Single(n.into()), - TokenAtOffset::Between(l, r) => TokenAtOffset::Between(l.into(), r.into()), + TokenAtOffset::Single(n) => TokenAtOffset::Single(SyntaxToken(n)), + TokenAtOffset::Between(l, r) => TokenAtOffset::Between(SyntaxToken(l), SyntaxToken(r)), } } @@ -22,7 +22,7 @@ pub fn find_token_at_offset(node: &SyntaxNode, offset: TextUnit) -> TokenAtOffse pub fn ancestors_at_offset( node: &SyntaxNode, offset: TextUnit, -) -> impl Iterator { +) -> impl Iterator { find_token_at_offset(node, offset) .map(|token| token.parent().ancestors()) .kmerge_by(|node1, node2| node1.range().len() < node2.range().len()) @@ -37,7 +37,7 @@ pub fn ancestors_at_offset( /// ``` /// /// then the shorter node will be silently preferred. -pub fn find_node_at_offset(syntax: &SyntaxNode, offset: TextUnit) -> Option<&N> { +pub fn find_node_at_offset(syntax: &SyntaxNode, offset: TextUnit) -> Option { ancestors_at_offset(syntax, offset).find_map(N::cast) } @@ -59,5 +59,5 @@ pub fn non_trivia_sibling(element: SyntaxElement, direction: Direction) -> Optio } pub fn find_covering_element(root: &SyntaxNode, range: TextRange) -> SyntaxElement { - root.0.covering_node(range).into() + SyntaxElement::new(root.0.covering_node(range)) } -- cgit v1.2.3