From 22724f37f3ae73983bf700d10d80a8dbd4fa4073 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Mon, 5 Aug 2019 22:42:38 +0200 Subject: Lower fully qualified associated type paths I.e. `::Foo`. --- crates/ra_syntax/src/ast/extensions.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'crates/ra_syntax/src') 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 { #[derive(Debug, Clone, PartialEq, Eq)] pub enum PathSegmentKind { Name(ast::NameRef), + Type { type_ref: Option, trait_ref: Option }, SelfKw, SuperKw, CrateKw, @@ -112,6 +113,15 @@ impl ast::PathSegment { T![self] => PathSegmentKind::SelfKw, T![super] => PathSegmentKind::SuperKw, T![crate] => PathSegmentKind::CrateKw, + T![<] => { + // or + // T is any TypeRef, Trait has to be a PathType + let mut type_refs = + self.syntax().children().filter(|node| ast::TypeRef::can_cast(node.kind())); + let type_ref = type_refs.next().and_then(ast::TypeRef::cast); + let trait_ref = type_refs.next().and_then(ast::PathType::cast); + PathSegmentKind::Type { type_ref, trait_ref } + } _ => return None, } }; -- cgit v1.2.3