From 6a5a1f590201ba962a1f77ce1a7ff5870712728d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 24 Jan 2019 23:36:16 +0300 Subject: adapt ide_api to the new API --- crates/ra_ide_api/src/completion/complete_path.rs | 5 ++++- crates/ra_ide_api/src/completion/completion_item.rs | 1 + crates/ra_ide_api/src/navigation_target.rs | 11 +++++++---- 3 files changed, 12 insertions(+), 5 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 e039a333c..4768efdc1 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs @@ -40,7 +40,10 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { .add_to(acc) }); } - hir::ModuleDef::Function(_) | hir::ModuleDef::Struct(_) | hir::ModuleDef::Def(_) => return, + hir::ModuleDef::Function(_) + | hir::ModuleDef::Struct(_) + | hir::ModuleDef::Def(_) + | 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 f2301653a..ee1f8bce0 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs @@ -222,6 +222,7 @@ impl Builder { hir::ModuleDef::Function(func) => return self.from_function(ctx, func), 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::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)), diff --git a/crates/ra_ide_api/src/navigation_target.rs b/crates/ra_ide_api/src/navigation_target.rs index b92670f36..fc76338d2 100644 --- a/crates/ra_ide_api/src/navigation_target.rs +++ b/crates/ra_ide_api/src/navigation_target.rs @@ -128,13 +128,16 @@ impl NavigationTarget { &*node, )); } + hir::ModuleDef::EnumVariant(var) => { + let (file_id, node) = var.source(db); + return Some(NavigationTarget::from_named( + file_id.original_file(db), + &*node, + )); + } }; let res = match def { - Def::EnumVariant(ev) => { - let (file_id, node) = ev.source(db); - NavigationTarget::from_named(file_id.original_file(db), &*node) - } Def::Trait(f) => { let (file_id, node) = f.source(db); NavigationTarget::from_named(file_id.original_file(db), &*node) -- cgit v1.2.3