From 1db2cbcb8bd61b4f19f61cc6319343e5ad894515 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 25 Jan 2019 00:50:08 +0300 Subject: move consts&statics to new id --- crates/ra_ide_api/src/completion/complete_path.rs | 2 ++ .../ra_ide_api/src/completion/completion_item.rs | 4 ++-- crates/ra_ide_api/src/navigation_target.rs | 22 ++++++++++++++-------- 3 files changed, 18 insertions(+), 10 deletions(-) (limited to 'crates/ra_ide_api/src') diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index 4768efdc1..bd5484516 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs @@ -43,6 +43,8 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { hir::ModuleDef::Function(_) | hir::ModuleDef::Struct(_) | hir::ModuleDef::Def(_) + | hir::ModuleDef::Const(_) + | hir::ModuleDef::Static(_) | hir::ModuleDef::EnumVariant(_) => return, }; } diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index ee1f8bce0..2f8ec41d2 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs @@ -223,11 +223,11 @@ impl Builder { hir::ModuleDef::Struct(it) => (CompletionItemKind::Struct, it.docs(ctx.db)), hir::ModuleDef::Enum(it) => (CompletionItemKind::Enum, it.docs(ctx.db)), hir::ModuleDef::EnumVariant(it) => (CompletionItemKind::EnumVariant, it.docs(ctx.db)), + hir::ModuleDef::Const(it) => (CompletionItemKind::Const, it.docs(ctx.db)), + hir::ModuleDef::Static(it) => (CompletionItemKind::Static, it.docs(ctx.db)), hir::ModuleDef::Def(def_id) => match def_id.resolve(ctx.db) { hir::Def::Trait(it) => (CompletionItemKind::Trait, it.docs(ctx.db)), hir::Def::Type(it) => (CompletionItemKind::TypeAlias, it.docs(ctx.db)), - hir::Def::Const(it) => (CompletionItemKind::Const, it.docs(ctx.db)), - hir::Def::Static(it) => (CompletionItemKind::Static, it.docs(ctx.db)), _ => return self, }, }; diff --git a/crates/ra_ide_api/src/navigation_target.rs b/crates/ra_ide_api/src/navigation_target.rs index fc76338d2..8406fee31 100644 --- a/crates/ra_ide_api/src/navigation_target.rs +++ b/crates/ra_ide_api/src/navigation_target.rs @@ -121,6 +121,20 @@ impl NavigationTarget { &*node, )); } + hir::ModuleDef::Const(s) => { + let (file_id, node) = s.source(db); + return Some(NavigationTarget::from_named( + file_id.original_file(db), + &*node, + )); + } + hir::ModuleDef::Static(s) => { + let (file_id, node) = s.source(db); + return Some(NavigationTarget::from_named( + file_id.original_file(db), + &*node, + )); + } hir::ModuleDef::Enum(e) => { let (file_id, node) = e.source(db); return Some(NavigationTarget::from_named( @@ -146,14 +160,6 @@ impl NavigationTarget { let (file_id, node) = f.source(db); NavigationTarget::from_named(file_id.original_file(db), &*node) } - Def::Static(f) => { - let (file_id, node) = f.source(db); - NavigationTarget::from_named(file_id.original_file(db), &*node) - } - Def::Const(f) => { - let (file_id, node) = f.source(db); - NavigationTarget::from_named(file_id.original_file(db), &*node) - } Def::Item => return None, }; Some(res) -- cgit v1.2.3