aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-10-16 14:44:24 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-10-16 14:44:24 +0100
commit1216878f7be20dd0e652fb8cdc395009fdcfae07 (patch)
tree6551967cc8c6e921b66071453ad7888a9121d326 /crates/ra_syntax/src/ast
parent39cb6c6d3f78b193f5873c3492e530bbd24d5dd2 (diff)
parent61f3a438d3a729a6be941bca1ff4c6a97a33f221 (diff)
Merge #134
134: Cargo Format run r=kjeremy a=kjeremy I'm not sure how appreciated this is but I figured I would run `cargo fmt` and see what came up. I made sure that `cargo test` still passes. Co-authored-by: Jeremy A. Kolb <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs2
-rw-r--r--crates/ra_syntax/src/ast/generated.rs.tera2
-rw-r--r--crates/ra_syntax/src/ast/mod.rs24
3 files changed, 15 insertions, 13 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 160d186b8..a15e00176 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -1,6 +1,8 @@
1// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-kinds` is run 1// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-kinds` is run
2// Do not edit manually 2// Do not edit manually
3 3
4#![cfg_attr(rustfmt, rustfmt_skip)]
5
4use crate::{ 6use crate::{
5 ast, 7 ast,
6 SyntaxNodeRef, AstNode, 8 SyntaxNodeRef, AstNode,
diff --git a/crates/ra_syntax/src/ast/generated.rs.tera b/crates/ra_syntax/src/ast/generated.rs.tera
index 5cb7a35ed..d2a281137 100644
--- a/crates/ra_syntax/src/ast/generated.rs.tera
+++ b/crates/ra_syntax/src/ast/generated.rs.tera
@@ -3,6 +3,8 @@ the below applies to the result of this template
3#}// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-kinds` is run 3#}// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-kinds` is run
4// Do not edit manually 4// Do not edit manually
5 5
6#![cfg_attr(rustfmt, rustfmt_skip)]
7
6use crate::{ 8use crate::{
7 ast, 9 ast,
8 SyntaxNodeRef, AstNode, 10 SyntaxNodeRef, AstNode,
diff --git a/crates/ra_syntax/src/ast/mod.rs b/crates/ra_syntax/src/ast/mod.rs
index 88193a1ed..34958b6cb 100644
--- a/crates/ra_syntax/src/ast/mod.rs
+++ b/crates/ra_syntax/src/ast/mod.rs
@@ -4,15 +4,18 @@ use std::marker::PhantomData;
4 4
5use itertools::Itertools; 5use itertools::Itertools;
6 6
7pub use self::generated::*;
7use crate::{ 8use crate::{
8 SmolStr, SyntaxNodeRef, SyntaxKind::*,
9 yellow::{RefRoot, SyntaxNodeChildren}, 9 yellow::{RefRoot, SyntaxNodeChildren},
10 SmolStr,
11 SyntaxKind::*,
12 SyntaxNodeRef,
10}; 13};
11pub use self::generated::*;
12 14
13pub trait AstNode<'a>: Clone + Copy + 'a { 15pub trait AstNode<'a>: Clone + Copy + 'a {
14 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> 16 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self>
15 where Self: Sized; 17 where
18 Self: Sized;
16 fn syntax(self) -> SyntaxNodeRef<'a>; 19 fn syntax(self) -> SyntaxNodeRef<'a>;
17} 20}
18 21
@@ -64,9 +67,7 @@ pub trait AttrsOwner<'a>: AstNode<'a> {
64 67
65impl<'a> FnDef<'a> { 68impl<'a> FnDef<'a> {
66 pub fn has_atom_attr(&self, atom: &str) -> bool { 69 pub fn has_atom_attr(&self, atom: &str) -> bool {
67 self.attrs() 70 self.attrs().filter_map(|x| x.as_atom()).any(|x| x == atom)
68 .filter_map(|x| x.as_atom())
69 .any(|x| x == atom)
70 } 71 }
71} 72}
72 73
@@ -135,7 +136,7 @@ pub enum CommentFlavor {
135 Line, 136 Line,
136 Doc, 137 Doc,
137 ModuleDoc, 138 ModuleDoc,
138 Multiline 139 Multiline,
139} 140}
140 141
141impl CommentFlavor { 142impl CommentFlavor {
@@ -145,7 +146,7 @@ impl CommentFlavor {
145 Line => "//", 146 Line => "//",
146 Doc => "///", 147 Doc => "///",
147 ModuleDoc => "//!", 148 ModuleDoc => "//!",
148 Multiline => "/*" 149 Multiline => "/*",
149 } 150 }
150 } 151 }
151} 152}
@@ -166,16 +167,14 @@ impl<'a> Whitespace<'a> {
166 167
167impl<'a> Name<'a> { 168impl<'a> Name<'a> {
168 pub fn text(&self) -> SmolStr { 169 pub fn text(&self) -> SmolStr {
169 let ident = self.syntax().first_child() 170 let ident = self.syntax().first_child().unwrap();
170 .unwrap();
171 ident.leaf_text().unwrap().clone() 171 ident.leaf_text().unwrap().clone()
172 } 172 }
173} 173}
174 174
175impl<'a> NameRef<'a> { 175impl<'a> NameRef<'a> {
176 pub fn text(&self) -> SmolStr { 176 pub fn text(&self) -> SmolStr {
177 let ident = self.syntax().first_child() 177 let ident = self.syntax().first_child().unwrap();
178 .unwrap();
179 ident.leaf_text().unwrap().clone() 178 ident.leaf_text().unwrap().clone()
180 } 179 }
181} 180}
@@ -241,7 +240,6 @@ fn children<'a, P: AstNode<'a>, C: AstNode<'a>>(parent: P) -> AstChildren<'a, C>
241 AstChildren::new(parent.syntax()) 240 AstChildren::new(parent.syntax())
242} 241}
243 242
244
245#[derive(Debug)] 243#[derive(Debug)]
246pub struct AstChildren<'a, N> { 244pub struct AstChildren<'a, N> {
247 inner: SyntaxNodeChildren<RefRoot<'a>>, 245 inner: SyntaxNodeChildren<RefRoot<'a>>,