aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/nameres.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-06-01 18:48:06 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-06-01 18:48:06 +0100
commitccec71165bf1f8f79bd2d2a5c05bed55ff3a07a2 (patch)
tree695718725ac4c9fb60a6c5c29a4f83aa489cc6c2 /crates/ra_hir/src/nameres.rs
parent1e6b45b05ae378b9e376fcf02ecef15aa7dd1b6b (diff)
parent371961be0e0b0741599ebf3d9435c03fd45cf777 (diff)
Merge #1360
1360: Improve goto definition for MBE r=matklad a=edwin0cheng This PR improve the macro resolution for goto definition and expression macro invocation by using proper path resolution for external macros. Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/nameres.rs')
-rw-r--r--crates/ra_hir/src/nameres.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs
index aa26345b2..6b1160aa7 100644
--- a/crates/ra_hir/src/nameres.rs
+++ b/crates/ra_hir/src/nameres.rs
@@ -320,8 +320,22 @@ impl CrateDefMap {
320 (res.resolved_def, res.segment_index) 320 (res.resolved_def, res.segment_index)
321 } 321 }
322 322
323 pub(crate) fn find_macro(&self, name: &Name) -> Option<MacroDefId> { 323 pub(crate) fn find_macro(
324 self.public_macros.get(name).or(self.local_macros.get(name)).map(|it| *it) 324 &self,
325 db: &impl DefDatabase,
326 original_module: CrateModuleId,
327 path: &Path,
328 ) -> Option<MacroDefId> {
329 let name = path.expand_macro_expr()?;
330 // search local first
331 // FIXME: Remove public_macros check when we have a correct local_macors implementation
332 let local = self.public_macros.get(&name).or(self.local_macros.get(&name)).map(|it| *it);
333 if local.is_some() {
334 return local;
335 }
336
337 let res = self.resolve_path_fp_with_macro(db, ResolveMode::Other, original_module, path);
338 res.resolved_def.right().map(|m| m.id)
325 } 339 }
326 340
327 // Returns Yes if we are sure that additions to `ItemMap` wouldn't change 341 // Returns Yes if we are sure that additions to `ItemMap` wouldn't change