From 5d54aa678153d0af0edc8b4dd2d74709d10ca66c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 23 May 2019 20:18:47 +0300 Subject: add union to code_model --- crates/ra_ide_api/src/completion/complete_struct_literal.rs | 1 + crates/ra_ide_api/src/completion/presentation.rs | 1 + crates/ra_ide_api/src/display/navigation_target.rs | 8 ++++++++ crates/ra_ide_api/src/syntax_highlighting.rs | 1 + 4 files changed, 11 insertions(+) (limited to 'crates/ra_ide_api') diff --git a/crates/ra_ide_api/src/completion/complete_struct_literal.rs b/crates/ra_ide_api/src/completion/complete_struct_literal.rs index 48fbf67f7..a00c1b60b 100644 --- a/crates/ra_ide_api/src/completion/complete_struct_literal.rs +++ b/crates/ra_ide_api/src/completion/complete_struct_literal.rs @@ -20,6 +20,7 @@ pub(super) fn complete_struct_literal(acc: &mut Completions, ctx: &CompletionCon } // FIXME unions + AdtDef::Union(_) => (), AdtDef::Enum(_) => (), }; } diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index 9aa346688..064d379a4 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs @@ -63,6 +63,7 @@ impl Completions { return self.add_function_with_name(ctx, Some(local_name), *func); } Resolution::Def(Struct(it)) => (CompletionItemKind::Struct, it.docs(ctx.db)), + Resolution::Def(Union(it)) => (CompletionItemKind::Struct, it.docs(ctx.db)), Resolution::Def(Enum(it)) => (CompletionItemKind::Enum, it.docs(ctx.db)), Resolution::Def(EnumVariant(it)) => (CompletionItemKind::EnumVariant, it.docs(ctx.db)), Resolution::Def(Const(it)) => (CompletionItemKind::Const, it.docs(ctx.db)), diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs index 1c694cbc9..7f81483f7 100644 --- a/crates/ra_ide_api/src/display/navigation_target.rs +++ b/crates/ra_ide_api/src/display/navigation_target.rs @@ -154,6 +154,10 @@ impl NavigationTarget { let (file_id, node) = s.source(db); NavigationTarget::from_named(file_id.original_file(db), &*node) } + hir::AdtDef::Union(s) => { + let (file_id, node) = s.source(db); + NavigationTarget::from_named(file_id.original_file(db), &*node) + } hir::AdtDef::Enum(s) => { let (file_id, node) = s.source(db); NavigationTarget::from_named(file_id.original_file(db), &*node) @@ -169,6 +173,10 @@ impl NavigationTarget { let (file_id, node) = s.source(db); NavigationTarget::from_named(file_id.original_file(db), &*node) } + hir::ModuleDef::Union(s) => { + let (file_id, node) = s.source(db); + NavigationTarget::from_named(file_id.original_file(db), &*node) + } hir::ModuleDef::Const(s) => { let (file_id, node) = s.source(db); NavigationTarget::from_named(file_id.original_file(db), &*node) diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs index 89f20260f..77c9ae3b1 100644 --- a/crates/ra_ide_api/src/syntax_highlighting.rs +++ b/crates/ra_ide_api/src/syntax_highlighting.rs @@ -57,6 +57,7 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec "module", Some(Def(ModuleDef::Function(_))) => "function", Some(Def(ModuleDef::Struct(_))) => "type", + Some(Def(ModuleDef::Union(_))) => "type", Some(Def(ModuleDef::Enum(_))) => "type", Some(Def(ModuleDef::EnumVariant(_))) => "constant", Some(Def(ModuleDef::Const(_))) => "constant", -- cgit v1.2.3