Unnamed repository; edit this file 'description' to name the repository.
add more completion about "impl"
| -rw-r--r-- | crates/ide-completion/src/completions/item_list.rs | 4 | ||||
| -rw-r--r-- | crates/ide-completion/src/completions/keyword.rs | 2 | ||||
| -rw-r--r-- | crates/ide-completion/src/tests/expression.rs | 68 | ||||
| -rw-r--r-- | crates/ide-completion/src/tests/item.rs | 2 | ||||
| -rw-r--r-- | crates/ide-completion/src/tests/item_list.rs | 10 | ||||
| -rw-r--r-- | crates/ide-completion/src/tests/special.rs | 12 |
6 files changed, 76 insertions, 22 deletions
diff --git a/crates/ide-completion/src/completions/item_list.rs b/crates/ide-completion/src/completions/item_list.rs index 4ae00ccd81..30ffeff261 100644 --- a/crates/ide-completion/src/completions/item_list.rs +++ b/crates/ide-completion/src/completions/item_list.rs @@ -114,6 +114,8 @@ fn add_keywords(acc: &mut Completions, ctx: &CompletionContext<'_>, kind: Option add_keyword("trait", "trait $1 {\n $0\n}"); if no_vis_qualifiers { add_keyword("impl", "impl $1 {\n $0\n}"); + add_keyword("impl for", "impl $1 for $2 {\n $0\n}"); + add_keyword("impl<> for <>", "impl<$4> $1 for $2<$3> {\n $0\n}"); } } @@ -144,6 +146,8 @@ fn add_keywords(acc: &mut Completions, ctx: &CompletionContext<'_>, kind: Option add_keyword("use", "use $0"); if no_vis_qualifiers { add_keyword("impl", "impl $1 {\n $0\n}"); + add_keyword("impl for", "impl $1 for $2 {\n $0\n}"); + add_keyword("impl<> for <>", "impl<$4> $1 for $2<$3> {\n $0\n}"); } } diff --git a/crates/ide-completion/src/completions/keyword.rs b/crates/ide-completion/src/completions/keyword.rs index 14b0d543ca..d0ba910d93 100644 --- a/crates/ide-completion/src/completions/keyword.rs +++ b/crates/ide-completion/src/completions/keyword.rs @@ -56,6 +56,8 @@ mod tests { kw extern kw fn kw impl + kw impl for + kw impl<> for <> kw trait "#]], ); diff --git a/crates/ide-completion/src/tests/expression.rs b/crates/ide-completion/src/tests/expression.rs index 22d42ba750..5314be3c7f 100644 --- a/crates/ide-completion/src/tests/expression.rs +++ b/crates/ide-completion/src/tests/expression.rs @@ -171,6 +171,8 @@ impl Unit { kw if kw if let kw impl + kw impl for + kw impl<> for <> kw let kw letm kw loop @@ -236,8 +238,8 @@ fn complete_in_block() { } "#, expect![[r#" - fn foo() fn() - bt u32 u32 + fn foo() fn() + bt u32 u32 kw async kw const kw crate:: @@ -249,6 +251,8 @@ fn complete_in_block() { kw if kw if let kw impl + kw impl for + kw impl<> for <> kw let kw letm kw loop @@ -285,8 +289,8 @@ fn complete_after_if_expr() { } "#, expect![[r#" - fn foo() fn() - bt u32 u32 + fn foo() fn() + bt u32 u32 kw async kw const kw crate:: @@ -300,6 +304,8 @@ fn complete_after_if_expr() { kw if kw if let kw impl + kw impl for + kw impl<> for <> kw let kw letm kw loop @@ -360,8 +366,8 @@ fn completes_in_loop_ctx() { check( r"fn my() { loop { $0 } }", expect![[r#" - fn my() fn() - bt u32 u32 + fn my() fn() + bt u32 u32 kw async kw break kw const @@ -375,6 +381,8 @@ fn completes_in_loop_ctx() { kw if kw if let kw impl + kw impl for + kw impl<> for <> kw let kw letm kw loop @@ -946,8 +954,8 @@ fn else_completion_after_if() { fn foo() { if foo {} $0 } "#, expect![[r#" - fn foo() fn() - bt u32 u32 + fn foo() fn() + bt u32 u32 kw async kw const kw crate:: @@ -961,6 +969,8 @@ fn foo() { if foo {} $0 } kw if kw if let kw impl + kw impl for + kw impl<> for <> kw let kw letm kw loop @@ -988,8 +998,8 @@ fn foo() { if foo {} $0 } fn foo() { if foo {} el$0 } "#, expect![[r#" - fn foo() fn() - bt u32 u32 + fn foo() fn() + bt u32 u32 kw async kw const kw crate:: @@ -1003,6 +1013,8 @@ fn foo() { if foo {} el$0 } kw if kw if let kw impl + kw impl for + kw impl<> for <> kw let kw letm kw loop @@ -1080,8 +1092,8 @@ fn foo() { bar(if foo {} el$0) } fn foo() { if foo {} $0 let x = 92; } "#, expect![[r#" - fn foo() fn() - bt u32 u32 + fn foo() fn() + bt u32 u32 kw async kw const kw crate:: @@ -1095,6 +1107,8 @@ fn foo() { if foo {} $0 let x = 92; } kw if kw if let kw impl + kw impl for + kw impl<> for <> kw let kw letm kw loop @@ -1122,8 +1136,8 @@ fn foo() { if foo {} $0 let x = 92; } fn foo() { if foo {} el$0 let x = 92; } "#, expect![[r#" - fn foo() fn() - bt u32 u32 + fn foo() fn() + bt u32 u32 kw async kw const kw crate:: @@ -1137,6 +1151,8 @@ fn foo() { if foo {} el$0 let x = 92; } kw if kw if let kw impl + kw impl for + kw impl<> for <> kw let kw letm kw loop @@ -1164,8 +1180,8 @@ fn foo() { if foo {} el$0 let x = 92; } fn foo() { if foo {} el$0 { let x = 92; } } "#, expect![[r#" - fn foo() fn() - bt u32 u32 + fn foo() fn() + bt u32 u32 kw async kw const kw crate:: @@ -1179,6 +1195,8 @@ fn foo() { if foo {} el$0 { let x = 92; } } kw if kw if let kw impl + kw impl for + kw impl<> for <> kw let kw letm kw loop @@ -1217,9 +1235,9 @@ fn main() { pub struct UnstableThisShouldNotBeListed; "#, expect![[r#" - fn main() fn() + fn main() fn() md std - bt u32 u32 + bt u32 u32 kw async kw const kw crate:: @@ -1231,6 +1249,8 @@ pub struct UnstableThisShouldNotBeListed; kw if kw if let kw impl + kw impl for + kw impl<> for <> kw let kw letm kw loop @@ -1285,6 +1305,8 @@ pub struct UnstableButWeAreOnNightlyAnyway; kw if kw if let kw impl + kw impl for + kw impl<> for <> kw let kw letm kw loop @@ -1529,6 +1551,8 @@ fn main() { kw if kw if let kw impl + kw impl for + kw impl<> for <> kw let kw letm kw loop @@ -1986,6 +2010,8 @@ fn bar() { kw if kw if let kw impl + kw impl for + kw impl<> for <> kw let kw letm kw loop @@ -2044,9 +2070,9 @@ fn foo() { } "#, expect![[r#" - fn foo() fn() + fn foo() fn() md proc_macros - bt u32 u32 + bt u32 u32 kw async kw const kw crate:: @@ -2058,6 +2084,8 @@ fn foo() { kw if kw if let kw impl + kw impl for + kw impl<> for <> kw let kw letm kw loop diff --git a/crates/ide-completion/src/tests/item.rs b/crates/ide-completion/src/tests/item.rs index be2c37d101..a2d2cf39c2 100644 --- a/crates/ide-completion/src/tests/item.rs +++ b/crates/ide-completion/src/tests/item.rs @@ -284,6 +284,8 @@ fn bar() { kw if kw if let kw impl + kw impl for + kw impl<> for <> kw let kw letm kw loop diff --git a/crates/ide-completion/src/tests/item_list.rs b/crates/ide-completion/src/tests/item_list.rs index 841c42123a..ee77845588 100644 --- a/crates/ide-completion/src/tests/item_list.rs +++ b/crates/ide-completion/src/tests/item_list.rs @@ -16,6 +16,8 @@ fn in_mod_item_list() { kw extern kw fn kw impl + kw impl for + kw impl<> for <> kw mod kw pub kw pub(crate) @@ -50,6 +52,8 @@ fn in_source_file_item_list() { kw extern kw fn kw impl + kw impl for + kw impl<> for <> kw mod kw pub kw pub(crate) @@ -83,6 +87,8 @@ fn in_item_list_after_attr() { kw extern kw fn kw impl + kw impl for + kw impl<> for <> kw mod kw pub kw pub(crate) @@ -122,6 +128,8 @@ fn after_unsafe_token() { kw extern kw fn kw impl + kw impl for + kw impl<> for <> kw trait "#]], ); @@ -385,6 +393,8 @@ fn after_unit_struct() { kw extern kw fn kw impl + kw impl for + kw impl<> for <> kw mod kw pub kw pub(crate) diff --git a/crates/ide-completion/src/tests/special.rs b/crates/ide-completion/src/tests/special.rs index 70caeac95b..ca579b8fc1 100644 --- a/crates/ide-completion/src/tests/special.rs +++ b/crates/ide-completion/src/tests/special.rs @@ -1008,6 +1008,8 @@ fn here_we_go() { kw if kw if let kw impl + kw impl for + kw impl<> for <> kw let kw letm kw loop @@ -1059,6 +1061,8 @@ fn here_we_go() { kw if kw if let kw impl + kw impl for + kw impl<> for <> kw let kw letm kw loop @@ -1184,6 +1188,8 @@ fn bar() { qu$0 } kw if kw if let kw impl + kw impl for + kw impl<> for <> kw let kw letm kw loop @@ -1428,8 +1434,8 @@ fn foo() { "#, Some('_'), expect![[r#" - fn foo() fn() - bt u32 u32 + fn foo() fn() + bt u32 u32 kw async kw const kw crate:: @@ -1441,6 +1447,8 @@ fn foo() { kw if kw if let kw impl + kw impl for + kw impl<> for <> kw let kw letm kw loop |