Skip to content

Commit 97b725e

Browse files
committed
Remove name_only from import map query
1 parent f96442a commit 97b725e

File tree

2 files changed

+10
-30
lines changed

2 files changed

+10
-30
lines changed

crates/hir-def/src/import_map.rs

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,6 @@ pub enum SearchMode {
318318
pub struct Query {
319319
query: String,
320320
lowercased: String,
321-
name_only: bool,
322321
assoc_items_only: bool,
323322
search_mode: SearchMode,
324323
case_sensitive: bool,
@@ -332,7 +331,6 @@ impl Query {
332331
Self {
333332
query,
334333
lowercased,
335-
name_only: false,
336334
assoc_items_only: false,
337335
search_mode: SearchMode::Contains,
338336
case_sensitive: false,
@@ -341,13 +339,6 @@ impl Query {
341339
}
342340
}
343341

344-
/// Matches entries' names only, ignoring the rest of
345-
/// the qualifier.
346-
/// Example: for `std::marker::PhantomData`, the name is `PhantomData`.
347-
pub fn name_only(self) -> Self {
348-
Self { name_only: true, ..self }
349-
}
350-
351342
/// Matches only the entries that are associated items, ignoring the rest.
352343
pub fn assoc_items_only(self) -> Self {
353344
Self { assoc_items_only: true, ..self }
@@ -389,17 +380,13 @@ impl Query {
389380
return false;
390381
}
391382

392-
let mut input = if import.is_trait_assoc_item || self.name_only {
393-
import.path.segments.last().unwrap().display(db.upcast()).to_string()
394-
} else {
395-
import.path.display(db).to_string()
396-
};
397-
if enforce_lowercase || !self.case_sensitive {
383+
let mut input = import.path.segments.last().unwrap().display(db.upcast()).to_string();
384+
let case_insensitive = enforce_lowercase || !self.case_sensitive;
385+
if case_insensitive {
398386
input.make_ascii_lowercase();
399387
}
400388

401-
let query_string =
402-
if !enforce_lowercase && self.case_sensitive { &self.query } else { &self.lowercased };
389+
let query_string = if case_insensitive { &self.lowercased } else { &self.query };
403390

404391
match self.search_mode {
405392
SearchMode::Equals => &input == query_string,
@@ -875,7 +862,6 @@ mod tests {
875862
Query::new("fmt".to_string()).search_mode(SearchMode::Fuzzy),
876863
expect![[r#"
877864
dep::fmt (t)
878-
dep::fmt::Display (t)
879865
dep::fmt::Display::FMT_CONST (a)
880866
dep::fmt::Display::format_function (a)
881867
dep::fmt::Display::format_method (a)
@@ -917,9 +903,8 @@ mod tests {
917903
.search_mode(SearchMode::Fuzzy)
918904
.exclude_import_kind(ImportKind::AssociatedItem),
919905
expect![[r#"
920-
dep::fmt (t)
921-
dep::fmt::Display (t)
922-
"#]],
906+
dep::fmt (t)
907+
"#]],
923908
);
924909

925910
check_search(
@@ -968,7 +953,6 @@ mod tests {
968953
dep::Fmt (t)
969954
dep::Fmt (v)
970955
dep::fmt (t)
971-
dep::fmt::Display (t)
972956
dep::fmt::Display::fmt (a)
973957
dep::format (f)
974958
"#]],
@@ -996,7 +980,6 @@ mod tests {
996980
dep::Fmt (t)
997981
dep::Fmt (v)
998982
dep::fmt (t)
999-
dep::fmt::Display (t)
1000983
dep::fmt::Display::fmt (a)
1001984
"#]],
1002985
);
@@ -1037,15 +1020,14 @@ mod tests {
10371020
dep::Fmt (t)
10381021
dep::Fmt (v)
10391022
dep::fmt (t)
1040-
dep::fmt::Display (t)
10411023
dep::fmt::Display::fmt (a)
10421024
"#]],
10431025
);
10441026

10451027
check_search(
10461028
ra_fixture,
10471029
"main",
1048-
Query::new("fmt".to_string()).name_only(),
1030+
Query::new("fmt".to_string()),
10491031
expect![[r#"
10501032
dep::Fmt (m)
10511033
dep::Fmt (t)

crates/ide-db/src/items_locator.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ pub fn items_with_name<'a>(
4848
let mut local_query = symbol_index::Query::new(exact_name.clone());
4949
local_query.exact();
5050

51-
let external_query = import_map::Query::new(exact_name)
52-
.name_only()
53-
.search_mode(import_map::SearchMode::Equals);
51+
let external_query =
52+
import_map::Query::new(exact_name).search_mode(import_map::SearchMode::Equals);
5453

5554
(
5655
local_query,
@@ -61,8 +60,7 @@ pub fn items_with_name<'a>(
6160
let mut local_query = symbol_index::Query::new(fuzzy_search_string.clone());
6261

6362
let mut external_query = import_map::Query::new(fuzzy_search_string.clone())
64-
.search_mode(import_map::SearchMode::Fuzzy)
65-
.name_only();
63+
.search_mode(import_map::SearchMode::Fuzzy);
6664
match assoc_item_search {
6765
AssocItemSearch::Include => {}
6866
AssocItemSearch::Exclude => {

0 commit comments

Comments
 (0)