diff options
author | Aleksey Kladov <[email protected]> | 2018-10-02 15:07:12 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-10-02 15:09:23 +0100 |
commit | a261a1836ba02a1c091c5165795dc165ca399a87 (patch) | |
tree | e8bab3ea497a8e7207a24e481361bdd56ed81eaa /crates/ra_syntax/src/ast | |
parent | cd9c5f4ab205e092b87be6affe6d7e78d877dbf0 (diff) |
Move to rowan for syntax tree impl
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/mod.rs | 13 |
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; | |||
3 | use std::marker::PhantomData; | 3 | use std::marker::PhantomData; |
4 | 4 | ||
5 | use itertools::Itertools; | 5 | use itertools::Itertools; |
6 | use smol_str::SmolStr; | ||
7 | 6 | ||
8 | use { | 7 | use { |
9 | SyntaxNodeRef, SyntaxKind::*, | 8 | SmolStr, SyntaxNodeRef, SyntaxKind::*, |
10 | yellow::{RefRoot, SyntaxNodeChildren}, | 9 | yellow::{RefRoot, SyntaxNodeChildren}, |
11 | }; | 10 | }; |
12 | pub use self::generated::*; | 11 | pub 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 | ||
97 | impl<'a> Lifetime<'a> { | 96 | impl<'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 | ||