mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Merge #395
395: generalize r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
6044ec5057
5 changed files with 27 additions and 26 deletions
|
@ -67,11 +67,11 @@ pub fn matching_brace(file: &SourceFileNode, offset: TextUnit) -> Option<TextUni
|
|||
Some(matching_node.range().start())
|
||||
}
|
||||
|
||||
pub fn highlight(file: &SourceFileNode) -> Vec<HighlightedRange> {
|
||||
pub fn highlight(root: SyntaxNodeRef) -> Vec<HighlightedRange> {
|
||||
// Visited nodes to handle highlighting priorities
|
||||
let mut highlighted = FxHashSet::default();
|
||||
let mut res = Vec::new();
|
||||
for node in file.syntax().descendants() {
|
||||
for node in root.descendants() {
|
||||
if highlighted.contains(&node) {
|
||||
continue;
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ fn main() {}
|
|||
println!("Hello, {}!", 92);
|
||||
"#,
|
||||
);
|
||||
let hls = highlight(&file);
|
||||
let hls = highlight(file.syntax());
|
||||
assert_eq_dbg(
|
||||
r#"[HighlightedRange { range: [1; 11), tag: "comment" },
|
||||
HighlightedRange { range: [12; 14), tag: "keyword" },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue