diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-10-27 14:38:28 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-10-27 14:38:28 +0000 |
commit | cf309b6a5f2d51e9509568ab82446cc3eae29f94 (patch) | |
tree | 54c4a26d7a6688a89515cdc97ec02c1a9f9103bf /crates/ra_assists/src/assists/split_import.rs | |
parent | ad950830d0902aaacfb5a76355a203626eb93b5f (diff) | |
parent | cda6355de23825c201d02e6062cb2dd414e98bf9 (diff) |
Merge #2094
2094: simplify AssistCtx API r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/assists/split_import.rs')
-rw-r--r-- | crates/ra_assists/src/assists/split_import.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/crates/ra_assists/src/assists/split_import.rs b/crates/ra_assists/src/assists/split_import.rs index 8d8a28987..5f8d6b0be 100644 --- a/crates/ra_assists/src/assists/split_import.rs +++ b/crates/ra_assists/src/assists/split_import.rs | |||
@@ -16,7 +16,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
16 | // ``` | 16 | // ``` |
17 | // use std::{collections::HashMap}; | 17 | // use std::{collections::HashMap}; |
18 | // ``` | 18 | // ``` |
19 | pub(crate) fn split_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 19 | pub(crate) fn split_import(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
20 | let colon_colon = ctx.find_token_at_offset(T![::])?; | 20 | let colon_colon = ctx.find_token_at_offset(T![::])?; |
21 | let path = ast::Path::cast(colon_colon.parent())?; | 21 | let path = ast::Path::cast(colon_colon.parent())?; |
22 | let top_path = successors(Some(path), |it| it.parent_path()).last()?; | 22 | let top_path = successors(Some(path), |it| it.parent_path()).last()?; |
@@ -32,14 +32,12 @@ pub(crate) fn split_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assis | |||
32 | None => top_path.syntax().text_range().end(), | 32 | None => top_path.syntax().text_range().end(), |
33 | }; | 33 | }; |
34 | 34 | ||
35 | ctx.add_action(AssistId("split_import"), "split import", |edit| { | 35 | ctx.add_assist(AssistId("split_import"), "split import", |edit| { |
36 | edit.target(colon_colon.text_range()); | 36 | edit.target(colon_colon.text_range()); |
37 | edit.insert(l_curly, "{"); | 37 | edit.insert(l_curly, "{"); |
38 | edit.insert(r_curly, "}"); | 38 | edit.insert(r_curly, "}"); |
39 | edit.set_cursor(l_curly + TextUnit::of_str("{")); | 39 | edit.set_cursor(l_curly + TextUnit::of_str("{")); |
40 | }); | 40 | }) |
41 | |||
42 | ctx.build() | ||
43 | } | 41 | } |
44 | 42 | ||
45 | #[cfg(test)] | 43 | #[cfg(test)] |