From 4c90b7e2ecd03e739a3c92bbe5afd4c90fe2812d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 15 Nov 2019 23:24:56 +0300 Subject: Sourcify some things If we want to support macros properly, we need to get rid of those FileIds everywhere... --- crates/ra_hir_def/src/lib.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'crates/ra_hir_def/src') diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 0a59c4ad7..a240a10b8 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs @@ -78,14 +78,13 @@ impl ModuleSource { } } - pub fn from_child_node( - db: &impl db::DefDatabase2, - file_id: FileId, - child: &SyntaxNode, - ) -> ModuleSource { - if let Some(m) = child.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi()) { + pub fn from_child_node(db: &impl db::DefDatabase2, child: Source<&SyntaxNode>) -> ModuleSource { + if let Some(m) = + child.ast.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi()) + { ModuleSource::Module(m) } else { + let file_id = child.file_id.original_file(db); let source_file = db.parse(file_id).tree(); ModuleSource::SourceFile(source_file) } -- cgit v1.2.3