diff options
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting.rs')
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting.rs | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index ab45c364a..bbcd52a1c 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs | |||
@@ -160,23 +160,25 @@ pub(crate) fn highlight( | |||
160 | // Check if macro takes a format string and remember it for highlighting later. | 160 | // Check if macro takes a format string and remember it for highlighting later. |
161 | // The macros that accept a format string expand to a compiler builtin macros | 161 | // The macros that accept a format string expand to a compiler builtin macros |
162 | // `format_args` and `format_args_nl`. | 162 | // `format_args` and `format_args_nl`. |
163 | if let Some(fmt_macro_call) = parent.parent().and_then(ast::MacroCall::cast) { | 163 | if let Some(name) = parent |
164 | if let Some(name) = | 164 | .parent() |
165 | fmt_macro_call.path().and_then(|p| p.segment()).and_then(|s| s.name_ref()) | 165 | .and_then(ast::MacroCall::cast) |
166 | { | 166 | .and_then(|mc| mc.path()) |
167 | match name.text().as_str() { | 167 | .and_then(|p| p.segment()) |
168 | "format_args" | "format_args_nl" => { | 168 | .and_then(|s| s.name_ref()) |
169 | format_string = parent | 169 | { |
170 | .children_with_tokens() | 170 | match name.text().as_str() { |
171 | .filter(|t| t.kind() != WHITESPACE) | 171 | "format_args" | "format_args_nl" => { |
172 | .nth(1) | 172 | format_string = parent |
173 | .filter(|e| { | 173 | .children_with_tokens() |
174 | ast::String::can_cast(e.kind()) | 174 | .filter(|t| t.kind() != WHITESPACE) |
175 | || ast::RawString::can_cast(e.kind()) | 175 | .nth(1) |
176 | }) | 176 | .filter(|e| { |
177 | } | 177 | ast::String::can_cast(e.kind()) |
178 | _ => {} | 178 | || ast::RawString::can_cast(e.kind()) |
179 | }) | ||
179 | } | 180 | } |
181 | _ => {} | ||
180 | } | 182 | } |
181 | } | 183 | } |
182 | 184 | ||
@@ -493,6 +495,9 @@ fn highlight_element( | |||
493 | h |= HighlightModifier::Unsafe; | 495 | h |= HighlightModifier::Unsafe; |
494 | h | 496 | h |
495 | } | 497 | } |
498 | T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => { | ||
499 | Highlight::new(HighlightTag::Macro) | ||
500 | } | ||
496 | 501 | ||
497 | k if k.is_keyword() => { | 502 | k if k.is_keyword() => { |
498 | let h = Highlight::new(HighlightTag::Keyword); | 503 | let h = Highlight::new(HighlightTag::Keyword); |