From 9e35bf91b827900b089a7ea937cb73707bebc420 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sat, 20 Apr 2019 23:05:25 +0800 Subject: Fix bugs --- crates/ra_hir/src/ids.rs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir/src/ids.rs') 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 { match file_id.0 { HirFileIdRepr::File(file_id) => db.parse(file_id), HirFileIdRepr::Macro(macro_call_id) => { - // returning an empty string looks fishy... - parse_macro(db, macro_call_id).unwrap_or_else(|| SourceFile::parse("")) + parse_macro(db, macro_call_id).unwrap_or_else(|| { + // Note: + // The final goal we would like to make all parse_macro success, + // such that the following log will not call anyway. + log::warn!("fail on macro_parse: {}", macro_call_id.debug_dump(db)); + + // returning an empty string looks fishy... + SourceFile::parse("") + }) } } } @@ -299,3 +306,16 @@ impl AstItemDef for TypeAliasId { db.lookup_intern_type_alias(self) } } + +impl MacroCallId { + pub fn debug_dump(&self, db: &impl DefDatabase) -> String { + let loc = self.clone().loc(db); + let node = loc.ast_id.to_node(db); + let syntax_str = node.syntax().to_string(); + + // dump the file name + let file_id: HirFileId = self.clone().into(); + let original = file_id.original_file(db); + format!("macro call [file: {:#?}] : {}", db.file_relative_path(original), syntax_str) + } +} -- cgit v1.2.3