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/ast_transform.rs | 4 ++-- crates/ra_assists/src/handlers/add_missing_impl_members.rs | 2 +- crates/ra_assists/src/handlers/generate_new.rs | 6 +++--- crates/ra_assists/src/handlers/introduce_named_lifetime.rs | 4 ++-- crates/ra_assists/src/handlers/move_bounds.rs | 2 +- crates/ra_assists/src/utils.rs | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) (limited to 'crates/ra_assists') diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs index 01adb834c..5ea4f9f5b 100644 --- a/crates/ra_assists/src/ast_transform.rs +++ b/crates/ra_assists/src/ast_transform.rs @@ -41,7 +41,7 @@ impl<'a> SubstituteTypeParams<'a> { source_scope: &'a SemanticsScope<'a>, // FIXME: there's implicit invariant that `trait_` and `source_scope` match... trait_: hir::Trait, - impl_def: ast::ImplDef, + impl_def: ast::Impl, ) -> SubstituteTypeParams<'a> { let substs = get_syntactic_substs(impl_def).unwrap_or_default(); let generic_def: hir::GenericDef = trait_.into(); @@ -80,7 +80,7 @@ impl<'a> SubstituteTypeParams<'a> { // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the // trait ref, and then go from the types in the substs back to the syntax) - fn get_syntactic_substs(impl_def: ast::ImplDef) -> Option> { + fn get_syntactic_substs(impl_def: ast::Impl) -> Option> { let target_trait = impl_def.target_trait()?; let path_type = match target_trait { ast::TypeRef::PathType(path) => path, 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)?; diff --git a/crates/ra_assists/src/handlers/generate_new.rs b/crates/ra_assists/src/handlers/generate_new.rs index 22b47d254..3c67749ee 100644 --- a/crates/ra_assists/src/handlers/generate_new.rs +++ b/crates/ra_assists/src/handlers/generate_new.rs @@ -122,7 +122,7 @@ fn generate_impl_text(strukt: &ast::Struct, 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: &AssistContext, strukt: &ast::Struct) -> Option> { +fn find_struct_impl(ctx: &AssistContext, strukt: &ast::Struct) -> Option> { let db = ctx.db(); let module = strukt.syntax().ancestors().find(|node| { ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) @@ -130,7 +130,7 @@ fn find_struct_impl(ctx: &AssistContext, strukt: &ast::Struct) -> Option; impl S {}` @@ -158,7 +158,7 @@ fn find_struct_impl(ctx: &AssistContext, strukt: &ast::Struct) -> Option bool { +fn has_new_fn(imp: &ast::Impl) -> bool { if let Some(il) = imp.assoc_item_list() { for item in il.assoc_items() { if let ast::AssocItem::Fn(f) = item { diff --git a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs index 4ad173ef0..92a1a5925 100644 --- a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs +++ b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs @@ -40,7 +40,7 @@ pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext) - .filter(|lifetime| lifetime.text() == "'_")?; if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::Fn::cast) { generate_fn_def_assist(acc, &fn_def, lifetime_token.text_range()) - } else if let Some(impl_def) = lifetime_token.ancestors().find_map(ast::ImplDef::cast) { + } else if let Some(impl_def) = lifetime_token.ancestors().find_map(ast::Impl::cast) { generate_impl_def_assist(acc, &impl_def, lifetime_token.text_range()) } else { None @@ -93,7 +93,7 @@ fn generate_fn_def_assist( /// Generate the assist for the impl def case fn generate_impl_def_assist( acc: &mut Assists, - impl_def: &ast::ImplDef, + impl_def: &ast::Impl, lifetime_loc: TextRange, ) -> Option<()> { let new_lifetime_param = generate_unique_lifetime_param_name(&impl_def.generic_param_list())?; diff --git a/crates/ra_assists/src/handlers/move_bounds.rs b/crates/ra_assists/src/handlers/move_bounds.rs index fd1d87423..6d394443e 100644 --- a/crates/ra_assists/src/handlers/move_bounds.rs +++ b/crates/ra_assists/src/handlers/move_bounds.rs @@ -39,7 +39,7 @@ pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext match parent { ast::Fn(it) => it.body()?.syntax().clone().into(), ast::Trait(it) => it.assoc_item_list()?.syntax().clone().into(), - ast::ImplDef(it) => it.assoc_item_list()?.syntax().clone().into(), + ast::Impl(it) => it.assoc_item_list()?.syntax().clone().into(), ast::Enum(it) => it.variant_list()?.syntax().clone().into(), ast::Struct(it) => { it.syntax().children_with_tokens() diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs index 337e3474f..bb16ebd4e 100644 --- a/crates/ra_assists/src/utils.rs +++ b/crates/ra_assists/src/utils.rs @@ -56,7 +56,7 @@ pub(crate) fn render_snippet(_cap: SnippetCap, node: &SyntaxNode, cursor: Cursor pub fn get_missing_assoc_items( sema: &Semantics, - impl_def: &ast::ImplDef, + impl_def: &ast::Impl, ) -> Vec { // Names must be unique between constants and functions. However, type aliases // may share the same name as a function or constant. @@ -109,7 +109,7 @@ pub fn get_missing_assoc_items( pub(crate) fn resolve_target_trait( sema: &Semantics, - impl_def: &ast::ImplDef, + impl_def: &ast::Impl, ) -> Option { let ast_path = impl_def .target_trait() -- cgit v1.2.3