diff options
Diffstat (limited to 'crates/ra_analysis/src/completion/reference_completion.rs')
-rw-r--r-- | crates/ra_analysis/src/completion/reference_completion.rs | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/crates/ra_analysis/src/completion/reference_completion.rs b/crates/ra_analysis/src/completion/reference_completion.rs index a96570415..d301a3c02 100644 --- a/crates/ra_analysis/src/completion/reference_completion.rs +++ b/crates/ra_analysis/src/completion/reference_completion.rs | |||
@@ -13,7 +13,7 @@ use crate::{ | |||
13 | descriptors::{ | 13 | descriptors::{ |
14 | module::{ModuleDescriptor}, | 14 | module::{ModuleDescriptor}, |
15 | function::FnScopes, | 15 | function::FnScopes, |
16 | Path, PathKind, | 16 | Path, |
17 | }, | 17 | }, |
18 | Cancelable | 18 | Cancelable |
19 | }; | 19 | }; |
@@ -148,9 +148,13 @@ fn complete_path( | |||
148 | acc: &mut Vec<CompletionItem>, | 148 | acc: &mut Vec<CompletionItem>, |
149 | db: &RootDatabase, | 149 | db: &RootDatabase, |
150 | module: &ModuleDescriptor, | 150 | module: &ModuleDescriptor, |
151 | path: Path, | 151 | mut path: Path, |
152 | ) -> Cancelable<()> { | 152 | ) -> Cancelable<()> { |
153 | let target_module = match find_target_module(module, path) { | 153 | if path.segments.is_empty() { |
154 | return Ok(()); | ||
155 | } | ||
156 | path.segments.pop(); | ||
157 | let target_module = match module.resolve_path(path) { | ||
154 | None => return Ok(()), | 158 | None => return Ok(()), |
155 | Some(it) => it, | 159 | Some(it) => it, |
156 | }; | 160 | }; |
@@ -167,19 +171,6 @@ fn complete_path( | |||
167 | Ok(()) | 171 | Ok(()) |
168 | } | 172 | } |
169 | 173 | ||
170 | fn find_target_module(module: &ModuleDescriptor, path: Path) -> Option<ModuleDescriptor> { | ||
171 | if path.kind != PathKind::Crate { | ||
172 | return None; | ||
173 | } | ||
174 | let mut segments = path.segments; | ||
175 | segments.pop(); | ||
176 | let mut target_module = module.crate_root(); | ||
177 | for name in segments { | ||
178 | target_module = target_module.child(&name)?; | ||
179 | } | ||
180 | Some(target_module) | ||
181 | } | ||
182 | |||
183 | fn complete_mod_item_snippets(acc: &mut Vec<CompletionItem>) { | 174 | fn complete_mod_item_snippets(acc: &mut Vec<CompletionItem>) { |
184 | acc.push(CompletionItem { | 175 | acc.push(CompletionItem { |
185 | label: "tfn".to_string(), | 176 | label: "tfn".to_string(), |