Unnamed repository; edit this file 'description' to name the repository.
Added the "negation" semantic token
daladim 6 months ago
parent e78de70 · commit fb07998
-rw-r--r--crates/ide/src/syntax_highlighting/highlight.rs2
-rw-r--r--crates/ide/src/syntax_highlighting/tags.rs5
-rw-r--r--crates/rust-analyzer/src/lsp/semantic_tokens.rs1
-rw-r--r--crates/rust-analyzer/src/lsp/to_proto.rs1
4 files changed, 7 insertions, 2 deletions
diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs
index d73575fb95..829d1279a8 100644
--- a/crates/ide/src/syntax_highlighting/highlight.rs
+++ b/crates/ide/src/syntax_highlighting/highlight.rs
@@ -137,7 +137,7 @@ fn punctuation(
}
(T![!], MACRO_RULES) => HlPunct::MacroBang.into(),
(T![!], NEVER_TYPE) => HlTag::BuiltinType.into(),
- (T![!], PREFIX_EXPR) => HlOperator::Logical.into(),
+ (T![!], PREFIX_EXPR) => HlOperator::Negation.into(),
(T![*], PTR_TYPE) => HlTag::Keyword.into(),
(T![*], PREFIX_EXPR) => {
let h = HlTag::Operator(HlOperator::Other).into();
diff --git a/crates/ide/src/syntax_highlighting/tags.rs b/crates/ide/src/syntax_highlighting/tags.rs
index 4b8762640c..456a612987 100644
--- a/crates/ide/src/syntax_highlighting/tags.rs
+++ b/crates/ide/src/syntax_highlighting/tags.rs
@@ -124,8 +124,10 @@ pub enum HlOperator {
Bitwise,
/// +, -, *, /, +=, -=, *=, /=
Arithmetic,
- /// &&, ||, !
+ /// &&, ||
Logical,
+ /// !
+ Negation,
/// >, <, ==, >=, <=, !=
Comparison,
/// Other operators
@@ -194,6 +196,7 @@ impl HlTag {
HlOperator::Arithmetic => "arithmetic",
HlOperator::Logical => "logical",
HlOperator::Comparison => "comparison",
+ HlOperator::Negation => "negation",
HlOperator::Other => "operator",
},
HlTag::StringLiteral => "string_literal",
diff --git a/crates/rust-analyzer/src/lsp/semantic_tokens.rs b/crates/rust-analyzer/src/lsp/semantic_tokens.rs
index 3c21e19925..828118a086 100644
--- a/crates/rust-analyzer/src/lsp/semantic_tokens.rs
+++ b/crates/rust-analyzer/src/lsp/semantic_tokens.rs
@@ -91,6 +91,7 @@ define_semantic_token_types![
(LIFETIME, "lifetime"),
(LOGICAL, "logical") => OPERATOR,
(MACRO_BANG, "macroBang") => MACRO,
+ (NEGATION, "negation") => OPERATOR,
(PARENTHESIS, "parenthesis"),
(PROC_MACRO, "procMacro") => MACRO,
(PUNCTUATION, "punctuation"),
diff --git a/crates/rust-analyzer/src/lsp/to_proto.rs b/crates/rust-analyzer/src/lsp/to_proto.rs
index cd384ca713..2d2dacbe2e 100644
--- a/crates/rust-analyzer/src/lsp/to_proto.rs
+++ b/crates/rust-analyzer/src/lsp/to_proto.rs
@@ -840,6 +840,7 @@ fn semantic_token_type_and_modifiers(
HlOperator::Bitwise => types::BITWISE,
HlOperator::Arithmetic => types::ARITHMETIC,
HlOperator::Logical => types::LOGICAL,
+ HlOperator::Negation => types::NEGATION,
HlOperator::Comparison => types::COMPARISON,
HlOperator::Other => types::OPERATOR,
},