aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_editor/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-12-31 16:06:00 +0000
committerAleksey Kladov <[email protected]>2018-12-31 16:06:00 +0000
commit862c99d0d5ef7c791a9319fa76c436762d88460c (patch)
tree8430cf52c1d20f32b675274422c3fa97dab841b0 /crates/ra_editor/src
parentf1e8ebfbeb5f84405fb609e3841df02e270037c4 (diff)
generalize highlighting to work with nodes
Diffstat (limited to 'crates/ra_editor/src')
-rw-r--r--crates/ra_editor/src/lib.rs6
1 files changed, 3 insertions, 3 deletions
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" },