aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/resolve.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/resolve.rs')
-rw-r--r--crates/ra_hir/src/resolve.rs24
1 files changed, 6 insertions, 18 deletions
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs
index d1f97c104..bc9170cdc 100644
--- a/crates/ra_hir/src/resolve.rs
+++ b/crates/ra_hir/src/resolve.rs
@@ -10,6 +10,7 @@ use crate::{
10 code_model_api::Crate, 10 code_model_api::Crate,
11 MacroCallId, 11 MacroCallId,
12 MacroCallLoc, 12 MacroCallLoc,
13 AstId,
13 db::HirDatabase, 14 db::HirDatabase,
14 name::{Name, KnownName}, 15 name::{Name, KnownName},
15 nameres::{PerNs, CrateDefMap, CrateModuleId}, 16 nameres::{PerNs, CrateDefMap, CrateModuleId},
@@ -17,7 +18,7 @@ use crate::{
17 expr::{scope::{ExprScopes, ScopeId}, PatId}, 18 expr::{scope::{ExprScopes, ScopeId}, PatId},
18 impl_block::ImplBlock, 19 impl_block::ImplBlock,
19 path::Path, 20 path::Path,
20 Trait 21 Trait,
21}; 22};
22 23
23#[derive(Debug, Clone, Default)] 24#[derive(Debug, Clone, Default)]
@@ -138,25 +139,12 @@ impl Resolver {
138 &self, 139 &self,
139 db: &impl HirDatabase, 140 db: &impl HirDatabase,
140 path: Option<Path>, 141 path: Option<Path>,
141 call: &ast::MacroCall, 142 ast_id: AstId<ast::MacroCall>,
142 ) -> Option<MacroCallId> { 143 ) -> Option<MacroCallId> {
143 let name = path.and_then(|path| path.expand_macro_expr()).unwrap_or_else(Name::missing); 144 let name = path.and_then(|path| path.expand_macro_expr()).unwrap_or_else(Name::missing);
144 let macro_def_id = self.module().and_then(|(module, _)| module.find_macro(&name)); 145 let def_id = self.module().and_then(|(module, _)| module.find_macro(&name))?;
145 if let Some(def_id) = macro_def_id { 146 let call_loc = MacroCallLoc { def: *def_id, ast_id }.id(db);
146 self.module().and_then(|(module, _)| { 147 Some(call_loc)
147 // we do this to get the ast_id for the macro call
148 // if we used the ast_id from the def_id variable
149 // it gives us the ast_id of the defenition site
150 let module = module.mk_module(module.root());
151 let hir_file_id = module.definition_source(db).0;
152 let ast_id = db.ast_id_map(hir_file_id).ast_id(call).with_file_id(hir_file_id);
153 let call_loc = MacroCallLoc { def: *def_id, ast_id }.id(db);
154
155 Some(call_loc)
156 })
157 } else {
158 None
159 }
160 } 148 }
161 149
162 /// Returns the resolved path segments 150 /// Returns the resolved path segments