Skip to content

Commit 07060b3

Browse files
bors[bot]ruabmbua
andauthored
Merge #4654
4654: Add semantic highlight to ? operator r=matklad a=ruabmbua Made it an operator with controlFlow modifier. To highlight in vscode as red: ```json "editor.semanticTokenColorCustomizations": { "enabled": true, "rules": { "operator.controlFlow": "#ff0000", } } ``` ![Bildschirmfoto von 2020-05-29 21-32-06](https://user-images.githubusercontent.com/2522373/83297998-f3585a00-a1f3-11ea-9d14-4ef04b9b6b9a.png) #4597 Co-authored-by: Roland Ruckerbauer <roland.rucky@gmail.com>
2 parents 5d84028 + 18aa4bc commit 07060b3

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

crates/ra_ide/src/syntax_highlighting.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ fn highlight_element(
391391
INT_NUMBER | FLOAT_NUMBER => HighlightTag::NumericLiteral.into(),
392392
BYTE => HighlightTag::ByteLiteral.into(),
393393
CHAR => HighlightTag::CharLiteral.into(),
394+
QUESTION => Highlight::new(HighlightTag::Operator) | HighlightModifier::ControlFlow,
394395
LIFETIME => {
395396
let h = Highlight::new(HighlightTag::Lifetime);
396397
match element.parent().map(|it| it.kind()) {

crates/ra_ide/src/syntax_highlighting/tags.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pub enum HighlightTag {
4242
Local,
4343
UnresolvedReference,
4444
FormatSpecifier,
45+
Operator,
4546
}
4647

4748
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
@@ -89,6 +90,7 @@ impl HighlightTag {
8990
HighlightTag::Local => "variable",
9091
HighlightTag::UnresolvedReference => "unresolved_reference",
9192
HighlightTag::FormatSpecifier => "format_specifier",
93+
HighlightTag::Operator => "operator",
9294
}
9395
}
9496
}

crates/rust-analyzer/src/to_proto.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ fn semantic_token_type_and_modifiers(
317317
HighlightTag::Keyword => lsp_types::SemanticTokenType::KEYWORD,
318318
HighlightTag::UnresolvedReference => semantic_tokens::UNRESOLVED_REFERENCE,
319319
HighlightTag::FormatSpecifier => semantic_tokens::FORMAT_SPECIFIER,
320+
HighlightTag::Operator => lsp_types::SemanticTokenType::OPERATOR,
320321
};
321322

322323
for modifier in highlight.modifiers.iter() {

0 commit comments

Comments
 (0)