diff options
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting.rs')
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting.rs | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index be57eeb0a..8a995d779 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs | |||
@@ -361,7 +361,9 @@ fn highlight_element( | |||
361 | } | 361 | } |
362 | 362 | ||
363 | // Highlight references like the definitions they resolve to | 363 | // Highlight references like the definitions they resolve to |
364 | NAME_REF if element.ancestors().any(|it| it.kind() == ATTR) => return None, | 364 | NAME_REF if element.ancestors().any(|it| it.kind() == ATTR) => { |
365 | Highlight::from(HighlightTag::Function) | HighlightModifier::Attribute | ||
366 | } | ||
365 | NAME_REF => { | 367 | NAME_REF => { |
366 | let name_ref = element.into_node().and_then(ast::NameRef::cast).unwrap(); | 368 | let name_ref = element.into_node().and_then(ast::NameRef::cast).unwrap(); |
367 | match classify_name_ref(sema, &name_ref) { | 369 | match classify_name_ref(sema, &name_ref) { |
@@ -411,6 +413,8 @@ fn highlight_element( | |||
411 | | T![in] => h | HighlightModifier::ControlFlow, | 413 | | T![in] => h | HighlightModifier::ControlFlow, |
412 | T![for] if !is_child_of_impl(element) => h | HighlightModifier::ControlFlow, | 414 | T![for] if !is_child_of_impl(element) => h | HighlightModifier::ControlFlow, |
413 | T![unsafe] => h | HighlightModifier::Unsafe, | 415 | T![unsafe] => h | HighlightModifier::Unsafe, |
416 | T![true] | T![false] => HighlightTag::BoolLiteral.into(), | ||
417 | T![self] => HighlightTag::SelfKeyword.into(), | ||
414 | _ => h, | 418 | _ => h, |
415 | } | 419 | } |
416 | } | 420 | } |
@@ -478,23 +482,31 @@ fn highlight_name(db: &RootDatabase, def: Definition) -> Highlight { | |||
478 | } | 482 | } |
479 | 483 | ||
480 | fn highlight_name_by_syntax(name: ast::Name) -> Highlight { | 484 | fn highlight_name_by_syntax(name: ast::Name) -> Highlight { |
481 | let default = HighlightTag::Function.into(); | 485 | let default = HighlightTag::UnresolvedReference; |
482 | 486 | ||
483 | let parent = match name.syntax().parent() { | 487 | let parent = match name.syntax().parent() { |
484 | Some(it) => it, | 488 | Some(it) => it, |
485 | _ => return default, | 489 | _ => return default.into(), |
486 | }; | 490 | }; |
487 | 491 | ||
488 | match parent.kind() { | 492 | let tag = match parent.kind() { |
489 | STRUCT_DEF => HighlightTag::Struct.into(), | 493 | STRUCT_DEF => HighlightTag::Struct, |
490 | ENUM_DEF => HighlightTag::Enum.into(), | 494 | ENUM_DEF => HighlightTag::Enum, |
491 | UNION_DEF => HighlightTag::Union.into(), | 495 | UNION_DEF => HighlightTag::Union, |
492 | TRAIT_DEF => HighlightTag::Trait.into(), | 496 | TRAIT_DEF => HighlightTag::Trait, |
493 | TYPE_ALIAS_DEF => HighlightTag::TypeAlias.into(), | 497 | TYPE_ALIAS_DEF => HighlightTag::TypeAlias, |
494 | TYPE_PARAM => HighlightTag::TypeParam.into(), | 498 | TYPE_PARAM => HighlightTag::TypeParam, |
495 | RECORD_FIELD_DEF => HighlightTag::Field.into(), | 499 | RECORD_FIELD_DEF => HighlightTag::Field, |
500 | MODULE => HighlightTag::Module, | ||
501 | FN_DEF => HighlightTag::Function, | ||
502 | CONST_DEF => HighlightTag::Constant, | ||
503 | STATIC_DEF => HighlightTag::Static, | ||
504 | ENUM_VARIANT => HighlightTag::EnumVariant, | ||
505 | BIND_PAT => HighlightTag::Local, | ||
496 | _ => default, | 506 | _ => default, |
497 | } | 507 | }; |
508 | |||
509 | tag.into() | ||
498 | } | 510 | } |
499 | 511 | ||
500 | fn highlight_injection( | 512 | fn highlight_injection( |