mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
resolve extern crates propertly
This commit is contained in:
parent
e89da32bb7
commit
7784c7a701
4 changed files with 98 additions and 51 deletions
|
@ -5,7 +5,7 @@ use relative_path::{RelativePath, RelativePathBuf};
|
|||
|
||||
use crate::{FileId, FileResolver, SourceRoot, FileResolverImp};
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
#[derive(Default, Debug, Clone)]
|
||||
pub struct FileMap(Vec<(FileId, RelativePathBuf)>);
|
||||
|
||||
impl FileMap {
|
||||
|
@ -28,6 +28,11 @@ impl FileMap {
|
|||
self.iter().map(|(id, _)| id).collect()
|
||||
}
|
||||
|
||||
pub fn file_id(&self, path: &str) -> FileId {
|
||||
assert!(path.starts_with('/'));
|
||||
self.iter().find(|(_, p)| p == &path[1..]).unwrap().0
|
||||
}
|
||||
|
||||
fn iter<'a>(&'a self) -> impl Iterator<Item = (FileId, &'a RelativePath)> + 'a {
|
||||
self.0
|
||||
.iter()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue