aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/handlers/generate_new.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-07-30 16:51:06 +0100
committerGitHub <[email protected]>2020-07-30 16:51:06 +0100
commit97df465391f50521c5102474d7e0ee2ea61ef48e (patch)
tree2bda021d9fafc6af927ebfbcafd31537496bd53c /crates/ra_assists/src/handlers/generate_new.rs
parent0c8944314cb323416c8ad6ad27347ca056c5a91c (diff)
parent216a5344c8ef3c3e430d2761dc8b1a7b60250a15 (diff)
Merge #5602
5602: Rename StructDef -> Struct r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/handlers/generate_new.rs')
-rw-r--r--crates/ra_assists/src/handlers/generate_new.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/crates/ra_assists/src/handlers/generate_new.rs b/crates/ra_assists/src/handlers/generate_new.rs
index 340f9b103..22b47d254 100644
--- a/crates/ra_assists/src/handlers/generate_new.rs
+++ b/crates/ra_assists/src/handlers/generate_new.rs
@@ -31,7 +31,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
31// 31//
32// ``` 32// ```
33pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 33pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
34 let strukt = ctx.find_node_at_offset::<ast::StructDef>()?; 34 let strukt = ctx.find_node_at_offset::<ast::Struct>()?;
35 35
36 // We want to only apply this to non-union structs with named fields 36 // We want to only apply this to non-union structs with named fields
37 let field_list = match strukt.kind() { 37 let field_list = match strukt.kind() {
@@ -91,7 +91,7 @@ pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
91 91
92// Generates the surrounding `impl Type { <code> }` including type and lifetime 92// Generates the surrounding `impl Type { <code> }` including type and lifetime
93// parameters 93// parameters
94fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String { 94fn generate_impl_text(strukt: &ast::Struct, code: &str) -> String {
95 let type_params = strukt.generic_param_list(); 95 let type_params = strukt.generic_param_list();
96 let mut buf = String::with_capacity(code.len()); 96 let mut buf = String::with_capacity(code.len());
97 buf.push_str("\n\nimpl"); 97 buf.push_str("\n\nimpl");
@@ -122,7 +122,7 @@ fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String {
122// 122//
123// FIXME: change the new fn checking to a more semantic approach when that's more 123// FIXME: change the new fn checking to a more semantic approach when that's more
124// viable (e.g. we process proc macros, etc) 124// viable (e.g. we process proc macros, etc)
125fn find_struct_impl(ctx: &AssistContext, strukt: &ast::StructDef) -> Option<Option<ast::ImplDef>> { 125fn find_struct_impl(ctx: &AssistContext, strukt: &ast::Struct) -> Option<Option<ast::ImplDef>> {
126 let db = ctx.db(); 126 let db = ctx.db();
127 let module = strukt.syntax().ancestors().find(|node| { 127 let module = strukt.syntax().ancestors().find(|node| {
128 ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) 128 ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind())