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 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'crates/ra_assists/src/handlers/add_missing_impl_members.rs') 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()) }; -- cgit v1.2.3 From 1142112c70b705f59b7d559d9d72cdc831865158 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 14:51:08 +0200 Subject: Rename FnDef -> Fn --- crates/ra_assists/src/handlers/add_missing_impl_members.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/ra_assists/src/handlers/add_missing_impl_members.rs') 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 a2d9006e4..4f377e37f 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs @@ -118,7 +118,7 @@ fn add_missing_impl_members_inner( let def_name = |item: &ast::AssocItem| -> Option { match item { - ast::AssocItem::FnDef(def) => def.name(), + ast::AssocItem::Fn(def) => def.name(), ast::AssocItem::TypeAliasDef(def) => def.name(), ast::AssocItem::ConstDef(def) => def.name(), ast::AssocItem::MacroCall(_) => None, @@ -129,13 +129,13 @@ fn add_missing_impl_members_inner( let missing_items = get_missing_assoc_items(&ctx.sema, &impl_def) .iter() .map(|i| match i { - hir::AssocItem::Function(i) => ast::AssocItem::FnDef(i.source(ctx.db()).value), + hir::AssocItem::Function(i) => ast::AssocItem::Fn(i.source(ctx.db()).value), hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAliasDef(i.source(ctx.db()).value), hir::AssocItem::Const(i) => ast::AssocItem::ConstDef(i.source(ctx.db()).value), }) .filter(|t| def_name(&t).is_some()) .filter(|t| match t { - ast::AssocItem::FnDef(def) => match mode { + ast::AssocItem::Fn(def) => match mode { AddMissingImplMembersMode::DefaultMethodsOnly => def.body().is_some(), AddMissingImplMembersMode::NoDefaultMethods => def.body().is_none(), }, @@ -158,7 +158,7 @@ fn add_missing_impl_members_inner( .into_iter() .map(|it| ast_transform::apply(&*ast_transform, it)) .map(|it| match it { - ast::AssocItem::FnDef(def) => ast::AssocItem::FnDef(add_body(def)), + ast::AssocItem::Fn(def) => ast::AssocItem::Fn(add_body(def)), ast::AssocItem::TypeAliasDef(def) => { ast::AssocItem::TypeAliasDef(def.remove_bounds()) } @@ -174,7 +174,7 @@ fn add_missing_impl_members_inner( Some(cap) => { let mut cursor = Cursor::Before(first_new_item.syntax()); let placeholder; - if let ast::AssocItem::FnDef(func) = &first_new_item { + if let ast::AssocItem::Fn(func) = &first_new_item { if let Some(m) = func.syntax().descendants().find_map(ast::MacroCall::cast) { if m.syntax().text() == "todo!()" { placeholder = m; @@ -192,7 +192,7 @@ fn add_missing_impl_members_inner( }) } -fn add_body(fn_def: ast::FnDef) -> ast::FnDef { +fn add_body(fn_def: ast::Fn) -> ast::Fn { if fn_def.body().is_some() { return fn_def; } -- cgit v1.2.3 From eb2f8063444b11257111f4f8ade990ec810e0361 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 15:25:46 +0200 Subject: Rename TypeAliasDef -> TypeAlias --- crates/ra_assists/src/handlers/add_missing_impl_members.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'crates/ra_assists/src/handlers/add_missing_impl_members.rs') 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 4f377e37f..1e4d4748c 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs @@ -119,7 +119,7 @@ fn add_missing_impl_members_inner( let def_name = |item: &ast::AssocItem| -> Option { match item { ast::AssocItem::Fn(def) => def.name(), - ast::AssocItem::TypeAliasDef(def) => def.name(), + ast::AssocItem::TypeAlias(def) => def.name(), ast::AssocItem::ConstDef(def) => def.name(), ast::AssocItem::MacroCall(_) => None, } @@ -130,7 +130,7 @@ fn add_missing_impl_members_inner( .iter() .map(|i| match i { hir::AssocItem::Function(i) => ast::AssocItem::Fn(i.source(ctx.db()).value), - hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAliasDef(i.source(ctx.db()).value), + hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAlias(i.source(ctx.db()).value), hir::AssocItem::Const(i) => ast::AssocItem::ConstDef(i.source(ctx.db()).value), }) .filter(|t| def_name(&t).is_some()) @@ -159,9 +159,7 @@ fn add_missing_impl_members_inner( .map(|it| ast_transform::apply(&*ast_transform, it)) .map(|it| match it { ast::AssocItem::Fn(def) => ast::AssocItem::Fn(add_body(def)), - ast::AssocItem::TypeAliasDef(def) => { - ast::AssocItem::TypeAliasDef(def.remove_bounds()) - } + ast::AssocItem::TypeAlias(def) => ast::AssocItem::TypeAlias(def.remove_bounds()), _ => it, }) .map(|it| edit::remove_attrs_and_docs(&it)); -- cgit v1.2.3 From 3cd4112bdc924c132cb0eab9d064511a215421ec Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 18:02:20 +0200 Subject: Finalize const&static grammar --- crates/ra_assists/src/handlers/add_missing_impl_members.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_assists/src/handlers/add_missing_impl_members.rs') 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 1e4d4748c..1ab176c26 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs @@ -120,7 +120,7 @@ fn add_missing_impl_members_inner( match item { ast::AssocItem::Fn(def) => def.name(), ast::AssocItem::TypeAlias(def) => def.name(), - ast::AssocItem::ConstDef(def) => def.name(), + ast::AssocItem::Const(def) => def.name(), ast::AssocItem::MacroCall(_) => None, } .map(|it| it.text().clone()) @@ -131,7 +131,7 @@ fn add_missing_impl_members_inner( .map(|i| match i { hir::AssocItem::Function(i) => ast::AssocItem::Fn(i.source(ctx.db()).value), hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAlias(i.source(ctx.db()).value), - hir::AssocItem::Const(i) => ast::AssocItem::ConstDef(i.source(ctx.db()).value), + hir::AssocItem::Const(i) => ast::AssocItem::Const(i.source(ctx.db()).value), }) .filter(|t| def_name(&t).is_some()) .filter(|t| match t { -- cgit v1.2.3 From c5798c4d75aa807aec47208a49101bdec3affcca Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 18:28:28 +0200 Subject: Finalize impl Grammar --- crates/ra_assists/src/handlers/add_missing_impl_members.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_assists/src/handlers/add_missing_impl_members.rs') 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 1ab176c26..95a750aee 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs @@ -111,7 +111,7 @@ fn add_missing_impl_members_inner( label: &'static str, ) -> Option<()> { let _p = ra_prof::profile("add_missing_impl_members_inner"); - let impl_def = ctx.find_node_at_offset::()?; + let impl_def = ctx.find_node_at_offset::()?; let impl_item_list = impl_def.assoc_item_list()?; let trait_ = resolve_target_trait(&ctx.sema, &impl_def)?; -- cgit v1.2.3