aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax/src/ast/node_ext.rs
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2020-12-15 18:23:51 +0000
committerLukas Wirth <[email protected]>2020-12-16 13:16:09 +0000
commitdd496223f50232fe98312ee8edc89eb4b5ee3d85 (patch)
tree4d50c04ca78f9458ab536ff1edee76eba6ab1957 /crates/syntax/src/ast/node_ext.rs
parentd34611633b3b2404188b9e12b08c5def589808c2 (diff)
Node-ify lifetimes
Diffstat (limited to 'crates/syntax/src/ast/node_ext.rs')
-rw-r--r--crates/syntax/src/ast/node_ext.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs
index 40dec3c7f..c45cb514a 100644
--- a/crates/syntax/src/ast/node_ext.rs
+++ b/crates/syntax/src/ast/node_ext.rs
@@ -12,6 +12,12 @@ use crate::{
12 SmolStr, SyntaxElement, SyntaxToken, T, 12 SmolStr, SyntaxElement, SyntaxToken, T,
13}; 13};
14 14
15impl ast::Lifetime {
16 pub fn text(&self) -> &SmolStr {
17 text_of_first_token(self.syntax())
18 }
19}
20
15impl ast::Name { 21impl ast::Name {
16 pub fn text(&self) -> &SmolStr { 22 pub fn text(&self) -> &SmolStr {
17 text_of_first_token(self.syntax()) 23 text_of_first_token(self.syntax())
@@ -393,7 +399,7 @@ pub enum TypeBoundKind {
393 /// for<'a> ... 399 /// for<'a> ...
394 ForType(ast::ForType), 400 ForType(ast::ForType),
395 /// 'a 401 /// 'a
396 Lifetime(SyntaxToken), 402 Lifetime(ast::Lifetime),
397} 403}
398 404
399impl ast::TypeBound { 405impl ast::TypeBound {
@@ -402,7 +408,7 @@ impl ast::TypeBound {
402 TypeBoundKind::PathType(path_type) 408 TypeBoundKind::PathType(path_type)
403 } else if let Some(for_type) = support::children(self.syntax()).next() { 409 } else if let Some(for_type) = support::children(self.syntax()).next() {
404 TypeBoundKind::ForType(for_type) 410 TypeBoundKind::ForType(for_type)
405 } else if let Some(lifetime) = self.lifetime_token() { 411 } else if let Some(lifetime) = self.lifetime() {
406 TypeBoundKind::Lifetime(lifetime) 412 TypeBoundKind::Lifetime(lifetime)
407 } else { 413 } else {
408 unreachable!() 414 unreachable!()
@@ -440,7 +446,7 @@ impl ast::LifetimeParam {
440 .children_with_tokens() 446 .children_with_tokens()
441 .filter_map(|it| it.into_token()) 447 .filter_map(|it| it.into_token())
442 .skip_while(|x| x.kind() != T![:]) 448 .skip_while(|x| x.kind() != T![:])
443 .filter(|it| it.kind() == T![lifetime]) 449 .filter(|it| it.kind() == T![lifetime_ident])
444 } 450 }
445} 451}
446 452