diff options
Diffstat (limited to 'crates/ra_analysis/src/imp.rs')
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 771dad475..eae73c2c4 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -165,9 +165,11 @@ impl db::RootDatabase { | |||
165 | }; | 165 | }; |
166 | } | 166 | } |
167 | // If that fails try the index based approach. | 167 | // If that fails try the index based approach. |
168 | for (file_id, symbol) in self.index_resolve(name_ref)? { | 168 | rr.resolves_to.extend( |
169 | rr.add_resolution(file_id, symbol); | 169 | self.index_resolve(name_ref)? |
170 | } | 170 | .into_iter() |
171 | .map(NavigationTarget::from_symbol), | ||
172 | ); | ||
171 | return Ok(Some(rr)); | 173 | return Ok(Some(rr)); |
172 | } | 174 | } |
173 | if let Some(name) = find_node_at_offset::<ast::Name>(syntax, position.offset) { | 175 | if let Some(name) = find_node_at_offset::<ast::Name>(syntax, position.offset) { |
@@ -352,13 +354,15 @@ impl db::RootDatabase { | |||
352 | 354 | ||
353 | // Resolve the function's NameRef (NOTE: this isn't entirely accurate). | 355 | // Resolve the function's NameRef (NOTE: this isn't entirely accurate). |
354 | let file_symbols = self.index_resolve(name_ref)?; | 356 | let file_symbols = self.index_resolve(name_ref)?; |
355 | for (fn_file_id, fs) in file_symbols { | 357 | for symbol in file_symbols { |
356 | if fs.ptr.kind() == FN_DEF { | 358 | if symbol.ptr.kind() == FN_DEF { |
357 | let fn_file = self.source_file(fn_file_id); | 359 | let fn_file = self.source_file(symbol.file_id); |
358 | let fn_def = fs.ptr.resolve(&fn_file); | 360 | let fn_def = symbol.ptr.resolve(&fn_file); |
359 | let fn_def = ast::FnDef::cast(fn_def.borrowed()).unwrap(); | 361 | let fn_def = ast::FnDef::cast(fn_def.borrowed()).unwrap(); |
360 | let descr = ctry!(source_binder::function_from_source( | 362 | let descr = ctry!(source_binder::function_from_source( |
361 | self, fn_file_id, fn_def | 363 | self, |
364 | symbol.file_id, | ||
365 | fn_def | ||
362 | )?); | 366 | )?); |
363 | if let Some(descriptor) = descr.signature_info(self) { | 367 | if let Some(descriptor) = descr.signature_info(self) { |
364 | // If we have a calling expression let's find which argument we are on | 368 | // If we have a calling expression let's find which argument we are on |
@@ -438,7 +442,7 @@ impl db::RootDatabase { | |||
438 | .collect::<Vec<_>>(); | 442 | .collect::<Vec<_>>(); |
439 | Ok(res) | 443 | Ok(res) |
440 | } | 444 | } |
441 | fn index_resolve(&self, name_ref: ast::NameRef) -> Cancelable<Vec<(FileId, FileSymbol)>> { | 445 | fn index_resolve(&self, name_ref: ast::NameRef) -> Cancelable<Vec<FileSymbol>> { |
442 | let name = name_ref.text(); | 446 | let name = name_ref.text(); |
443 | let mut query = Query::new(name.to_string()); | 447 | let mut query = Query::new(name.to_string()); |
444 | query.exact(); | 448 | query.exact(); |