about summary refs log tree commit diff
diff options
context:
space:
mode:
authorpetr-tik <petr-tik@users.noreply.github.com>2021-02-05 23:46:39 +0000
committerpetr-tik <petr-tik@users.noreply.github.com>2021-02-05 23:46:39 +0000
commitf4e3eceb6f9c708cb94ee5e2940c6ad4f3abc629 (patch)
tree4507ec2bc139c08b6d03ad0a774c1a64502299d0
parent582a202d6ead6d2b793923c8f63801d34c72a448 (diff)
downloadrust-f4e3eceb6f9c708cb94ee5e2940c6ad4f3abc629.tar.gz
rust-f4e3eceb6f9c708cb94ee5e2940c6ad4f3abc629.zip
Add a semantic token type for char literals
The LSP spec doesn't recognise character literals, so
had to extend the suported types to our own custom type
-rw-r--r--crates/rust-analyzer/src/semantic_tokens.rs1
-rw-r--r--crates/rust-analyzer/src/to_proto.rs3
2 files changed, 3 insertions, 1 deletions
diff --git a/crates/rust-analyzer/src/semantic_tokens.rs b/crates/rust-analyzer/src/semantic_tokens.rs
index 7ce9a4ab6dd..be0bea00b7e 100644
--- a/crates/rust-analyzer/src/semantic_tokens.rs
+++ b/crates/rust-analyzer/src/semantic_tokens.rs
@@ -44,6 +44,7 @@ define_semantic_token_types![
     (BRACE, "brace"),
     (BRACKET, "bracket"),
     (BUILTIN_TYPE, "builtinType"),
+    (CHAR_LITERAL, "characterLiteral"),
     (COMMA, "comma"),
     (COLON, "colon"),
     (DOT, "dot"),
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs
index 96f915f1ce7..5236932e8a3 100644
--- a/crates/rust-analyzer/src/to_proto.rs
+++ b/crates/rust-analyzer/src/to_proto.rs
@@ -426,7 +426,8 @@ fn semantic_token_type_and_modifiers(
         HlTag::None => semantic_tokens::GENERIC,
         HlTag::ByteLiteral | HlTag::NumericLiteral => lsp_types::SemanticTokenType::NUMBER,
         HlTag::BoolLiteral => semantic_tokens::BOOLEAN,
-        HlTag::CharLiteral | HlTag::StringLiteral => lsp_types::SemanticTokenType::STRING,
+        HlTag::StringLiteral => lsp_types::SemanticTokenType::STRING,
+        HlTag::CharLiteral => semantic_tokens::CHAR_LITERAL,
         HlTag::Comment => lsp_types::SemanticTokenType::COMMENT,
         HlTag::Attribute => semantic_tokens::ATTRIBUTE,
         HlTag::Keyword => lsp_types::SemanticTokenType::KEYWORD,