Remove name_only
from import map query
This commit is contained in:
parent
f96442aa90
commit
97b725e269
@ -318,7 +318,6 @@ pub enum SearchMode {
|
||||
pub struct Query {
|
||||
query: String,
|
||||
lowercased: String,
|
||||
name_only: bool,
|
||||
assoc_items_only: bool,
|
||||
search_mode: SearchMode,
|
||||
case_sensitive: bool,
|
||||
@ -332,7 +331,6 @@ impl Query {
|
||||
Self {
|
||||
query,
|
||||
lowercased,
|
||||
name_only: false,
|
||||
assoc_items_only: false,
|
||||
search_mode: SearchMode::Contains,
|
||||
case_sensitive: false,
|
||||
@ -341,13 +339,6 @@ impl Query {
|
||||
}
|
||||
}
|
||||
|
||||
/// Matches entries' names only, ignoring the rest of
|
||||
/// the qualifier.
|
||||
/// Example: for `std::marker::PhantomData`, the name is `PhantomData`.
|
||||
pub fn name_only(self) -> Self {
|
||||
Self { name_only: true, ..self }
|
||||
}
|
||||
|
||||
/// Matches only the entries that are associated items, ignoring the rest.
|
||||
pub fn assoc_items_only(self) -> Self {
|
||||
Self { assoc_items_only: true, ..self }
|
||||
@ -389,17 +380,13 @@ impl Query {
|
||||
return false;
|
||||
}
|
||||
|
||||
let mut input = if import.is_trait_assoc_item || self.name_only {
|
||||
import.path.segments.last().unwrap().display(db.upcast()).to_string()
|
||||
} else {
|
||||
import.path.display(db).to_string()
|
||||
};
|
||||
if enforce_lowercase || !self.case_sensitive {
|
||||
let mut input = import.path.segments.last().unwrap().display(db.upcast()).to_string();
|
||||
let case_insensitive = enforce_lowercase || !self.case_sensitive;
|
||||
if case_insensitive {
|
||||
input.make_ascii_lowercase();
|
||||
}
|
||||
|
||||
let query_string =
|
||||
if !enforce_lowercase && self.case_sensitive { &self.query } else { &self.lowercased };
|
||||
let query_string = if case_insensitive { &self.lowercased } else { &self.query };
|
||||
|
||||
match self.search_mode {
|
||||
SearchMode::Equals => &input == query_string,
|
||||
@ -875,7 +862,6 @@ mod tests {
|
||||
Query::new("fmt".to_string()).search_mode(SearchMode::Fuzzy),
|
||||
expect![[r#"
|
||||
dep::fmt (t)
|
||||
dep::fmt::Display (t)
|
||||
dep::fmt::Display::FMT_CONST (a)
|
||||
dep::fmt::Display::format_function (a)
|
||||
dep::fmt::Display::format_method (a)
|
||||
@ -917,9 +903,8 @@ mod tests {
|
||||
.search_mode(SearchMode::Fuzzy)
|
||||
.exclude_import_kind(ImportKind::AssociatedItem),
|
||||
expect![[r#"
|
||||
dep::fmt (t)
|
||||
dep::fmt::Display (t)
|
||||
"#]],
|
||||
dep::fmt (t)
|
||||
"#]],
|
||||
);
|
||||
|
||||
check_search(
|
||||
@ -968,7 +953,6 @@ mod tests {
|
||||
dep::Fmt (t)
|
||||
dep::Fmt (v)
|
||||
dep::fmt (t)
|
||||
dep::fmt::Display (t)
|
||||
dep::fmt::Display::fmt (a)
|
||||
dep::format (f)
|
||||
"#]],
|
||||
@ -996,7 +980,6 @@ mod tests {
|
||||
dep::Fmt (t)
|
||||
dep::Fmt (v)
|
||||
dep::fmt (t)
|
||||
dep::fmt::Display (t)
|
||||
dep::fmt::Display::fmt (a)
|
||||
"#]],
|
||||
);
|
||||
@ -1037,7 +1020,6 @@ mod tests {
|
||||
dep::Fmt (t)
|
||||
dep::Fmt (v)
|
||||
dep::fmt (t)
|
||||
dep::fmt::Display (t)
|
||||
dep::fmt::Display::fmt (a)
|
||||
"#]],
|
||||
);
|
||||
@ -1045,7 +1027,7 @@ mod tests {
|
||||
check_search(
|
||||
ra_fixture,
|
||||
"main",
|
||||
Query::new("fmt".to_string()).name_only(),
|
||||
Query::new("fmt".to_string()),
|
||||
expect![[r#"
|
||||
dep::Fmt (m)
|
||||
dep::Fmt (t)
|
||||
|
@ -48,9 +48,8 @@ pub fn items_with_name<'a>(
|
||||
let mut local_query = symbol_index::Query::new(exact_name.clone());
|
||||
local_query.exact();
|
||||
|
||||
let external_query = import_map::Query::new(exact_name)
|
||||
.name_only()
|
||||
.search_mode(import_map::SearchMode::Equals);
|
||||
let external_query =
|
||||
import_map::Query::new(exact_name).search_mode(import_map::SearchMode::Equals);
|
||||
|
||||
(
|
||||
local_query,
|
||||
@ -61,8 +60,7 @@ pub fn items_with_name<'a>(
|
||||
let mut local_query = symbol_index::Query::new(fuzzy_search_string.clone());
|
||||
|
||||
let mut external_query = import_map::Query::new(fuzzy_search_string.clone())
|
||||
.search_mode(import_map::SearchMode::Fuzzy)
|
||||
.name_only();
|
||||
.search_mode(import_map::SearchMode::Fuzzy);
|
||||
match assoc_item_search {
|
||||
AssocItemSearch::Include => {}
|
||||
AssocItemSearch::Exclude => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user