From 9f65ae20c2eb862ffd73d0389e4efc272d52ce39 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sat, 11 Jan 2020 16:37:42 +0800 Subject: Use dummy value for macro file in bulitin macros --- crates/ra_hir_expand/src/builtin_macro.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir_expand') diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs index 2c119269c..e9e275670 100644 --- a/crates/ra_hir_expand/src/builtin_macro.rs +++ b/crates/ra_hir_expand/src/builtin_macro.rs @@ -62,8 +62,13 @@ register_builtin! { } fn to_line_number(db: &dyn AstDatabase, file: HirFileId, pos: TextUnit) -> usize { - // FIXME: Use expansion info let file_id = file.original_file(db); + + // FIXME: if the file is coming from macro, we return a dummy value for now. + if file.call_node(db).map(|it| it.file_id != file_id.into()).unwrap_or(true) { + return 0; + } + let text = db.file_text(file_id); let mut line_num = 1; @@ -150,8 +155,11 @@ fn option_env_expand( } fn to_col_number(db: &dyn AstDatabase, file: HirFileId, pos: TextUnit) -> usize { - // FIXME: Use expansion info let file_id = file.original_file(db); + // FIXME: if the file is coming from macro, we return a dummy value for now. + if file.call_node(db).map(|it| it.file_id != file_id.into()).unwrap_or(true) { + return 0; + } let text = db.file_text(file_id); let pos = pos.to_usize(); -- cgit v1.2.3