Highlight all occurrences of a constant name.
(
&self,
symbol_map: &SymbolMap,
content: &str,
target_name: &str,
)
| 317 | |
| 318 | /// Highlight all occurrences of a constant name. |
| 319 | fn highlight_constant( |
| 320 | &self, |
| 321 | symbol_map: &SymbolMap, |
| 322 | content: &str, |
| 323 | target_name: &str, |
| 324 | ) -> Vec<DocumentHighlight> { |
| 325 | let mut highlights = Vec::new(); |
| 326 | |
| 327 | for span in &symbol_map.spans { |
| 328 | if let SymbolKind::ConstantReference { name } = &span.kind |
| 329 | && name == target_name |
| 330 | { |
| 331 | highlights.push(DocumentHighlight { |
| 332 | range: byte_range_to_lsp_range(content, span.start as usize, span.end as usize), |
| 333 | kind: Some(DocumentHighlightKind::READ), |
| 334 | }); |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | highlights.sort_by(cmp_highlight_range); |
| 339 | highlights |
| 340 | } |
| 341 | |
| 342 | /// Highlight all occurrences of `self`, `static`, or `parent` within |
| 343 | /// the same class body. |
no test coverage detected