diff options
Diffstat (limited to 'crates/ra_ide_api/src/syntax_highlighting.rs')
-rw-r--r-- | crates/ra_ide_api/src/syntax_highlighting.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs index a0c5e78ad..d9a28d2b5 100644 --- a/crates/ra_ide_api/src/syntax_highlighting.rs +++ b/crates/ra_ide_api/src/syntax_highlighting.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use rustc_hash::FxHashSet; | 1 | use rustc_hash::FxHashSet; |
2 | 2 | ||
3 | use ra_syntax::{ast, AstNode, TextRange, Direction, SyntaxKind::*}; | 3 | use ra_syntax::{ast, AstNode, TextRange, Direction, SyntaxKind::*, SyntaxElement}; |
4 | use ra_db::SourceDatabase; | 4 | use ra_db::SourceDatabase; |
5 | 5 | ||
6 | use crate::{FileId, db::RootDatabase}; | 6 | use crate::{FileId, db::RootDatabase}; |
@@ -15,9 +15,9 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa | |||
15 | let source_file = db.parse(file_id); | 15 | let source_file = db.parse(file_id); |
16 | 16 | ||
17 | // Visited nodes to handle highlighting priorities | 17 | // Visited nodes to handle highlighting priorities |
18 | let mut highlighted = FxHashSet::default(); | 18 | let mut highlighted: FxHashSet<SyntaxElement> = FxHashSet::default(); |
19 | let mut res = Vec::new(); | 19 | let mut res = Vec::new(); |
20 | for node in source_file.syntax().descendants() { | 20 | for node in source_file.syntax().descendants_with_tokens() { |
21 | if highlighted.contains(&node) { | 21 | if highlighted.contains(&node) { |
22 | continue; | 22 | continue; |
23 | } | 23 | } |
@@ -31,14 +31,14 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa | |||
31 | LIFETIME => "parameter", | 31 | LIFETIME => "parameter", |
32 | k if k.is_keyword() => "keyword", | 32 | k if k.is_keyword() => "keyword", |
33 | _ => { | 33 | _ => { |
34 | if let Some(macro_call) = ast::MacroCall::cast(node) { | 34 | if let Some(macro_call) = node.as_node().and_then(ast::MacroCall::cast) { |
35 | if let Some(path) = macro_call.path() { | 35 | if let Some(path) = macro_call.path() { |
36 | if let Some(segment) = path.segment() { | 36 | if let Some(segment) = path.segment() { |
37 | if let Some(name_ref) = segment.name_ref() { | 37 | if let Some(name_ref) = segment.name_ref() { |
38 | highlighted.insert(name_ref.syntax()); | 38 | highlighted.insert(name_ref.syntax().into()); |
39 | let range_start = name_ref.syntax().range().start(); | 39 | let range_start = name_ref.syntax().range().start(); |
40 | let mut range_end = name_ref.syntax().range().end(); | 40 | let mut range_end = name_ref.syntax().range().end(); |
41 | for sibling in path.syntax().siblings(Direction::Next) { | 41 | for sibling in path.syntax().siblings_with_tokens(Direction::Next) { |
42 | match sibling.kind() { | 42 | match sibling.kind() { |
43 | EXCL | IDENT => range_end = sibling.range().end(), | 43 | EXCL | IDENT => range_end = sibling.range().end(), |
44 | _ => (), | 44 | _ => (), |