aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists')
-rw-r--r--crates/ra_assists/src/split_import.rs5
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 @@
1use std::iter::successors;
2
1use hir::db::HirDatabase; 3use hir::db::HirDatabase;
2use ra_syntax::{ 4use ra_syntax::{
3 TextUnit, AstNode, SyntaxKind::COLONCOLON, 5 TextUnit, AstNode, SyntaxKind::COLONCOLON,
4 ast, 6 ast,
5 algo::generate,
6}; 7};
7 8
8use crate::{AssistCtx, Assist, AssistId}; 9use crate::{AssistCtx, Assist, AssistId};
@@ -10,7 +11,7 @@ use crate::{AssistCtx, Assist, AssistId};
10pub(crate) fn split_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 11pub(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() {