From f316e074d2a2906a130d3046b5c3aa24daffb766 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 29 Feb 2020 21:23:16 +0100 Subject: Add a FIXME --- crates/ra_assists/src/utils/insert_use.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'crates/ra_assists/src') diff --git a/crates/ra_assists/src/utils/insert_use.rs b/crates/ra_assists/src/utils/insert_use.rs index 36fd2fc0b..c507e71e0 100644 --- a/crates/ra_assists/src/utils/insert_use.rs +++ b/crates/ra_assists/src/utils/insert_use.rs @@ -1,4 +1,6 @@ //! Handle syntactic aspects of inserting a new `use`. +// FIXME: rewrite according to the plan, outlined in +// https://github.com/rust-analyzer/rust-analyzer/issues/3301#issuecomment-592931553 use hir::{self, ModPath}; use ra_syntax::{ -- cgit v1.2.3 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 --- crates/ra_assists/src/ast_transform.rs | 8 ++++---- .../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 +- crates/ra_assists/src/utils.rs | 10 +++++----- 5 files changed, 21 insertions(+), 21 deletions(-) (limited to 'crates/ra_assists/src') diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs index a74ac42d5..0e53c1eee 100644 --- a/crates/ra_assists/src/ast_transform.rs +++ b/crates/ra_assists/src/ast_transform.rs @@ -40,9 +40,9 @@ impl<'a> SubstituteTypeParams<'a> { db: &'a RootDatabase, // FIXME: there's implicit invariant that `trait_` and `source_scope` match... trait_: hir::Trait, - impl_block: ast::ImplBlock, + impl_def: ast::ImplDef, ) -> SubstituteTypeParams<'a> { - let substs = get_syntactic_substs(impl_block).unwrap_or_default(); + let substs = get_syntactic_substs(impl_def).unwrap_or_default(); let generic_def: hir::GenericDef = trait_.into(); let substs_by_param: FxHashMap<_, _> = generic_def .params(db) @@ -59,8 +59,8 @@ 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_block: ast::ImplBlock) -> Option> { - let target_trait = impl_block.target_trait()?; + fn get_syntactic_substs(impl_def: ast::ImplDef) -> Option> { + let target_trait = impl_def.target_trait()?; let path_type = match target_trait { ast::TypeRef::PathType(path) => path, _ => return None, 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() diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs index d544caee7..3d6c59bda 100644 --- a/crates/ra_assists/src/utils.rs +++ b/crates/ra_assists/src/utils.rs @@ -13,14 +13,14 @@ pub use insert_use::insert_use_statement; pub fn get_missing_impl_items( sema: &Semantics, - impl_block: &ast::ImplBlock, + impl_def: &ast::ImplDef, ) -> Vec { // Names must be unique between constants and functions. However, type aliases // may share the same name as a function or constant. let mut impl_fns_consts = FxHashSet::default(); let mut impl_type = FxHashSet::default(); - if let Some(item_list) = impl_block.item_list() { + if let Some(item_list) = impl_def.item_list() { for item in item_list.impl_items() { match item { ast::ImplItem::FnDef(f) => { @@ -44,7 +44,7 @@ pub fn get_missing_impl_items( } } - resolve_target_trait(sema, impl_block).map_or(vec![], |target_trait| { + resolve_target_trait(sema, impl_def).map_or(vec![], |target_trait| { target_trait .items(sema.db) .iter() @@ -65,9 +65,9 @@ pub fn get_missing_impl_items( pub(crate) fn resolve_target_trait( sema: &Semantics, - impl_block: &ast::ImplBlock, + impl_def: &ast::ImplDef, ) -> Option { - let ast_path = impl_block + let ast_path = impl_def .target_trait() .map(|it| it.syntax().clone()) .and_then(ast::PathType::cast)? -- cgit v1.2.3