aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/semantic_tokens.rs117
1 files changed, 61 insertions, 56 deletions
diff --git a/crates/rust-analyzer/src/semantic_tokens.rs b/crates/rust-analyzer/src/semantic_tokens.rs
index 71f4f58a3..2dc5cb119 100644
--- a/crates/rust-analyzer/src/semantic_tokens.rs
+++ b/crates/rust-analyzer/src/semantic_tokens.rs
@@ -4,64 +4,69 @@ use std::ops;
4 4
5use lsp_types::{Range, SemanticToken, SemanticTokenModifier, SemanticTokenType, SemanticTokens}; 5use lsp_types::{Range, SemanticToken, SemanticTokenModifier, SemanticTokenType, SemanticTokens};
6 6
7pub(crate) const ATTRIBUTE: SemanticTokenType = SemanticTokenType::new("attribute"); 7macro_rules! define_semantic_token_types {
8pub(crate) const BUILTIN_TYPE: SemanticTokenType = SemanticTokenType::new("builtinType"); 8 ($(($ident:ident, $string:literal)),*$(,)?) => {
9pub(crate) const ENUM_MEMBER: SemanticTokenType = SemanticTokenType::new("enumMember"); 9 $(pub(crate) const $ident: SemanticTokenType = SemanticTokenType::new($string);)*
10pub(crate) const LIFETIME: SemanticTokenType = SemanticTokenType::new("lifetime"); 10
11pub(crate) const TYPE_ALIAS: SemanticTokenType = SemanticTokenType::new("typeAlias"); 11 pub(crate) const SUPPORTED_TYPES: &[SemanticTokenType] = &[
12pub(crate) const UNION: SemanticTokenType = SemanticTokenType::new("union"); 12 SemanticTokenType::COMMENT,
13pub(crate) const UNRESOLVED_REFERENCE: SemanticTokenType = 13 SemanticTokenType::KEYWORD,
14 SemanticTokenType::new("unresolvedReference"); 14 SemanticTokenType::STRING,
15pub(crate) const FORMAT_SPECIFIER: SemanticTokenType = SemanticTokenType::new("formatSpecifier"); 15 SemanticTokenType::NUMBER,
16 16 SemanticTokenType::REGEXP,
17pub(crate) const CONSTANT: SemanticTokenModifier = SemanticTokenModifier::new("constant"); 17 SemanticTokenType::OPERATOR,
18pub(crate) const CONTROL_FLOW: SemanticTokenModifier = SemanticTokenModifier::new("controlFlow"); 18 SemanticTokenType::NAMESPACE,
19pub(crate) const MUTABLE: SemanticTokenModifier = SemanticTokenModifier::new("mutable"); 19 SemanticTokenType::TYPE,
20pub(crate) const UNSAFE: SemanticTokenModifier = SemanticTokenModifier::new("unsafe"); 20 SemanticTokenType::STRUCT,
21 21 SemanticTokenType::CLASS,
22pub(crate) const SUPPORTED_TYPES: &[SemanticTokenType] = &[ 22 SemanticTokenType::INTERFACE,
23 SemanticTokenType::COMMENT, 23 SemanticTokenType::ENUM,
24 SemanticTokenType::KEYWORD, 24 SemanticTokenType::TYPE_PARAMETER,
25 SemanticTokenType::STRING, 25 SemanticTokenType::FUNCTION,
26 SemanticTokenType::NUMBER, 26 SemanticTokenType::MEMBER,
27 SemanticTokenType::REGEXP, 27 SemanticTokenType::PROPERTY,
28 SemanticTokenType::OPERATOR, 28 SemanticTokenType::MACRO,
29 SemanticTokenType::NAMESPACE, 29 SemanticTokenType::VARIABLE,
30 SemanticTokenType::TYPE, 30 SemanticTokenType::PARAMETER,
31 SemanticTokenType::STRUCT, 31 SemanticTokenType::LABEL,
32 SemanticTokenType::CLASS, 32 $($ident),*
33 SemanticTokenType::INTERFACE, 33 ];
34 SemanticTokenType::ENUM, 34 };
35 SemanticTokenType::TYPE_PARAMETER, 35}
36 SemanticTokenType::FUNCTION, 36
37 SemanticTokenType::MEMBER, 37define_semantic_token_types![
38 SemanticTokenType::PROPERTY, 38 (ATTRIBUTE, "attribute"),
39 SemanticTokenType::MACRO, 39 (BUILTIN_TYPE, "builtinType"),
40 SemanticTokenType::VARIABLE, 40 (ENUM_MEMBER, "enumMember"),
41 SemanticTokenType::PARAMETER, 41 (LIFETIME, "lifetime"),
42 SemanticTokenType::LABEL, 42 (TYPE_ALIAS, "typeAlias"),
43 ATTRIBUTE, 43 (UNION, "union"),
44 BUILTIN_TYPE, 44 (UNRESOLVED_REFERENCE, "unresolvedReference"),
45 ENUM_MEMBER, 45 (FORMAT_SPECIFIER, "formatSpecifier"),
46 LIFETIME,
47 TYPE_ALIAS,
48 UNION,
49 UNRESOLVED_REFERENCE,
50 FORMAT_SPECIFIER,
51]; 46];
52 47
53pub(crate) const SUPPORTED_MODIFIERS: &[SemanticTokenModifier] = &[ 48macro_rules! define_semantic_token_modifiers {
54 SemanticTokenModifier::DOCUMENTATION, 49 ($(($ident:ident, $string:literal)),*$(,)?) => {
55 SemanticTokenModifier::DECLARATION, 50 $(pub(crate) const $ident: SemanticTokenModifier = SemanticTokenModifier::new($string);)*
56 SemanticTokenModifier::DEFINITION, 51
57 SemanticTokenModifier::STATIC, 52 pub(crate) const SUPPORTED_MODIFIERS: &[SemanticTokenModifier] = &[
58 SemanticTokenModifier::ABSTRACT, 53 SemanticTokenModifier::DOCUMENTATION,
59 SemanticTokenModifier::DEPRECATED, 54 SemanticTokenModifier::DECLARATION,
60 SemanticTokenModifier::READONLY, 55 SemanticTokenModifier::DEFINITION,
61 CONSTANT, 56 SemanticTokenModifier::STATIC,
62 MUTABLE, 57 SemanticTokenModifier::ABSTRACT,
63 UNSAFE, 58 SemanticTokenModifier::DEPRECATED,
64 CONTROL_FLOW, 59 SemanticTokenModifier::READONLY,
60 $($ident),*
61 ];
62 };
63}
64
65define_semantic_token_modifiers![
66 (CONSTANT, "constant"),
67 (CONTROL_FLOW, "controlFlow"),
68 (MUTABLE, "mutable"),
69 (UNSAFE, "unsafe"),
65]; 70];
66 71
67#[derive(Default)] 72#[derive(Default)]