From 11115ebad8d0cb367478a4f154abe08c0c25aa95 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 16 Jun 2021 18:50:18 +0200 Subject: Don't complete paths after attributes --- crates/ide_completion/src/completions/keyword.rs | 43 ------------------- crates/ide_completion/src/completions/snippet.rs | 2 +- .../src/completions/unqualified_path.rs | 48 ---------------------- 3 files changed, 1 insertion(+), 92 deletions(-) (limited to 'crates/ide_completion/src/completions') diff --git a/crates/ide_completion/src/completions/keyword.rs b/crates/ide_completion/src/completions/keyword.rs index 7970e75c7..0a3df79d4 100644 --- a/crates/ide_completion/src/completions/keyword.rs +++ b/crates/ide_completion/src/completions/keyword.rs @@ -349,49 +349,6 @@ fn quux() -> i32 { ); } - #[test] - fn test_keywords_in_trait_def() { - check( - r"trait My { $0 }", - expect![[r#" - kw unsafe - kw fn - kw const - kw type - "#]], - ); - } - - #[test] - fn test_keywords_in_impl_def() { - check( - r"impl My { $0 }", - expect![[r#" - kw pub(crate) - kw pub - kw unsafe - kw fn - kw const - kw type - "#]], - ); - } - - #[test] - fn test_keywords_in_impl_def_with_attr() { - check( - r"impl My { #[foo] $0 }", - expect![[r#" - kw pub(crate) - kw pub - kw unsafe - kw fn - kw const - kw type - "#]], - ); - } - #[test] fn test_keywords_in_loop() { check( diff --git a/crates/ide_completion/src/completions/snippet.rs b/crates/ide_completion/src/completions/snippet.rs index 4e64a0090..d142265e0 100644 --- a/crates/ide_completion/src/completions/snippet.rs +++ b/crates/ide_completion/src/completions/snippet.rs @@ -36,7 +36,7 @@ pub(crate) fn complete_expr_snippet(acc: &mut Completions, ctx: &CompletionConte } pub(crate) fn complete_item_snippet(acc: &mut Completions, ctx: &CompletionContext) { - if !ctx.expects_item() || ctx.previous_token_is(T![unsafe]) { + if !ctx.expects_item() || ctx.previous_token_is(T![unsafe]) || ctx.path_qual().is_some() { return; } if ctx.has_visibility_prev_sibling() { diff --git a/crates/ide_completion/src/completions/unqualified_path.rs b/crates/ide_completion/src/completions/unqualified_path.rs index 2c623bf7a..3910de2c4 100644 --- a/crates/ide_completion/src/completions/unqualified_path.rs +++ b/crates/ide_completion/src/completions/unqualified_path.rs @@ -500,18 +500,6 @@ fn f() {$0} check( r#" #[rustc_builtin_macro] -pub macro Clone {} - -struct S; -impl S { - $0 -} -"#, - expect![[r#""#]], - ); - check( - r#" -#[rustc_builtin_macro] pub macro bench {} fn f() {$0} @@ -772,42 +760,6 @@ impl My$0 ) } - #[test] - fn completes_in_assoc_item_list() { - check( - r#" -macro_rules! foo {} -mod bar {} - -struct MyStruct {} -impl MyStruct { - $0 -} -"#, - expect![[r#" - md bar - ma foo!(…) macro_rules! foo - "#]], - ) - } - - #[test] - fn completes_in_item_list() { - check( - r#" -struct MyStruct {} -macro_rules! foo {} -mod bar {} - -$0 -"#, - expect![[r#" - md bar - ma foo!(…) macro_rules! foo - "#]], - ) - } - #[test] fn completes_types_and_const_in_arg_list() { check( -- cgit v1.2.3