diff options
author | Jeremy A. Kolb <[email protected]> | 2018-10-15 22:44:23 +0100 |
---|---|---|
committer | Jeremy A. Kolb <[email protected]> | 2018-10-16 14:41:10 +0100 |
commit | 61f3a438d3a729a6be941bca1ff4c6a97a33f221 (patch) | |
tree | 6551967cc8c6e921b66071453ad7888a9121d326 /crates/ra_syntax/src/yellow/mod.rs | |
parent | 39cb6c6d3f78b193f5873c3492e530bbd24d5dd2 (diff) |
Cargo Format
Run `cargo fmt` and ignore generated files
Diffstat (limited to 'crates/ra_syntax/src/yellow/mod.rs')
-rw-r--r-- | crates/ra_syntax/src/yellow/mod.rs | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/crates/ra_syntax/src/yellow/mod.rs b/crates/ra_syntax/src/yellow/mod.rs index ab9bca0f0..b5c9da813 100644 --- a/crates/ra_syntax/src/yellow/mod.rs +++ b/crates/ra_syntax/src/yellow/mod.rs | |||
@@ -1,16 +1,16 @@ | |||
1 | mod builder; | 1 | mod builder; |
2 | mod syntax_text; | 2 | mod syntax_text; |
3 | 3 | ||
4 | use self::syntax_text::SyntaxText; | ||
5 | use crate::{SmolStr, SyntaxKind, TextRange, TextUnit}; | ||
6 | use rowan::Types; | ||
4 | use std::{ | 7 | use std::{ |
5 | fmt, | 8 | fmt, |
6 | hash::{Hash, Hasher}, | 9 | hash::{Hash, Hasher}, |
7 | }; | 10 | }; |
8 | use rowan::Types; | ||
9 | use crate::{SyntaxKind, TextUnit, TextRange, SmolStr}; | ||
10 | use self::syntax_text::SyntaxText; | ||
11 | 11 | ||
12 | pub use rowan::{TreeRoot}; | ||
13 | pub(crate) use self::builder::GreenBuilder; | 12 | pub(crate) use self::builder::GreenBuilder; |
13 | pub use rowan::TreeRoot; | ||
14 | 14 | ||
15 | #[derive(Debug, Clone, Copy)] | 15 | #[derive(Debug, Clone, Copy)] |
16 | pub enum RaTypes {} | 16 | pub enum RaTypes {} |
@@ -31,9 +31,7 @@ pub struct SyntaxError { | |||
31 | } | 31 | } |
32 | 32 | ||
33 | #[derive(Clone, Copy)] | 33 | #[derive(Clone, Copy)] |
34 | pub struct SyntaxNode<R: TreeRoot<RaTypes> = OwnedRoot>( | 34 | pub struct SyntaxNode<R: TreeRoot<RaTypes> = OwnedRoot>(::rowan::SyntaxNode<RaTypes, R>); |
35 | ::rowan::SyntaxNode<RaTypes, R>, | ||
36 | ); | ||
37 | pub type SyntaxNodeRef<'a> = SyntaxNode<RefRoot<'a>>; | 35 | pub type SyntaxNodeRef<'a> = SyntaxNode<RefRoot<'a>>; |
38 | 36 | ||
39 | impl<R1, R2> PartialEq<SyntaxNode<R1>> for SyntaxNode<R2> | 37 | impl<R1, R2> PartialEq<SyntaxNode<R1>> for SyntaxNode<R2> |
@@ -69,16 +67,16 @@ impl<'a> SyntaxNodeRef<'a> { | |||
69 | pub fn leaf_text(self) -> Option<&'a SmolStr> { | 67 | pub fn leaf_text(self) -> Option<&'a SmolStr> { |
70 | self.0.leaf_text() | 68 | self.0.leaf_text() |
71 | } | 69 | } |
72 | pub fn ancestors(self) -> impl Iterator<Item=SyntaxNodeRef<'a>> { | 70 | pub fn ancestors(self) -> impl Iterator<Item = SyntaxNodeRef<'a>> { |
73 | crate::algo::generate(Some(self), |&node| node.parent()) | 71 | crate::algo::generate(Some(self), |&node| node.parent()) |
74 | } | 72 | } |
75 | pub fn descendants(self) -> impl Iterator<Item=SyntaxNodeRef<'a>> { | 73 | pub fn descendants(self) -> impl Iterator<Item = SyntaxNodeRef<'a>> { |
76 | crate::algo::walk::walk(self).filter_map(|event| match event { | 74 | crate::algo::walk::walk(self).filter_map(|event| match event { |
77 | crate::algo::walk::WalkEvent::Enter(node) => Some(node), | 75 | crate::algo::walk::WalkEvent::Enter(node) => Some(node), |
78 | crate::algo::walk::WalkEvent::Exit(_) => None, | 76 | crate::algo::walk::WalkEvent::Exit(_) => None, |
79 | }) | 77 | }) |
80 | } | 78 | } |
81 | pub fn siblings(self, direction: Direction) -> impl Iterator<Item=SyntaxNodeRef<'a>> { | 79 | pub fn siblings(self, direction: Direction) -> impl Iterator<Item = SyntaxNodeRef<'a>> { |
82 | crate::algo::generate(Some(self), move |&node| match direction { | 80 | crate::algo::generate(Some(self), move |&node| match direction { |
83 | Direction::Next => node.next_sibling(), | 81 | Direction::Next => node.next_sibling(), |
84 | Direction::Prev => node.prev_sibling(), | 82 | Direction::Prev => node.prev_sibling(), |
@@ -142,9 +140,7 @@ impl<R: TreeRoot<RaTypes>> fmt::Debug for SyntaxNode<R> { | |||
142 | } | 140 | } |
143 | 141 | ||
144 | #[derive(Debug)] | 142 | #[derive(Debug)] |
145 | pub struct SyntaxNodeChildren<R: TreeRoot<RaTypes>>( | 143 | pub struct SyntaxNodeChildren<R: TreeRoot<RaTypes>>(::rowan::SyntaxNodeChildren<RaTypes, R>); |
146 | ::rowan::SyntaxNodeChildren<RaTypes, R> | ||
147 | ); | ||
148 | 144 | ||
149 | impl<R: TreeRoot<RaTypes>> Iterator for SyntaxNodeChildren<R> { | 145 | impl<R: TreeRoot<RaTypes>> Iterator for SyntaxNodeChildren<R> { |
150 | type Item = SyntaxNode<R>; | 146 | type Item = SyntaxNode<R>; |
@@ -154,7 +150,6 @@ impl<R: TreeRoot<RaTypes>> Iterator for SyntaxNodeChildren<R> { | |||
154 | } | 150 | } |
155 | } | 151 | } |
156 | 152 | ||
157 | |||
158 | fn has_short_text(kind: SyntaxKind) -> bool { | 153 | fn has_short_text(kind: SyntaxKind) -> bool { |
159 | use crate::SyntaxKind::*; | 154 | use crate::SyntaxKind::*; |
160 | match kind { | 155 | match kind { |