From f92177cfb5088809892455262841e24cf1ecf5b6 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 30 Aug 2019 20:16:28 +0200 Subject: Add an expr_source method analogous to the source methods in the code model ... and use that instead of exposing the source map. --- crates/ra_syntax/src/ptr.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'crates/ra_syntax/src/ptr.rs') diff --git a/crates/ra_syntax/src/ptr.rs b/crates/ra_syntax/src/ptr.rs index 992034ef0..80e55d2aa 100644 --- a/crates/ra_syntax/src/ptr.rs +++ b/crates/ra_syntax/src/ptr.rs @@ -15,9 +15,8 @@ impl SyntaxNodePtr { SyntaxNodePtr { range: node.text_range(), kind: node.kind() } } - pub fn to_node(self, root: &SyntaxNode) -> SyntaxNode { - assert!(root.parent().is_none()); - successors(Some(root.clone()), |node| { + pub fn to_node(self, parent: &SyntaxNode) -> SyntaxNode { + successors(Some(parent.clone()), |node| { node.children().find(|it| self.range.is_subrange(&it.text_range())) }) .find(|it| it.text_range() == self.range && it.kind() == self.kind) -- cgit v1.2.3