From 1895888aec1c87096809057b19a602e1cec9ada6 Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Thu, 21 May 2020 17:44:45 +0100 Subject: Handle more cases in `highlight_name_by_syntax` --- crates/ra_ide/src/syntax_highlighting.rs | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 5f20fae80..61aeb28cb 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -481,23 +481,31 @@ fn highlight_name(db: &RootDatabase, def: Definition) -> Highlight { } fn highlight_name_by_syntax(name: ast::Name) -> Highlight { - let default = HighlightTag::Function.into(); + let default = HighlightTag::UnresolvedReference; let parent = match name.syntax().parent() { Some(it) => it, - _ => return default, + _ => return default.into(), }; - match parent.kind() { - STRUCT_DEF => HighlightTag::Struct.into(), - ENUM_DEF => HighlightTag::Enum.into(), - UNION_DEF => HighlightTag::Union.into(), - TRAIT_DEF => HighlightTag::Trait.into(), - TYPE_ALIAS_DEF => HighlightTag::TypeAlias.into(), - TYPE_PARAM => HighlightTag::TypeParam.into(), - RECORD_FIELD_DEF => HighlightTag::Field.into(), + let tag = match parent.kind() { + STRUCT_DEF => HighlightTag::Struct, + ENUM_DEF => HighlightTag::Enum, + UNION_DEF => HighlightTag::Union, + TRAIT_DEF => HighlightTag::Trait, + TYPE_ALIAS_DEF => HighlightTag::TypeAlias, + TYPE_PARAM => HighlightTag::TypeParam, + RECORD_FIELD_DEF => HighlightTag::Field, + MODULE => HighlightTag::Module, + FN_DEF => HighlightTag::Function, + CONST_DEF => HighlightTag::Constant, + STATIC_DEF => HighlightTag::Static, + ENUM_VARIANT => HighlightTag::EnumVariant, + BIND_PAT => HighlightTag::Local, _ => default, - } + }; + + tag.into() } fn highlight_injection( -- cgit v1.2.3