diff options
Diffstat (limited to 'crates/ra_analysis/src/imp.rs')
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 58 |
1 files changed, 17 insertions, 41 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 49b863756..1bbf0cb6d 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -266,7 +266,6 @@ impl AnalysisImpl { | |||
266 | &self, | 266 | &self, |
267 | position: FilePosition, | 267 | position: FilePosition, |
268 | ) -> Cancelable<Vec<(FileId, FileSymbol)>> { | 268 | ) -> Cancelable<Vec<(FileId, FileSymbol)>> { |
269 | let module_tree = self.module_tree(position.file_id)?; | ||
270 | let file = self.db.file_syntax(position.file_id); | 269 | let file = self.db.file_syntax(position.file_id); |
271 | let syntax = file.syntax(); | 270 | let syntax = file.syntax(); |
272 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, position.offset) { | 271 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, position.offset) { |
@@ -292,25 +291,23 @@ impl AnalysisImpl { | |||
292 | if let Some(name) = find_node_at_offset::<ast::Name>(syntax, position.offset) { | 291 | if let Some(name) = find_node_at_offset::<ast::Name>(syntax, position.offset) { |
293 | if let Some(module) = name.syntax().parent().and_then(ast::Module::cast) { | 292 | if let Some(module) = name.syntax().parent().and_then(ast::Module::cast) { |
294 | if module.has_semi() { | 293 | if module.has_semi() { |
295 | let file_ids = self.resolve_module(&*module_tree, position.file_id, module); | 294 | let parent_module = |
296 | 295 | ModuleDescriptor::guess_from_file_id(&*self.db, position.file_id)?; | |
297 | let res = file_ids | 296 | let child_name = module.name(); |
298 | .into_iter() | 297 | match (parent_module, child_name) { |
299 | .map(|id| { | 298 | (Some(parent_module), Some(child_name)) => { |
300 | let name = module | 299 | if let Some(child) = parent_module.child(&child_name.text()) { |
301 | .name() | 300 | let file_id = child.source().file_id(); |
302 | .map(|n| n.text()) | 301 | let symbol = FileSymbol { |
303 | .unwrap_or_else(|| SmolStr::new("")); | 302 | name: child_name.text(), |
304 | let symbol = FileSymbol { | 303 | node_range: TextRange::offset_len(0.into(), 0.into()), |
305 | name, | 304 | kind: MODULE, |
306 | node_range: TextRange::offset_len(0.into(), 0.into()), | 305 | }; |
307 | kind: MODULE, | 306 | return Ok(vec![(file_id, symbol)]); |
308 | }; | 307 | } |
309 | (id, symbol) | 308 | } |
310 | }) | 309 | _ => (), |
311 | .collect(); | 310 | } |
312 | |||
313 | return Ok(res); | ||
314 | } | 311 | } |
315 | } | 312 | } |
316 | } | 313 | } |
@@ -519,27 +516,6 @@ impl AnalysisImpl { | |||
519 | query.limit(4); | 516 | query.limit(4); |
520 | self.world_symbols(query) | 517 | self.world_symbols(query) |
521 | } | 518 | } |
522 | |||
523 | fn resolve_module( | ||
524 | &self, | ||
525 | module_tree: &ModuleTree, | ||
526 | file_id: FileId, | ||
527 | module: ast::Module, | ||
528 | ) -> Vec<FileId> { | ||
529 | let name = match module.name() { | ||
530 | Some(name) => name.text(), | ||
531 | None => return Vec::new(), | ||
532 | }; | ||
533 | let module_id = match module_tree.any_module_for_source(ModuleSource::SourceFile(file_id)) { | ||
534 | Some(id) => id, | ||
535 | None => return Vec::new(), | ||
536 | }; | ||
537 | module_id | ||
538 | .child(module_tree, name.as_str()) | ||
539 | .and_then(|it| it.source(&module_tree).as_file()) | ||
540 | .into_iter() | ||
541 | .collect() | ||
542 | } | ||
543 | } | 519 | } |
544 | 520 | ||
545 | impl SourceChange { | 521 | impl SourceChange { |