diff options
author | Steffen Lyngbaek <[email protected]> | 2020-03-19 07:11:25 +0000 |
---|---|---|
committer | Steffen Lyngbaek <[email protected]> | 2020-03-19 21:17:34 +0000 |
commit | ec24c090063b3b86349f7812b716412d83dad069 (patch) | |
tree | 5dd13a24ef92a10bd686a80bbb2e59b83bf015d0 /crates/ra_ide/src | |
parent | eb51abdc646e11b8c23fee83b6f052d3dde87985 (diff) |
Remove const
- Add test for @ matching
- Address comments
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r-- | crates/ra_ide/src/completion/complete_pattern.rs | 22 | ||||
-rw-r--r-- | crates/ra_ide/src/completion/complete_scope.rs | 22 | ||||
-rw-r--r-- | crates/ra_ide/src/completion/completion_context.rs | 10 |
3 files changed, 48 insertions, 6 deletions
diff --git a/crates/ra_ide/src/completion/complete_pattern.rs b/crates/ra_ide/src/completion/complete_pattern.rs index e8e676a4c..bc8fade6f 100644 --- a/crates/ra_ide/src/completion/complete_pattern.rs +++ b/crates/ra_ide/src/completion/complete_pattern.rs | |||
@@ -98,6 +98,13 @@ mod tests { | |||
98 | kind: Const, | 98 | kind: Const, |
99 | }, | 99 | }, |
100 | CompletionItem { | 100 | CompletionItem { |
101 | label: "Z", | ||
102 | source_range: [246; 246), | ||
103 | delete: [246; 246), | ||
104 | insert: "Z", | ||
105 | kind: Const, | ||
106 | }, | ||
107 | CompletionItem { | ||
101 | label: "m", | 108 | label: "m", |
102 | source_range: [246; 246), | 109 | source_range: [246; 246), |
103 | delete: [246; 246), | 110 | delete: [246; 246), |
@@ -138,6 +145,21 @@ mod tests { | |||
138 | insert: "E", | 145 | insert: "E", |
139 | kind: Enum, | 146 | kind: Enum, |
140 | }, | 147 | }, |
148 | CompletionItem { | ||
149 | label: "E", | ||
150 | source_range: [151; 151), | ||
151 | delete: [151; 151), | ||
152 | insert: "E", | ||
153 | kind: Enum, | ||
154 | }, | ||
155 | CompletionItem { | ||
156 | label: "m!", | ||
157 | source_range: [151; 151), | ||
158 | delete: [151; 151), | ||
159 | insert: "m!($0)", | ||
160 | kind: Macro, | ||
161 | detail: "macro_rules! m", | ||
162 | }, | ||
141 | ] | 163 | ] |
142 | "###); | 164 | "###); |
143 | } | 165 | } |
diff --git a/crates/ra_ide/src/completion/complete_scope.rs b/crates/ra_ide/src/completion/complete_scope.rs index 1cb2ed070..2ca552733 100644 --- a/crates/ra_ide/src/completion/complete_scope.rs +++ b/crates/ra_ide/src/completion/complete_scope.rs | |||
@@ -11,7 +11,6 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) { | |||
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::ModuleDef(ModuleDef::Function(..))) => (), | 12 | (true, ScopeDef::ModuleDef(ModuleDef::Function(..))) => (), |
13 | (true, ScopeDef::ModuleDef(ModuleDef::Static(..))) => (), | 13 | (true, ScopeDef::ModuleDef(ModuleDef::Static(..))) => (), |
14 | (true, ScopeDef::ModuleDef(ModuleDef::Const(..))) => (), | ||
15 | (true, ScopeDef::Local(..)) => (), | 14 | (true, ScopeDef::Local(..)) => (), |
16 | _ => acc.add_resolution(ctx, name.to_string(), &res), | 15 | _ => acc.add_resolution(ctx, name.to_string(), &res), |
17 | }); | 16 | }); |
@@ -28,6 +27,27 @@ mod tests { | |||
28 | } | 27 | } |
29 | 28 | ||
30 | #[test] | 29 | #[test] |
30 | fn bind_pat_and_path_ignore_at() { | ||
31 | assert_debug_snapshot!( | ||
32 | do_reference_completion( | ||
33 | r" | ||
34 | enum Enum { | ||
35 | A, | ||
36 | B, | ||
37 | } | ||
38 | fn quux(x: Option<Enum>) { | ||
39 | match x { | ||
40 | None => (), | ||
41 | Some(en<|> @ Enum::A) => (), | ||
42 | } | ||
43 | } | ||
44 | " | ||
45 | ), | ||
46 | @r###"[]"### | ||
47 | ); | ||
48 | } | ||
49 | |||
50 | #[test] | ||
31 | fn bind_pat_and_path_ignore_ref() { | 51 | fn bind_pat_and_path_ignore_ref() { |
32 | assert_debug_snapshot!( | 52 | assert_debug_snapshot!( |
33 | do_reference_completion( | 53 | do_reference_completion( |
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index 65bdac182..319e33b61 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs | |||
@@ -197,11 +197,11 @@ impl<'a> CompletionContext<'a> { | |||
197 | self.is_pat_binding = true; | 197 | self.is_pat_binding = true; |
198 | } | 198 | } |
199 | 199 | ||
200 | if parent.and_then(ast::RecordFieldPatList::cast).is_none() { | 200 | if parent.and_then(ast::RecordFieldPatList::cast).is_none() |
201 | let bind_pat_string = bind_pat.syntax().to_string(); | 201 | && bind_pat.pat().is_none() |
202 | if !bind_pat_string.contains("ref ") && !bind_pat_string.contains(" @ ") { | 202 | && !bind_pat.is_ref() |
203 | self.is_pat_binding_and_path = true; | 203 | { |
204 | } | 204 | self.is_pat_binding_and_path = true; |
205 | } | 205 | } |
206 | } | 206 | } |
207 | if is_node::<ast::Param>(name.syntax()) { | 207 | if is_node::<ast::Param>(name.syntax()) { |