mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Revert #11912 as it parses all visited files
This commit is contained in:
parent
9050db2e80
commit
295f0c57a5
3 changed files with 13 additions and 16 deletions
|
@ -334,7 +334,7 @@ impl CrateGraph {
|
||||||
|
|
||||||
/// Returns an iterator over all transitive dependencies of the given crate,
|
/// Returns an iterator over all transitive dependencies of the given crate,
|
||||||
/// including the crate itself.
|
/// 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 worklist = vec![of];
|
||||||
let mut deps = FxHashSet::default();
|
let mut deps = FxHashSet::default();
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ impl CrateGraph {
|
||||||
|
|
||||||
/// Returns all transitive reverse dependencies of the given crate,
|
/// Returns all transitive reverse dependencies of the given crate,
|
||||||
/// including the crate itself.
|
/// 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 worklist = vec![of];
|
||||||
let mut rev_deps = FxHashSet::default();
|
let mut rev_deps = FxHashSet::default();
|
||||||
rev_deps.insert(of);
|
rev_deps.insert(of);
|
||||||
|
|
|
@ -175,8 +175,11 @@ impl Crate {
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn transitive_reverse_dependencies(self, db: &dyn HirDatabase) -> Vec<Crate> {
|
pub fn transitive_reverse_dependencies(
|
||||||
db.crate_graph().transitive_rev_deps(self.id).into_iter().map(|id| Crate { id }).collect()
|
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 {
|
pub fn root_module(self, db: &dyn HirDatabase) -> Module {
|
||||||
|
|
|
@ -102,18 +102,12 @@ impl SearchScope {
|
||||||
/// Build a search scope spanning all the reverse dependencies of the given crate.
|
/// Build a search scope spanning all the reverse dependencies of the given crate.
|
||||||
fn reverse_dependencies(db: &RootDatabase, of: hir::Crate) -> SearchScope {
|
fn reverse_dependencies(db: &RootDatabase, of: hir::Crate) -> SearchScope {
|
||||||
let mut entries = FxHashMap::default();
|
let mut entries = FxHashMap::default();
|
||||||
let mut insert_modules = |of: hir::Crate| {
|
for rev_dep in of.transitive_reverse_dependencies(db) {
|
||||||
entries.extend(of.modules(db).into_iter().filter_map(|module| {
|
let root_file = rev_dep.root_file(db);
|
||||||
match module.definition_source(db) {
|
let source_root_id = db.file_source_root(root_file);
|
||||||
InFile { file_id, value: ModuleSource::SourceFile(..) } => {
|
let source_root = db.source_root(source_root_id);
|
||||||
Some((file_id.original_file(db), None))
|
entries.extend(source_root.iter().map(|id| (id, None)));
|
||||||
}
|
}
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
insert_modules(of);
|
|
||||||
of.transitive_reverse_dependencies(db).into_iter().for_each(insert_modules);
|
|
||||||
SearchScope { entries }
|
SearchScope { entries }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue