diff options
Diffstat (limited to 'crates/libsyntax2/src/yellow/mod.rs')
-rw-r--r-- | crates/libsyntax2/src/yellow/mod.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/crates/libsyntax2/src/yellow/mod.rs b/crates/libsyntax2/src/yellow/mod.rs index b94c794fe..82eda79d6 100644 --- a/crates/libsyntax2/src/yellow/mod.rs +++ b/crates/libsyntax2/src/yellow/mod.rs | |||
@@ -2,6 +2,7 @@ mod builder; | |||
2 | mod green; | 2 | mod green; |
3 | mod red; | 3 | mod red; |
4 | mod syntax; | 4 | mod syntax; |
5 | mod syntax_text; | ||
5 | 6 | ||
6 | use std::{ | 7 | use std::{ |
7 | sync::Arc, | 8 | sync::Arc, |
@@ -12,6 +13,7 @@ pub(crate) use self::{ | |||
12 | builder::GreenBuilder, | 13 | builder::GreenBuilder, |
13 | green::GreenNode, | 14 | green::GreenNode, |
14 | red::RedNode, | 15 | red::RedNode, |
16 | syntax_text::SyntaxText, | ||
15 | }; | 17 | }; |
16 | 18 | ||
17 | #[derive(Debug)] | 19 | #[derive(Debug)] |
@@ -32,6 +34,12 @@ pub struct OwnedRoot(Arc<SyntaxRoot>); | |||
32 | #[derive(Clone, Copy, Debug)] | 34 | #[derive(Clone, Copy, Debug)] |
33 | pub struct RefRoot<'a>(&'a OwnedRoot); // TODO: shared_from_this instead of double indirection | 35 | pub struct RefRoot<'a>(&'a OwnedRoot); // TODO: shared_from_this instead of double indirection |
34 | 36 | ||
37 | impl<'a> RefRoot<'a> { | ||
38 | fn syntax_root(&self) -> &'a SyntaxRoot { | ||
39 | self.0.syntax_root() | ||
40 | } | ||
41 | } | ||
42 | |||
35 | impl TreeRoot for OwnedRoot { | 43 | impl TreeRoot for OwnedRoot { |
36 | fn borrowed(&self) -> RefRoot { | 44 | fn borrowed(&self) -> RefRoot { |
37 | RefRoot(&self) | 45 | RefRoot(&self) |
@@ -78,7 +86,7 @@ impl RedPtr { | |||
78 | RedPtr(red.into()) | 86 | RedPtr(red.into()) |
79 | } | 87 | } |
80 | 88 | ||
81 | unsafe fn get<'a>(self, _root: &'a impl TreeRoot) -> &'a RedNode { | 89 | unsafe fn get<'a>(self, _root: &'a SyntaxRoot) -> &'a RedNode { |
82 | &*self.0.as_ptr() | 90 | &*self.0.as_ptr() |
83 | } | 91 | } |
84 | } | 92 | } |