mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
make source_root API more abstract
This commit is contained in:
parent
3bdb456d17
commit
9ae455ea52
7 changed files with 31 additions and 17 deletions
|
@ -12,7 +12,7 @@ pub use crate::{
|
|||
cancellation::Canceled,
|
||||
input::{CrateGraph, CrateId, Dependency, Edition, FileId, SourceRoot, SourceRootId},
|
||||
};
|
||||
pub use ::salsa;
|
||||
pub use salsa;
|
||||
|
||||
pub trait CheckCanceled {
|
||||
/// Aborts current query if there are pending changes.
|
||||
|
@ -93,8 +93,7 @@ pub trait SourceDatabase: CheckCanceled + std::fmt::Debug {
|
|||
fn source_root_crates(db: &impl SourceDatabase, id: SourceRootId) -> Arc<Vec<CrateId>> {
|
||||
let root = db.source_root(id);
|
||||
let graph = db.crate_graph();
|
||||
let res =
|
||||
root.files.values().filter_map(|&it| graph.crate_id_for_crate_root(it)).collect::<Vec<_>>();
|
||||
let res = root.walk().filter_map(|it| graph.crate_id_for_crate_root(it)).collect::<Vec<_>>();
|
||||
Arc::new(res)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue