From 22f064cca7651eaf2980fcfa27618d99c633a589 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Tue, 10 Mar 2020 22:00:31 +0800 Subject: Add resolve_extern_path in DB --- crates/ra_db/src/lib.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'crates/ra_db/src/lib.rs') diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index fb002d717..9bf3fe248 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs @@ -11,7 +11,8 @@ use ra_syntax::{ast, Parse, SourceFile, TextRange, TextUnit}; pub use crate::{ cancellation::Canceled, input::{ - CrateGraph, CrateId, CrateName, Dependency, Edition, Env, FileId, SourceRoot, SourceRootId, + CrateGraph, CrateId, CrateName, Dependency, Edition, Env, ExternSourceId, FileId, + SourceRoot, SourceRootId, }, }; pub use relative_path::{RelativePath, RelativePathBuf}; @@ -87,6 +88,12 @@ pub trait FileLoader { fn resolve_relative_path(&self, anchor: FileId, relative_path: &RelativePath) -> Option; fn relevant_crates(&self, file_id: FileId) -> Arc>; + + fn resolve_extern_path( + &self, + extern_id: ExternSourceId, + relative_path: &RelativePath, + ) -> Option; } /// Database which stores all significant input facts: source code and project @@ -164,4 +171,13 @@ impl FileLoader for FileLoaderDelegate<&'_ T> { let source_root = self.0.file_source_root(file_id); self.0.source_root_crates(source_root) } + + fn resolve_extern_path( + &self, + extern_id: ExternSourceId, + relative_path: &RelativePath, + ) -> Option { + let source_root = self.0.source_root(SourceRootId(extern_id.0)); + source_root.file_by_relative_path(&relative_path) + } } -- cgit v1.2.3