Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions crates/base-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,32 @@ impl Files {
};
}

pub fn file_source_root(&self, id: vfs::FileId) -> FileSourceRootInput {
pub fn file_source_root(
&self,
db: &dyn SourceDatabase,
id: vfs::FileId,
) -> FileSourceRootInput {
let file_source_root = match self.file_source_roots.get(&id) {
Some(file_source_root) => file_source_root,
None => panic!(
"Unable to get `FileSourceRootInput` with `vfs::FileId` ({id:?}); this is a bug",
"Unable to get `FileSourceRootInput` with `vfs::FileId` ({id:?}, path: {}); this is a bug",
self.path_for_file(db, id)
.map_or_else(|| "<unknown>".to_owned(), |path| path.to_string()),
),
};
*file_source_root
}

fn path_for_file(&self, db: &dyn SourceDatabase, id: vfs::FileId) -> Option<vfs::VfsPath> {
for source_root in &*self.source_roots {
let source_root = *source_root.value();
if let Some(path) = source_root.source_root(db).path_for_file(&id) {
return Some(path.clone());
}
}
None
}

pub fn set_file_source_root_with_durability(
&self,
db: &mut dyn SourceDatabase,
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-def/src/test_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl SourceDatabase for TestDB {
}

fn file_source_root(&self, id: base_db::FileId) -> FileSourceRootInput {
self.files.file_source_root(id)
self.files.file_source_root(self, id)
}

fn set_file_source_root_with_durability(
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-ty/src/test_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl SourceDatabase for TestDB {
}

fn file_source_root(&self, id: base_db::FileId) -> FileSourceRootInput {
self.files.file_source_root(id)
self.files.file_source_root(self, id)
}

fn set_file_source_root_with_durability(
Expand Down
2 changes: 1 addition & 1 deletion crates/ide-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl SourceDatabase for RootDatabase {
}

fn file_source_root(&self, id: vfs::FileId) -> FileSourceRootInput {
self.files.file_source_root(id)
self.files.file_source_root(self, id)
}

fn set_file_source_root_with_durability(
Expand Down
Loading