aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r--crates/ra_hir_def/src/body.rs16
-rw-r--r--crates/ra_hir_def/src/lib.rs2
2 files changed, 7 insertions, 11 deletions
diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs
index d3e4c50ae..8ab92b23a 100644
--- a/crates/ra_hir_def/src/body.rs
+++ b/crates/ra_hir_def/src/body.rs
@@ -26,7 +26,7 @@ use crate::{
26 DefWithBodyId, HasModule, Lookup, ModuleId, 26 DefWithBodyId, HasModule, Lookup, ModuleId,
27}; 27};
28 28
29pub(crate) struct Expander { 29pub struct Expander {
30 crate_def_map: Arc<CrateDefMap>, 30 crate_def_map: Arc<CrateDefMap>,
31 current_file_id: HirFileId, 31 current_file_id: HirFileId,
32 hygiene: Hygiene, 32 hygiene: Hygiene,
@@ -35,18 +35,14 @@ pub(crate) struct Expander {
35} 35}
36 36
37impl Expander { 37impl Expander {
38 pub(crate) fn new( 38 pub fn new(db: &impl DefDatabase, current_file_id: HirFileId, module: ModuleId) -> Expander {
39 db: &impl DefDatabase,
40 current_file_id: HirFileId,
41 module: ModuleId,
42 ) -> Expander {
43 let crate_def_map = db.crate_def_map(module.krate); 39 let crate_def_map = db.crate_def_map(module.krate);
44 let hygiene = Hygiene::new(db, current_file_id); 40 let hygiene = Hygiene::new(db, current_file_id);
45 let ast_id_map = db.ast_id_map(current_file_id); 41 let ast_id_map = db.ast_id_map(current_file_id);
46 Expander { crate_def_map, current_file_id, hygiene, ast_id_map, module } 42 Expander { crate_def_map, current_file_id, hygiene, ast_id_map, module }
47 } 43 }
48 44
49 pub(crate) fn enter_expand<T: ast::AstNode, DB: DefDatabase>( 45 pub fn enter_expand<T: ast::AstNode, DB: DefDatabase>(
50 &mut self, 46 &mut self,
51 db: &DB, 47 db: &DB,
52 macro_call: ast::MacroCall, 48 macro_call: ast::MacroCall,
@@ -84,14 +80,14 @@ impl Expander {
84 None 80 None
85 } 81 }
86 82
87 pub(crate) fn exit(&mut self, db: &impl DefDatabase, mut mark: Mark) { 83 pub fn exit(&mut self, db: &impl DefDatabase, mut mark: Mark) {
88 self.hygiene = Hygiene::new(db, mark.file_id); 84 self.hygiene = Hygiene::new(db, mark.file_id);
89 self.current_file_id = mark.file_id; 85 self.current_file_id = mark.file_id;
90 self.ast_id_map = mem::take(&mut mark.ast_id_map); 86 self.ast_id_map = mem::take(&mut mark.ast_id_map);
91 mark.bomb.defuse(); 87 mark.bomb.defuse();
92 } 88 }
93 89
94 pub(crate) fn to_source<T>(&self, value: T) -> InFile<T> { 90 pub fn to_source<T>(&self, value: T) -> InFile<T> {
95 InFile { file_id: self.current_file_id, value } 91 InFile { file_id: self.current_file_id, value }
96 } 92 }
97 93
@@ -116,7 +112,7 @@ impl Expander {
116 } 112 }
117} 113}
118 114
119pub(crate) struct Mark { 115pub struct Mark {
120 file_id: HirFileId, 116 file_id: HirFileId,
121 ast_id_map: Arc<AstIdMap>, 117 ast_id_map: Arc<AstIdMap>,
122 bomb: DropBomb, 118 bomb: DropBomb,
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index f6c7f38d1..f58ce9a95 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -48,7 +48,7 @@ use ra_arena::{impl_arena_id, RawId};
48use ra_db::{impl_intern_key, salsa, CrateId}; 48use ra_db::{impl_intern_key, salsa, CrateId};
49use ra_syntax::{ast, AstNode}; 49use ra_syntax::{ast, AstNode};
50 50
51use crate::body::Expander; 51pub use crate::body::Expander;
52use crate::builtin_type::BuiltinType; 52use crate::builtin_type::BuiltinType;
53 53
54#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 54#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]