Skip to content

Commit 052e9fa

Browse files
committed
Introduce new semantic highlight token for format specifier
1 parent da1f316 commit 052e9fa

File tree

9 files changed

+48
-37
lines changed

9 files changed

+48
-37
lines changed

crates/ra_ide/src/snapshots/highlight_injection.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
.macro { color: #94BFF3; }
2121
.module { color: #AFD8AF; }
2222
.variable { color: #DCDCCC; }
23+
.format_specifier { color: #CC696B; }
2324
.mutable { text-decoration: underline; }
2425

2526
.keyword { color: #F0DFAF; font-weight: bold; }

crates/ra_ide/src/snapshots/highlight_strings.html

Lines changed: 36 additions & 35 deletions
Large diffs are not rendered by default.

crates/ra_ide/src/snapshots/highlighting.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
.macro { color: #94BFF3; }
2121
.module { color: #AFD8AF; }
2222
.variable { color: #DCDCCC; }
23+
.format_specifier { color: #CC696B; }
2324
.mutable { text-decoration: underline; }
2425

2526
.keyword { color: #F0DFAF; font-weight: bold; }

crates/ra_ide/src/snapshots/rainbow_highlighting.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
.macro { color: #94BFF3; }
2121
.module { color: #AFD8AF; }
2222
.variable { color: #DCDCCC; }
23+
.format_specifier { color: #CC696B; }
2324
.mutable { text-decoration: underline; }
2425

2526
.keyword { color: #F0DFAF; font-weight: bold; }

crates/ra_ide/src/syntax_highlighting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ fn highlight_format_specifier(kind: FormatSpecifier) -> Option<HighlightTag> {
290290
| FormatSpecifier::DollarSign
291291
| FormatSpecifier::Dot
292292
| FormatSpecifier::Asterisk
293-
| FormatSpecifier::QuestionMark => HighlightTag::Attribute,
293+
| FormatSpecifier::QuestionMark => HighlightTag::FormatSpecifier,
294294
FormatSpecifier::Integer | FormatSpecifier::Zero => HighlightTag::NumericLiteral,
295295
FormatSpecifier::Identifier => HighlightTag::Local,
296296
})

crates/ra_ide/src/syntax_highlighting/html.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
7979
.macro { color: #94BFF3; }
8080
.module { color: #AFD8AF; }
8181
.variable { color: #DCDCCC; }
82+
.format_specifier { color: #CC696B; }
8283
.mutable { text-decoration: underline; }
8384
8485
.keyword { color: #F0DFAF; font-weight: bold; }

crates/ra_ide/src/syntax_highlighting/tags.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ pub enum HighlightTag {
3939
Union,
4040
Local,
4141
UnresolvedReference,
42+
FormatSpecifier,
4243
}
4344

4445
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
@@ -81,6 +82,7 @@ impl HighlightTag {
8182
HighlightTag::Union => "union",
8283
HighlightTag::Local => "variable",
8384
HighlightTag::UnresolvedReference => "unresolved_reference",
85+
HighlightTag::FormatSpecifier => "format_specifier",
8486
}
8587
}
8688
}

crates/rust-analyzer/src/conv.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ use crate::{
2525
Result,
2626
};
2727
use semantic_tokens::{
28-
ATTRIBUTE, BUILTIN_TYPE, ENUM_MEMBER, LIFETIME, TYPE_ALIAS, UNION, UNRESOLVED_REFERENCE,
28+
ATTRIBUTE, BUILTIN_TYPE, ENUM_MEMBER, FORMAT_SPECIFIER, LIFETIME, TYPE_ALIAS, UNION,
29+
UNRESOLVED_REFERENCE,
2930
};
3031

3132
pub trait Conv {
@@ -381,6 +382,7 @@ impl Conv for Highlight {
381382
HighlightTag::Attribute => ATTRIBUTE,
382383
HighlightTag::Keyword => SemanticTokenType::KEYWORD,
383384
HighlightTag::UnresolvedReference => UNRESOLVED_REFERENCE,
385+
HighlightTag::FormatSpecifier => FORMAT_SPECIFIER,
384386
};
385387

386388
for modifier in self.modifiers.iter() {

crates/rust-analyzer/src/semantic_tokens.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub(crate) const TYPE_ALIAS: SemanticTokenType = SemanticTokenType::new("typeAli
1212
pub(crate) const UNION: SemanticTokenType = SemanticTokenType::new("union");
1313
pub(crate) const UNRESOLVED_REFERENCE: SemanticTokenType =
1414
SemanticTokenType::new("unresolvedReference");
15+
pub(crate) const FORMAT_SPECIFIER: SemanticTokenType = SemanticTokenType::new("formatSpecifier");
1516

1617
pub(crate) const CONSTANT: SemanticTokenModifier = SemanticTokenModifier::new("constant");
1718
pub(crate) const CONTROL_FLOW: SemanticTokenModifier = SemanticTokenModifier::new("controlFlow");
@@ -46,6 +47,7 @@ pub(crate) const SUPPORTED_TYPES: &[SemanticTokenType] = &[
4647
TYPE_ALIAS,
4748
UNION,
4849
UNRESOLVED_REFERENCE,
50+
FORMAT_SPECIFIER,
4951
];
5052

5153
pub(crate) const SUPPORTED_MODIFIERS: &[SemanticTokenModifier] = &[

0 commit comments

Comments
 (0)