Tag yield and await as ControlFlow in semantic highlighting

This commit is contained in:
Lukas Wirth 2021-04-23 16:43:48 +02:00
parent 85bab7539a
commit c005ce60a0
2 changed files with 13 additions and 5 deletions

View File

@ -254,15 +254,17 @@ pub(super) fn element(
k if k.is_keyword() => { k if k.is_keyword() => {
let h = Highlight::new(HlTag::Keyword); let h = Highlight::new(HlTag::Keyword);
match k { match k {
T![break] T![await]
| T![break]
| T![continue] | T![continue]
| T![else] | T![else]
| T![if] | T![if]
| T![in]
| T![loop] | T![loop]
| T![match] | T![match]
| T![return] | T![return]
| T![while] | T![while]
| T![in] => h | HlMod::ControlFlow, | T![yield] => h | HlMod::ControlFlow,
T![for] if !is_child_of_impl(&element) => h | HlMod::ControlFlow, T![for] if !is_child_of_impl(&element) => h | HlMod::ControlFlow,
T![unsafe] => h | HlMod::Unsafe, T![unsafe] => h | HlMod::Unsafe,
T![true] | T![false] => HlTag::BoolLiteral.into(), T![true] | T![false] => HlTag::BoolLiteral.into(),

View File

@ -47,21 +47,27 @@ pub enum HlMod {
/// `foo` in `fn foo(x: i32)` is a definition, `foo` in `foo(90 + 2)` is /// `foo` in `fn foo(x: i32)` is a definition, `foo` in `foo(90 + 2)` is
/// not. /// not.
Definition, Definition,
/// Doc-strings like this one.
Documentation, Documentation,
/// Highlighting injection like rust code in doc strings or ra_fixture.
Injected, Injected,
/// Mutable binding.
Mutable, Mutable,
/// Value that is being consumed in a function call
Consuming, Consuming,
/// Callable item or value.
Callable, Callable,
/// Used for associated functions /// Used for associated functions.
Static, Static,
/// Used for items in impls&traits. /// Used for items in traits and impls.
Associated, Associated,
/// Used for intra doc links in doc injection. /// Used for intra doc links in doc injection.
IntraDocLink, IntraDocLink,
/// Used for items in traits and trait impls. /// Used for items in traits and trait impls.
Trait, Trait,
/// Keep this last! // Keep this last!
/// Used for unsafe functions, mutable statics, union accesses and unsafe operations.
Unsafe, Unsafe,
} }