From 2984da672e0c73d56501c6b6e4d19fd28152b5eb Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 11:42:51 +0200 Subject: Split ItemList & AssocItemList --- crates/ra_assists/src/handlers/add_missing_impl_members.rs | 3 ++- crates/ra_assists/src/handlers/generate_new.rs | 2 +- crates/ra_assists/src/handlers/move_bounds.rs | 4 ++-- crates/ra_assists/src/utils.rs | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) (limited to 'crates/ra_assists/src') 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 f185e61e5..a2d9006e4 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs @@ -112,7 +112,7 @@ fn add_missing_impl_members_inner( ) -> Option<()> { let _p = ra_prof::profile("add_missing_impl_members_inner"); let impl_def = ctx.find_node_at_offset::()?; - let impl_item_list = impl_def.item_list()?; + let impl_item_list = impl_def.assoc_item_list()?; let trait_ = resolve_target_trait(&ctx.sema, &impl_def)?; @@ -121,6 +121,7 @@ fn add_missing_impl_members_inner( ast::AssocItem::FnDef(def) => def.name(), ast::AssocItem::TypeAliasDef(def) => def.name(), ast::AssocItem::ConstDef(def) => def.name(), + ast::AssocItem::MacroCall(_) => None, } .map(|it| it.text().clone()) }; diff --git a/crates/ra_assists/src/handlers/generate_new.rs b/crates/ra_assists/src/handlers/generate_new.rs index e27def1d8..25bc171bf 100644 --- a/crates/ra_assists/src/handlers/generate_new.rs +++ b/crates/ra_assists/src/handlers/generate_new.rs @@ -158,7 +158,7 @@ fn find_struct_impl(ctx: &AssistContext, strukt: &ast::StructDef) -> Option bool { - if let Some(il) = imp.item_list() { + if let Some(il) = imp.assoc_item_list() { for item in il.assoc_items() { if let ast::AssocItem::FnDef(f) = item { if let Some(name) = f.name() { diff --git a/crates/ra_assists/src/handlers/move_bounds.rs b/crates/ra_assists/src/handlers/move_bounds.rs index ba3dafb99..6b73fff44 100644 --- a/crates/ra_assists/src/handlers/move_bounds.rs +++ b/crates/ra_assists/src/handlers/move_bounds.rs @@ -38,8 +38,8 @@ pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext let anchor = match_ast! { match parent { ast::FnDef(it) => it.body()?.syntax().clone().into(), - ast::TraitDef(it) => it.item_list()?.syntax().clone().into(), - ast::ImplDef(it) => it.item_list()?.syntax().clone().into(), + ast::TraitDef(it) => it.assoc_item_list()?.syntax().clone().into(), + ast::ImplDef(it) => it.assoc_item_list()?.syntax().clone().into(), ast::EnumDef(it) => it.variant_list()?.syntax().clone().into(), ast::StructDef(it) => { it.syntax().children_with_tokens() diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs index 02de902d6..27c33df23 100644 --- a/crates/ra_assists/src/utils.rs +++ b/crates/ra_assists/src/utils.rs @@ -63,7 +63,7 @@ pub fn get_missing_assoc_items( let mut impl_fns_consts = FxHashSet::default(); let mut impl_type = FxHashSet::default(); - if let Some(item_list) = impl_def.item_list() { + if let Some(item_list) = impl_def.assoc_item_list() { for item in item_list.assoc_items() { match item { ast::AssocItem::FnDef(f) => { @@ -83,6 +83,7 @@ pub fn get_missing_assoc_items( impl_fns_consts.insert(n.syntax().to_string()); } } + ast::AssocItem::MacroCall(_) => (), } } } -- cgit v1.2.3