diff options
author | Aleksey Kladov <[email protected]> | 2018-07-30 10:44:14 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-07-30 10:44:14 +0100 |
commit | a2a810f118bb2ec541f852bf02eebdf02c7326f7 (patch) | |
tree | 1b48a5b2f10e0f4a706e496eabd27e8490c332be /src/yellow/syntax.rs | |
parent | 423298dddd50d28ce891b10695417401226235a3 (diff) |
Add parent links
Diffstat (limited to 'src/yellow/syntax.rs')
-rw-r--r-- | src/yellow/syntax.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/yellow/syntax.rs b/src/yellow/syntax.rs index c31b832d0..ae3302ed9 100644 --- a/src/yellow/syntax.rs +++ b/src/yellow/syntax.rs | |||
@@ -90,6 +90,14 @@ impl<ROOT: TreeRoot> SyntaxNode<ROOT> { | |||
90 | res | 90 | res |
91 | } | 91 | } |
92 | 92 | ||
93 | pub fn parent(&self) -> Option<SyntaxNode<ROOT>> { | ||
94 | let parent = self.red().parent()?; | ||
95 | Some(SyntaxNode { | ||
96 | root: self.root.clone(), | ||
97 | red: parent, | ||
98 | }) | ||
99 | } | ||
100 | |||
93 | fn red(&self) -> &RedNode { | 101 | fn red(&self) -> &RedNode { |
94 | unsafe { self.red.as_ref() } | 102 | unsafe { self.red.as_ref() } |
95 | } | 103 | } |