aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model_impl
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-18 13:36:56 +0000
committerAleksey Kladov <[email protected]>2019-01-19 12:37:25 +0000
commitc0aeb5204c010a11db2015113a7858b517415de1 (patch)
tree0a41b5828fde247ce21af57c182235e935d3ffb8 /crates/ra_hir/src/code_model_impl
parentb93c6bc5575db4acc5aa5867b6f0cc0dd37858f4 (diff)
switched to lowerd module
Diffstat (limited to 'crates/ra_hir/src/code_model_impl')
-rw-r--r--crates/ra_hir/src/code_model_impl/module.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs
index a5c032d69..f110548c6 100644
--- a/crates/ra_hir/src/code_model_impl/module.rs
+++ b/crates/ra_hir/src/code_model_impl/module.rs
@@ -5,7 +5,7 @@ use crate::{
5 Module, ModuleSource, Problem, 5 Module, ModuleSource, Problem,
6 Crate, DefId, DefLoc, DefKind, Name, Path, PathKind, PerNs, Def, 6 Crate, DefId, DefLoc, DefKind, Name, Path, PathKind, PerNs, Def,
7 module_tree::ModuleId, 7 module_tree::ModuleId,
8 nameres::ModuleScope, 8 nameres::{ModuleScope, lower::LoweredImport},
9 db::HirDatabase, 9 db::HirDatabase,
10}; 10};
11 11
@@ -37,7 +37,7 @@ impl Module {
37 Some(link.name(&module_tree).clone()) 37 Some(link.name(&module_tree).clone())
38 } 38 }
39 39
40 pub fn definition_source_impl(&self, db: &impl HirDatabase) -> (FileId, ModuleSource) { 40 pub(crate) fn definition_source_impl(&self, db: &impl HirDatabase) -> (FileId, ModuleSource) {
41 let loc = self.def_id.loc(db); 41 let loc = self.def_id.loc(db);
42 let file_id = loc.source_item_id.file_id.as_original_file(); 42 let file_id = loc.source_item_id.file_id.as_original_file();
43 let syntax_node = db.file_item(loc.source_item_id); 43 let syntax_node = db.file_item(loc.source_item_id);
@@ -50,7 +50,7 @@ impl Module {
50 (file_id, module_source) 50 (file_id, module_source)
51 } 51 }
52 52
53 pub fn declaration_source_impl( 53 pub(crate) fn declaration_source_impl(
54 &self, 54 &self,
55 db: &impl HirDatabase, 55 db: &impl HirDatabase,
56 ) -> Option<(FileId, TreeArc<ast::Module>)> { 56 ) -> Option<(FileId, TreeArc<ast::Module>)> {
@@ -66,6 +66,17 @@ impl Module {
66 Some((file_id, src)) 66 Some((file_id, src))
67 } 67 }
68 68
69 pub(crate) fn import_source_impl(
70 &self,
71 db: &impl HirDatabase,
72 import: LoweredImport,
73 ) -> TreeArc<ast::PathSegment> {
74 let loc = self.def_id.loc(db);
75 let source_map = db.lower_module_source_map(loc.source_root_id, loc.module_id);
76 let (_, source) = self.definition_source(db);
77 source_map.get(&source, import)
78 }
79
69 pub(crate) fn krate_impl(&self, db: &impl HirDatabase) -> Option<Crate> { 80 pub(crate) fn krate_impl(&self, db: &impl HirDatabase) -> Option<Crate> {
70 let root = self.crate_root(db); 81 let root = self.crate_root(db);
71 let loc = root.def_id.loc(db); 82 let loc = root.def_id.loc(db);