From a1e18695548b5cd6661f26a985b34c8b105e1896 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 29 Feb 2020 21:24:40 +0100 Subject: Rename ast::ImplBlock -> ast::ImplDef --- .../ra_assists/src/handlers/add_missing_impl_members.rs | 6 +++--- crates/ra_assists/src/handlers/add_new.rs | 16 ++++++++-------- crates/ra_assists/src/handlers/move_bounds.rs | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'crates/ra_assists/src/handlers') diff --git a/crates/ra_assists/src/handlers/add_missing_impl_members.rs b/crates/ra_assists/src/handlers/add_missing_impl_members.rs index 4005014bd..639180d37 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs @@ -101,7 +101,7 @@ fn add_missing_impl_members_inner( label: &'static str, ) -> Option { let _p = ra_prof::profile("add_missing_impl_members_inner"); - let impl_node = ctx.find_node_at_offset::()?; + let impl_node = ctx.find_node_at_offset::()?; let impl_item_list = impl_node.item_list()?; let trait_ = resolve_target_trait(&ctx.sema, &impl_node)?; @@ -257,7 +257,7 @@ impl Foo for S { } #[test] - fn test_empty_impl_block() { + fn test_empty_impl_def() { check_assist( add_missing_impl_members, " @@ -308,7 +308,7 @@ impl Foo for S { } #[test] - fn test_cursor_after_empty_impl_block() { + fn test_cursor_after_empty_impl_def() { check_assist( add_missing_impl_members, " diff --git a/crates/ra_assists/src/handlers/add_new.rs b/crates/ra_assists/src/handlers/add_new.rs index 166e907fb..697e7cda6 100644 --- a/crates/ra_assists/src/handlers/add_new.rs +++ b/crates/ra_assists/src/handlers/add_new.rs @@ -41,14 +41,14 @@ pub(crate) fn add_new(ctx: AssistCtx) -> Option { }; // Return early if we've found an existing new fn - let impl_block = find_struct_impl(&ctx, &strukt)?; + let impl_def = find_struct_impl(&ctx, &strukt)?; ctx.add_assist(AssistId("add_new"), "Add default constructor", |edit| { edit.target(strukt.syntax().text_range()); let mut buf = String::with_capacity(512); - if impl_block.is_some() { + if impl_def.is_some() { buf.push('\n'); } @@ -71,10 +71,10 @@ pub(crate) fn add_new(ctx: AssistCtx) -> Option { buf.push_str("} }"); - let (start_offset, end_offset) = impl_block - .and_then(|impl_block| { + let (start_offset, end_offset) = impl_def + .and_then(|impl_def| { buf.push('\n'); - let start = impl_block + let start = impl_def .syntax() .descendants_with_tokens() .find(|t| t.kind() == T!['{'])? @@ -128,7 +128,7 @@ fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String { // // FIXME: change the new fn checking to a more semantic approach when that's more // viable (e.g. we process proc macros, etc) -fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option> { +fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option> { let db = ctx.db; let module = strukt.syntax().ancestors().find(|node| { ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) @@ -136,7 +136,7 @@ fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option; impl S {}` @@ -164,7 +164,7 @@ fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option bool { +fn has_new_fn(imp: &ast::ImplDef) -> bool { if let Some(il) = imp.item_list() { for item in il.impl_items() { if let ast::ImplItem::FnDef(f) = item { diff --git a/crates/ra_assists/src/handlers/move_bounds.rs b/crates/ra_assists/src/handlers/move_bounds.rs index 86b235366..0b501f3e5 100644 --- a/crates/ra_assists/src/handlers/move_bounds.rs +++ b/crates/ra_assists/src/handlers/move_bounds.rs @@ -37,7 +37,7 @@ pub(crate) fn move_bounds_to_where_clause(ctx: AssistCtx) -> Option { let anchor: SyntaxElement = match parent.kind() { FN_DEF => ast::FnDef::cast(parent)?.body()?.syntax().clone().into(), TRAIT_DEF => ast::TraitDef::cast(parent)?.item_list()?.syntax().clone().into(), - IMPL_BLOCK => ast::ImplBlock::cast(parent)?.item_list()?.syntax().clone().into(), + IMPL_DEF => ast::ImplDef::cast(parent)?.item_list()?.syntax().clone().into(), ENUM_DEF => ast::EnumDef::cast(parent)?.variant_list()?.syntax().clone().into(), STRUCT_DEF => parent .children_with_tokens() -- cgit v1.2.3