@@ -8,102 +8,130 @@ use lsp_types::{
8
8
} ;
9
9
10
10
macro_rules! define_semantic_token_types {
11
- ( $( ( $ident: ident, $string: literal) ) ,* $( , ) ?) => {
12
- $( pub ( crate ) const $ident: SemanticTokenType = SemanticTokenType :: new( $string) ; ) *
11
+ (
12
+ standard {
13
+ $( $standard: ident) ,* $( , ) ?
14
+ }
15
+ custom {
16
+ $( ( $custom: ident, $string: literal) ) ,* $( , ) ?
17
+ }
18
+
19
+ ) => {
20
+ $( pub ( crate ) const $standard: SemanticTokenType = SemanticTokenType :: $standard; ) *
21
+ $( pub ( crate ) const $custom: SemanticTokenType = SemanticTokenType :: new( $string) ; ) *
13
22
14
23
pub ( crate ) const SUPPORTED_TYPES : & [ SemanticTokenType ] = & [
15
- SemanticTokenType :: CLASS ,
16
- SemanticTokenType :: COMMENT ,
17
- SemanticTokenType :: ENUM_MEMBER ,
18
- SemanticTokenType :: ENUM ,
19
- SemanticTokenType :: FUNCTION ,
20
- SemanticTokenType :: INTERFACE ,
21
- SemanticTokenType :: KEYWORD ,
22
- SemanticTokenType :: MACRO ,
23
- SemanticTokenType :: METHOD ,
24
- SemanticTokenType :: NAMESPACE ,
25
- SemanticTokenType :: NUMBER ,
26
- SemanticTokenType :: OPERATOR ,
27
- SemanticTokenType :: PARAMETER ,
28
- SemanticTokenType :: PROPERTY ,
29
- SemanticTokenType :: REGEXP ,
30
- SemanticTokenType :: STRING ,
31
- SemanticTokenType :: STRUCT ,
32
- SemanticTokenType :: TYPE_PARAMETER ,
33
- SemanticTokenType :: TYPE ,
34
- SemanticTokenType :: VARIABLE ,
35
- SemanticTokenType :: DECORATOR ,
36
- $( $ident) ,*
24
+ $( SemanticTokenType :: $standard, ) *
25
+ $( $custom) ,*
37
26
] ;
38
27
} ;
39
28
}
40
29
41
30
define_semantic_token_types ! [
42
- ( ANGLE , "angle" ) ,
43
- ( ARITHMETIC , "arithmetic" ) ,
44
- ( ATTRIBUTE_BRACKET , "attributeBracket" ) ,
45
- ( BITWISE , "bitwise" ) ,
46
- ( BOOLEAN , "boolean" ) ,
47
- ( BRACE , "brace" ) ,
48
- ( BRACKET , "bracket" ) ,
49
- ( BUILTIN_ATTRIBUTE , "builtinAttribute" ) ,
50
- ( BUILTIN_TYPE , "builtinType" ) ,
51
- ( CHAR , "character" ) ,
52
- ( COLON , "colon" ) ,
53
- ( COMMA , "comma" ) ,
54
- ( COMPARISON , "comparison" ) ,
55
- ( CONST_PARAMETER , "constParameter" ) ,
56
- ( DERIVE , "derive" ) ,
57
- ( DERIVE_HELPER , "deriveHelper" ) ,
58
- ( DOT , "dot" ) ,
59
- ( ESCAPE_SEQUENCE , "escapeSequence" ) ,
60
- ( FORMAT_SPECIFIER , "formatSpecifier" ) ,
61
- ( GENERIC , "generic" ) ,
62
- ( LABEL , "label" ) ,
63
- ( LIFETIME , "lifetime" ) ,
64
- ( LOGICAL , "logical" ) ,
65
- ( MACRO_BANG , "macroBang" ) ,
66
- ( PARENTHESIS , "parenthesis" ) ,
67
- ( PUNCTUATION , "punctuation" ) ,
68
- ( SELF_KEYWORD , "selfKeyword" ) ,
69
- ( SELF_TYPE_KEYWORD , "selfTypeKeyword" ) ,
70
- ( SEMICOLON , "semicolon" ) ,
71
- ( TYPE_ALIAS , "typeAlias" ) ,
72
- ( TOOL_MODULE , "toolModule" ) ,
73
- ( UNION , "union" ) ,
74
- ( UNRESOLVED_REFERENCE , "unresolvedReference" ) ,
31
+ standard {
32
+ COMMENT ,
33
+ DECORATOR ,
34
+ ENUM_MEMBER ,
35
+ ENUM ,
36
+ FUNCTION ,
37
+ INTERFACE ,
38
+ KEYWORD ,
39
+ MACRO ,
40
+ METHOD ,
41
+ NAMESPACE ,
42
+ NUMBER ,
43
+ OPERATOR ,
44
+ PARAMETER ,
45
+ PROPERTY ,
46
+ STRING ,
47
+ STRUCT ,
48
+ TYPE_PARAMETER ,
49
+ VARIABLE ,
50
+ }
51
+
52
+ custom {
53
+ ( ANGLE , "angle" ) ,
54
+ ( ARITHMETIC , "arithmetic" ) ,
55
+ ( ATTRIBUTE , "attribute" ) ,
56
+ ( ATTRIBUTE_BRACKET , "attributeBracket" ) ,
57
+ ( BITWISE , "bitwise" ) ,
58
+ ( BOOLEAN , "boolean" ) ,
59
+ ( BRACE , "brace" ) ,
60
+ ( BRACKET , "bracket" ) ,
61
+ ( BUILTIN_ATTRIBUTE , "builtinAttribute" ) ,
62
+ ( BUILTIN_TYPE , "builtinType" ) ,
63
+ ( CHAR , "character" ) ,
64
+ ( COLON , "colon" ) ,
65
+ ( COMMA , "comma" ) ,
66
+ ( COMPARISON , "comparison" ) ,
67
+ ( CONST_PARAMETER , "constParameter" ) ,
68
+ ( DERIVE , "derive" ) ,
69
+ ( DERIVE_HELPER , "deriveHelper" ) ,
70
+ ( DOT , "dot" ) ,
71
+ ( ESCAPE_SEQUENCE , "escapeSequence" ) ,
72
+ ( FORMAT_SPECIFIER , "formatSpecifier" ) ,
73
+ ( GENERIC , "generic" ) ,
74
+ ( LABEL , "label" ) ,
75
+ ( LIFETIME , "lifetime" ) ,
76
+ ( LOGICAL , "logical" ) ,
77
+ ( MACRO_BANG , "macroBang" ) ,
78
+ ( PARENTHESIS , "parenthesis" ) ,
79
+ ( PUNCTUATION , "punctuation" ) ,
80
+ ( SELF_KEYWORD , "selfKeyword" ) ,
81
+ ( SELF_TYPE_KEYWORD , "selfTypeKeyword" ) ,
82
+ ( SEMICOLON , "semicolon" ) ,
83
+ ( TYPE_ALIAS , "typeAlias" ) ,
84
+ ( TOOL_MODULE , "toolModule" ) ,
85
+ ( UNION , "union" ) ,
86
+ ( UNRESOLVED_REFERENCE , "unresolvedReference" ) ,
87
+ }
75
88
] ;
76
89
77
90
macro_rules! define_semantic_token_modifiers {
78
- ( $( ( $ident: ident, $string: literal) ) ,* $( , ) ?) => {
79
- $( pub ( crate ) const $ident: SemanticTokenModifier = SemanticTokenModifier :: new( $string) ; ) *
91
+ (
92
+ standard {
93
+ $( $standard: ident) ,* $( , ) ?
94
+ }
95
+ custom {
96
+ $( ( $custom: ident, $string: literal) ) ,* $( , ) ?
97
+ }
98
+
99
+ ) => {
100
+
101
+ $( pub ( crate ) const $standard: SemanticTokenModifier = SemanticTokenModifier :: $standard; ) *
102
+ $( pub ( crate ) const $custom: SemanticTokenModifier = SemanticTokenModifier :: new( $string) ; ) *
80
103
81
104
pub ( crate ) const SUPPORTED_MODIFIERS : & [ SemanticTokenModifier ] = & [
82
- SemanticTokenModifier :: DOCUMENTATION ,
83
- SemanticTokenModifier :: DECLARATION ,
84
- SemanticTokenModifier :: STATIC ,
85
- SemanticTokenModifier :: DEFAULT_LIBRARY ,
86
- $( $ident) ,*
105
+ $( SemanticTokenModifier :: $standard, ) *
106
+ $( $custom) ,*
87
107
] ;
88
108
} ;
89
109
}
90
110
91
111
define_semantic_token_modifiers ! [
92
- ( ASYNC , "async" ) ,
93
- ( ATTRIBUTE_MODIFIER , "attribute" ) ,
94
- ( CALLABLE , "callable" ) ,
95
- ( CONSTANT , "constant" ) ,
96
- ( CONSUMING , "consuming" ) ,
97
- ( CONTROL_FLOW , "controlFlow" ) ,
98
- ( CRATE_ROOT , "crateRoot" ) ,
99
- ( INJECTED , "injected" ) ,
100
- ( INTRA_DOC_LINK , "intraDocLink" ) ,
101
- ( LIBRARY , "library" ) ,
102
- ( MUTABLE , "mutable" ) ,
103
- ( PUBLIC , "public" ) ,
104
- ( REFERENCE , "reference" ) ,
105
- ( TRAIT_MODIFIER , "trait" ) ,
106
- ( UNSAFE , "unsafe" ) ,
112
+ standard {
113
+ DOCUMENTATION ,
114
+ DECLARATION ,
115
+ STATIC ,
116
+ DEFAULT_LIBRARY ,
117
+ }
118
+ custom {
119
+ ( ASYNC , "async" ) ,
120
+ ( ATTRIBUTE_MODIFIER , "attribute" ) ,
121
+ ( CALLABLE , "callable" ) ,
122
+ ( CONSTANT , "constant" ) ,
123
+ ( CONSUMING , "consuming" ) ,
124
+ ( CONTROL_FLOW , "controlFlow" ) ,
125
+ ( CRATE_ROOT , "crateRoot" ) ,
126
+ ( INJECTED , "injected" ) ,
127
+ ( INTRA_DOC_LINK , "intraDocLink" ) ,
128
+ ( LIBRARY , "library" ) ,
129
+ ( MUTABLE , "mutable" ) ,
130
+ ( PUBLIC , "public" ) ,
131
+ ( REFERENCE , "reference" ) ,
132
+ ( TRAIT_MODIFIER , "trait" ) ,
133
+ ( UNSAFE , "unsafe" ) ,
134
+ }
107
135
] ;
108
136
109
137
#[ derive( Default ) ]
0 commit comments