diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-11-21 11:57:32 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-11-21 11:57:32 +0000 |
commit | 031bc868293539714157e3d93cc338b011f5661d (patch) | |
tree | 624843cfddada855a6a80380e817bb188596c441 /crates/ra_analysis/src/completion | |
parent | 713c3ea30b38199e05e1f70094d85177f16915f8 (diff) | |
parent | 5a61b218f8869532ccb6be9dccff9e7d8641bf49 (diff) |
Merge #236
236: WIP: Module name resolution r=matklad a=matklad
work towards #231
Co-authored-by: Aleksey Kladov <[email protected]>
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 | } |