aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ids.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ids.rs')
-rw-r--r--crates/ra_hir/src/ids.rs24
1 files changed, 22 insertions, 2 deletions
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs
index 141c9072f..2a1ed9b81 100644
--- a/crates/ra_hir/src/ids.rs
+++ b/crates/ra_hir/src/ids.rs
@@ -63,8 +63,15 @@ impl HirFileId {
63 match file_id.0 { 63 match file_id.0 {
64 HirFileIdRepr::File(file_id) => db.parse(file_id), 64 HirFileIdRepr::File(file_id) => db.parse(file_id),
65 HirFileIdRepr::Macro(macro_call_id) => { 65 HirFileIdRepr::Macro(macro_call_id) => {
66 // returning an empty string looks fishy... 66 parse_macro(db, macro_call_id).unwrap_or_else(|| {
67 parse_macro(db, macro_call_id).unwrap_or_else(|| SourceFile::parse("")) 67 // Note:
68 // The final goal we would like to make all parse_macro success,
69 // such that the following log will not call anyway.
70 log::warn!("fail on macro_parse: {}", macro_call_id.debug_dump(db));
71
72 // returning an empty string looks fishy...
73 SourceFile::parse("")
74 })
68 } 75 }
69 } 76 }
70 } 77 }
@@ -299,3 +306,16 @@ impl AstItemDef<ast::TypeAliasDef> for TypeAliasId {
299 db.lookup_intern_type_alias(self) 306 db.lookup_intern_type_alias(self)
300 } 307 }
301} 308}
309
310impl MacroCallId {
311 pub fn debug_dump(&self, db: &impl DefDatabase) -> String {
312 let loc = self.clone().loc(db);
313 let node = loc.ast_id.to_node(db);
314 let syntax_str = node.syntax().to_string();
315
316 // dump the file name
317 let file_id: HirFileId = self.clone().into();
318 let original = file_id.original_file(db);
319 format!("macro call [file: {:#?}] : {}", db.file_relative_path(original), syntax_str)
320 }
321}