diff options
Diffstat (limited to 'crates/ide_completion/src/completions/qualified_path.rs')
-rw-r--r-- | crates/ide_completion/src/completions/qualified_path.rs | 159 |
1 files changed, 1 insertions, 158 deletions
diff --git a/crates/ide_completion/src/completions/qualified_path.rs b/crates/ide_completion/src/completions/qualified_path.rs index 9432caa22..0597879ac 100644 --- a/crates/ide_completion/src/completions/qualified_path.rs +++ b/crates/ide_completion/src/completions/qualified_path.rs | |||
@@ -49,7 +49,7 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon | |||
49 | hir::PathResolution::Def(hir::ModuleDef::Module(module)) => { | 49 | hir::PathResolution::Def(hir::ModuleDef::Module(module)) => { |
50 | let module_scope = module.scope(ctx.db, context_module); | 50 | let module_scope = module.scope(ctx.db, context_module); |
51 | for (name, def) in module_scope { | 51 | for (name, def) in module_scope { |
52 | if ctx.use_item_syntax.is_some() { | 52 | if ctx.in_use_tree() { |
53 | if let hir::ScopeDef::Unknown = def { | 53 | if let hir::ScopeDef::Unknown = def { |
54 | if let Some(name_ref) = ctx.name_ref_syntax.as_ref() { | 54 | if let Some(name_ref) = ctx.name_ref_syntax.as_ref() { |
55 | if name_ref.syntax().text() == name.to_string().as_str() { | 55 | if name_ref.syntax().text() == name.to_string().as_str() { |
@@ -213,12 +213,6 @@ mod tests { | |||
213 | } | 213 | } |
214 | 214 | ||
215 | #[test] | 215 | #[test] |
216 | fn dont_complete_current_use() { | ||
217 | cov_mark::check!(dont_complete_current_use); | ||
218 | check(r#"use self::foo$0;"#, expect![[""]]); | ||
219 | } | ||
220 | |||
221 | #[test] | ||
222 | fn dont_complete_values_in_type_pos() { | 216 | fn dont_complete_values_in_type_pos() { |
223 | check( | 217 | check( |
224 | r#" | 218 | r#" |
@@ -249,20 +243,6 @@ fn foo() { | |||
249 | } | 243 | } |
250 | 244 | ||
251 | #[test] | 245 | #[test] |
252 | fn dont_complete_current_use_in_braces_with_glob() { | ||
253 | check( | ||
254 | r#" | ||
255 | mod foo { pub struct S; } | ||
256 | use self::{foo::*, bar$0}; | ||
257 | "#, | ||
258 | expect![[r#" | ||
259 | st S | ||
260 | md foo | ||
261 | "#]], | ||
262 | ); | ||
263 | } | ||
264 | |||
265 | #[test] | ||
266 | fn dont_complete_primitive_in_use() { | 246 | fn dont_complete_primitive_in_use() { |
267 | check_builtin(r#"use self::$0;"#, expect![[""]]); | 247 | check_builtin(r#"use self::$0;"#, expect![[""]]); |
268 | } | 248 | } |
@@ -299,108 +279,6 @@ use self::{foo::*, bar$0}; | |||
299 | } | 279 | } |
300 | 280 | ||
301 | #[test] | 281 | #[test] |
302 | fn completes_mod_with_same_name_as_function() { | ||
303 | check( | ||
304 | r#" | ||
305 | use self::my::$0; | ||
306 | |||
307 | mod my { pub struct Bar; } | ||
308 | fn my() {} | ||
309 | "#, | ||
310 | expect![[r#" | ||
311 | st Bar | ||
312 | "#]], | ||
313 | ); | ||
314 | } | ||
315 | |||
316 | #[test] | ||
317 | fn filters_visibility() { | ||
318 | check( | ||
319 | r#" | ||
320 | use self::my::$0; | ||
321 | |||
322 | mod my { | ||
323 | struct Bar; | ||
324 | pub struct Foo; | ||
325 | pub use Bar as PublicBar; | ||
326 | } | ||
327 | "#, | ||
328 | expect![[r#" | ||
329 | st Foo | ||
330 | st PublicBar | ||
331 | "#]], | ||
332 | ); | ||
333 | } | ||
334 | |||
335 | #[test] | ||
336 | fn completes_use_item_starting_with_self() { | ||
337 | check( | ||
338 | r#" | ||
339 | use self::m::$0; | ||
340 | |||
341 | mod m { pub struct Bar; } | ||
342 | "#, | ||
343 | expect![[r#" | ||
344 | st Bar | ||
345 | "#]], | ||
346 | ); | ||
347 | } | ||
348 | |||
349 | #[test] | ||
350 | fn completes_use_item_starting_with_crate() { | ||
351 | check( | ||
352 | r#" | ||
353 | //- /lib.rs | ||
354 | mod foo; | ||
355 | struct Spam; | ||
356 | //- /foo.rs | ||
357 | use crate::Sp$0 | ||
358 | "#, | ||
359 | expect![[r#" | ||
360 | md foo | ||
361 | st Spam | ||
362 | "#]], | ||
363 | ); | ||
364 | } | ||
365 | |||
366 | #[test] | ||
367 | fn completes_nested_use_tree() { | ||
368 | check( | ||
369 | r#" | ||
370 | //- /lib.rs | ||
371 | mod foo; | ||
372 | struct Spam; | ||
373 | //- /foo.rs | ||
374 | use crate::{Sp$0}; | ||
375 | "#, | ||
376 | expect![[r#" | ||
377 | md foo | ||
378 | st Spam | ||
379 | "#]], | ||
380 | ); | ||
381 | } | ||
382 | |||
383 | #[test] | ||
384 | fn completes_deeply_nested_use_tree() { | ||
385 | check( | ||
386 | r#" | ||
387 | //- /lib.rs | ||
388 | mod foo; | ||
389 | pub mod bar { | ||
390 | pub mod baz { | ||
391 | pub struct Spam; | ||
392 | } | ||
393 | } | ||
394 | //- /foo.rs | ||
395 | use crate::{bar::{baz::Sp$0}}; | ||
396 | "#, | ||
397 | expect![[r#" | ||
398 | st Spam | ||
399 | "#]], | ||
400 | ); | ||
401 | } | ||
402 | |||
403 | #[test] | ||
404 | fn completes_enum_variant() { | 282 | fn completes_enum_variant() { |
405 | check( | 283 | check( |
406 | r#" | 284 | r#" |
@@ -497,22 +375,6 @@ fn foo() { let _ = U::$0 } | |||
497 | } | 375 | } |
498 | 376 | ||
499 | #[test] | 377 | #[test] |
500 | fn completes_use_paths_across_crates() { | ||
501 | check( | ||
502 | r#" | ||
503 | //- /main.rs crate:main deps:foo | ||
504 | use foo::$0; | ||
505 | |||
506 | //- /foo/lib.rs crate:foo | ||
507 | pub mod bar { pub struct S; } | ||
508 | "#, | ||
509 | expect![[r#" | ||
510 | md bar | ||
511 | "#]], | ||
512 | ); | ||
513 | } | ||
514 | |||
515 | #[test] | ||
516 | fn completes_trait_associated_method_1() { | 378 | fn completes_trait_associated_method_1() { |
517 | check( | 379 | check( |
518 | r#" | 380 | r#" |
@@ -714,25 +576,6 @@ impl MyStruct { | |||
714 | } | 576 | } |
715 | 577 | ||
716 | #[test] | 578 | #[test] |
717 | fn test_super_super_completion() { | ||
718 | check( | ||
719 | r#" | ||
720 | mod a { | ||
721 | const A: usize = 0; | ||
722 | mod b { | ||
723 | const B: usize = 0; | ||
724 | mod c { use super::super::$0 } | ||
725 | } | ||
726 | } | ||
727 | "#, | ||
728 | expect![[r#" | ||
729 | md b | ||
730 | ct A | ||
731 | "#]], | ||
732 | ); | ||
733 | } | ||
734 | |||
735 | #[test] | ||
736 | fn completes_reexported_items_under_correct_name() { | 579 | fn completes_reexported_items_under_correct_name() { |
737 | check( | 580 | check( |
738 | r#" | 581 | r#" |