diff options
Diffstat (limited to 'crates/ide_completion/src')
-rw-r--r-- | crates/ide_completion/src/completions/keyword.rs | 32 | ||||
-rw-r--r-- | crates/ide_completion/src/completions/mod_.rs | 4 | ||||
-rw-r--r-- | crates/ide_completion/src/completions/qualified_path.rs | 20 | ||||
-rw-r--r-- | crates/ide_completion/src/completions/unqualified_path.rs | 17 | ||||
-rw-r--r-- | crates/ide_completion/src/tests.rs | 1 | ||||
-rw-r--r-- | crates/ide_completion/src/tests/items.rs | 108 |
6 files changed, 111 insertions, 71 deletions
diff --git a/crates/ide_completion/src/completions/keyword.rs b/crates/ide_completion/src/completions/keyword.rs index af67f9315..c5cd3c2f7 100644 --- a/crates/ide_completion/src/completions/keyword.rs +++ b/crates/ide_completion/src/completions/keyword.rs | |||
@@ -388,22 +388,6 @@ fn quux() -> i32 { | |||
388 | } | 388 | } |
389 | 389 | ||
390 | #[test] | 390 | #[test] |
391 | fn test_where_keyword() { | ||
392 | check( | ||
393 | r"trait A $0", | ||
394 | expect![[r#" | ||
395 | kw where | ||
396 | "#]], | ||
397 | ); | ||
398 | check( | ||
399 | r"impl A $0", | ||
400 | expect![[r#" | ||
401 | kw where | ||
402 | "#]], | ||
403 | ); | ||
404 | } | ||
405 | |||
406 | #[test] | ||
407 | fn no_keyword_completion_in_comments() { | 391 | fn no_keyword_completion_in_comments() { |
408 | cov_mark::check!(no_keyword_completion_in_comments); | 392 | cov_mark::check!(no_keyword_completion_in_comments); |
409 | check( | 393 | check( |
@@ -480,22 +464,6 @@ fn foo() { | |||
480 | } | 464 | } |
481 | 465 | ||
482 | #[test] | 466 | #[test] |
483 | fn before_field() { | ||
484 | check( | ||
485 | r#" | ||
486 | struct Foo { | ||
487 | $0 | ||
488 | pub f: i32, | ||
489 | } | ||
490 | "#, | ||
491 | expect![[r#" | ||
492 | kw pub(crate) | ||
493 | kw pub | ||
494 | "#]], | ||
495 | ) | ||
496 | } | ||
497 | |||
498 | #[test] | ||
499 | fn skip_struct_initializer() { | 467 | fn skip_struct_initializer() { |
500 | cov_mark::check!(no_keyword_completion_in_record_lit); | 468 | cov_mark::check!(no_keyword_completion_in_record_lit); |
501 | check( | 469 | check( |
diff --git a/crates/ide_completion/src/completions/mod_.rs b/crates/ide_completion/src/completions/mod_.rs index dee3ec88d..1c864c0e7 100644 --- a/crates/ide_completion/src/completions/mod_.rs +++ b/crates/ide_completion/src/completions/mod_.rs | |||
@@ -141,11 +141,11 @@ fn module_chain_to_containing_module_file( | |||
141 | 141 | ||
142 | #[cfg(test)] | 142 | #[cfg(test)] |
143 | mod tests { | 143 | mod tests { |
144 | use crate::{tests::filtered_completion_list, CompletionKind}; | 144 | use crate::tests::completion_list; |
145 | use expect_test::{expect, Expect}; | 145 | use expect_test::{expect, Expect}; |
146 | 146 | ||
147 | fn check(ra_fixture: &str, expect: Expect) { | 147 | fn check(ra_fixture: &str, expect: Expect) { |
148 | let actual = filtered_completion_list(ra_fixture, CompletionKind::Magic); | 148 | let actual = completion_list(ra_fixture); |
149 | expect.assert_eq(&actual); | 149 | expect.assert_eq(&actual); |
150 | } | 150 | } |
151 | 151 | ||
diff --git a/crates/ide_completion/src/completions/qualified_path.rs b/crates/ide_completion/src/completions/qualified_path.rs index 0597879ac..88f4d940d 100644 --- a/crates/ide_completion/src/completions/qualified_path.rs +++ b/crates/ide_completion/src/completions/qualified_path.rs | |||
@@ -556,26 +556,6 @@ fn f() {m::$0} | |||
556 | } | 556 | } |
557 | 557 | ||
558 | #[test] | 558 | #[test] |
559 | fn completes_in_assoc_item_list() { | ||
560 | check( | ||
561 | r#" | ||
562 | #[macro_export] | ||
563 | macro_rules! foo { () => {} } | ||
564 | mod bar {} | ||
565 | |||
566 | struct MyStruct {} | ||
567 | impl MyStruct { | ||
568 | crate::$0 | ||
569 | } | ||
570 | "#, | ||
571 | expect![[r##" | ||
572 | md bar | ||
573 | ma foo!(…) #[macro_export] macro_rules! foo | ||
574 | "##]], | ||
575 | ); | ||
576 | } | ||
577 | |||
578 | #[test] | ||
579 | fn completes_reexported_items_under_correct_name() { | 559 | fn completes_reexported_items_under_correct_name() { |
580 | check( | 560 | check( |
581 | r#" | 561 | r#" |
diff --git a/crates/ide_completion/src/completions/unqualified_path.rs b/crates/ide_completion/src/completions/unqualified_path.rs index 6f96eceb9..1864bfbcc 100644 --- a/crates/ide_completion/src/completions/unqualified_path.rs +++ b/crates/ide_completion/src/completions/unqualified_path.rs | |||
@@ -713,23 +713,6 @@ fn f() {} | |||
713 | } | 713 | } |
714 | 714 | ||
715 | #[test] | 715 | #[test] |
716 | fn completes_target_type_or_trait_in_impl_block() { | ||
717 | check( | ||
718 | r#" | ||
719 | trait MyTrait {} | ||
720 | struct MyStruct {} | ||
721 | |||
722 | impl My$0 | ||
723 | "#, | ||
724 | expect![[r#" | ||
725 | sp Self | ||
726 | tt MyTrait | ||
727 | st MyStruct | ||
728 | "#]], | ||
729 | ) | ||
730 | } | ||
731 | |||
732 | #[test] | ||
733 | fn completes_types_and_const_in_arg_list() { | 716 | fn completes_types_and_const_in_arg_list() { |
734 | check( | 717 | check( |
735 | r#" | 718 | r#" |
diff --git a/crates/ide_completion/src/tests.rs b/crates/ide_completion/src/tests.rs index 4b7e19cc0..1ea6017ce 100644 --- a/crates/ide_completion/src/tests.rs +++ b/crates/ide_completion/src/tests.rs | |||
@@ -6,6 +6,7 @@ | |||
6 | 6 | ||
7 | mod item_list; | 7 | mod item_list; |
8 | mod use_tree; | 8 | mod use_tree; |
9 | mod items; | ||
9 | 10 | ||
10 | use hir::{PrefixKind, Semantics}; | 11 | use hir::{PrefixKind, Semantics}; |
11 | use ide_db::{ | 12 | use ide_db::{ |
diff --git a/crates/ide_completion/src/tests/items.rs b/crates/ide_completion/src/tests/items.rs new file mode 100644 index 000000000..dd4ba3864 --- /dev/null +++ b/crates/ide_completion/src/tests/items.rs | |||
@@ -0,0 +1,108 @@ | |||
1 | //! Completions tests for item specifics overall. | ||
2 | //! | ||
3 | //! Except for use items which are tested in [super::use_tree] and mod declarations with are tested | ||
4 | //! in [crate::completions::mod_]. | ||
5 | use expect_test::{expect, Expect}; | ||
6 | |||
7 | use crate::tests::completion_list; | ||
8 | |||
9 | fn check(ra_fixture: &str, expect: Expect) { | ||
10 | let base = r#"#[rustc_builtin_macro] | ||
11 | pub macro Clone {} | ||
12 | enum Enum { Variant } | ||
13 | struct Struct {} | ||
14 | #[macro_export] | ||
15 | macro_rules! foo {} | ||
16 | mod bar {} | ||
17 | const CONST: () = (); | ||
18 | trait Trait {} | ||
19 | "#; | ||
20 | let actual = completion_list(&format!("{}{}", base, ra_fixture)); | ||
21 | expect.assert_eq(&actual) | ||
22 | } | ||
23 | |||
24 | #[test] | ||
25 | fn target_type_or_trait_in_impl_block() { | ||
26 | // FIXME: should not complete `Self` | ||
27 | check( | ||
28 | r#" | ||
29 | impl My$0 | ||
30 | "#, | ||
31 | expect![[r##" | ||
32 | sp Self | ||
33 | tt Trait | ||
34 | en Enum | ||
35 | st Struct | ||
36 | md bar | ||
37 | ma foo!(…) #[macro_export] macro_rules! foo | ||
38 | ma foo!(…) #[macro_export] macro_rules! foo | ||
39 | bt u32 | ||
40 | bt bool | ||
41 | bt u8 | ||
42 | bt isize | ||
43 | bt u16 | ||
44 | bt u64 | ||
45 | bt u128 | ||
46 | bt f32 | ||
47 | bt i128 | ||
48 | bt i16 | ||
49 | bt str | ||
50 | bt i64 | ||
51 | bt char | ||
52 | bt f64 | ||
53 | bt i32 | ||
54 | bt i8 | ||
55 | bt usize | ||
56 | "##]], | ||
57 | ) | ||
58 | } | ||
59 | |||
60 | #[test] | ||
61 | fn after_trait_name_in_trait_def() { | ||
62 | // FIXME: should only complete `where` | ||
63 | check( | ||
64 | r"trait A $0", | ||
65 | expect![[r##" | ||
66 | kw where | ||
67 | sn tmod (Test module) | ||
68 | sn tfn (Test function) | ||
69 | sn macro_rules | ||
70 | md bar | ||
71 | ma foo!(…) #[macro_export] macro_rules! foo | ||
72 | ma foo!(…) #[macro_export] macro_rules! foo | ||
73 | "##]], | ||
74 | ); | ||
75 | } | ||
76 | |||
77 | #[test] | ||
78 | fn after_trait_or_target_name_in_impl() { | ||
79 | // FIXME: should only complete `for` and `where` | ||
80 | check( | ||
81 | r"impl A $0", | ||
82 | expect![[r##" | ||
83 | kw where | ||
84 | sn tmod (Test module) | ||
85 | sn tfn (Test function) | ||
86 | sn macro_rules | ||
87 | md bar | ||
88 | ma foo!(…) #[macro_export] macro_rules! foo | ||
89 | ma foo!(…) #[macro_export] macro_rules! foo | ||
90 | "##]], | ||
91 | ); | ||
92 | } | ||
93 | |||
94 | #[test] | ||
95 | fn before_record_field() { | ||
96 | check( | ||
97 | r#" | ||
98 | struct Foo { | ||
99 | $0 | ||
100 | pub f: i32, | ||
101 | } | ||
102 | "#, | ||
103 | expect![[r#" | ||
104 | kw pub(crate) | ||
105 | kw pub | ||
106 | "#]], | ||
107 | ) | ||
108 | } | ||