aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db/src/helpers
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2021-01-16 22:53:15 +0000
committerKirill Bulatov <[email protected]>2021-01-17 00:57:34 +0000
commit68626e4ef5acfea05812b68f41efa2bcd5bea448 (patch)
tree92ec1a8a69ce3058fd6da44f2f80f2460c9bda1d /crates/ide_db/src/helpers
parentdb335a1bbf1d1bea2c761f67efb4b49831738e31 (diff)
Draft the working completion
Diffstat (limited to 'crates/ide_db/src/helpers')
-rw-r--r--crates/ide_db/src/helpers/import_assets.rs30
1 files changed, 20 insertions, 10 deletions
diff --git a/crates/ide_db/src/helpers/import_assets.rs b/crates/ide_db/src/helpers/import_assets.rs
index e284220c1..a080b6ca7 100644
--- a/crates/ide_db/src/helpers/import_assets.rs
+++ b/crates/ide_db/src/helpers/import_assets.rs
@@ -5,7 +5,7 @@ use rustc_hash::FxHashSet;
5use syntax::{ast, AstNode}; 5use syntax::{ast, AstNode};
6 6
7use crate::{ 7use crate::{
8 imports_locator::{self, AssocItemSearch}, 8 imports_locator::{self, AssocItemSearch, DEFAULT_QUERY_SEARCH_LIMIT},
9 RootDatabase, 9 RootDatabase,
10}; 10};
11 11
@@ -173,6 +173,7 @@ impl ImportAssets {
173 let current_crate = self.module_with_candidate.krate(); 173 let current_crate = self.module_with_candidate.krate();
174 174
175 let filter = |candidate: Either<hir::ModuleDef, hir::MacroDef>| { 175 let filter = |candidate: Either<hir::ModuleDef, hir::MacroDef>| {
176 // TODO kb process all traits at once instead?
176 trait_candidates.clear(); 177 trait_candidates.clear();
177 match &self.import_candidate { 178 match &self.import_candidate {
178 ImportCandidate::TraitAssocItem(trait_candidate) => { 179 ImportCandidate::TraitAssocItem(trait_candidate) => {
@@ -191,6 +192,11 @@ impl ImportAssets {
191 None, 192 None,
192 |_, assoc| { 193 |_, assoc| {
193 if canidate_assoc_item == assoc { 194 if canidate_assoc_item == assoc {
195 if let AssocItem::Function(f) = assoc {
196 if f.self_param(db).is_some() {
197 return None;
198 }
199 }
194 Some(assoc_to_module_def(assoc)) 200 Some(assoc_to_module_def(assoc))
195 } else { 201 } else {
196 None 202 None
@@ -238,17 +244,21 @@ impl ImportAssets {
238 // see https://github.com/rust-analyzer/rust-analyzer/pull/7293#issuecomment-761585032 244 // see https://github.com/rust-analyzer/rust-analyzer/pull/7293#issuecomment-761585032
239 // and https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Blanket.20trait.20impls.20lookup 245 // and https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Blanket.20trait.20impls.20lookup
240 // for the details 246 // for the details
241 NameToImport::Fuzzy(fuzzy_name) => imports_locator::find_similar_imports( 247 NameToImport::Fuzzy(fuzzy_name) => {
242 sema, 248 let (assoc_item_search, limit) = match self.import_candidate {
243 current_crate,
244 fuzzy_name.clone(),
245 match self.import_candidate {
246 ImportCandidate::TraitAssocItem(_) | ImportCandidate::TraitMethod(_) => { 249 ImportCandidate::TraitAssocItem(_) | ImportCandidate::TraitMethod(_) => {
247 AssocItemSearch::AssocItemsOnly 250 (AssocItemSearch::AssocItemsOnly, None)
248 } 251 }
249 _ => AssocItemSearch::Exclude, 252 _ => (AssocItemSearch::Exclude, Some(DEFAULT_QUERY_SEARCH_LIMIT)),
250 }, 253 };
251 ), 254 imports_locator::find_similar_imports(
255 sema,
256 current_crate,
257 fuzzy_name.clone(),
258 assoc_item_search,
259 limit,
260 )
261 }
252 }; 262 };
253 263
254 let mut res = unfiltered_imports 264 let mut res = unfiltered_imports