diff options
author | Aleksey Kladov <[email protected]> | 2020-10-06 15:19:18 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-10-06 15:19:18 +0100 |
commit | 2090b534fc249a493823bb8e9039c0123aa0b90e (patch) | |
tree | f6f8469d5e4bbd37655aabb75edf32a392b0ed0c /crates/assists/src/handlers/extract_struct_from_enum_variant.rs | |
parent | 9507a01e9e76afca9f6f8d460089fc199703b820 (diff) |
Move ModPath->ast::Path function to IDE layer
closes #6092
Diffstat (limited to 'crates/assists/src/handlers/extract_struct_from_enum_variant.rs')
-rw-r--r-- | crates/assists/src/handlers/extract_struct_from_enum_variant.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/crates/assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs index f5f03ef36..7f4f80b23 100644 --- a/crates/assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs | |||
@@ -10,9 +10,10 @@ use syntax::{ | |||
10 | }; | 10 | }; |
11 | 11 | ||
12 | use crate::{ | 12 | use crate::{ |
13 | assist_context::AssistBuilder, utils::insert_use, AssistContext, AssistId, AssistKind, Assists, | 13 | assist_context::AssistBuilder, |
14 | utils::{insert_use, mod_path_to_ast, ImportScope}, | ||
15 | AssistContext, AssistId, AssistKind, Assists, | ||
14 | }; | 16 | }; |
15 | use insert_use::ImportScope; | ||
16 | 17 | ||
17 | // Assist: extract_struct_from_enum_variant | 18 | // Assist: extract_struct_from_enum_variant |
18 | // | 19 | // |
@@ -111,7 +112,8 @@ fn insert_import( | |||
111 | let scope = ImportScope::find_insert_use_container(path.syntax(), ctx)?; | 112 | let scope = ImportScope::find_insert_use_container(path.syntax(), ctx)?; |
112 | let syntax = scope.as_syntax_node(); | 113 | let syntax = scope.as_syntax_node(); |
113 | 114 | ||
114 | let new_syntax = insert_use(&scope, mod_path.to_ast_path(), ctx.config.insert_use.merge); | 115 | let new_syntax = |
116 | insert_use(&scope, mod_path_to_ast(&mod_path), ctx.config.insert_use.merge); | ||
115 | // FIXME: this will currently panic as multiple imports will have overlapping text ranges | 117 | // FIXME: this will currently panic as multiple imports will have overlapping text ranges |
116 | builder.replace(syntax.text_range(), new_syntax.to_string()) | 118 | builder.replace(syntax.text_range(), new_syntax.to_string()) |
117 | } | 119 | } |