mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Simplify highlighting infra
This also fixes the killer whale bug
This commit is contained in:
parent
981a0d708e
commit
e30c1c3fbf
11 changed files with 287 additions and 276 deletions
|
@ -4,9 +4,9 @@ use syntax::{
|
|||
AstNode, AstToken, SyntaxElement, SyntaxKind, SyntaxNode, TextRange,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
syntax_highlighting::HighlightedRangeStack, HighlightTag, HighlightedRange, SymbolKind,
|
||||
};
|
||||
use crate::{HighlightTag, HighlightedRange, SymbolKind};
|
||||
|
||||
use super::highlights::Highlights;
|
||||
|
||||
#[derive(Default)]
|
||||
pub(super) struct FormatStringHighlighter {
|
||||
|
@ -39,22 +39,20 @@ impl FormatStringHighlighter {
|
|||
}
|
||||
pub(super) fn highlight_format_string(
|
||||
&self,
|
||||
range_stack: &mut HighlightedRangeStack,
|
||||
stack: &mut Highlights,
|
||||
string: &impl HasFormatSpecifier,
|
||||
range: TextRange,
|
||||
) {
|
||||
if self.format_string.as_ref() == Some(&SyntaxElement::from(string.syntax().clone())) {
|
||||
range_stack.push();
|
||||
string.lex_format_specifier(|piece_range, kind| {
|
||||
if let Some(highlight) = highlight_format_specifier(kind) {
|
||||
range_stack.add(HighlightedRange {
|
||||
stack.add(HighlightedRange {
|
||||
range: piece_range + range.start(),
|
||||
highlight: highlight.into(),
|
||||
binding_hash: None,
|
||||
});
|
||||
}
|
||||
});
|
||||
range_stack.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue