From ec316cb21117dbefacd67af2f33779fb2d66fdea Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 3 Jan 2021 15:58:15 +0200 Subject: Ignore associated items during unqialified path fuzzy completions --- crates/completion/src/completions/unqualified_path.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'crates/completion/src/completions/unqualified_path.rs') diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs index 81a6d00e2..068b6b407 100644 --- a/crates/completion/src/completions/unqualified_path.rs +++ b/crates/completion/src/completions/unqualified_path.rs @@ -3,7 +3,7 @@ use std::iter; use either::Either; -use hir::{Adt, ModPath, ModuleDef, ScopeDef, Type}; +use hir::{Adt, AsAssocItem, ModPath, ModuleDef, ScopeDef, Type}; use ide_db::helpers::insert_use::ImportScope; use ide_db::imports_locator; use syntax::AstNode; @@ -143,6 +143,14 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<() potential_import_name, true, ) + .filter(|import_candidate| match import_candidate { + Either::Left(ModuleDef::Function(function)) => function.as_assoc_item(ctx.db).is_none(), + Either::Left(ModuleDef::Const(const_)) => const_.as_assoc_item(ctx.db).is_none(), + Either::Left(ModuleDef::TypeAlias(type_alias)) => { + type_alias.as_assoc_item(ctx.db).is_none() + } + _ => true, + }) .filter_map(|import_candidate| { Some(match import_candidate { Either::Left(module_def) => { -- cgit v1.2.3 From ca42a52051e69d441b3f32ba4268286a8f0d8685 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 4 Jan 2021 18:33:05 +0200 Subject: Code review fixes --- crates/completion/src/completions/unqualified_path.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'crates/completion/src/completions/unqualified_path.rs') diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs index 068b6b407..f376ded57 100644 --- a/crates/completion/src/completions/unqualified_path.rs +++ b/crates/completion/src/completions/unqualified_path.rs @@ -3,7 +3,7 @@ use std::iter; use either::Either; -use hir::{Adt, AsAssocItem, ModPath, ModuleDef, ScopeDef, Type}; +use hir::{Adt, ModPath, ModuleDef, ScopeDef, Type}; use ide_db::helpers::insert_use::ImportScope; use ide_db::imports_locator; use syntax::AstNode; @@ -142,15 +142,8 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<() Some(40), potential_import_name, true, + true, ) - .filter(|import_candidate| match import_candidate { - Either::Left(ModuleDef::Function(function)) => function.as_assoc_item(ctx.db).is_none(), - Either::Left(ModuleDef::Const(const_)) => const_.as_assoc_item(ctx.db).is_none(), - Either::Left(ModuleDef::TypeAlias(type_alias)) => { - type_alias.as_assoc_item(ctx.db).is_none() - } - _ => true, - }) .filter_map(|import_candidate| { Some(match import_candidate { Either::Left(module_def) => { -- cgit v1.2.3 From 27b3b13824f223b69558c84de264267bd3fee9c2 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 4 Jan 2021 22:01:35 +0200 Subject: Small helpers --- crates/completion/src/completions/unqualified_path.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/completion/src/completions/unqualified_path.rs') diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs index f376ded57..2f41a3f96 100644 --- a/crates/completion/src/completions/unqualified_path.rs +++ b/crates/completion/src/completions/unqualified_path.rs @@ -124,8 +124,8 @@ fn complete_enum_variants(acc: &mut Completions, ctx: &CompletionContext, ty: &T // Note that having this flag set to `true` does not guarantee that the feature is enabled: your client needs to have the corredponding // capability enabled. fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { - let _p = profile::span("fuzzy_completion"); let potential_import_name = ctx.token.to_string(); + let _p = profile::span("fuzzy_completion").detail(|| potential_import_name.clone()); if potential_import_name.len() < 2 { return None; -- cgit v1.2.3