Merge #11946
11946: internal: Revert #11912 as it parses all visited files r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
e691ae0ab2
@ -334,7 +334,7 @@ pub fn iter(&self) -> impl Iterator<Item = CrateId> + '_ {
|
||||
|
||||
/// Returns an iterator over all transitive dependencies of the given crate,
|
||||
/// including the crate itself.
|
||||
pub fn transitive_deps(&self, of: CrateId) -> impl Iterator<Item = CrateId> + '_ {
|
||||
pub fn transitive_deps(&self, of: CrateId) -> impl Iterator<Item = CrateId> {
|
||||
let mut worklist = vec![of];
|
||||
let mut deps = FxHashSet::default();
|
||||
|
||||
@ -351,7 +351,7 @@ pub fn transitive_deps(&self, of: CrateId) -> impl Iterator<Item = CrateId> + '_
|
||||
|
||||
/// Returns all transitive reverse dependencies of the given crate,
|
||||
/// including the crate itself.
|
||||
pub fn transitive_rev_deps(&self, of: CrateId) -> impl Iterator<Item = CrateId> + '_ {
|
||||
pub fn transitive_rev_deps(&self, of: CrateId) -> impl Iterator<Item = CrateId> {
|
||||
let mut worklist = vec![of];
|
||||
let mut rev_deps = FxHashSet::default();
|
||||
rev_deps.insert(of);
|
||||
|
@ -175,8 +175,11 @@ pub fn reverse_dependencies(self, db: &dyn HirDatabase) -> Vec<Crate> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn transitive_reverse_dependencies(self, db: &dyn HirDatabase) -> Vec<Crate> {
|
||||
db.crate_graph().transitive_rev_deps(self.id).into_iter().map(|id| Crate { id }).collect()
|
||||
pub fn transitive_reverse_dependencies(
|
||||
self,
|
||||
db: &dyn HirDatabase,
|
||||
) -> impl Iterator<Item = Crate> {
|
||||
db.crate_graph().transitive_rev_deps(self.id).map(|id| Crate { id })
|
||||
}
|
||||
|
||||
pub fn root_module(self, db: &dyn HirDatabase) -> Module {
|
||||
|
@ -102,18 +102,12 @@ fn crate_graph(db: &RootDatabase) -> SearchScope {
|
||||
/// Build a search scope spanning all the reverse dependencies of the given crate.
|
||||
fn reverse_dependencies(db: &RootDatabase, of: hir::Crate) -> SearchScope {
|
||||
let mut entries = FxHashMap::default();
|
||||
let mut insert_modules = |of: hir::Crate| {
|
||||
entries.extend(of.modules(db).into_iter().filter_map(|module| {
|
||||
match module.definition_source(db) {
|
||||
InFile { file_id, value: ModuleSource::SourceFile(..) } => {
|
||||
Some((file_id.original_file(db), None))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}));
|
||||
};
|
||||
insert_modules(of);
|
||||
of.transitive_reverse_dependencies(db).into_iter().for_each(insert_modules);
|
||||
for rev_dep in of.transitive_reverse_dependencies(db) {
|
||||
let root_file = rev_dep.root_file(db);
|
||||
let source_root_id = db.file_source_root(root_file);
|
||||
let source_root = db.source_root(source_root_id);
|
||||
entries.extend(source_root.iter().map(|id| (id, None)));
|
||||
}
|
||||
SearchScope { entries }
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user