From 18aa4bcb0328393db0c20de0241e1e9606901144 Mon Sep 17 00:00:00 2001 From: Roland Ruckerbauer Date: Fri, 29 May 2020 21:17:14 +0200 Subject: [PATCH] Add semantic highlight to QUESTION token Made it an operator with controlFlow modifier. --- crates/ra_ide/src/syntax_highlighting.rs | 1 + crates/ra_ide/src/syntax_highlighting/tags.rs | 2 ++ crates/rust-analyzer/src/to_proto.rs | 1 + 3 files changed, 4 insertions(+) diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 8a995d779b..cd6464b405 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -391,6 +391,7 @@ fn highlight_element( INT_NUMBER | FLOAT_NUMBER => HighlightTag::NumericLiteral.into(), BYTE => HighlightTag::ByteLiteral.into(), CHAR => HighlightTag::CharLiteral.into(), + QUESTION => Highlight::new(HighlightTag::Operator) | HighlightModifier::ControlFlow, LIFETIME => { let h = Highlight::new(HighlightTag::Lifetime); 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 46c718c91e..1514531de2 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 { Local, UnresolvedReference, FormatSpecifier, + Operator, } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] @@ -89,6 +90,7 @@ impl HighlightTag { HighlightTag::Local => "variable", HighlightTag::UnresolvedReference => "unresolved_reference", HighlightTag::FormatSpecifier => "format_specifier", + HighlightTag::Operator => "operator", } } } diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 8e8e7033db..2fbbb4e632 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( HighlightTag::Keyword => lsp_types::SemanticTokenType::KEYWORD, HighlightTag::UnresolvedReference => semantic_tokens::UNRESOLVED_REFERENCE, HighlightTag::FormatSpecifier => semantic_tokens::FORMAT_SPECIFIER, + HighlightTag::Operator => lsp_types::SemanticTokenType::OPERATOR, }; for modifier in highlight.modifiers.iter() {