aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/completions/qualified_path.rs
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-05-27 20:12:50 +0100
committerLukas Wirth <[email protected]>2021-05-27 20:12:50 +0100
commitea251cbd4a22c7754bb5668b9f25fc0c7b47284c (patch)
tree5956fa2300defdc96f1ecb294db77a1705561527 /crates/ide_completion/src/completions/qualified_path.rs
parent7ad378fec06dae4ba2417f2a109e4759bbcf75db (diff)
Complete modules in item lists
Diffstat (limited to 'crates/ide_completion/src/completions/qualified_path.rs')
-rw-r--r--crates/ide_completion/src/completions/qualified_path.rs22
1 files changed, 20 insertions, 2 deletions
diff --git a/crates/ide_completion/src/completions/qualified_path.rs b/crates/ide_completion/src/completions/qualified_path.rs
index 4aa37df91..7a0e1ead3 100644
--- a/crates/ide_completion/src/completions/qualified_path.rs
+++ b/crates/ide_completion/src/completions/qualified_path.rs
@@ -7,7 +7,7 @@ use syntax::AstNode;
7use crate::{CompletionContext, Completions}; 7use crate::{CompletionContext, Completions};
8 8
9pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionContext) { 9pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionContext) {
10 if ctx.is_path_disallowed() { 10 if ctx.is_path_disallowed() || ctx.expects_item() {
11 return; 11 return;
12 } 12 }
13 let path = match &ctx.path_qual { 13 let path = match &ctx.path_qual {
@@ -20,7 +20,7 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon
20 None => return, 20 None => return,
21 }; 21 };
22 let context_module = ctx.scope.module(); 22 let context_module = ctx.scope.module();
23 if ctx.expects_item() || ctx.expects_assoc_item() { 23 if ctx.expects_assoc_item() {
24 if let PathResolution::Def(hir::ModuleDef::Module(module)) = resolution { 24 if let PathResolution::Def(hir::ModuleDef::Module(module)) = resolution {
25 let module_scope = module.scope(ctx.db, context_module); 25 let module_scope = module.scope(ctx.db, context_module);
26 for (name, def) in module_scope { 26 for (name, def) in module_scope {
@@ -637,6 +637,24 @@ impl MyStruct {
637 } 637 }
638 638
639 #[test] 639 #[test]
640 #[ignore] // FIXME doesn't complete anything atm
641 fn completes_in_item_list() {
642 check(
643 r#"
644struct MyStruct {}
645macro_rules! foo {}
646mod bar {}
647
648crate::$0
649"#,
650 expect![[r#"
651 md bar
652 ma foo! macro_rules! foo
653 "#]],
654 )
655 }
656
657 #[test]
640 fn test_super_super_completion() { 658 fn test_super_super_completion() {
641 check( 659 check(
642 r#" 660 r#"