diff options
author | Aleksey Kladov <[email protected]> | 2021-01-09 12:18:49 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-01-09 12:38:32 +0000 |
commit | d4fb7476efc8bf956c56ba2b0e946f48f38a6efc (patch) | |
tree | 43f190a26a4a8ed68fa28bbd234ca977a2f6dd6a /crates/ide/src/syntax_highlighting.rs | |
parent | 8a0bd500363fd2953c2a469083b00be54c602ebb (diff) |
Better names
Diffstat (limited to 'crates/ide/src/syntax_highlighting.rs')
-rw-r--r-- | crates/ide/src/syntax_highlighting.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs index 8bb7acb82..3ba91b3f5 100644 --- a/crates/ide/src/syntax_highlighting.rs +++ b/crates/ide/src/syntax_highlighting.rs | |||
@@ -74,7 +74,7 @@ pub(crate) fn highlight( | |||
74 | }; | 74 | }; |
75 | 75 | ||
76 | let mut bindings_shadow_count: FxHashMap<Name, u32> = FxHashMap::default(); | 76 | let mut bindings_shadow_count: FxHashMap<Name, u32> = FxHashMap::default(); |
77 | let mut stack = highlights::Highlights::new(range_to_highlight); | 77 | let mut hl = highlights::Highlights::new(range_to_highlight); |
78 | 78 | ||
79 | let mut current_macro_call: Option<ast::MacroCall> = None; | 79 | let mut current_macro_call: Option<ast::MacroCall> = None; |
80 | let mut current_macro_rules: Option<ast::MacroRules> = None; | 80 | let mut current_macro_rules: Option<ast::MacroRules> = None; |
@@ -98,7 +98,7 @@ pub(crate) fn highlight( | |||
98 | match event.clone().map(|it| it.into_node().and_then(ast::MacroCall::cast)) { | 98 | match event.clone().map(|it| it.into_node().and_then(ast::MacroCall::cast)) { |
99 | WalkEvent::Enter(Some(mc)) => { | 99 | WalkEvent::Enter(Some(mc)) => { |
100 | if let Some(range) = macro_call_range(&mc) { | 100 | if let Some(range) = macro_call_range(&mc) { |
101 | stack.add(HlRange { | 101 | hl.add(HlRange { |
102 | range, | 102 | range, |
103 | highlight: HlTag::Symbol(SymbolKind::Macro).into(), | 103 | highlight: HlTag::Symbol(SymbolKind::Macro).into(), |
104 | binding_hash: None, | 104 | binding_hash: None, |
@@ -136,7 +136,7 @@ pub(crate) fn highlight( | |||
136 | inside_attribute = false | 136 | inside_attribute = false |
137 | } | 137 | } |
138 | if let Some((new_comments, inj)) = injection::extract_doc_comments(node) { | 138 | if let Some((new_comments, inj)) = injection::extract_doc_comments(node) { |
139 | injection::highlight_doc_comment(new_comments, inj, &mut stack); | 139 | injection::highlight_doc_comment(new_comments, inj, &mut hl); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | WalkEvent::Enter(NodeOrToken::Node(node)) if ast::Attr::can_cast(node.kind()) => { | 142 | WalkEvent::Enter(NodeOrToken::Node(node)) if ast::Attr::can_cast(node.kind()) => { |
@@ -181,7 +181,7 @@ pub(crate) fn highlight( | |||
181 | if let Some(token) = element.as_token().cloned().and_then(ast::String::cast) { | 181 | if let Some(token) = element.as_token().cloned().and_then(ast::String::cast) { |
182 | if token.is_raw() { | 182 | if token.is_raw() { |
183 | let expanded = element_to_highlight.as_token().unwrap().clone(); | 183 | let expanded = element_to_highlight.as_token().unwrap().clone(); |
184 | if injection::highlight_injection(&mut stack, &sema, token, expanded).is_some() { | 184 | if injection::highlight_injection(&mut hl, &sema, token, expanded).is_some() { |
185 | continue; | 185 | continue; |
186 | } | 186 | } |
187 | } | 187 | } |
@@ -198,18 +198,18 @@ pub(crate) fn highlight( | |||
198 | } | 198 | } |
199 | 199 | ||
200 | if macro_rules_highlighter.highlight(element_to_highlight.clone()).is_none() { | 200 | if macro_rules_highlighter.highlight(element_to_highlight.clone()).is_none() { |
201 | stack.add(HlRange { range, highlight, binding_hash }); | 201 | hl.add(HlRange { range, highlight, binding_hash }); |
202 | } | 202 | } |
203 | 203 | ||
204 | if let Some(string) = | 204 | if let Some(string) = |
205 | element_to_highlight.as_token().cloned().and_then(ast::String::cast) | 205 | element_to_highlight.as_token().cloned().and_then(ast::String::cast) |
206 | { | 206 | { |
207 | format_string_highlighter.highlight_format_string(&mut stack, &string, range); | 207 | format_string_highlighter.highlight_format_string(&mut hl, &string, range); |
208 | // Highlight escape sequences | 208 | // Highlight escape sequences |
209 | if let Some(char_ranges) = string.char_ranges() { | 209 | if let Some(char_ranges) = string.char_ranges() { |
210 | for (piece_range, _) in char_ranges.iter().filter(|(_, char)| char.is_ok()) { | 210 | for (piece_range, _) in char_ranges.iter().filter(|(_, char)| char.is_ok()) { |
211 | if string.text()[piece_range.start().into()..].starts_with('\\') { | 211 | if string.text()[piece_range.start().into()..].starts_with('\\') { |
212 | stack.add(HlRange { | 212 | hl.add(HlRange { |
213 | range: piece_range + range.start(), | 213 | range: piece_range + range.start(), |
214 | highlight: HlTag::EscapeSequence.into(), | 214 | highlight: HlTag::EscapeSequence.into(), |
215 | binding_hash: None, | 215 | binding_hash: None, |
@@ -221,7 +221,7 @@ pub(crate) fn highlight( | |||
221 | } | 221 | } |
222 | } | 222 | } |
223 | 223 | ||
224 | stack.to_vec() | 224 | hl.to_vec() |
225 | } | 225 | } |
226 | 226 | ||
227 | fn macro_call_range(macro_call: &ast::MacroCall) -> Option<TextRange> { | 227 | fn macro_call_range(macro_call: &ast::MacroCall) -> Option<TextRange> { |