aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/yellow/mod.rs
diff options
context:
space:
mode:
authorJeremy A. Kolb <[email protected]>2018-10-15 22:44:23 +0100
committerJeremy A. Kolb <[email protected]>2018-10-16 14:41:10 +0100
commit61f3a438d3a729a6be941bca1ff4c6a97a33f221 (patch)
tree6551967cc8c6e921b66071453ad7888a9121d326 /crates/ra_syntax/src/yellow/mod.rs
parent39cb6c6d3f78b193f5873c3492e530bbd24d5dd2 (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.rs23
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 @@
1mod builder; 1mod builder;
2mod syntax_text; 2mod syntax_text;
3 3
4use self::syntax_text::SyntaxText;
5use crate::{SmolStr, SyntaxKind, TextRange, TextUnit};
6use rowan::Types;
4use std::{ 7use std::{
5 fmt, 8 fmt,
6 hash::{Hash, Hasher}, 9 hash::{Hash, Hasher},
7}; 10};
8use rowan::Types;
9use crate::{SyntaxKind, TextUnit, TextRange, SmolStr};
10use self::syntax_text::SyntaxText;
11 11
12pub use rowan::{TreeRoot};
13pub(crate) use self::builder::GreenBuilder; 12pub(crate) use self::builder::GreenBuilder;
13pub use rowan::TreeRoot;
14 14
15#[derive(Debug, Clone, Copy)] 15#[derive(Debug, Clone, Copy)]
16pub enum RaTypes {} 16pub enum RaTypes {}
@@ -31,9 +31,7 @@ pub struct SyntaxError {
31} 31}
32 32
33#[derive(Clone, Copy)] 33#[derive(Clone, Copy)]
34pub struct SyntaxNode<R: TreeRoot<RaTypes> = OwnedRoot>( 34pub struct SyntaxNode<R: TreeRoot<RaTypes> = OwnedRoot>(::rowan::SyntaxNode<RaTypes, R>);
35 ::rowan::SyntaxNode<RaTypes, R>,
36);
37pub type SyntaxNodeRef<'a> = SyntaxNode<RefRoot<'a>>; 35pub type SyntaxNodeRef<'a> = SyntaxNode<RefRoot<'a>>;
38 36
39impl<R1, R2> PartialEq<SyntaxNode<R1>> for SyntaxNode<R2> 37impl<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)]
145pub struct SyntaxNodeChildren<R: TreeRoot<RaTypes>>( 143pub struct SyntaxNodeChildren<R: TreeRoot<RaTypes>>(::rowan::SyntaxNodeChildren<RaTypes, R>);
146 ::rowan::SyntaxNodeChildren<RaTypes, R>
147);
148 144
149impl<R: TreeRoot<RaTypes>> Iterator for SyntaxNodeChildren<R> { 145impl<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
158fn has_short_text(kind: SyntaxKind) -> bool { 153fn has_short_text(kind: SyntaxKind) -> bool {
159 use crate::SyntaxKind::*; 154 use crate::SyntaxKind::*;
160 match kind { 155 match kind {