mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Add resolve_extern_path in DB
This commit is contained in:
parent
8153a0b3ef
commit
22f064cca7
5 changed files with 48 additions and 3 deletions
|
@ -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<FileId>;
|
||||
fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>>;
|
||||
|
||||
fn resolve_extern_path(
|
||||
&self,
|
||||
extern_id: ExternSourceId,
|
||||
relative_path: &RelativePath,
|
||||
) -> Option<FileId>;
|
||||
}
|
||||
|
||||
/// Database which stores all significant input facts: source code and project
|
||||
|
@ -164,4 +171,13 @@ impl<T: SourceDatabaseExt> 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<FileId> {
|
||||
let source_root = self.0.source_root(SourceRootId(extern_id.0));
|
||||
source_root.file_by_relative_path(&relative_path)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue