File tree Expand file tree Collapse file tree 7 files changed +134
-142
lines changed
crates/ide_completion/src Expand file tree Collapse file tree 7 files changed +134
-142
lines changed Original file line number Diff line number Diff line change @@ -255,60 +255,6 @@ mod tests {
255
255
expect. assert_eq ( & actual) ;
256
256
}
257
257
258
- fn check_builtin ( ra_fixture : & str , expect : Expect ) {
259
- let actual = filtered_completion_list ( ra_fixture, CompletionKind :: BuiltinType ) ;
260
- expect. assert_eq ( & actual) ;
261
- }
262
-
263
- #[ test]
264
- fn dont_complete_primitive_in_use ( ) {
265
- check_builtin ( r#"use self::$0;"# , expect ! [ [ "" ] ] ) ;
266
- }
267
-
268
- #[ test]
269
- fn dont_complete_primitive_in_module_scope ( ) {
270
- check_builtin ( r#"fn foo() { self::$0 }"# , expect ! [ [ "" ] ] ) ;
271
- }
272
-
273
- #[ test]
274
- fn completes_enum_variant ( ) {
275
- check (
276
- r#"
277
- enum E { Foo, Bar(i32) }
278
- fn foo() { let _ = E::$0 }
279
- "# ,
280
- expect ! [ [ r#"
281
- ev Foo ()
282
- ev Bar(…) (i32)
283
- "# ] ] ,
284
- ) ;
285
- }
286
-
287
- #[ test]
288
- fn completes_struct_associated_items ( ) {
289
- check (
290
- r#"
291
- //- /lib.rs
292
- struct S;
293
-
294
- impl S {
295
- fn a() {}
296
- fn b(&self) {}
297
- const C: i32 = 42;
298
- type T = i32;
299
- }
300
-
301
- fn foo() { let _ = S::$0 }
302
- "# ,
303
- expect ! [ [ r#"
304
- fn a() fn()
305
- me b(…) fn(&self)
306
- ct C const C: i32 = 42;
307
- ta T type T = i32;
308
- "# ] ] ,
309
- ) ;
310
- }
311
-
312
258
#[ test]
313
259
fn associated_item_visibility ( ) {
314
260
check (
@@ -336,21 +282,6 @@ fn foo() { let _ = S::$0 }
336
282
) ;
337
283
}
338
284
339
- #[ test]
340
- fn completes_enum_associated_method ( ) {
341
- check (
342
- r#"
343
- enum E {};
344
- impl E { fn m() { } }
345
-
346
- fn foo() { let _ = E::$0 }
347
- "# ,
348
- expect ! [ [ r#"
349
- fn m() fn()
350
- "# ] ] ,
351
- ) ;
352
- }
353
-
354
285
#[ test]
355
286
fn completes_union_associated_method ( ) {
356
287
check (
Original file line number Diff line number Diff line change 1
1
//! Tests and test utilities for completions.
2
2
//!
3
- //! Most tests live in this module or its submodules unless for very specific completions like
4
- //! `attributes` or `lifetimes` where the completed concept is a distinct thing.
5
- //! Notable examples for completions that are being tested in this module's submodule are paths.
6
- //! Another exception are `check_edit` tests which usually live in the completion modules themselves,
7
- //! as the main purpose of this test module here is to give the developer an overview of whats being
8
- //! completed where, not how.
3
+ //! Most tests live in this module or its submodules. The tests in these submodules are "location"
4
+ //! oriented, that is they try to check completions for something like type position, param position
5
+ //! etc.
6
+ //! Tests that are more orientated towards specific completion types like visibility checks of path
7
+ //! completions or `check_edit` tests usually live in their respective completion modules instead.
8
+ //! This gives this test module and its submodules here the main purpose of giving the developer an
9
+ //! overview of whats being completed where, not how.
9
10
10
11
mod attribute;
11
12
mod expression;
@@ -55,6 +56,7 @@ macro_rules! makro {}
55
56
#[rustc_builtin_macro]
56
57
pub macro Clone {}
57
58
fn function() {}
59
+ union Union { field: i32 }
58
60
"# ;
59
61
60
62
pub ( crate ) const TEST_CONFIG : CompletionConfig = CompletionConfig {
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ impl Unit {
70
70
}
71
71
}
72
72
"# ,
73
+ // `self` is in here twice, once as the module, once as the local
73
74
expect ! [ [ r##"
74
75
kw unsafe
75
76
kw fn
@@ -114,12 +115,42 @@ impl Unit {
114
115
?? Unresolved
115
116
fn function() fn()
116
117
sc STATIC
118
+ un Union
117
119
ev TupleV(…) (u32)
118
120
ct CONST
119
121
ma makro!(…) #[macro_export] macro_rules! makro
120
122
me self.foo() fn(self)
121
123
"## ] ] ,
122
124
) ;
125
+ check (
126
+ r#"
127
+ use non_existant::Unresolved;
128
+ mod qualified { pub enum Enum { Variant } }
129
+
130
+ impl Unit {
131
+ fn foo<'lifetime, TypeParam, const CONST_PARAM: usize>(self) {
132
+ fn local_func() {}
133
+ self::$0
134
+ }
135
+ }
136
+ "# ,
137
+ expect ! [ [ r##"
138
+ tt Trait
139
+ en Enum
140
+ st Record
141
+ st Tuple
142
+ md module
143
+ st Unit
144
+ md qualified
145
+ ma makro!(…) #[macro_export] macro_rules! makro
146
+ ?? Unresolved
147
+ fn function() fn()
148
+ sc STATIC
149
+ un Union
150
+ ev TupleV(…) (u32)
151
+ ct CONST
152
+ "## ] ] ,
153
+ ) ;
123
154
}
124
155
125
156
#[ test]
@@ -247,3 +278,27 @@ fn quux(x: i32) {
247
278
"# ] ] ,
248
279
) ;
249
280
}
281
+
282
+ #[ test]
283
+ fn enum_qualified ( ) {
284
+ check (
285
+ r#"
286
+ impl Enum {
287
+ type AssocType = ();
288
+ const ASSOC_CONST: () = ();
289
+ fn assoc_fn() {}
290
+ }
291
+ fn func() {
292
+ Enum::$0
293
+ }
294
+ "# ,
295
+ expect ! [ [ r#"
296
+ ev TupleV(…) (u32)
297
+ ev RecordV { field: u32 }
298
+ ev UnitV ()
299
+ ct ASSOC_CONST const ASSOC_CONST: () = ();
300
+ fn assoc_fn() fn()
301
+ ta AssocType type AssocType = ();
302
+ "# ] ] ,
303
+ ) ;
304
+ }
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ impl Tra$0
28
28
md module
29
29
st Unit
30
30
ma makro!(…) #[macro_export] macro_rules! makro
31
+ un Union
31
32
ma makro!(…) #[macro_export] macro_rules! makro
32
33
bt u32
33
34
"## ] ] ,
@@ -51,6 +52,7 @@ impl Trait for Str$0
51
52
md module
52
53
st Unit
53
54
ma makro!(…) #[macro_export] macro_rules! makro
55
+ un Union
54
56
ma makro!(…) #[macro_export] macro_rules! makro
55
57
bt u32
56
58
"## ] ] ,
You can’t perform that action at this time.
0 commit comments