diff options
author | Kirill Bulatov <[email protected]> | 2021-01-04 16:33:05 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2021-01-04 16:33:05 +0000 |
commit | ca42a52051e69d441b3f32ba4268286a8f0d8685 (patch) | |
tree | 217c9b610f657a3b60833c4e7b1c0bbf5c29d122 /crates/hir_def | |
parent | ed1ef3ae13a8f7bc2144bd06d0271d9a6e3205a0 (diff) |
Code review fixes
Diffstat (limited to 'crates/hir_def')
-rw-r--r-- | crates/hir_def/src/import_map.rs | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/crates/hir_def/src/import_map.rs b/crates/hir_def/src/import_map.rs index dd3a7198f..1325a93d1 100644 --- a/crates/hir_def/src/import_map.rs +++ b/crates/hir_def/src/import_map.rs | |||
@@ -199,7 +199,7 @@ impl ImportMap { | |||
199 | ItemInNs::Values(module_def_id) | 199 | ItemInNs::Values(module_def_id) |
200 | }; | 200 | }; |
201 | 201 | ||
202 | let mut assoc_item_info = original_import_info.to_owned(); | 202 | let mut assoc_item_info = original_import_info.clone(); |
203 | assoc_item_info.path.segments.push(assoc_item_name.to_owned()); | 203 | assoc_item_info.path.segments.push(assoc_item_name.to_owned()); |
204 | assoc_item_info.is_trait_assoc_item = true; | 204 | assoc_item_info.is_trait_assoc_item = true; |
205 | self.map.insert(assoc_item, assoc_item_info); | 205 | self.map.insert(assoc_item, assoc_item_info); |
@@ -325,38 +325,38 @@ impl Query { | |||
325 | self.exclude_import_kinds.insert(import_kind); | 325 | self.exclude_import_kinds.insert(import_kind); |
326 | self | 326 | self |
327 | } | 327 | } |
328 | } | ||
329 | 328 | ||
330 | fn import_matches_query(import: &ImportInfo, query: &Query, enforce_lowercase: bool) -> bool { | 329 | fn import_matches(&self, import: &ImportInfo, enforce_lowercase: bool) -> bool { |
331 | let mut input = if import.is_trait_assoc_item || query.name_only { | 330 | let mut input = if import.is_trait_assoc_item || self.name_only { |
332 | import.path.segments.last().unwrap().to_string() | 331 | import.path.segments.last().unwrap().to_string() |
333 | } else { | 332 | } else { |
334 | import.path.to_string() | 333 | import.path.to_string() |
335 | }; | 334 | }; |
336 | if enforce_lowercase || !query.case_sensitive { | 335 | if enforce_lowercase || !self.case_sensitive { |
337 | input.make_ascii_lowercase(); | 336 | input.make_ascii_lowercase(); |
338 | } | 337 | } |
339 | 338 | ||
340 | let query_string = | 339 | let query_string = |
341 | if !enforce_lowercase && query.case_sensitive { &query.query } else { &query.lowercased }; | 340 | if !enforce_lowercase && self.case_sensitive { &self.query } else { &self.lowercased }; |
342 | 341 | ||
343 | match query.search_mode { | 342 | match self.search_mode { |
344 | SearchMode::Equals => &input == query_string, | 343 | SearchMode::Equals => &input == query_string, |
345 | SearchMode::Contains => input.contains(query_string), | 344 | SearchMode::Contains => input.contains(query_string), |
346 | SearchMode::Fuzzy => { | 345 | SearchMode::Fuzzy => { |
347 | let mut unchecked_query_chars = query_string.chars(); | 346 | let mut unchecked_query_chars = query_string.chars(); |
348 | let mut mismatching_query_char = unchecked_query_chars.next(); | 347 | let mut mismatching_query_char = unchecked_query_chars.next(); |
349 | 348 | ||
350 | for input_char in input.chars() { | 349 | for input_char in input.chars() { |
351 | match mismatching_query_char { | 350 | match mismatching_query_char { |
352 | None => return true, | 351 | None => return true, |
353 | Some(matching_query_char) if matching_query_char == input_char => { | 352 | Some(matching_query_char) if matching_query_char == input_char => { |
354 | mismatching_query_char = unchecked_query_chars.next(); | 353 | mismatching_query_char = unchecked_query_chars.next(); |
354 | } | ||
355 | _ => (), | ||
355 | } | 356 | } |
356 | _ => (), | ||
357 | } | 357 | } |
358 | mismatching_query_char.is_none() | ||
358 | } | 359 | } |
359 | mismatching_query_char.is_none() | ||
360 | } | 360 | } |
361 | } | 361 | } |
362 | } | 362 | } |
@@ -390,7 +390,7 @@ pub fn search_dependencies<'a>( | |||
390 | let importables = &import_map.importables[indexed_value.value as usize..]; | 390 | let importables = &import_map.importables[indexed_value.value as usize..]; |
391 | 391 | ||
392 | let common_importable_data = &import_map.map[&importables[0]]; | 392 | let common_importable_data = &import_map.map[&importables[0]]; |
393 | if !import_matches_query(common_importable_data, &query, true) { | 393 | if !query.import_matches(common_importable_data, true) { |
394 | continue; | 394 | continue; |
395 | } | 395 | } |
396 | 396 | ||
@@ -410,7 +410,7 @@ pub fn search_dependencies<'a>( | |||
410 | }) | 410 | }) |
411 | .filter(|item| { | 411 | .filter(|item| { |
412 | !query.case_sensitive // we've already checked the common importables path case-insensitively | 412 | !query.case_sensitive // we've already checked the common importables path case-insensitively |
413 | || import_matches_query(&import_map.map[item], &query, false) | 413 | || query.import_matches(&import_map.map[item], false) |
414 | }); | 414 | }); |
415 | res.extend(iter); | 415 | res.extend(iter); |
416 | 416 | ||