aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-05-30 09:26:04 +0100
committerGitHub <[email protected]>2020-05-30 09:26:04 +0100
commit07060b3daa9592090da45245ea13c28304449d9d (patch)
tree7105d929653cdd471c573ad24f52cefc5146d580 /crates
parent5d8402817044ac4039c7315e70565d6b0414b9d3 (diff)
parent18aa4bcb0328393db0c20de0241e1e9606901144 (diff)
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) https://github.com/rust-analyzer/rust-analyzer/issues/4597 Co-authored-by: Roland Ruckerbauer <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs1
-rw-r--r--crates/ra_ide/src/syntax_highlighting/tags.rs2
-rw-r--r--crates/rust-analyzer/src/to_proto.rs1
3 files changed, 4 insertions, 0 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 8a995d779..cd6464b40 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -391,6 +391,7 @@ fn highlight_element(
391 INT_NUMBER | FLOAT_NUMBER => HighlightTag::NumericLiteral.into(), 391 INT_NUMBER | FLOAT_NUMBER => HighlightTag::NumericLiteral.into(),
392 BYTE => HighlightTag::ByteLiteral.into(), 392 BYTE => HighlightTag::ByteLiteral.into(),
393 CHAR => HighlightTag::CharLiteral.into(), 393 CHAR => HighlightTag::CharLiteral.into(),
394 QUESTION => Highlight::new(HighlightTag::Operator) | HighlightModifier::ControlFlow,
394 LIFETIME => { 395 LIFETIME => {
395 let h = Highlight::new(HighlightTag::Lifetime); 396 let h = Highlight::new(HighlightTag::Lifetime);
396 match element.parent().map(|it| it.kind()) { 397 match element.parent().map(|it| it.kind()) {
diff --git a/crates/ra_ide/src/syntax_highlighting/tags.rs b/crates/ra_ide/src/syntax_highlighting/tags.rs
index 46c718c91..1514531de 100644
--- a/crates/ra_ide/src/syntax_highlighting/tags.rs
+++ b/crates/ra_ide/src/syntax_highlighting/tags.rs
@@ -42,6 +42,7 @@ pub enum HighlightTag {
42 Local, 42 Local,
43 UnresolvedReference, 43 UnresolvedReference,
44 FormatSpecifier, 44 FormatSpecifier,
45 Operator,
45} 46}
46 47
47#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] 48#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
@@ -89,6 +90,7 @@ impl HighlightTag {
89 HighlightTag::Local => "variable", 90 HighlightTag::Local => "variable",
90 HighlightTag::UnresolvedReference => "unresolved_reference", 91 HighlightTag::UnresolvedReference => "unresolved_reference",
91 HighlightTag::FormatSpecifier => "format_specifier", 92 HighlightTag::FormatSpecifier => "format_specifier",
93 HighlightTag::Operator => "operator",
92 } 94 }
93 } 95 }
94} 96}
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs
index 8e8e7033d..2fbbb4e63 100644
--- a/crates/rust-analyzer/src/to_proto.rs
+++ b/crates/rust-analyzer/src/to_proto.rs
@@ -317,6 +317,7 @@ fn semantic_token_type_and_modifiers(
317 HighlightTag::Keyword => lsp_types::SemanticTokenType::KEYWORD, 317 HighlightTag::Keyword => lsp_types::SemanticTokenType::KEYWORD,
318 HighlightTag::UnresolvedReference => semantic_tokens::UNRESOLVED_REFERENCE, 318 HighlightTag::UnresolvedReference => semantic_tokens::UNRESOLVED_REFERENCE,
319 HighlightTag::FormatSpecifier => semantic_tokens::FORMAT_SPECIFIER, 319 HighlightTag::FormatSpecifier => semantic_tokens::FORMAT_SPECIFIER,
320 HighlightTag::Operator => lsp_types::SemanticTokenType::OPERATOR,
320 }; 321 };
321 322
322 for modifier in highlight.modifiers.iter() { 323 for modifier in highlight.modifiers.iter() {