diff options
Diffstat (limited to 'crates/ra_assists')
-rw-r--r-- | crates/ra_assists/src/split_import.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/crates/ra_assists/src/split_import.rs b/crates/ra_assists/src/split_import.rs index 4bf1852db..57e0efaf2 100644 --- a/crates/ra_assists/src/split_import.rs +++ b/crates/ra_assists/src/split_import.rs | |||
@@ -1,8 +1,9 @@ | |||
1 | use std::iter::successors; | ||
2 | |||
1 | use hir::db::HirDatabase; | 3 | use hir::db::HirDatabase; |
2 | use ra_syntax::{ | 4 | use ra_syntax::{ |
3 | TextUnit, AstNode, SyntaxKind::COLONCOLON, | 5 | TextUnit, AstNode, SyntaxKind::COLONCOLON, |
4 | ast, | 6 | ast, |
5 | algo::generate, | ||
6 | }; | 7 | }; |
7 | 8 | ||
8 | use crate::{AssistCtx, Assist, AssistId}; | 9 | use crate::{AssistCtx, Assist, AssistId}; |
@@ -10,7 +11,7 @@ use crate::{AssistCtx, Assist, AssistId}; | |||
10 | pub(crate) fn split_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 11 | pub(crate) fn split_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
11 | let colon_colon = ctx.token_at_offset().find(|leaf| leaf.kind() == COLONCOLON)?; | 12 | let colon_colon = ctx.token_at_offset().find(|leaf| leaf.kind() == COLONCOLON)?; |
12 | let path = ast::Path::cast(colon_colon.parent())?; | 13 | let path = ast::Path::cast(colon_colon.parent())?; |
13 | let top_path = generate(Some(path), |it| it.parent_path()).last()?; | 14 | let top_path = successors(Some(path), |it| it.parent_path()).last()?; |
14 | 15 | ||
15 | let use_tree = top_path.syntax().ancestors().find_map(ast::UseTree::cast); | 16 | let use_tree = top_path.syntax().ancestors().find_map(ast::UseTree::cast); |
16 | if use_tree.is_none() { | 17 | if use_tree.is_none() { |