aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/syntax_highlighting.rs
diff options
context:
space:
mode:
authorGeorge Fraser <[email protected]>2020-05-10 19:26:19 +0100
committerGeorge Fraser <[email protected]>2020-05-10 21:11:14 +0100
commit63b75a40c8c9e1f24fbd21c423f62f303281b77c (patch)
treebef6f11c4190be0f0bfd27365630d701ea51bc55 /crates/ra_ide/src/syntax_highlighting.rs
parent3f1c73633eb3e5d8a2df3a72dc772087cfb18be4 (diff)
Color `for` as a regular keyword when it's part of impl _ for _
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting.rs')
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 16123c5cb..be57eeb0a 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -403,13 +403,13 @@ fn highlight_element(
403 T![break] 403 T![break]
404 | T![continue] 404 | T![continue]
405 | T![else] 405 | T![else]
406 | T![for]
407 | T![if] 406 | T![if]
408 | T![loop] 407 | T![loop]
409 | T![match] 408 | T![match]
410 | T![return] 409 | T![return]
411 | T![while] 410 | T![while]
412 | T![in] => h | HighlightModifier::ControlFlow, 411 | T![in] => h | HighlightModifier::ControlFlow,
412 T![for] if !is_child_of_impl(element) => h | HighlightModifier::ControlFlow,
413 T![unsafe] => h | HighlightModifier::Unsafe, 413 T![unsafe] => h | HighlightModifier::Unsafe,
414 _ => h, 414 _ => h,
415 } 415 }
@@ -433,6 +433,13 @@ fn highlight_element(
433 } 433 }
434} 434}
435 435
436fn is_child_of_impl(element: SyntaxElement) -> bool {
437 match element.parent() {
438 Some(e) => e.kind() == IMPL_DEF,
439 _ => false,
440 }
441}
442
436fn highlight_name(db: &RootDatabase, def: Definition) -> Highlight { 443fn highlight_name(db: &RootDatabase, def: Definition) -> Highlight {
437 match def { 444 match def {
438 Definition::Macro(_) => HighlightTag::Macro, 445 Definition::Macro(_) => HighlightTag::Macro,