From a261a1836ba02a1c091c5165795dc165ca399a87 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 2 Oct 2018 17:07:12 +0300 Subject: Move to rowan for syntax tree impl --- crates/ra_syntax/src/ast/mod.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'crates/ra_syntax/src/ast') 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; use std::marker::PhantomData; use itertools::Itertools; -use smol_str::SmolStr; use { - SyntaxNodeRef, SyntaxKind::*, + SmolStr, SyntaxNodeRef, SyntaxKind::*, yellow::{RefRoot, SyntaxNodeChildren}, }; pub use self::generated::*; @@ -76,7 +75,7 @@ impl<'a> Attr<'a> { let tt = self.value()?; let (_bra, attr, _ket) = tt.syntax().children().collect_tuple()?; if attr.kind() == IDENT { - Some(attr.leaf_text().unwrap()) + Some(attr.leaf_text().unwrap().clone()) } else { None } @@ -87,7 +86,7 @@ impl<'a> Attr<'a> { let (_bra, attr, args, _ket) = tt.syntax().children().collect_tuple()?; let args = TokenTree::cast(args)?; if attr.kind() == IDENT { - Some((attr.leaf_text().unwrap(), args)) + Some((attr.leaf_text().unwrap().clone(), args)) } else { None } @@ -96,7 +95,7 @@ impl<'a> Attr<'a> { impl<'a> Lifetime<'a> { pub fn text(&self) -> SmolStr { - self.syntax().leaf_text().unwrap() + self.syntax().leaf_text().unwrap().clone() } } @@ -104,7 +103,7 @@ impl<'a> Name<'a> { pub fn text(&self) -> SmolStr { let ident = self.syntax().first_child() .unwrap(); - ident.leaf_text().unwrap() + ident.leaf_text().unwrap().clone() } } @@ -112,7 +111,7 @@ impl<'a> NameRef<'a> { pub fn text(&self) -> SmolStr { let ident = self.syntax().first_child() .unwrap(); - ident.leaf_text().unwrap() + ident.leaf_text().unwrap().clone() } } -- cgit v1.2.3