Debian Codegraph @

runtime/queries/solidity/highlights.scm

raw symbols SCIP
1 ; identifiers
2 ; -----------
3 (identifier) @variable
4 ((identifier) @variable.builtin (#any-of? @variable.builtin "this" "msg" "block" "tx"))
5 (yul_identifier) @variable
6
7 ; Pragma
8 (pragma_directive) @keyword.directive
9 (solidity_version_comparison_operator _ @keyword.directive)
10
11 ; Literals
12 ; --------
13 [
14 (string)
15 (hex_string_literal)
16 (unicode_string_literal)
17 (yul_string_literal)
18 (yul_hex_string_literal)
19 ] @string
20 (hex_string_literal "hex" @string.special.symbol)
21 (unicode_string_literal "unicode" @string.special.symbol)
22 [
23 (number_literal)
24 (yul_decimal_number)
25 (yul_hex_number)
26 ] @constant.numeric
27 [
28 (true)
29 (false)
30 (yul_boolean)
31 ] @constant.builtin.boolean
32
33 (comment) @comment
34
35 ; Definitions and references
36 ; -----------
37 (type_name) @type
38
39 [
40 (primitive_type)
41 (number_unit)
42 ] @type.builtin
43
44 (user_defined_type (_) @type)
45 (user_defined_type_definition name: (identifier) @type)
46 (type_alias (identifier) @type)
47
48 ; Color payable in payable address conversion as type and not as keyword
49 (payable_conversion_expression "payable" @type)
50 ; Ensures that delimiters in mapping( ... => .. ) are not colored like types
51 (type_name "(" @punctuation.bracket "=>" @punctuation.delimiter ")" @punctuation.bracket)
52
53 ; Definitions
54 (struct_declaration name: (identifier) @type)
55 (enum_declaration name: (identifier) @type)
56 (contract_declaration name: (identifier) @type)
57 (library_declaration name: (identifier) @type)
58 (interface_declaration name: (identifier) @type)
59 (event_definition name: (identifier) @type)
60 (error_declaration name: (identifier) @type)
61 (function_definition name: (identifier) @function)
62 (modifier_definition name: (identifier) @function)
63 (yul_evm_builtin) @function.builtin
64
65 ; Use constructor coloring for special functions
66 (constructor_definition "constructor" @constructor)
67 (error_declaration "error" @constructor)
68 (fallback_receive_definition "receive" @constructor)
69 (fallback_receive_definition "fallback" @constructor)
70
71 (struct_member name: (identifier) @variable.other.member)
72 (enum_value) @constant
73 ; SCREAMING_SNAKE_CASE identifier are constants
74 ((identifier) @constant (#match? @constant "^[A-Z][A-Z_]+$"))
75
76 ; Member access
77 (member_expression property: (identifier) @variable.other.member)
78
79 ; Invocations
80 (emit_statement name: (expression (identifier) @type))
81 (revert_statement error: (expression (identifier) @type))
82 (modifier_invocation . (_) @function)
83
84 (call_expression . (_(member_expression property: (_) @function.method)))
85 (call_expression . (expression (identifier) @function))
86
87 ; Function parameters
88 (call_struct_argument name: (identifier) @field)
89 (event_parameter name: (identifier) @variable.parameter)
90 (parameter name: (identifier) @variable.parameter)
91
92 ; Yul functions
93 (yul_function_call function: (_) @function)
94 (yul_function_definition
95 ("function" (yul_identifier) @function "(" (
96 (yul_identifier) @variable.parameter ("," (yul_identifier) @variable.parameter)*
97 )
98 )
99 )
100
101 ; Structs and members
102 (struct_expression type: ((expression (identifier)) @type .))
103 (struct_field_assignment name: (identifier) @variable.other.member)
104
105
106 ; Tokens
107 ; -------
108
109 ; Keywords
110 (meta_type_expression "type" @keyword)
111 [
112 "abstract"
113 "contract"
114 "interface"
115 "library"
116 "is"
117 "struct"
118 "enum"
119 "event"
120 "type"
121 "assembly"
122 "emit"
123 "public"
124 "internal"
125 "private"
126 "external"
127 "pure"
128 "view"
129 "payable"
130 "modifier"
131 "var"
132 "let"
133 (virtual)
134 (override_specifier)
135 (yul_leave)
136 ] @keyword
137
138 [
139 "memory"
140 "storage"
141 "calldata"
142 "constant"
143 "transient"
144 (immutable)
145 ] @keyword.storage.modifier
146
147 [
148 "for"
149 "while"
150 "do"
151 ] @keyword.control.repeat
152
153 [
154 "break"
155 "continue"
156 "if"
157 "else"
158 "switch"
159 "case"
160 "default"
161 ] @keyword.control.conditional
162
163 [
164 "try"
165 "catch"
166 "revert"
167 ] @keyword.control.exception
168
169 [
170 "return"
171 "returns"
172 ] @keyword.control.return
173
174 "function" @keyword.function
175
176 "import" @keyword.control.import
177 "using" @keyword.control.import
178 (import_directive "as" @keyword.control.import)
179 (import_directive "from" @keyword.control.import)
180 (event_parameter "indexed" @keyword)
181
182 ; Punctuation
183 [
184 "("
185 ")"
186 "["
187 "]"
188 "{"
189 "}"
190 ] @punctuation.bracket
191
192 [
193 "."
194 ","
195 ":"
196 "->"
197 "=>"
198 ] @punctuation.delimiter
199
200 ; Operators
201 [
202 "&&"
203 "||"
204 ">>"
205 "<<"
206 "&"
207 "^"
208 "|"
209 "+"
210 "-"
211 "*"
212 "/"
213 "%"
214 "**"
215 "<"
216 "<="
217 "=="
218 "!="
219 ">="
220 ">"
221 "!"
222 "~"
223 "-"
224 "+"
225 "++"
226 "--"
227 "+="
228 "-="
229 "*="
230 "/="
231 "%="
232 "^="
233 "&="
234 "|="
235 "<<="
236 ">>="
237 ] @operator
238
239 ; The operator symbol in `using {f as +} for T` / user-definable `operator`.
240 (user_definable_operator) @operator
241
242 [
243 "delete"
244 "new"
245 ] @keyword.operator