aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db/src/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_db/src/helpers')
-rw-r--r--crates/ide_db/src/helpers/import_assets.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/crates/ide_db/src/helpers/import_assets.rs b/crates/ide_db/src/helpers/import_assets.rs
index b3e90717a..b78d1969d 100644
--- a/crates/ide_db/src/helpers/import_assets.rs
+++ b/crates/ide_db/src/helpers/import_assets.rs
@@ -3,6 +3,7 @@ use hir::{
3 AsAssocItem, AssocItem, AssocItemContainer, Crate, ItemInNs, MacroDef, ModPath, Module, 3 AsAssocItem, AssocItem, AssocItemContainer, Crate, ItemInNs, MacroDef, ModPath, Module,
4 ModuleDef, Name, PathResolution, PrefixKind, ScopeDef, Semantics, SemanticsScope, Type, 4 ModuleDef, Name, PathResolution, PrefixKind, ScopeDef, Semantics, SemanticsScope, Type,
5}; 5};
6use itertools::Itertools;
6use rustc_hash::FxHashSet; 7use rustc_hash::FxHashSet;
7use syntax::{ast, AstNode}; 8use syntax::{ast, AstNode};
8 9
@@ -164,16 +165,13 @@ impl<'a> ImportAssets<'a> {
164 &self, 165 &self,
165 sema: &Semantics<RootDatabase>, 166 sema: &Semantics<RootDatabase>,
166 prefix_kind: PrefixKind, 167 prefix_kind: PrefixKind,
167 ) -> FxHashSet<LocatedImport> { 168 ) -> Vec<LocatedImport> {
168 let _p = profile::span("import_assets::search_for_imports"); 169 let _p = profile::span("import_assets::search_for_imports");
169 self.search_for(sema, Some(prefix_kind)) 170 self.search_for(sema, Some(prefix_kind))
170 } 171 }
171 172
172 /// This may return non-absolute paths if a part of the returned path is already imported into scope. 173 /// This may return non-absolute paths if a part of the returned path is already imported into scope.
173 pub fn search_for_relative_paths( 174 pub fn search_for_relative_paths(&self, sema: &Semantics<RootDatabase>) -> Vec<LocatedImport> {
174 &self,
175 sema: &Semantics<RootDatabase>,
176 ) -> FxHashSet<LocatedImport> {
177 let _p = profile::span("import_assets::search_for_relative_paths"); 175 let _p = profile::span("import_assets::search_for_relative_paths");
178 self.search_for(sema, None) 176 self.search_for(sema, None)
179 } 177 }
@@ -182,7 +180,7 @@ impl<'a> ImportAssets<'a> {
182 &self, 180 &self,
183 sema: &Semantics<RootDatabase>, 181 sema: &Semantics<RootDatabase>,
184 prefixed: Option<PrefixKind>, 182 prefixed: Option<PrefixKind>,
185 ) -> FxHashSet<LocatedImport> { 183 ) -> Vec<LocatedImport> {
186 let items_with_candidate_name = match self.name_to_import() { 184 let items_with_candidate_name = match self.name_to_import() {
187 NameToImport::Exact(exact_name) => items_locator::with_for_exact_name( 185 NameToImport::Exact(exact_name) => items_locator::with_for_exact_name(
188 sema, 186 sema,
@@ -216,6 +214,7 @@ impl<'a> ImportAssets<'a> {
216 .into_iter() 214 .into_iter()
217 .filter(|import| import.import_path.len() > 1) 215 .filter(|import| import.import_path.len() > 1)
218 .filter(|import| !scope_definitions.contains(&ScopeDef::from(import.item_to_import))) 216 .filter(|import| !scope_definitions.contains(&ScopeDef::from(import.item_to_import)))
217 .sorted_by_key(|import| import.import_path.clone())
219 .collect() 218 .collect()
220 } 219 }
221 220