From 61687b9db67d34bbcce8596496448c0717d98316 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 6 Jan 2019 13:41:12 +0300 Subject: fix tests --- crates/ra_analysis/src/imp.rs | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'crates/ra_analysis/src') diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 5988fb779..44e7aca44 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs @@ -105,39 +105,36 @@ impl db::RootDatabase { &self, position: FilePosition, ) -> Cancelable> { - let descr = match source_binder::module_from_position(self, position)? { + let module = match source_binder::module_from_position(self, position)? { None => return Ok(Vec::new()), Some(it) => it, }; - let (file_id, decl) = match descr.parent_link_source(self) { + let (file_id, ast_module) = module.source(self); + let ast_module = match ast_module { None => return Ok(Vec::new()), Some(it) => it, }; - let decl = decl.borrowed(); - let decl_name = decl.name().unwrap(); + let ast_module = ast_module.borrowed(); + let name = ast_module.name().unwrap(); Ok(vec![NavigationTarget { file_id, - name: decl_name.text(), - range: decl_name.syntax().range(), + name: name.text(), + range: name.syntax().range(), kind: MODULE, ptr: None, }]) } /// Returns `Vec` for the same reason as `parent_module` pub(crate) fn crate_for(&self, file_id: FileId) -> Cancelable> { - let descr = match source_binder::module_from_file_id(self, file_id)? { + let module = match source_binder::module_from_file_id(self, file_id)? { + Some(it) => it, None => return Ok(Vec::new()), + }; + let krate = match module.krate(self)? { Some(it) => it, + None => return Ok(Vec::new()), }; - let root = descr.crate_root(); - let file_id = root.file_id(); - - let crate_graph = self.crate_graph(); - let crate_id = crate_graph.crate_id_for_crate_root(file_id); - Ok(crate_id.into_iter().collect()) - } - pub(crate) fn crate_root(&self, crate_id: CrateId) -> FileId { - self.crate_graph().crate_root(crate_id) + Ok(vec![krate.crate_id()]) } pub(crate) fn find_all_refs( &self, -- cgit v1.2.3