aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorMatthew Jasper <[email protected]>2020-05-21 17:44:45 +0100
committerMatthew Jasper <[email protected]>2020-05-24 15:12:17 +0100
commit1895888aec1c87096809057b19a602e1cec9ada6 (patch)
tree0bee9dbb6794748dc3aebce59292cbf466010af2 /crates
parente2d36cb692f042f2051a8a88d271a297a3d333a4 (diff)
Handle more cases in `highlight_name_by_syntax`
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs30
1 files changed, 19 insertions, 11 deletions
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 {
481} 481}
482 482
483fn highlight_name_by_syntax(name: ast::Name) -> Highlight { 483fn highlight_name_by_syntax(name: ast::Name) -> Highlight {
484 let default = HighlightTag::Function.into(); 484 let default = HighlightTag::UnresolvedReference;
485 485
486 let parent = match name.syntax().parent() { 486 let parent = match name.syntax().parent() {
487 Some(it) => it, 487 Some(it) => it,
488 _ => return default, 488 _ => return default.into(),
489 }; 489 };
490 490
491 match parent.kind() { 491 let tag = match parent.kind() {
492 STRUCT_DEF => HighlightTag::Struct.into(), 492 STRUCT_DEF => HighlightTag::Struct,
493 ENUM_DEF => HighlightTag::Enum.into(), 493 ENUM_DEF => HighlightTag::Enum,
494 UNION_DEF => HighlightTag::Union.into(), 494 UNION_DEF => HighlightTag::Union,
495 TRAIT_DEF => HighlightTag::Trait.into(), 495 TRAIT_DEF => HighlightTag::Trait,
496 TYPE_ALIAS_DEF => HighlightTag::TypeAlias.into(), 496 TYPE_ALIAS_DEF => HighlightTag::TypeAlias,
497 TYPE_PARAM => HighlightTag::TypeParam.into(), 497 TYPE_PARAM => HighlightTag::TypeParam,
498 RECORD_FIELD_DEF => HighlightTag::Field.into(), 498 RECORD_FIELD_DEF => HighlightTag::Field,
499 MODULE => HighlightTag::Module,
500 FN_DEF => HighlightTag::Function,
501 CONST_DEF => HighlightTag::Constant,
502 STATIC_DEF => HighlightTag::Static,
503 ENUM_VARIANT => HighlightTag::EnumVariant,
504 BIND_PAT => HighlightTag::Local,
499 _ => default, 505 _ => default,
500 } 506 };
507
508 tag.into()
501} 509}
502 510
503fn highlight_injection( 511fn highlight_injection(