From bbb40d746368eb6a38498649a723c7ead0ef8136 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 5 Jun 2020 16:45:20 +0200 Subject: Minimize FileLoader interface --- crates/ra_hir_expand/src/builtin_macro.rs | 18 ++++++------------ crates/ra_hir_expand/src/test_db.rs | 9 +-------- 2 files changed, 7 insertions(+), 20 deletions(-) (limited to 'crates/ra_hir_expand/src') diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs index eec5fb8eb..7579546d2 100644 --- a/crates/ra_hir_expand/src/builtin_macro.rs +++ b/crates/ra_hir_expand/src/builtin_macro.rs @@ -295,19 +295,13 @@ fn concat_expand( fn relative_file(db: &dyn AstDatabase, call_id: MacroCallId, path: &str) -> Option { let call_site = call_id.as_file().original_file(db); - - // Handle trivial case - if let Some(res) = db.resolve_path(call_site, path) { - // Prevent include itself - return if res == call_site { None } else { Some(res) }; + let res = db.resolve_path(call_site, path)?; + // Prevent include itself + if res == call_site { + None + } else { + Some(res) } - - // Extern paths ? - let krate = *db.relevant_crates(call_site).get(0)?; - let (extern_source_id, relative_file) = - db.crate_graph()[krate].extern_source.extern_path(path)?; - - db.resolve_extern_path(extern_source_id, &relative_file) } fn parse_string(tt: &tt::Subtree) -> Result { diff --git a/crates/ra_hir_expand/src/test_db.rs b/crates/ra_hir_expand/src/test_db.rs index 765a2f6d1..fdf225f55 100644 --- a/crates/ra_hir_expand/src/test_db.rs +++ b/crates/ra_hir_expand/src/test_db.rs @@ -5,7 +5,7 @@ use std::{ sync::{Arc, Mutex}, }; -use ra_db::{salsa, CrateId, ExternSourceId, FileId, FileLoader, FileLoaderDelegate, RelativePath}; +use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate}; #[salsa::database( ra_db::SourceDatabaseExtStorage, @@ -47,11 +47,4 @@ impl FileLoader for TestDB { fn relevant_crates(&self, file_id: FileId) -> Arc> { FileLoaderDelegate(self).relevant_crates(file_id) } - fn resolve_extern_path( - &self, - anchor: ExternSourceId, - relative_path: &RelativePath, - ) -> Option { - FileLoaderDelegate(self).resolve_extern_path(anchor, relative_path) - } } -- cgit v1.2.3