aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2020-06-10 11:30:33 +0100
committerJonas Schievink <[email protected]>2020-06-10 11:40:33 +0100
commit56c7145993f94a12bf923f08cbd62d963e62bbd1 (patch)
treed61f3726112bc0c2fd5749ce7d95777de1246c43 /crates/ra_hir
parentbcf875f46ae5142c42ddac8094e1b6652182d4be (diff)
Limit import map queries
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/code_model.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index c8329d971..a55fe03a6 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -104,12 +104,16 @@ impl Crate {
104 db: &dyn DefDatabase, 104 db: &dyn DefDatabase,
105 query: &str, 105 query: &str,
106 ) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> { 106 ) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> {
107 import_map::search_dependencies(db, self.into(), import_map::Query::new(query).anchor_end()) 107 import_map::search_dependencies(
108 .into_iter() 108 db,
109 .map(|item| match item { 109 self.into(),
110 ItemInNs::Types(mod_id) | ItemInNs::Values(mod_id) => Either::Left(mod_id.into()), 110 import_map::Query::new(query).anchor_end().limit(40),
111 ItemInNs::Macros(mac_id) => Either::Right(mac_id.into()), 111 )
112 }) 112 .into_iter()
113 .map(|item| match item {
114 ItemInNs::Types(mod_id) | ItemInNs::Values(mod_id) => Either::Left(mod_id.into()),
115 ItemInNs::Macros(mac_id) => Either::Right(mac_id.into()),
116 })
113 } 117 }
114 118
115 pub fn all(db: &dyn HirDatabase) -> Vec<Crate> { 119 pub fn all(db: &dyn HirDatabase) -> Vec<Crate> {