From c0aeb5204c010a11db2015113a7858b517415de1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 18 Jan 2019 16:36:56 +0300 Subject: switched to lowerd module --- crates/ra_ide_api/src/completion/complete_scope.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'crates/ra_ide_api/src/completion') diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs index 699680748..4276e47e8 100644 --- a/crates/ra_ide_api/src/completion/complete_scope.rs +++ b/crates/ra_ide_api/src/completion/complete_scope.rs @@ -1,5 +1,5 @@ use rustc_hash::FxHashSet; -use ra_syntax::TextUnit; +use ra_syntax::{AstNode, TextUnit}; use crate::completion::{CompletionItem, CompletionItemKind, Completions, CompletionKind, CompletionContext}; @@ -17,18 +17,15 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) { } let module_scope = module.scope(ctx.db); - let (file_id, _) = module.definition_source(ctx.db); module_scope .entries() .filter(|(_name, res)| { - // Don't expose this item - // FIXME: this penetrates through all kinds of abstractions, - // we need to figura out the way to do it less ugly. + // For cases like `use self::foo<|>` don't suggest foo itself. match res.import { None => true, Some(import) => { - let range = import.range(ctx.db, file_id); - !range.is_subrange(&ctx.leaf.range()) + let source = module.import_source(ctx.db, import); + !source.syntax().range().is_subrange(&ctx.leaf.range()) } } }) -- cgit v1.2.3