aboutsummaryrefslogtreecommitdiff
path: root/crates/assists/src/handlers
diff options
context:
space:
mode:
authorDomantas Jadenkus <[email protected]>2021-02-13 20:51:48 +0000
committerDomantas Jadenkus <[email protected]>2021-02-13 20:51:48 +0000
commit7f100fff92ab4944f3d49cf7ffdcd91fc3578936 (patch)
tree5c3de8598d60c9ec74be9f00a3affefa68ab9c04 /crates/assists/src/handlers
parent36e8a55bee478d296f3903eb4b14914914801b38 (diff)
cargo fmt
Diffstat (limited to 'crates/assists/src/handlers')
-rw-r--r--crates/assists/src/handlers/generate_from_impl_for_enum.rs2
-rw-r--r--crates/assists/src/handlers/generate_impl.rs2
-rw-r--r--crates/assists/src/handlers/replace_derive_with_manual_impl.rs24
3 files changed, 19 insertions, 9 deletions
diff --git a/crates/assists/src/handlers/generate_from_impl_for_enum.rs b/crates/assists/src/handlers/generate_from_impl_for_enum.rs
index fac2447c9..d9388a737 100644
--- a/crates/assists/src/handlers/generate_from_impl_for_enum.rs
+++ b/crates/assists/src/handlers/generate_from_impl_for_enum.rs
@@ -3,7 +3,7 @@ use ide_db::RootDatabase;
3use syntax::ast::{self, AstNode, NameOwner}; 3use syntax::ast::{self, AstNode, NameOwner};
4use test_utils::mark; 4use test_utils::mark;
5 5
6use crate::{AssistContext, AssistId, AssistKind, Assists, utils::generate_trait_impl_text}; 6use crate::{utils::generate_trait_impl_text, AssistContext, AssistId, AssistKind, Assists};
7 7
8// Assist: generate_from_impl_for_enum 8// Assist: generate_from_impl_for_enum
9// 9//
diff --git a/crates/assists/src/handlers/generate_impl.rs b/crates/assists/src/handlers/generate_impl.rs
index e2762e5d2..050bcd4e2 100644
--- a/crates/assists/src/handlers/generate_impl.rs
+++ b/crates/assists/src/handlers/generate_impl.rs
@@ -1,6 +1,6 @@
1use syntax::ast::{self, AstNode, NameOwner}; 1use syntax::ast::{self, AstNode, NameOwner};
2 2
3use crate::{AssistContext, AssistId, AssistKind, Assists, utils::generate_impl_text}; 3use crate::{utils::generate_impl_text, AssistContext, AssistId, AssistKind, Assists};
4 4
5// Assist: generate_impl 5// Assist: generate_impl
6// 6//
diff --git a/crates/assists/src/handlers/replace_derive_with_manual_impl.rs b/crates/assists/src/handlers/replace_derive_with_manual_impl.rs
index 7f44d752f..c69bc5cac 100644
--- a/crates/assists/src/handlers/replace_derive_with_manual_impl.rs
+++ b/crates/assists/src/handlers/replace_derive_with_manual_impl.rs
@@ -1,9 +1,20 @@
1use ide_db::helpers::mod_path_to_ast; 1use ide_db::helpers::mod_path_to_ast;
2use ide_db::imports_locator; 2use ide_db::imports_locator;
3use itertools::Itertools; 3use itertools::Itertools;
4use syntax::{SyntaxKind::{IDENT, WHITESPACE}, TextSize, ast::{self, AstNode, NameOwner, make}}; 4use syntax::{
5 5 ast::{self, make, AstNode, NameOwner},
6use crate::{AssistId, AssistKind, assist_context::{AssistBuilder, AssistContext, Assists}, utils::{Cursor, DefaultMethods, add_trait_assoc_items_to_impl, filter_assoc_items, generate_trait_impl_text, render_snippet}}; 6 SyntaxKind::{IDENT, WHITESPACE},
7 TextSize,
8};
9
10use crate::{
11 assist_context::{AssistBuilder, AssistContext, Assists},
12 utils::{
13 add_trait_assoc_items_to_impl, filter_assoc_items, generate_trait_impl_text,
14 render_snippet, Cursor, DefaultMethods,
15 },
16 AssistId, AssistKind,
17};
7 18
8// Assist: replace_derive_with_manual_impl 19// Assist: replace_derive_with_manual_impl
9// 20//
@@ -105,10 +116,9 @@ fn add_assist(
105 update_attribute(builder, &input, &trait_name, &attr); 116 update_attribute(builder, &input, &trait_name, &attr);
106 let trait_path = format!("{}", trait_path); 117 let trait_path = format!("{}", trait_path);
107 match (ctx.config.snippet_cap, impl_def_with_items) { 118 match (ctx.config.snippet_cap, impl_def_with_items) {
108 (None, _) => builder.insert( 119 (None, _) => {
109 insert_pos, 120 builder.insert(insert_pos, generate_trait_impl_text(adt, &trait_path, ""))
110 generate_trait_impl_text(adt, &trait_path, ""), 121 }
111 ),
112 (Some(cap), None) => builder.insert_snippet( 122 (Some(cap), None) => builder.insert_snippet(
113 cap, 123 cap,
114 insert_pos, 124 insert_pos,