diff options
Diffstat (limited to 'crates/ra_ide_api/src/syntax_highlighting.rs')
-rw-r--r-- | crates/ra_ide_api/src/syntax_highlighting.rs | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs index 6c4391e1e..a435fe56e 100644 --- a/crates/ra_ide_api/src/syntax_highlighting.rs +++ b/crates/ra_ide_api/src/syntax_highlighting.rs | |||
@@ -9,20 +9,12 @@ use crate::{ | |||
9 | pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRange> { | 9 | pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRange> { |
10 | let source_file = db.parse(file_id); | 10 | let source_file = db.parse(file_id); |
11 | let mut res = ra_ide_api_light::highlight(source_file.syntax()); | 11 | let mut res = ra_ide_api_light::highlight(source_file.syntax()); |
12 | for macro_call in source_file | 12 | for macro_call in source_file.syntax().descendants().filter_map(ast::MacroCall::cast) { |
13 | .syntax() | ||
14 | .descendants() | ||
15 | .filter_map(ast::MacroCall::cast) | ||
16 | { | ||
17 | if let Some((off, exp)) = hir::MacroDef::ast_expand(macro_call) { | 13 | if let Some((off, exp)) = hir::MacroDef::ast_expand(macro_call) { |
18 | let mapped_ranges = ra_ide_api_light::highlight(&exp.syntax()) | 14 | let mapped_ranges = |
19 | .into_iter() | 15 | ra_ide_api_light::highlight(&exp.syntax()).into_iter().filter_map(|r| { |
20 | .filter_map(|r| { | ||
21 | let mapped_range = exp.map_range_back(r.range)?; | 16 | let mapped_range = exp.map_range_back(r.range)?; |
22 | let res = HighlightedRange { | 17 | let res = HighlightedRange { range: mapped_range + off, tag: r.tag }; |
23 | range: mapped_range + off, | ||
24 | tag: r.tag, | ||
25 | }; | ||
26 | Some(res) | 18 | Some(res) |
27 | }); | 19 | }); |
28 | res.extend(mapped_ranges); | 20 | res.extend(mapped_ranges); |