aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db/src/items_locator.rs
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2021-03-20 20:54:04 +0000
committerKirill Bulatov <[email protected]>2021-03-20 20:55:34 +0000
commit879432452d15d4e9c373a6233a0cd15e22f20ef3 (patch)
tree918eb815d2da4758d00dfac387b805de6a771c11 /crates/ide_db/src/items_locator.rs
parenta631108d2dd0596b079b59efa37b1af00d7555db (diff)
Docs
Diffstat (limited to 'crates/ide_db/src/items_locator.rs')
-rw-r--r--crates/ide_db/src/items_locator.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/crates/ide_db/src/items_locator.rs b/crates/ide_db/src/items_locator.rs
index 088be72c4..518cddd74 100644
--- a/crates/ide_db/src/items_locator.rs
+++ b/crates/ide_db/src/items_locator.rs
@@ -1,6 +1,7 @@
1//! This module contains an import search functionality that is provided to the assists module. 1//! This module has the functionality to search the project and its dependencies for a certain item,
2//! Later, this should be moved away to a separate crate that is accessible from the assists module. 2//! by its name and a few criteria.
3 3//! The main reason for this module to exist is the fact that project's items and dependencies' items
4//! are located in different caches, with different APIs.
4use either::Either; 5use either::Either;
5use hir::{ 6use hir::{
6 import_map::{self, ImportKind}, 7 import_map::{self, ImportKind},
@@ -16,24 +17,29 @@ use crate::{
16}; 17};
17use rustc_hash::FxHashSet; 18use rustc_hash::FxHashSet;
18 19
19pub(crate) const DEFAULT_QUERY_SEARCH_LIMIT: usize = 40; 20/// A value to use, when uncertain which limit to pick.
21pub const DEFAULT_QUERY_SEARCH_LIMIT: usize = 40;
20 22
21/// TODO kb docs here and around + update the module doc 23/// Three possible ways to search for the name in associated and/or other items.
22#[derive(Debug, Clone, Copy)] 24#[derive(Debug, Clone, Copy)]
23pub enum AssocItemSearch { 25pub enum AssocItemSearch {
26 /// Search for the name in both associated and other items.
24 Include, 27 Include,
28 /// Search for the name in other items only.
25 Exclude, 29 Exclude,
30 /// Search for the name in the associated items only.
26 AssocItemsOnly, 31 AssocItemsOnly,
27} 32}
28 33
29pub fn locate_for_name( 34/// Searches for importable items with the given name in the crate and its dependencies.
35pub fn items_with_name(
30 sema: &Semantics<'_, RootDatabase>, 36 sema: &Semantics<'_, RootDatabase>,
31 krate: Crate, 37 krate: Crate,
32 name: NameToImport, 38 name: NameToImport,
33 assoc_item_search: AssocItemSearch, 39 assoc_item_search: AssocItemSearch,
34 limit: Option<usize>, 40 limit: Option<usize>,
35) -> FxHashSet<ItemInNs> { 41) -> FxHashSet<ItemInNs> {
36 let _p = profile::span("locate_for_name").detail(|| { 42 let _p = profile::span("items_with_name").detail(|| {
37 format!( 43 format!(
38 "Name: {} ({:?}), crate: {:?}, limit: {:?}", 44 "Name: {} ({:?}), crate: {:?}, limit: {:?}",
39 name.text(), 45 name.text(),