diff options
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 31bf13425..179faebfb 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -20,7 +20,7 @@ use crate::{ | |||
20 | HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, PerNs, Name, | 20 | HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, PerNs, Name, |
21 | AsName, Module, HirFileId, Crate, Trait, Resolver, Ty,Path, | 21 | AsName, Module, HirFileId, Crate, Trait, Resolver, Ty,Path, |
22 | expr::{BodySourceMap, scope::{ScopeId, ExprScopes}}, | 22 | expr::{BodySourceMap, scope::{ScopeId, ExprScopes}}, |
23 | ids::{LocationCtx,MacroCallId}, | 23 | ids::{LocationCtx, MacroDefId}, |
24 | docs::{docs_from_ast,Documentation}, | 24 | docs::{docs_from_ast,Documentation}, |
25 | expr, AstId, | 25 | expr, AstId, |
26 | }; | 26 | }; |
@@ -191,13 +191,12 @@ pub enum PathResolution { | |||
191 | 191 | ||
192 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 192 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
193 | pub struct MacroByExampleDef { | 193 | pub struct MacroByExampleDef { |
194 | pub(crate) id: MacroCallId, | 194 | pub(crate) id: MacroDefId, |
195 | } | 195 | } |
196 | 196 | ||
197 | impl MacroByExampleDef { | 197 | impl MacroByExampleDef { |
198 | pub fn source(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc<ast::MacroCall>) { | 198 | pub fn source(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc<ast::MacroCall>) { |
199 | let loc = self.id.loc(db); | 199 | (self.id.0.file_id(), self.id.0.to_node(db)) |
200 | (self.id.into(), loc.def.0.to_node(db)) | ||
201 | } | 200 | } |
202 | } | 201 | } |
203 | 202 | ||
@@ -284,21 +283,9 @@ impl SourceAnalyzer { | |||
284 | self.infer.as_ref()?.field_resolution(expr_id) | 283 | self.infer.as_ref()?.field_resolution(expr_id) |
285 | } | 284 | } |
286 | 285 | ||
287 | pub fn resolve_macro_call( | 286 | pub fn resolve_macro_call(&self, macro_call: &ast::MacroCall) -> Option<MacroByExampleDef> { |
288 | &self, | 287 | let id = self.resolver.resolve_macro_call(macro_call.path().and_then(Path::from_ast))?; |
289 | db: &impl HirDatabase, | 288 | Some(MacroByExampleDef { id }) |
290 | file_id: FileId, | ||
291 | macro_call: &ast::MacroCall, | ||
292 | ) -> Option<MacroByExampleDef> { | ||
293 | let hir_id = file_id.into(); | ||
294 | let ast_id = db.ast_id_map(hir_id).ast_id(macro_call).with_file_id(hir_id); | ||
295 | let call_id = self.resolver.resolve_macro_call( | ||
296 | db, | ||
297 | macro_call.path().and_then(Path::from_ast), | ||
298 | ast_id, | ||
299 | ); | ||
300 | |||
301 | call_id.map(|id| MacroByExampleDef { id }) | ||
302 | } | 289 | } |
303 | 290 | ||
304 | pub fn resolve_hir_path( | 291 | pub fn resolve_hir_path( |