aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model_impl
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-02-16 21:10:26 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-02-16 21:10:26 +0000
commitedd4c1d8a6c270fe39ae881c23c722c658c87c32 (patch)
tree0e6b42eaaa3228d7af8d54355d034e698db5c743 /crates/ra_hir/src/code_model_impl
parent6932b77093fd444def066e80ed37defa2742f2a9 (diff)
parent0242acae5388188c06d826f4aed41eee3e91d018 (diff)
Merge #842
842: Turn ImplBlock into a copy type just containing IDs r=matklad a=flodiebold 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. Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/code_model_impl')
-rw-r--r--crates/ra_hir/src/code_model_impl/module.rs22
1 files changed, 5 insertions, 17 deletions
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 @@
1use ra_db::FileId;
2use ra_syntax::{ast, SyntaxNode, TreeArc}; 1use ra_syntax::{ast, SyntaxNode, TreeArc};
3 2
4use crate::{ 3use crate::{
5 Module, ModuleSource, Problem, 4 Module, ModuleSource, Problem,
6 Name, 5 Name,
7 module_tree::ModuleId, 6 module_tree::ModuleId,
8 impl_block::ImplId, 7 nameres::lower::ImportId,
9 nameres::{lower::ImportId},
10 HirDatabase, PersistentHirDatabase, 8 HirDatabase, PersistentHirDatabase,
9 HirFileId
11}; 10};
12 11
13impl Module { 12impl Module {
@@ -24,22 +23,21 @@ impl Module {
24 pub(crate) fn definition_source_impl( 23 pub(crate) fn definition_source_impl(
25 &self, 24 &self,
26 db: &impl PersistentHirDatabase, 25 db: &impl PersistentHirDatabase,
27 ) -> (FileId, ModuleSource) { 26 ) -> (HirFileId, ModuleSource) {
28 let module_tree = db.module_tree(self.krate); 27 let module_tree = db.module_tree(self.krate);
29 let file_id = self.module_id.file_id(&module_tree); 28 let file_id = self.module_id.file_id(&module_tree);
30 let decl_id = self.module_id.decl_id(&module_tree); 29 let decl_id = self.module_id.decl_id(&module_tree);
31 let module_source = ModuleSource::new(db, file_id, decl_id); 30 let module_source = ModuleSource::new(db, file_id, decl_id);
32 let file_id = file_id.as_original_file();
33 (file_id, module_source) 31 (file_id, module_source)
34 } 32 }
35 33
36 pub(crate) fn declaration_source_impl( 34 pub(crate) fn declaration_source_impl(
37 &self, 35 &self,
38 db: &impl HirDatabase, 36 db: &impl HirDatabase,
39 ) -> Option<(FileId, TreeArc<ast::Module>)> { 37 ) -> Option<(HirFileId, TreeArc<ast::Module>)> {
40 let module_tree = db.module_tree(self.krate); 38 let module_tree = db.module_tree(self.krate);
41 let link = self.module_id.parent_link(&module_tree)?; 39 let link = self.module_id.parent_link(&module_tree)?;
42 let file_id = link.owner(&module_tree).file_id(&module_tree).as_original_file(); 40 let file_id = link.owner(&module_tree).file_id(&module_tree);
43 let src = link.source(&module_tree, db); 41 let src = link.source(&module_tree, db);
44 Some((file_id, src)) 42 Some((file_id, src))
45 } 43 }
@@ -54,16 +52,6 @@ impl Module {
54 source_map.get(&source, import) 52 source_map.get(&source, import)
55 } 53 }
56 54
57 pub(crate) fn impl_source_impl(
58 &self,
59 db: &impl HirDatabase,
60 impl_id: ImplId,
61 ) -> TreeArc<ast::ImplBlock> {
62 let source_map = db.impls_in_module_source_map(*self);
63 let (_, source) = self.definition_source(db);
64 source_map.get(&source, impl_id)
65 }
66
67 pub(crate) fn crate_root_impl(&self, db: &impl PersistentHirDatabase) -> Module { 55 pub(crate) fn crate_root_impl(&self, db: &impl PersistentHirDatabase) -> Module {
68 let module_tree = db.module_tree(self.krate); 56 let module_tree = db.module_tree(self.krate);
69 let module_id = self.module_id.crate_root(&module_tree); 57 let module_id = self.module_id.crate_root(&module_tree);