diff options
Diffstat (limited to 'crates/ra_syntax/src/ast/extensions.rs')
-rw-r--r-- | crates/ra_syntax/src/ast/extensions.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index b50a89864..fc252e79c 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs | |||
@@ -5,9 +5,7 @@ use itertools::Itertools; | |||
5 | use ra_parser::SyntaxKind; | 5 | use ra_parser::SyntaxKind; |
6 | 6 | ||
7 | use crate::{ | 7 | use crate::{ |
8 | ast::{ | 8 | ast::{self, support, AstNode, AstToken, AttrInput, NameOwner, SyntaxNode}, |
9 | self, child_opt, children, support, AstNode, AstToken, AttrInput, NameOwner, SyntaxNode, | ||
10 | }, | ||
11 | SmolStr, SyntaxElement, SyntaxToken, T, | 9 | SmolStr, SyntaxElement, SyntaxToken, T, |
12 | }; | 10 | }; |
13 | 11 | ||
@@ -161,7 +159,7 @@ impl ast::ImplDef { | |||
161 | } | 159 | } |
162 | 160 | ||
163 | fn target(&self) -> (Option<ast::TypeRef>, Option<ast::TypeRef>) { | 161 | fn target(&self) -> (Option<ast::TypeRef>, Option<ast::TypeRef>) { |
164 | let mut types = children(self); | 162 | let mut types = support::children(self.syntax()); |
165 | let first = types.next(); | 163 | let first = types.next(); |
166 | let second = types.next(); | 164 | let second = types.next(); |
167 | (first, second) | 165 | (first, second) |
@@ -177,9 +175,9 @@ pub enum StructKind { | |||
177 | 175 | ||
178 | impl StructKind { | 176 | impl StructKind { |
179 | fn from_node<N: AstNode>(node: &N) -> StructKind { | 177 | fn from_node<N: AstNode>(node: &N) -> StructKind { |
180 | if let Some(nfdl) = child_opt::<_, ast::RecordFieldDefList>(node) { | 178 | if let Some(nfdl) = support::child::<ast::RecordFieldDefList>(node.syntax()) { |
181 | StructKind::Record(nfdl) | 179 | StructKind::Record(nfdl) |
182 | } else if let Some(pfl) = child_opt::<_, ast::TupleFieldDefList>(node) { | 180 | } else if let Some(pfl) = support::child::<ast::TupleFieldDefList>(node.syntax()) { |
183 | StructKind::Tuple(pfl) | 181 | StructKind::Tuple(pfl) |
184 | } else { | 182 | } else { |
185 | StructKind::Unit | 183 | StructKind::Unit |
@@ -322,9 +320,9 @@ pub enum TypeBoundKind { | |||
322 | 320 | ||
323 | impl ast::TypeBound { | 321 | impl ast::TypeBound { |
324 | pub fn kind(&self) -> TypeBoundKind { | 322 | pub fn kind(&self) -> TypeBoundKind { |
325 | if let Some(path_type) = children(self).next() { | 323 | if let Some(path_type) = support::children(self.syntax()).next() { |
326 | TypeBoundKind::PathType(path_type) | 324 | TypeBoundKind::PathType(path_type) |
327 | } else if let Some(for_type) = children(self).next() { | 325 | } else if let Some(for_type) = support::children(self.syntax()).next() { |
328 | TypeBoundKind::ForType(for_type) | 326 | TypeBoundKind::ForType(for_type) |
329 | } else if let Some(lifetime) = self.lifetime_token() { | 327 | } else if let Some(lifetime) = self.lifetime_token() { |
330 | TypeBoundKind::Lifetime(lifetime) | 328 | TypeBoundKind::Lifetime(lifetime) |
@@ -364,7 +362,7 @@ pub enum VisibilityKind { | |||
364 | 362 | ||
365 | impl ast::Visibility { | 363 | impl ast::Visibility { |
366 | pub fn kind(&self) -> VisibilityKind { | 364 | pub fn kind(&self) -> VisibilityKind { |
367 | if let Some(path) = children(self).next() { | 365 | if let Some(path) = support::children(self.syntax()).next() { |
368 | VisibilityKind::In(path) | 366 | VisibilityKind::In(path) |
369 | } else if self.crate_kw_token().is_some() { | 367 | } else if self.crate_kw_token().is_some() { |
370 | VisibilityKind::PubCrate | 368 | VisibilityKind::PubCrate |