diff options
author | Aleksey Kladov <[email protected]> | 2018-07-30 12:08:06 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-07-30 12:08:06 +0100 |
commit | 1edb58a802f183f79dc2c4bc15921394ef8abb31 (patch) | |
tree | 24114171c61a9f433b9a54008057fa0297f91302 /src/yellow/syntax.rs | |
parent | 6983091d6d255bcfd17c4f8c14015d8abc77928d (diff) |
reformat
Diffstat (limited to 'src/yellow/syntax.rs')
-rw-r--r-- | src/yellow/syntax.rs | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/yellow/syntax.rs b/src/yellow/syntax.rs index 64af08236..19a9b8ac2 100644 --- a/src/yellow/syntax.rs +++ b/src/yellow/syntax.rs | |||
@@ -1,17 +1,12 @@ | |||
1 | use std::{ | 1 | use std::{fmt, ops::Deref, ptr, sync::Arc}; |
2 | fmt, | ||
3 | sync::Arc, | ||
4 | ptr, | ||
5 | ops::Deref, | ||
6 | }; | ||
7 | 2 | ||
8 | use { | 3 | use { |
9 | TextRange, TextUnit, | 4 | yellow::{GreenNode, RedNode}, |
10 | SyntaxKind::{self, *}, | 5 | SyntaxKind::{self, *}, |
11 | yellow::{RedNode, GreenNode}, | 6 | TextRange, TextUnit, |
12 | }; | 7 | }; |
13 | 8 | ||
14 | pub trait TreeRoot: Deref<Target=SyntaxRoot> + Clone {} | 9 | pub trait TreeRoot: Deref<Target = SyntaxRoot> + Clone {} |
15 | impl TreeRoot for Arc<SyntaxRoot> {} | 10 | impl TreeRoot for Arc<SyntaxRoot> {} |
16 | impl<'a> TreeRoot for &'a SyntaxRoot {} | 11 | impl<'a> TreeRoot for &'a SyntaxRoot {} |
17 | 12 | ||
@@ -50,7 +45,10 @@ impl SyntaxNode<Arc<SyntaxRoot>> { | |||
50 | pub(crate) fn new_owned(root: SyntaxRoot) -> Self { | 45 | pub(crate) fn new_owned(root: SyntaxRoot) -> Self { |
51 | let root = Arc::new(root); | 46 | let root = Arc::new(root); |
52 | let red_weak = ptr::NonNull::from(&root.red); | 47 | let red_weak = ptr::NonNull::from(&root.red); |
53 | SyntaxNode { root, red: red_weak } | 48 | SyntaxNode { |
49 | root, | ||
50 | red: red_weak, | ||
51 | } | ||
54 | } | 52 | } |
55 | } | 53 | } |
56 | 54 | ||
@@ -68,10 +66,7 @@ impl<ROOT: TreeRoot> SyntaxNode<ROOT> { | |||
68 | 66 | ||
69 | pub fn range(&self) -> TextRange { | 67 | pub fn range(&self) -> TextRange { |
70 | let red = self.red(); | 68 | let red = self.red(); |
71 | TextRange::offset_len( | 69 | TextRange::offset_len(red.start_offset(), red.green().text_len()) |
72 | red.start_offset(), | ||
73 | red.green().text_len(), | ||
74 | ) | ||
75 | } | 70 | } |
76 | 71 | ||
77 | pub fn text(&self) -> String { | 72 | pub fn text(&self) -> String { |