aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ids.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-10-14 14:20:55 +0100
committerAleksey Kladov <[email protected]>2019-10-14 14:23:55 +0100
commitabf2179c0b606730acadc61451739baecfa33a5d (patch)
tree66ee446941554eccedce82e3b7dcb25dbe4ce6d5 /crates/ra_hir/src/ids.rs
parent1555a1aa0d5d45e4b317db272c07ad3e8470553d (diff)
Prepare SourceDatabase API for lazy file loading
Diffstat (limited to 'crates/ra_hir/src/ids.rs')
-rw-r--r--crates/ra_hir/src/ids.rs35
1 files changed, 1 insertions, 34 deletions
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs
index 85b022744..499dcafea 100644
--- a/crates/ra_hir/src/ids.rs
+++ b/crates/ra_hir/src/ids.rs
@@ -85,11 +85,7 @@ impl HirFileId {
85 // Note: 85 // Note:
86 // The final goal we would like to make all parse_macro success, 86 // The final goal we would like to make all parse_macro success,
87 // such that the following log will not call anyway. 87 // such that the following log will not call anyway.
88 log::warn!( 88 log::warn!("fail on macro_parse: (reason: {})", err,);
89 "fail on macro_parse: (reason: {}) {}",
90 err,
91 macro_call_id.debug_dump(db)
92 );
93 }) 89 })
94 .ok()?; 90 .ok()?;
95 match macro_file.macro_file_kind { 91 match macro_file.macro_file_kind {
@@ -367,35 +363,6 @@ impl AstItemDef<ast::TypeAliasDef> for TypeAliasId {
367 } 363 }
368} 364}
369 365
370impl MacroCallId {
371 pub fn debug_dump(self, db: &impl AstDatabase) -> String {
372 let loc = self.loc(db);
373 let node = loc.ast_id.to_node(db);
374 let syntax_str = {
375 let mut res = String::new();
376 node.syntax().text().for_each_chunk(|chunk| {
377 if !res.is_empty() {
378 res.push(' ')
379 }
380 res.push_str(chunk)
381 });
382 res
383 };
384
385 // dump the file name
386 let file_id: HirFileId = self.loc(db).ast_id.file_id();
387 let original = file_id.original_file(db);
388 let macro_rules = db.macro_def(loc.def);
389
390 format!(
391 "macro call [file: {:?}] : {}\nhas rules: {}",
392 db.file_relative_path(original),
393 syntax_str,
394 macro_rules.is_some()
395 )
396 }
397}
398
399/// This exists just for Chalk, because Chalk just has a single `StructId` where 366/// This exists just for Chalk, because Chalk just has a single `StructId` where
400/// we have different kinds of ADTs, primitive types and special type 367/// we have different kinds of ADTs, primitive types and special type
401/// constructors like tuples and function pointers. 368/// constructors like tuples and function pointers.