From 9c3b25177e3c8d609dd24d2c2e01cbb82cab665f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 3 Sep 2019 11:04:38 +0300 Subject: Correctly build BodySourceMap for macro-expanded expressions --- crates/ra_syntax/src/ptr.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'crates/ra_syntax') diff --git a/crates/ra_syntax/src/ptr.rs b/crates/ra_syntax/src/ptr.rs index 80e55d2aa..992034ef0 100644 --- a/crates/ra_syntax/src/ptr.rs +++ b/crates/ra_syntax/src/ptr.rs @@ -15,8 +15,9 @@ impl SyntaxNodePtr { SyntaxNodePtr { range: node.text_range(), kind: node.kind() } } - pub fn to_node(self, parent: &SyntaxNode) -> SyntaxNode { - successors(Some(parent.clone()), |node| { + pub fn to_node(self, root: &SyntaxNode) -> SyntaxNode { + assert!(root.parent().is_none()); + successors(Some(root.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