diff options
Diffstat (limited to 'crates/ra_syntax/src/ast/extensions.rs')
-rw-r--r-- | crates/ra_syntax/src/ast/extensions.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index 400eba210..33fe60762 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs | |||
@@ -5,8 +5,7 @@ use itertools::Itertools; | |||
5 | 5 | ||
6 | use crate::{ | 6 | use crate::{ |
7 | ast::{ | 7 | ast::{ |
8 | self, child_opt, child_token_opt, children, AstElement, AstNode, AstToken, AttrInput, | 8 | self, child_opt, children, support, AstNode, AstToken, AttrInput, NameOwner, SyntaxNode, |
9 | NameOwner, SyntaxNode, | ||
10 | }, | 9 | }, |
11 | SmolStr, SyntaxElement, | 10 | SmolStr, SyntaxElement, |
12 | SyntaxKind::*, | 11 | SyntaxKind::*, |
@@ -437,7 +436,7 @@ impl ast::TypeBound { | |||
437 | .skip_while(|it| it.kind() != T![const]) | 436 | .skip_while(|it| it.kind() != T![const]) |
438 | .find_map(ast::Question::cast) | 437 | .find_map(ast::Question::cast) |
439 | } else { | 438 | } else { |
440 | child_token_opt(self) | 439 | support::token(&self.syntax) |
441 | } | 440 | } |
442 | } | 441 | } |
443 | } | 442 | } |
@@ -509,7 +508,7 @@ impl ast::RangePat { | |||
509 | pub fn start(&self) -> Option<ast::Pat> { | 508 | pub fn start(&self) -> Option<ast::Pat> { |
510 | self.syntax() | 509 | self.syntax() |
511 | .children_with_tokens() | 510 | .children_with_tokens() |
512 | .take_while(|it| !ast::RangeSeparator::can_cast_element(it.kind())) | 511 | .take_while(|it| !ast::RangeSeparator::can_cast(it.kind())) |
513 | .filter_map(|it| it.into_node()) | 512 | .filter_map(|it| it.into_node()) |
514 | .find_map(ast::Pat::cast) | 513 | .find_map(ast::Pat::cast) |
515 | } | 514 | } |
@@ -517,7 +516,7 @@ impl ast::RangePat { | |||
517 | pub fn end(&self) -> Option<ast::Pat> { | 516 | pub fn end(&self) -> Option<ast::Pat> { |
518 | self.syntax() | 517 | self.syntax() |
519 | .children_with_tokens() | 518 | .children_with_tokens() |
520 | .skip_while(|it| !ast::RangeSeparator::can_cast_element(it.kind())) | 519 | .skip_while(|it| !ast::RangeSeparator::can_cast(it.kind())) |
521 | .filter_map(|it| it.into_node()) | 520 | .filter_map(|it| it.into_node()) |
522 | .find_map(ast::Pat::cast) | 521 | .find_map(ast::Pat::cast) |
523 | } | 522 | } |
@@ -525,10 +524,10 @@ impl ast::RangePat { | |||
525 | 524 | ||
526 | impl ast::TokenTree { | 525 | impl ast::TokenTree { |
527 | pub fn left_delimiter(&self) -> Option<ast::LeftDelimiter> { | 526 | pub fn left_delimiter(&self) -> Option<ast::LeftDelimiter> { |
528 | self.syntax().first_child_or_token().and_then(ast::LeftDelimiter::cast_element) | 527 | self.syntax().first_child_or_token()?.into_token().and_then(ast::LeftDelimiter::cast) |
529 | } | 528 | } |
530 | 529 | ||
531 | pub fn right_delimiter(&self) -> Option<ast::RightDelimiter> { | 530 | pub fn right_delimiter(&self) -> Option<ast::RightDelimiter> { |
532 | self.syntax().last_child_or_token().and_then(ast::RightDelimiter::cast_element) | 531 | self.syntax().last_child_or_token()?.into_token().and_then(ast::RightDelimiter::cast) |
533 | } | 532 | } |
534 | } | 533 | } |