From 0242acae5388188c06d826f4aed41eee3e91d018 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 16 Feb 2019 21:09:58 +0100 Subject: Turn ImplBlock into a copy type just containing IDs This makes it more like the other code model types. Also make Module::definition_source/declaration_source return HirFileIds, to make them more like the other source functions. --- crates/ra_hir/src/code_model_impl/module.rs | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'crates/ra_hir/src/code_model_impl') diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs index 1425fa693..2d3058afd 100644 --- a/crates/ra_hir/src/code_model_impl/module.rs +++ b/crates/ra_hir/src/code_model_impl/module.rs @@ -1,13 +1,12 @@ -use ra_db::FileId; use ra_syntax::{ast, SyntaxNode, TreeArc}; use crate::{ Module, ModuleSource, Problem, Name, module_tree::ModuleId, - impl_block::ImplId, - nameres::{lower::ImportId}, + nameres::lower::ImportId, HirDatabase, PersistentHirDatabase, + HirFileId }; impl Module { @@ -24,22 +23,21 @@ impl Module { pub(crate) fn definition_source_impl( &self, db: &impl PersistentHirDatabase, - ) -> (FileId, ModuleSource) { + ) -> (HirFileId, ModuleSource) { let module_tree = db.module_tree(self.krate); let file_id = self.module_id.file_id(&module_tree); let decl_id = self.module_id.decl_id(&module_tree); let module_source = ModuleSource::new(db, file_id, decl_id); - let file_id = file_id.as_original_file(); (file_id, module_source) } pub(crate) fn declaration_source_impl( &self, db: &impl HirDatabase, - ) -> Option<(FileId, TreeArc)> { + ) -> Option<(HirFileId, TreeArc)> { let module_tree = db.module_tree(self.krate); let link = self.module_id.parent_link(&module_tree)?; - let file_id = link.owner(&module_tree).file_id(&module_tree).as_original_file(); + let file_id = link.owner(&module_tree).file_id(&module_tree); let src = link.source(&module_tree, db); Some((file_id, src)) } @@ -54,16 +52,6 @@ impl Module { source_map.get(&source, import) } - pub(crate) fn impl_source_impl( - &self, - db: &impl HirDatabase, - impl_id: ImplId, - ) -> TreeArc { - let source_map = db.impls_in_module_source_map(*self); - let (_, source) = self.definition_source(db); - source_map.get(&source, impl_id) - } - pub(crate) fn crate_root_impl(&self, db: &impl PersistentHirDatabase) -> Module { let module_tree = db.module_tree(self.krate); let module_id = self.module_id.crate_root(&module_tree); -- cgit v1.2.3