aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/completion/complete_path.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-12-21 11:48:12 +0000
committerGitHub <[email protected]>2019-12-21 11:48:12 +0000
commitcdc9d682b066b110e0a44e5f8f1c574b38c16ba9 (patch)
treed1429d913719f73b4dee771e0c9ce85e871fc54a /crates/ra_ide/src/completion/complete_path.rs
parent90ef070db3dce0a7acb9cd11d0b0d72de13c9d79 (diff)
parent2d3fdf3fb52f32ececdfa19df7ab2971a24bae71 (diff)
Merge #2629
2629: Remove imports from hir r=matklad a=matklad We only used them to avoid self-confirming completions (`use self::foo`), but that can be handled more locally. bors r+ Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/completion/complete_path.rs')
-rw-r--r--crates/ra_ide/src/completion/complete_path.rs17
1 files changed, 7 insertions, 10 deletions
diff --git a/crates/ra_ide/src/completion/complete_path.rs b/crates/ra_ide/src/completion/complete_path.rs
index 28f94e0a7..8ce86ad7d 100644
--- a/crates/ra_ide/src/completion/complete_path.rs
+++ b/crates/ra_ide/src/completion/complete_path.rs
@@ -1,7 +1,6 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use either::Either; 3use hir::{Adt, PathResolution, ScopeDef};
4use hir::{Adt, HasSource, PathResolution};
5use ra_syntax::AstNode; 4use ra_syntax::AstNode;
6use test_utils::tested_by; 5use test_utils::tested_by;
7 6
@@ -19,17 +18,15 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
19 match def { 18 match def {
20 hir::ModuleDef::Module(module) => { 19 hir::ModuleDef::Module(module) => {
21 let module_scope = module.scope(ctx.db); 20 let module_scope = module.scope(ctx.db);
22 for (name, def, import) in module_scope { 21 for (name, def) in module_scope {
23 if let hir::ScopeDef::ModuleDef(hir::ModuleDef::BuiltinType(..)) = def { 22 if ctx.use_item_syntax.is_some() {
24 if ctx.use_item_syntax.is_some() { 23 if let hir::ScopeDef::ModuleDef(hir::ModuleDef::BuiltinType(..)) = def {
25 tested_by!(dont_complete_primitive_in_use); 24 tested_by!(dont_complete_primitive_in_use);
26 continue; 25 continue;
27 } 26 }
28 } 27 if let ScopeDef::Unknown = def {
29 if Some(module) == ctx.module { 28 if let Some(name_ref) = ctx.name_ref.as_ref() {
30 if let Some(import) = import { 29 if &name_ref.syntax().text() == name.to_string().as_str() {
31 if let Either::Left(use_tree) = import.source(ctx.db).value {
32 if use_tree.syntax().text_range().contains_inclusive(ctx.offset) {
33 // for `use self::foo<|>`, don't suggest `foo` as a completion 30 // for `use self::foo<|>`, don't suggest `foo` as a completion
34 tested_by!(dont_complete_current_use); 31 tested_by!(dont_complete_current_use);
35 continue; 32 continue;