From c005ce60a048a5df79b93ce45911ab0c6952a41b Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 23 Apr 2021 16:43:48 +0200 Subject: Tag `yield` and `await` as ControlFlow in semantic highlighting --- crates/ide/src/syntax_highlighting/highlight.rs | 6 ++++-- crates/ide/src/syntax_highlighting/tags.rs | 12 +++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'crates/ide/src/syntax_highlighting') diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs index 18552459b..62213dc47 100644 --- a/crates/ide/src/syntax_highlighting/highlight.rs +++ b/crates/ide/src/syntax_highlighting/highlight.rs @@ -254,15 +254,17 @@ pub(super) fn element( k if k.is_keyword() => { let h = Highlight::new(HlTag::Keyword); match k { - T![break] + T![await] + | T![break] | T![continue] | T![else] | T![if] + | T![in] | T![loop] | T![match] | T![return] | T![while] - | T![in] => h | HlMod::ControlFlow, + | T![yield] => h | HlMod::ControlFlow, T![for] if !is_child_of_impl(&element) => h | HlMod::ControlFlow, T![unsafe] => h | HlMod::Unsafe, T![true] | T![false] => HlTag::BoolLiteral.into(), diff --git a/crates/ide/src/syntax_highlighting/tags.rs b/crates/ide/src/syntax_highlighting/tags.rs index e58392d67..336af3f4c 100644 --- a/crates/ide/src/syntax_highlighting/tags.rs +++ b/crates/ide/src/syntax_highlighting/tags.rs @@ -47,21 +47,27 @@ pub enum HlMod { /// `foo` in `fn foo(x: i32)` is a definition, `foo` in `foo(90 + 2)` is /// not. Definition, + /// Doc-strings like this one. Documentation, + /// Highlighting injection like rust code in doc strings or ra_fixture. Injected, + /// Mutable binding. Mutable, + /// Value that is being consumed in a function call Consuming, + /// Callable item or value. Callable, - /// Used for associated functions + /// Used for associated functions. Static, - /// Used for items in impls&traits. + /// Used for items in traits and impls. Associated, /// Used for intra doc links in doc injection. IntraDocLink, /// Used for items in traits and trait impls. Trait, - /// Keep this last! + // Keep this last! + /// Used for unsafe functions, mutable statics, union accesses and unsafe operations. Unsafe, } -- cgit v1.2.3