aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/handlers/split_import.rs
diff options
context:
space:
mode:
authorvsrs <[email protected]>2020-05-08 17:34:34 +0100
committervsrs <[email protected]>2020-05-08 17:34:34 +0100
commit0ef17ef1ee9fb0ce7149176d12f4d225f6d01401 (patch)
treefa2f168120f36f8dbef5dc1e85fea0c0071639c2 /crates/ra_assists/src/handlers/split_import.rs
parent1be6320ea6cf7830195f80681fa0f43cc340da7e (diff)
parentd3eb9d8eafbebca7da95fa8a4813b92eb5080500 (diff)
Merge remote-tracking branch 'upstream/master' into uniformed_debug_lens
# Conflicts: # editors/code/src/commands/runnables.ts
Diffstat (limited to 'crates/ra_assists/src/handlers/split_import.rs')
-rw-r--r--crates/ra_assists/src/handlers/split_import.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/ra_assists/src/handlers/split_import.rs b/crates/ra_assists/src/handlers/split_import.rs
index d49563974..b2757e50c 100644
--- a/crates/ra_assists/src/handlers/split_import.rs
+++ b/crates/ra_assists/src/handlers/split_import.rs
@@ -2,7 +2,7 @@ use std::iter::successors;
2 2
3use ra_syntax::{ast, AstNode, T}; 3use ra_syntax::{ast, AstNode, T};
4 4
5use crate::{Assist, AssistCtx, AssistId}; 5use crate::{AssistContext, AssistId, Assists};
6 6
7// Assist: split_import 7// Assist: split_import
8// 8//
@@ -15,7 +15,7 @@ use crate::{Assist, AssistCtx, AssistId};
15// ``` 15// ```
16// use std::{collections::HashMap}; 16// use std::{collections::HashMap};
17// ``` 17// ```
18pub(crate) fn split_import(ctx: AssistCtx) -> Option<Assist> { 18pub(crate) fn split_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
19 let colon_colon = ctx.find_token_at_offset(T![::])?; 19 let colon_colon = ctx.find_token_at_offset(T![::])?;
20 let path = ast::Path::cast(colon_colon.parent())?.qualifier()?; 20 let path = ast::Path::cast(colon_colon.parent())?.qualifier()?;
21 let top_path = successors(Some(path.clone()), |it| it.parent_path()).last()?; 21 let top_path = successors(Some(path.clone()), |it| it.parent_path()).last()?;
@@ -26,10 +26,10 @@ pub(crate) fn split_import(ctx: AssistCtx) -> Option<Assist> {
26 if new_tree == use_tree { 26 if new_tree == use_tree {
27 return None; 27 return None;
28 } 28 }
29 let cursor = ctx.frange.range.start(); 29 let cursor = ctx.offset();
30 30
31 let target = colon_colon.text_range(); 31 let target = colon_colon.text_range();
32 ctx.add_assist(AssistId("split_import"), "Split import", target, |edit| { 32 acc.add(AssistId("split_import"), "Split import", target, |edit| {
33 edit.replace_ast(use_tree, new_tree); 33 edit.replace_ast(use_tree, new_tree);
34 edit.set_cursor(cursor); 34 edit.set_cursor(cursor);
35 }) 35 })