diff options
Diffstat (limited to 'crates/ra_syntax/src/ast/extensions.rs')
-rw-r--r-- | crates/ra_syntax/src/ast/extensions.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index d4873b39a..2a59cf653 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs | |||
@@ -91,6 +91,7 @@ impl ast::Attr { | |||
91 | #[derive(Debug, Clone, PartialEq, Eq)] | 91 | #[derive(Debug, Clone, PartialEq, Eq)] |
92 | pub enum PathSegmentKind { | 92 | pub enum PathSegmentKind { |
93 | Name(ast::NameRef), | 93 | Name(ast::NameRef), |
94 | Type { type_ref: Option<ast::TypeRef>, trait_ref: Option<ast::PathType> }, | ||
94 | SelfKw, | 95 | SelfKw, |
95 | SuperKw, | 96 | SuperKw, |
96 | CrateKw, | 97 | CrateKw, |
@@ -112,6 +113,15 @@ impl ast::PathSegment { | |||
112 | T![self] => PathSegmentKind::SelfKw, | 113 | T![self] => PathSegmentKind::SelfKw, |
113 | T![super] => PathSegmentKind::SuperKw, | 114 | T![super] => PathSegmentKind::SuperKw, |
114 | T![crate] => PathSegmentKind::CrateKw, | 115 | T![crate] => PathSegmentKind::CrateKw, |
116 | T![<] => { | ||
117 | // <T> or <T as Trait> | ||
118 | // T is any TypeRef, Trait has to be a PathType | ||
119 | let mut type_refs = | ||
120 | self.syntax().children().filter(|node| ast::TypeRef::can_cast(node.kind())); | ||
121 | let type_ref = type_refs.next().and_then(ast::TypeRef::cast); | ||
122 | let trait_ref = type_refs.next().and_then(ast::PathType::cast); | ||
123 | PathSegmentKind::Type { type_ref, trait_ref } | ||
124 | } | ||
115 | _ => return None, | 125 | _ => return None, |
116 | } | 126 | } |
117 | }; | 127 | }; |