diff options
Diffstat (limited to 'crates/ra_analysis/src/syntax_ptr.rs')
-rw-r--r-- | crates/ra_analysis/src/syntax_ptr.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/crates/ra_analysis/src/syntax_ptr.rs b/crates/ra_analysis/src/syntax_ptr.rs index 4afb1fc93..194b94584 100644 --- a/crates/ra_analysis/src/syntax_ptr.rs +++ b/crates/ra_analysis/src/syntax_ptr.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use ra_syntax::{File, SyntaxKind, SyntaxNode, SyntaxNodeRef, TextRange}; | 1 | use ra_syntax::{SourceFileNode, SyntaxKind, SyntaxNode, SyntaxNodeRef, TextRange}; |
2 | 2 | ||
3 | use crate::db::SyntaxDatabase; | 3 | use crate::db::SyntaxDatabase; |
4 | use crate::FileId; | 4 | use crate::FileId; |
@@ -43,7 +43,7 @@ impl LocalSyntaxPtr { | |||
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 | ||
46 | pub(crate) fn resolve(self, file: &File) -> SyntaxNode { | 46 | pub(crate) fn resolve(self, file: &SourceFileNode) -> SyntaxNode { |
47 | let mut curr = file.syntax(); | 47 | let mut curr = file.syntax(); |
48 | loop { | 48 | loop { |
49 | if curr.range() == self.range && curr.kind() == self.kind { | 49 | if curr.range() == self.range && curr.kind() == self.kind { |
@@ -62,12 +62,17 @@ impl LocalSyntaxPtr { | |||
62 | local: self, | 62 | local: self, |
63 | } | 63 | } |
64 | } | 64 | } |
65 | |||
66 | // Seems unfortunate to expose | ||
67 | pub(crate) fn range(self) -> TextRange { | ||
68 | self.range | ||
69 | } | ||
65 | } | 70 | } |
66 | 71 | ||
67 | #[test] | 72 | #[test] |
68 | fn test_local_syntax_ptr() { | 73 | fn test_local_syntax_ptr() { |
69 | use ra_syntax::{ast, AstNode}; | 74 | use ra_syntax::{ast, AstNode}; |
70 | let file = File::parse("struct Foo { f: u32, }"); | 75 | let file = SourceFileNode::parse("struct Foo { f: u32, }"); |
71 | let field = file | 76 | let field = file |
72 | .syntax() | 77 | .syntax() |
73 | .descendants() | 78 | .descendants() |