From b211c5814e994a411095e4392d804d692d58d43b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 4 May 2020 16:48:50 +0200 Subject: Remove false positive attr compleitons --- .../src/completion/complete_unqualified_path.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide/src/completion/complete_unqualified_path.rs') diff --git a/crates/ra_ide/src/completion/complete_unqualified_path.rs b/crates/ra_ide/src/completion/complete_unqualified_path.rs index a6a5568de..bd40af1cb 100644 --- a/crates/ra_ide/src/completion/complete_unqualified_path.rs +++ b/crates/ra_ide/src/completion/complete_unqualified_path.rs @@ -8,9 +8,12 @@ use hir::{Adt, ModuleDef, Type}; use ra_syntax::AstNode; pub(super) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionContext) { - if (!ctx.is_trivial_path && !ctx.is_pat_binding_or_const) - || ctx.record_lit_syntax.is_some() + if !(ctx.is_trivial_path || ctx.is_pat_binding_or_const) { + return; + } + if ctx.record_lit_syntax.is_some() || ctx.record_pat_syntax.is_some() + || ctx.attribute_under_caret.is_some() { return; } @@ -1369,4 +1372,18 @@ mod tests { "### ) } + + #[test] + fn dont_complete_attr() { + assert_debug_snapshot!( + do_reference_completion( + r" + struct Foo; + #[<|>] + fn f() {} + " + ), + @r###"[]"### + ) + } } -- cgit v1.2.3 From ecac5d7de2192873c24b7b06d4964d188d8abe6a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 May 2020 12:59:20 +0200 Subject: Switch to new magic marks --- crates/ra_ide/src/completion/complete_unqualified_path.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/ra_ide/src/completion/complete_unqualified_path.rs') diff --git a/crates/ra_ide/src/completion/complete_unqualified_path.rs b/crates/ra_ide/src/completion/complete_unqualified_path.rs index bd40af1cb..db791660a 100644 --- a/crates/ra_ide/src/completion/complete_unqualified_path.rs +++ b/crates/ra_ide/src/completion/complete_unqualified_path.rs @@ -1,7 +1,7 @@ //! Completion of names from the current scope, e.g. locals and imported items. use hir::ScopeDef; -use test_utils::tested_by; +use test_utils::mark; use crate::completion::{CompletionContext, Completions}; use hir::{Adt, ModuleDef, Type}; @@ -30,7 +30,7 @@ pub(super) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC if ctx.use_item_syntax.is_some() { if let (ScopeDef::Unknown, Some(name_ref)) = (&res, &ctx.name_ref_syntax) { if name_ref.syntax().text() == name.to_string().as_str() { - tested_by!(self_fulfilling_completion); + mark::hit!(self_fulfilling_completion); return; } } @@ -66,7 +66,7 @@ fn complete_enum_variants(acc: &mut Completions, ctx: &CompletionContext, ty: &T #[cfg(test)] mod tests { use insta::assert_debug_snapshot; - use test_utils::covers; + use test_utils::mark; use crate::completion::{test_utils::do_completion, CompletionItem, CompletionKind}; @@ -76,7 +76,7 @@ mod tests { #[test] fn self_fulfilling_completion() { - covers!(self_fulfilling_completion); + mark::check!(self_fulfilling_completion); assert_debug_snapshot!( do_reference_completion( r#" -- cgit v1.2.3