diff options
author | Aleksey Kladov <[email protected]> | 2018-11-21 09:57:05 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-11-21 09:57:05 +0000 |
commit | 049f8df93cca05af395ce873738dc85d5a25f3fc (patch) | |
tree | 55614a697cc531a53f2836c994d3211c6cd756c2 /crates/ra_analysis/src/completion | |
parent | b70b6bce19981df5d0cda6a0193fb9b07da6ea51 (diff) |
switch completion to new scope
Diffstat (limited to 'crates/ra_analysis/src/completion')
-rw-r--r-- | crates/ra_analysis/src/completion/mod.rs | 10 | ||||
-rw-r--r-- | crates/ra_analysis/src/completion/reference_completion.rs | 26 |
2 files changed, 21 insertions, 15 deletions
diff --git a/crates/ra_analysis/src/completion/mod.rs b/crates/ra_analysis/src/completion/mod.rs index 5e3ee79dd..a8a752fc7 100644 --- a/crates/ra_analysis/src/completion/mod.rs +++ b/crates/ra_analysis/src/completion/mod.rs | |||
@@ -204,9 +204,9 @@ mod tests { | |||
204 | <|> | 204 | <|> |
205 | } | 205 | } |
206 | ", | 206 | ", |
207 | r#"[CompletionItem { label: "Foo", lookup: None, snippet: None }, | 207 | r#"[CompletionItem { label: "quux", lookup: None, snippet: None }, |
208 | CompletionItem { label: "Baz", lookup: None, snippet: None }, | 208 | CompletionItem { label: "Foo", lookup: None, snippet: None }, |
209 | CompletionItem { label: "quux", lookup: None, snippet: None }]"#, | 209 | CompletionItem { label: "Baz", lookup: None, snippet: None }]"#, |
210 | ); | 210 | ); |
211 | } | 211 | } |
212 | 212 | ||
@@ -230,8 +230,8 @@ mod tests { | |||
230 | fn quux() { <|> } | 230 | fn quux() { <|> } |
231 | } | 231 | } |
232 | ", | 232 | ", |
233 | r#"[CompletionItem { label: "Bar", lookup: None, snippet: None }, | 233 | r#"[CompletionItem { label: "quux", lookup: None, snippet: None }, |
234 | CompletionItem { label: "quux", lookup: None, snippet: None }]"#, | 234 | CompletionItem { label: "Bar", lookup: None, snippet: None }]"#, |
235 | ); | 235 | ); |
236 | } | 236 | } |
237 | 237 | ||
diff --git a/crates/ra_analysis/src/completion/reference_completion.rs b/crates/ra_analysis/src/completion/reference_completion.rs index c94d9af75..84383b547 100644 --- a/crates/ra_analysis/src/completion/reference_completion.rs +++ b/crates/ra_analysis/src/completion/reference_completion.rs | |||
@@ -39,14 +39,17 @@ pub(super) fn completions( | |||
39 | let module_scope = module.scope(db)?; | 39 | let module_scope = module.scope(db)?; |
40 | acc.extend( | 40 | acc.extend( |
41 | module_scope | 41 | module_scope |
42 | .entries() | 42 | .items |
43 | .iter() | 43 | .iter() |
44 | .filter(|entry| { | 44 | .filter(|(_name, res)| { |
45 | // Don't expose this item | 45 | // Don't expose this item |
46 | !entry.ptr().range().is_subrange(&name_ref.syntax().range()) | 46 | match res.import_name { |
47 | None => true, | ||
48 | Some(ptr) => !ptr.range().is_subrange(&name_ref.syntax().range()), | ||
49 | } | ||
47 | }) | 50 | }) |
48 | .map(|entry| CompletionItem { | 51 | .map(|(name, _res)| CompletionItem { |
49 | label: entry.name().to_string(), | 52 | label: name.to_string(), |
50 | lookup: None, | 53 | lookup: None, |
51 | snippet: None, | 54 | snippet: None, |
52 | }), | 55 | }), |
@@ -173,11 +176,14 @@ fn complete_path( | |||
173 | Some(it) => it, | 176 | Some(it) => it, |
174 | }; | 177 | }; |
175 | let module_scope = target_module.scope(db)?; | 178 | let module_scope = target_module.scope(db)?; |
176 | let completions = module_scope.entries().iter().map(|entry| CompletionItem { | 179 | let completions = module_scope |
177 | label: entry.name().to_string(), | 180 | .items |
178 | lookup: None, | 181 | .iter() |
179 | snippet: None, | 182 | .map(|(name, _res)| CompletionItem { |
180 | }); | 183 | label: name.to_string(), |
184 | lookup: None, | ||
185 | snippet: None, | ||
186 | }); | ||
181 | acc.extend(completions); | 187 | acc.extend(completions); |
182 | Ok(()) | 188 | Ok(()) |
183 | } | 189 | } |