aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_analysis/src/syntax_highlighting.rs4
-rw-r--r--crates/ra_editor/src/lib.rs6
2 files changed, 5 insertions, 5 deletions
diff --git a/crates/ra_analysis/src/syntax_highlighting.rs b/crates/ra_analysis/src/syntax_highlighting.rs
index 38219da71..7e9139a74 100644
--- a/crates/ra_analysis/src/syntax_highlighting.rs
+++ b/crates/ra_analysis/src/syntax_highlighting.rs
@@ -9,14 +9,14 @@ use crate::{
9 9
10pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> { 10pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> {
11 let source_file = db.source_file(file_id); 11 let source_file = db.source_file(file_id);
12 let mut res = ra_editor::highlight(&source_file); 12 let mut res = ra_editor::highlight(source_file.syntax());
13 for macro_call in source_file 13 for macro_call in source_file
14 .syntax() 14 .syntax()
15 .descendants() 15 .descendants()
16 .filter_map(ast::MacroCall::cast) 16 .filter_map(ast::MacroCall::cast)
17 { 17 {
18 if let Some(exp) = crate::macros::expand(db, file_id, macro_call) { 18 if let Some(exp) = crate::macros::expand(db, file_id, macro_call) {
19 let mapped_ranges = ra_editor::highlight(exp.source_file()) 19 let mapped_ranges = ra_editor::highlight(exp.source_file().syntax())
20 .into_iter() 20 .into_iter()
21 .filter_map(|r| { 21 .filter_map(|r| {
22 let mapped_range = exp.map_range_back(r.range)?; 22 let mapped_range = exp.map_range_back(r.range)?;
diff --git a/crates/ra_editor/src/lib.rs b/crates/ra_editor/src/lib.rs
index a65637d52..a293fec34 100644
--- a/crates/ra_editor/src/lib.rs
+++ b/crates/ra_editor/src/lib.rs
@@ -79,11 +79,11 @@ pub fn matching_brace(file: &SourceFileNode, offset: TextUnit) -> Option<TextUni
79 Some(matching_node.range().start()) 79 Some(matching_node.range().start())
80} 80}
81 81
82pub fn highlight(file: &SourceFileNode) -> Vec<HighlightedRange> { 82pub fn highlight(root: SyntaxNodeRef) -> Vec<HighlightedRange> {
83 // Visited nodes to handle highlighting priorities 83 // Visited nodes to handle highlighting priorities
84 let mut highlighted = FxHashSet::default(); 84 let mut highlighted = FxHashSet::default();
85 let mut res = Vec::new(); 85 let mut res = Vec::new();
86 for node in file.syntax().descendants() { 86 for node in root.descendants() {
87 if highlighted.contains(&node) { 87 if highlighted.contains(&node) {
88 continue; 88 continue;
89 } 89 }
@@ -178,7 +178,7 @@ fn main() {}
178 println!("Hello, {}!", 92); 178 println!("Hello, {}!", 92);
179"#, 179"#,
180 ); 180 );
181 let hls = highlight(&file); 181 let hls = highlight(file.syntax());
182 assert_eq_dbg( 182 assert_eq_dbg(
183 r#"[HighlightedRange { range: [1; 11), tag: "comment" }, 183 r#"[HighlightedRange { range: [1; 11), tag: "comment" },
184 HighlightedRange { range: [12; 14), tag: "keyword" }, 184 HighlightedRange { range: [12; 14), tag: "keyword" },