diff options
Diffstat (limited to 'crates/ra_syntax/src/ptr.rs')
-rw-r--r-- | crates/ra_syntax/src/ptr.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/crates/ra_syntax/src/ptr.rs b/crates/ra_syntax/src/ptr.rs index d8de1c4c1..15a8b94cd 100644 --- a/crates/ra_syntax/src/ptr.rs +++ b/crates/ra_syntax/src/ptr.rs | |||
@@ -1,8 +1,9 @@ | |||
1 | use std::marker::PhantomData; | 1 | use std::{ |
2 | 2 | marker::PhantomData, | |
3 | iter::successors, | ||
4 | }; | ||
3 | use crate::{ | 5 | use crate::{ |
4 | AstNode, SourceFile, SyntaxKind, SyntaxNode, TextRange, | 6 | AstNode, SourceFile, SyntaxKind, SyntaxNode, TextRange, |
5 | algo::generate, | ||
6 | }; | 7 | }; |
7 | 8 | ||
8 | /// A pointer to a syntax node inside a file. It can be used to remember a | 9 | /// A pointer to a syntax node inside a file. It can be used to remember a |
@@ -19,7 +20,7 @@ impl SyntaxNodePtr { | |||
19 | } | 20 | } |
20 | 21 | ||
21 | pub fn to_node(self, source_file: &SourceFile) -> &SyntaxNode { | 22 | pub fn to_node(self, source_file: &SourceFile) -> &SyntaxNode { |
22 | generate(Some(source_file.syntax()), |&node| { | 23 | successors(Some(source_file.syntax()), |&node| { |
23 | node.children().find(|it| self.range.is_subrange(&it.range())) | 24 | node.children().find(|it| self.range.is_subrange(&it.range())) |
24 | }) | 25 | }) |
25 | .find(|it| it.range() == self.range && it.kind() == self.kind) | 26 | .find(|it| it.range() == self.range && it.kind() == self.kind) |