aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/completion/complete_scope.rs
diff options
context:
space:
mode:
authorSteffen Lyngbaek <[email protected]>2020-03-18 23:15:32 +0000
committerSteffen Lyngbaek <[email protected]>2020-03-19 21:12:00 +0000
commiteb51abdc646e11b8c23fee83b6f052d3dde87985 (patch)
tree1459c46b52fa33545a1ba5854cea6fdf053255cd /crates/ra_ide/src/completion/complete_scope.rs
parent6941a7faba49b3927df3106b70b780857d1bab17 (diff)
Fixes to more accurately give complete_scope completions
- Exclude const, static, functions form is_pat_binding_and_path (there might be more?) - Add a check to filter out Record Fields - Fix tests
Diffstat (limited to 'crates/ra_ide/src/completion/complete_scope.rs')
-rw-r--r--crates/ra_ide/src/completion/complete_scope.rs17
1 files changed, 5 insertions, 12 deletions
diff --git a/crates/ra_ide/src/completion/complete_scope.rs b/crates/ra_ide/src/completion/complete_scope.rs
index 6b0621081..1cb2ed070 100644
--- a/crates/ra_ide/src/completion/complete_scope.rs
+++ b/crates/ra_ide/src/completion/complete_scope.rs
@@ -1,7 +1,7 @@
1//! Completion of names from the current scope, e.g. locals and imported items. 1//! Completion of names from the current scope, e.g. locals and imported items.
2 2
3use crate::completion::{CompletionContext, Completions}; 3use crate::completion::{CompletionContext, Completions};
4use hir::ScopeDef; 4use hir::{ModuleDef, ScopeDef};
5 5
6pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) { 6pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) {
7 if !ctx.is_trivial_path && !ctx.is_pat_binding_and_path { 7 if !ctx.is_trivial_path && !ctx.is_pat_binding_and_path {
@@ -9,7 +9,10 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) {
9 } 9 }
10 10
11 ctx.scope().process_all_names(&mut |name, res| match (ctx.is_pat_binding_and_path, &res) { 11 ctx.scope().process_all_names(&mut |name, res| match (ctx.is_pat_binding_and_path, &res) {
12 (true, ScopeDef::Local(..)) => {} 12 (true, ScopeDef::ModuleDef(ModuleDef::Function(..))) => (),
13 (true, ScopeDef::ModuleDef(ModuleDef::Static(..))) => (),
14 (true, ScopeDef::ModuleDef(ModuleDef::Const(..))) => (),
15 (true, ScopeDef::Local(..)) => (),
13 _ => acc.add_resolution(ctx, name.to_string(), &res), 16 _ => acc.add_resolution(ctx, name.to_string(), &res),
14 }); 17 });
15} 18}
@@ -71,16 +74,6 @@ mod tests {
71 insert: "Enum", 74 insert: "Enum",
72 kind: Enum, 75 kind: Enum,
73 }, 76 },
74 CompletionItem {
75 label: "quux(…)",
76 source_range: [231; 233),
77 delete: [231; 233),
78 insert: "quux(${1:x})$0",
79 kind: Function,
80 lookup: "quux",
81 detail: "fn quux(x: Option<Enum>)",
82 trigger_call_info: true,
83 },
84 ] 77 ]
85 "### 78 "###
86 ); 79 );