diff options
Diffstat (limited to 'crates/ide_completion/src/completions.rs')
-rw-r--r-- | crates/ide_completion/src/completions.rs | 45 |
1 files changed, 1 insertions, 44 deletions
diff --git a/crates/ide_completion/src/completions.rs b/crates/ide_completion/src/completions.rs index dd92bc510..ffdcdc930 100644 --- a/crates/ide_completion/src/completions.rs +++ b/crates/ide_completion/src/completions.rs | |||
@@ -18,10 +18,8 @@ pub(crate) mod unqualified_path; | |||
18 | 18 | ||
19 | use std::iter; | 19 | use std::iter; |
20 | 20 | ||
21 | use either::Either; | 21 | use hir::known; |
22 | use hir::{known, HasVisibility}; | ||
23 | use ide_db::SymbolKind; | 22 | use ide_db::SymbolKind; |
24 | use rustc_hash::FxHashSet; | ||
25 | 23 | ||
26 | use crate::{ | 24 | use crate::{ |
27 | item::{Builder, CompletionKind}, | 25 | item::{Builder, CompletionKind}, |
@@ -254,44 +252,3 @@ fn complete_enum_variants( | |||
254 | } | 252 | } |
255 | } | 253 | } |
256 | } | 254 | } |
257 | |||
258 | fn complete_fields( | ||
259 | ctx: &CompletionContext, | ||
260 | receiver: &hir::Type, | ||
261 | mut f: impl FnMut(Either<hir::Field, usize>, hir::Type), | ||
262 | ) { | ||
263 | for receiver in receiver.autoderef(ctx.db) { | ||
264 | for (field, ty) in receiver.fields(ctx.db) { | ||
265 | if ctx.scope.module().map_or(false, |m| !field.is_visible_from(ctx.db, m)) { | ||
266 | // Skip private field. FIXME: If the definition location of the | ||
267 | // field is editable, we should show the completion | ||
268 | continue; | ||
269 | } | ||
270 | f(Either::Left(field), ty); | ||
271 | } | ||
272 | for (i, ty) in receiver.tuple_fields(ctx.db).into_iter().enumerate() { | ||
273 | // FIXME: Handle visibility | ||
274 | f(Either::Right(i), ty); | ||
275 | } | ||
276 | } | ||
277 | } | ||
278 | |||
279 | fn complete_methods( | ||
280 | ctx: &CompletionContext, | ||
281 | receiver: &hir::Type, | ||
282 | mut f: impl FnMut(hir::Function), | ||
283 | ) { | ||
284 | if let Some(krate) = ctx.krate { | ||
285 | let mut seen_methods = FxHashSet::default(); | ||
286 | let traits_in_scope = ctx.scope.traits_in_scope(); | ||
287 | receiver.iterate_method_candidates(ctx.db, krate, &traits_in_scope, None, |_ty, func| { | ||
288 | if func.self_param(ctx.db).is_some() | ||
289 | && ctx.scope.module().map_or(true, |m| func.is_visible_from(ctx.db, m)) | ||
290 | && seen_methods.insert(func.name(ctx.db)) | ||
291 | { | ||
292 | f(func); | ||
293 | } | ||
294 | None::<()> | ||
295 | }); | ||
296 | } | ||
297 | } | ||