aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/completions
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-05-27 17:15:18 +0100
committerLukas Wirth <[email protected]>2021-05-27 17:16:39 +0100
commit3a16950fd919f46fd879c36423810a40105b2c10 (patch)
tree0596de15d333b44681b07d0b69d3b1ef9751bd0c /crates/ide_completion/src/completions
parentf41c98342476087d0a4387e7d337ce2d897e0346 (diff)
Cleanup `ImmediateLocation` determination
Diffstat (limited to 'crates/ide_completion/src/completions')
-rw-r--r--crates/ide_completion/src/completions/keyword.rs2
-rw-r--r--crates/ide_completion/src/completions/qualified_path.rs22
2 files changed, 21 insertions, 3 deletions
diff --git a/crates/ide_completion/src/completions/keyword.rs b/crates/ide_completion/src/completions/keyword.rs
index 14d6ae54e..96447a603 100644
--- a/crates/ide_completion/src/completions/keyword.rs
+++ b/crates/ide_completion/src/completions/keyword.rs
@@ -104,7 +104,7 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
104 if expects_item || has_block_expr_parent { 104 if expects_item || has_block_expr_parent {
105 add_keyword(ctx, acc, "mod", "mod $0"); 105 add_keyword(ctx, acc, "mod", "mod $0");
106 } 106 }
107 if ctx.has_ident_or_ref_pat_parent() { 107 if ctx.expects_ident_pat_or_ref_expr() {
108 add_keyword(ctx, acc, "mut", "mut "); 108 add_keyword(ctx, acc, "mut", "mut ");
109 } 109 }
110 if expects_item || expects_assoc_item || has_block_expr_parent { 110 if expects_item || expects_assoc_item || has_block_expr_parent {
diff --git a/crates/ide_completion/src/completions/qualified_path.rs b/crates/ide_completion/src/completions/qualified_path.rs
index a90325e06..c16bb215f 100644
--- a/crates/ide_completion/src/completions/qualified_path.rs
+++ b/crates/ide_completion/src/completions/qualified_path.rs
@@ -20,7 +20,6 @@ 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
24 if ctx.expects_item() || ctx.expects_assoc_item() { 23 if ctx.expects_item() || ctx.expects_assoc_item() {
25 if let PathResolution::Def(hir::ModuleDef::Module(module)) = resolution { 24 if let PathResolution::Def(hir::ModuleDef::Module(module)) = resolution {
26 let module_scope = module.scope(ctx.db, context_module); 25 let module_scope = module.scope(ctx.db, context_module);
@@ -606,7 +605,7 @@ fn main() { T::$0; }
606macro_rules! foo { () => {} } 605macro_rules! foo { () => {} }
607 606
608fn main() { let _ = crate::$0 } 607fn main() { let _ = crate::$0 }
609 "#, 608"#,
610 expect![[r##" 609 expect![[r##"
611 fn main() fn() 610 fn main() fn()
612 ma foo!(…) #[macro_export] macro_rules! foo 611 ma foo!(…) #[macro_export] macro_rules! foo
@@ -615,6 +614,25 @@ fn main() { let _ = crate::$0 }
615 } 614 }
616 615
617 #[test] 616 #[test]
617 fn completes_qualified_macros_in_impl() {
618 check(
619 r#"
620#[macro_export]
621macro_rules! foo { () => {} }
622
623struct MyStruct {}
624
625impl MyStruct {
626 crate::$0
627}
628"#,
629 expect![[r##"
630 ma foo! #[macro_export] macro_rules! foo
631 "##]],
632 );
633 }
634
635 #[test]
618 fn test_super_super_completion() { 636 fn test_super_super_completion() {
619 check( 637 check(
620 r#" 638 r#"