aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-10-02 15:14:56 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-10-02 15:14:56 +0100
commit7ffc114dab6d1e25ead195a5937cd4f9ca51ef2c (patch)
treee8bab3ea497a8e7207a24e481361bdd56ed81eaa /crates/ra_syntax/src/ast
parentcd9c5f4ab205e092b87be6affe6d7e78d877dbf0 (diff)
parenta261a1836ba02a1c091c5165795dc165ca399a87 (diff)
Merge #85
85: start moving syntax tree to a separate crate r=matklad a=matklad WIP Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/mod.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/crates/ra_syntax/src/ast/mod.rs b/crates/ra_syntax/src/ast/mod.rs
index a6da82957..c1570b868 100644
--- a/crates/ra_syntax/src/ast/mod.rs
+++ b/crates/ra_syntax/src/ast/mod.rs
@@ -3,10 +3,9 @@ mod generated;
3use std::marker::PhantomData; 3use std::marker::PhantomData;
4 4
5use itertools::Itertools; 5use itertools::Itertools;
6use smol_str::SmolStr;
7 6
8use { 7use {
9 SyntaxNodeRef, SyntaxKind::*, 8 SmolStr, SyntaxNodeRef, SyntaxKind::*,
10 yellow::{RefRoot, SyntaxNodeChildren}, 9 yellow::{RefRoot, SyntaxNodeChildren},
11}; 10};
12pub use self::generated::*; 11pub use self::generated::*;
@@ -76,7 +75,7 @@ impl<'a> Attr<'a> {
76 let tt = self.value()?; 75 let tt = self.value()?;
77 let (_bra, attr, _ket) = tt.syntax().children().collect_tuple()?; 76 let (_bra, attr, _ket) = tt.syntax().children().collect_tuple()?;
78 if attr.kind() == IDENT { 77 if attr.kind() == IDENT {
79 Some(attr.leaf_text().unwrap()) 78 Some(attr.leaf_text().unwrap().clone())
80 } else { 79 } else {
81 None 80 None
82 } 81 }
@@ -87,7 +86,7 @@ impl<'a> Attr<'a> {
87 let (_bra, attr, args, _ket) = tt.syntax().children().collect_tuple()?; 86 let (_bra, attr, args, _ket) = tt.syntax().children().collect_tuple()?;
88 let args = TokenTree::cast(args)?; 87 let args = TokenTree::cast(args)?;
89 if attr.kind() == IDENT { 88 if attr.kind() == IDENT {
90 Some((attr.leaf_text().unwrap(), args)) 89 Some((attr.leaf_text().unwrap().clone(), args))
91 } else { 90 } else {
92 None 91 None
93 } 92 }
@@ -96,7 +95,7 @@ impl<'a> Attr<'a> {
96 95
97impl<'a> Lifetime<'a> { 96impl<'a> Lifetime<'a> {
98 pub fn text(&self) -> SmolStr { 97 pub fn text(&self) -> SmolStr {
99 self.syntax().leaf_text().unwrap() 98 self.syntax().leaf_text().unwrap().clone()
100 } 99 }
101} 100}
102 101
@@ -104,7 +103,7 @@ impl<'a> Name<'a> {
104 pub fn text(&self) -> SmolStr { 103 pub fn text(&self) -> SmolStr {
105 let ident = self.syntax().first_child() 104 let ident = self.syntax().first_child()
106 .unwrap(); 105 .unwrap();
107 ident.leaf_text().unwrap() 106 ident.leaf_text().unwrap().clone()
108 } 107 }
109} 108}
110 109
@@ -112,7 +111,7 @@ impl<'a> NameRef<'a> {
112 pub fn text(&self) -> SmolStr { 111 pub fn text(&self) -> SmolStr {
113 let ident = self.syntax().first_child() 112 let ident = self.syntax().first_child()
114 .unwrap(); 113 .unwrap();
115 ident.leaf_text().unwrap() 114 ident.leaf_text().unwrap().clone()
116 } 115 }
117} 116}
118 117