diff options
Diffstat (limited to 'crates/ide_completion/src/completions')
4 files changed, 55 insertions, 8 deletions
diff --git a/crates/ide_completion/src/completions/attribute.rs b/crates/ide_completion/src/completions/attribute.rs index d3392100d..7f76e357e 100644 --- a/crates/ide_completion/src/completions/attribute.rs +++ b/crates/ide_completion/src/completions/attribute.rs | |||
@@ -69,7 +69,7 @@ fn complete_new_attribute(acc: &mut Completions, ctx: &CompletionContext, attrib | |||
69 | } | 69 | } |
70 | 70 | ||
71 | if is_inner || !attr_completion.prefer_inner { | 71 | if is_inner || !attr_completion.prefer_inner { |
72 | acc.add(item.build()); | 72 | item.add_to(acc); |
73 | } | 73 | } |
74 | }; | 74 | }; |
75 | 75 | ||
@@ -96,7 +96,7 @@ fn complete_new_attribute(acc: &mut Completions, ctx: &CompletionContext, attrib | |||
96 | if let Some(docs) = mac.docs(ctx.sema.db) { | 96 | if let Some(docs) = mac.docs(ctx.sema.db) { |
97 | item.documentation(docs); | 97 | item.documentation(docs); |
98 | } | 98 | } |
99 | acc.add(item.build()); | 99 | item.add_to(acc); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | }); | 102 | }); |
diff --git a/crates/ide_completion/src/completions/flyimport.rs b/crates/ide_completion/src/completions/flyimport.rs index 7bf47bf75..c010cbbca 100644 --- a/crates/ide_completion/src/completions/flyimport.rs +++ b/crates/ide_completion/src/completions/flyimport.rs | |||
@@ -90,7 +90,6 @@ | |||
90 | //! Note that having this flag set to `true` does not guarantee that the feature is enabled: your client needs to have the corredponding | 90 | //! Note that having this flag set to `true` does not guarantee that the feature is enabled: your client needs to have the corredponding |
91 | //! capability enabled. | 91 | //! capability enabled. |
92 | 92 | ||
93 | use hir::ModPath; | ||
94 | use ide_db::helpers::{ | 93 | use ide_db::helpers::{ |
95 | import_assets::{ImportAssets, ImportCandidate}, | 94 | import_assets::{ImportAssets, ImportCandidate}, |
96 | insert_use::ImportScope, | 95 | insert_use::ImportScope, |
@@ -208,7 +207,7 @@ fn import_assets(ctx: &CompletionContext, fuzzy_name: String) -> Option<ImportAs | |||
208 | } | 207 | } |
209 | 208 | ||
210 | fn compute_fuzzy_completion_order_key( | 209 | fn compute_fuzzy_completion_order_key( |
211 | proposed_mod_path: &ModPath, | 210 | proposed_mod_path: &hir::ModPath, |
212 | user_input_lowercased: &str, | 211 | user_input_lowercased: &str, |
213 | ) -> usize { | 212 | ) -> usize { |
214 | cov_mark::hit!(certain_fuzzy_order_test); | 213 | cov_mark::hit!(certain_fuzzy_order_test); |
diff --git a/crates/ide_completion/src/completions/qualified_path.rs b/crates/ide_completion/src/completions/qualified_path.rs index 4dfdc5ced..0b0a81410 100644 --- a/crates/ide_completion/src/completions/qualified_path.rs +++ b/crates/ide_completion/src/completions/qualified_path.rs | |||
@@ -208,6 +208,36 @@ mod tests { | |||
208 | } | 208 | } |
209 | 209 | ||
210 | #[test] | 210 | #[test] |
211 | fn dont_complete_values_in_type_pos() { | ||
212 | check( | ||
213 | r#" | ||
214 | const FOO: () = (); | ||
215 | static BAR: () = (); | ||
216 | struct Baz; | ||
217 | fn foo() { | ||
218 | let _: self::$0; | ||
219 | } | ||
220 | "#, | ||
221 | expect![[r#" | ||
222 | st Baz | ||
223 | "#]], | ||
224 | ); | ||
225 | } | ||
226 | |||
227 | #[test] | ||
228 | fn dont_complete_enum_variants_in_type_pos() { | ||
229 | check( | ||
230 | r#" | ||
231 | enum Foo { Bar } | ||
232 | fn foo() { | ||
233 | let _: Foo::$0; | ||
234 | } | ||
235 | "#, | ||
236 | expect![[r#""#]], | ||
237 | ); | ||
238 | } | ||
239 | |||
240 | #[test] | ||
211 | fn dont_complete_current_use_in_braces_with_glob() { | 241 | fn dont_complete_current_use_in_braces_with_glob() { |
212 | check( | 242 | check( |
213 | r#" | 243 | r#" |
diff --git a/crates/ide_completion/src/completions/unqualified_path.rs b/crates/ide_completion/src/completions/unqualified_path.rs index 52f40d496..1f6c4069f 100644 --- a/crates/ide_completion/src/completions/unqualified_path.rs +++ b/crates/ide_completion/src/completions/unqualified_path.rs | |||
@@ -77,6 +77,28 @@ mod tests { | |||
77 | } | 77 | } |
78 | 78 | ||
79 | #[test] | 79 | #[test] |
80 | fn dont_complete_values_in_type_pos() { | ||
81 | check( | ||
82 | r#" | ||
83 | const FOO: () = (); | ||
84 | static BAR: () = (); | ||
85 | enum Foo { | ||
86 | Bar | ||
87 | } | ||
88 | struct Baz; | ||
89 | fn foo() { | ||
90 | let local = (); | ||
91 | let _: $0; | ||
92 | } | ||
93 | "#, | ||
94 | expect![[r#" | ||
95 | en Foo | ||
96 | st Baz | ||
97 | "#]], | ||
98 | ); | ||
99 | } | ||
100 | |||
101 | #[test] | ||
80 | fn only_completes_modules_in_import() { | 102 | fn only_completes_modules_in_import() { |
81 | cov_mark::check!(only_completes_modules_in_import); | 103 | cov_mark::check!(only_completes_modules_in_import); |
82 | check( | 104 | check( |
@@ -347,7 +369,6 @@ fn x() -> $0 | |||
347 | "#, | 369 | "#, |
348 | expect![[r#" | 370 | expect![[r#" |
349 | st Foo | 371 | st Foo |
350 | fn x() fn() | ||
351 | "#]], | 372 | "#]], |
352 | ); | 373 | ); |
353 | } | 374 | } |
@@ -399,7 +420,6 @@ pub mod prelude { | |||
399 | } | 420 | } |
400 | "#, | 421 | "#, |
401 | expect![[r#" | 422 | expect![[r#" |
402 | fn foo() fn() | ||
403 | md std | 423 | md std |
404 | st Option | 424 | st Option |
405 | "#]], | 425 | "#]], |
@@ -494,7 +514,6 @@ pub mod prelude { | |||
494 | } | 514 | } |
495 | "#, | 515 | "#, |
496 | expect![[r#" | 516 | expect![[r#" |
497 | fn foo() fn() | ||
498 | md std | 517 | md std |
499 | md core | 518 | md core |
500 | st String | 519 | st String |
@@ -555,7 +574,6 @@ macro_rules! foo { () => {} } | |||
555 | fn main() { let x: $0 } | 574 | fn main() { let x: $0 } |
556 | "#, | 575 | "#, |
557 | expect![[r#" | 576 | expect![[r#" |
558 | fn main() fn() | ||
559 | ma foo!(…) macro_rules! foo | 577 | ma foo!(…) macro_rules! foo |
560 | "#]], | 578 | "#]], |
561 | ); | 579 | ); |