diff options
author | vsrs <[email protected]> | 2020-05-08 17:34:34 +0100 |
---|---|---|
committer | vsrs <[email protected]> | 2020-05-08 17:34:34 +0100 |
commit | 0ef17ef1ee9fb0ce7149176d12f4d225f6d01401 (patch) | |
tree | fa2f168120f36f8dbef5dc1e85fea0c0071639c2 /crates/ra_assists/src/handlers/add_new.rs | |
parent | 1be6320ea6cf7830195f80681fa0f43cc340da7e (diff) | |
parent | d3eb9d8eafbebca7da95fa8a4813b92eb5080500 (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/add_new.rs')
-rw-r--r-- | crates/ra_assists/src/handlers/add_new.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/ra_assists/src/handlers/add_new.rs b/crates/ra_assists/src/handlers/add_new.rs index 1c3f8435a..fe7451dcf 100644 --- a/crates/ra_assists/src/handlers/add_new.rs +++ b/crates/ra_assists/src/handlers/add_new.rs | |||
@@ -7,7 +7,7 @@ use ra_syntax::{ | |||
7 | }; | 7 | }; |
8 | use stdx::{format_to, SepBy}; | 8 | use stdx::{format_to, SepBy}; |
9 | 9 | ||
10 | use crate::{Assist, AssistCtx, AssistId}; | 10 | use crate::{AssistContext, AssistId, Assists}; |
11 | 11 | ||
12 | // Assist: add_new | 12 | // Assist: add_new |
13 | // | 13 | // |
@@ -29,7 +29,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
29 | // } | 29 | // } |
30 | // | 30 | // |
31 | // ``` | 31 | // ``` |
32 | pub(crate) fn add_new(ctx: AssistCtx) -> Option<Assist> { | 32 | pub(crate) fn add_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
33 | let strukt = ctx.find_node_at_offset::<ast::StructDef>()?; | 33 | let strukt = ctx.find_node_at_offset::<ast::StructDef>()?; |
34 | 34 | ||
35 | // We want to only apply this to non-union structs with named fields | 35 | // We want to only apply this to non-union structs with named fields |
@@ -42,7 +42,7 @@ pub(crate) fn add_new(ctx: AssistCtx) -> Option<Assist> { | |||
42 | let impl_def = find_struct_impl(&ctx, &strukt)?; | 42 | let impl_def = find_struct_impl(&ctx, &strukt)?; |
43 | 43 | ||
44 | let target = strukt.syntax().text_range(); | 44 | let target = strukt.syntax().text_range(); |
45 | ctx.add_assist(AssistId("add_new"), "Add default constructor", target, |edit| { | 45 | acc.add(AssistId("add_new"), "Add default constructor", target, |edit| { |
46 | let mut buf = String::with_capacity(512); | 46 | let mut buf = String::with_capacity(512); |
47 | 47 | ||
48 | if impl_def.is_some() { | 48 | if impl_def.is_some() { |
@@ -123,7 +123,7 @@ fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String { | |||
123 | // | 123 | // |
124 | // FIXME: change the new fn checking to a more semantic approach when that's more | 124 | // FIXME: change the new fn checking to a more semantic approach when that's more |
125 | // viable (e.g. we process proc macros, etc) | 125 | // viable (e.g. we process proc macros, etc) |
126 | fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option<Option<ast::ImplDef>> { | 126 | fn find_struct_impl(ctx: &AssistContext, strukt: &ast::StructDef) -> Option<Option<ast::ImplDef>> { |
127 | let db = ctx.db; | 127 | let db = ctx.db; |
128 | let module = strukt.syntax().ancestors().find(|node| { | 128 | let module = strukt.syntax().ancestors().find(|node| { |
129 | ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) | 129 | ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) |