aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-08-05 21:42:38 +0100
committerFlorian Diebold <[email protected]>2019-08-12 20:43:00 +0100
commit22724f37f3ae73983bf700d10d80a8dbd4fa4073 (patch)
treef5970c453f15d2b60e7c7b026de34316a5c8f4e0 /crates/ra_syntax
parent6cfdfdecbaed38534397f16e1ea1cda38b0b9395 (diff)
Lower fully qualified associated type paths
I.e. `<T as Trait>::Foo`.
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast/extensions.rs10
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)]
92pub enum PathSegmentKind { 92pub 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 };