diff options
Diffstat (limited to 'crates/syntax/src/ast/node_ext.rs')
-rw-r--r-- | crates/syntax/src/ast/node_ext.rs | 12 |
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 | ||
15 | impl ast::Lifetime { | ||
16 | pub fn text(&self) -> &SmolStr { | ||
17 | text_of_first_token(self.syntax()) | ||
18 | } | ||
19 | } | ||
20 | |||
15 | impl ast::Name { | 21 | impl 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 | ||
399 | impl ast::TypeBound { | 405 | impl 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 | ||