From 6d253b58da955cee73b0715b91d728df5009937d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 7 Nov 2018 21:38:41 +0300 Subject: Complete paths in use trees --- crates/ra_syntax/src/ast/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'crates/ra_syntax') diff --git a/crates/ra_syntax/src/ast/mod.rs b/crates/ra_syntax/src/ast/mod.rs index d93f92672..6b0d62610 100644 --- a/crates/ra_syntax/src/ast/mod.rs +++ b/crates/ra_syntax/src/ast/mod.rs @@ -296,6 +296,15 @@ impl<'a> PathSegment<'a> { } } +impl<'a> UseTreeList<'a> { + pub fn parent_use_tree(self) -> UseTree<'a> { + self.syntax() + .parent() + .and_then(UseTree::cast) + .expect("UseTreeLists are always nested in UseTrees") + } +} + fn child_opt<'a, P: AstNode<'a>, C: AstNode<'a>>(parent: P) -> Option { children(parent).next() } -- cgit v1.2.3