Debian Codegraph @

runtime/queries/ecma/highlights.scm

raw symbols SCIP
1 ; Tokens
2 ;-------
3
4 [
5 ";"
6 (optional_chain) ; ?.
7 "."
8 ","
9 ] @punctuation.delimiter
10
11 [
12 "-"
13 "--"
14 "-="
15 "+"
16 "++"
17 "+="
18 "*"
19 "*="
20 "**"
21 "**="
22 "/"
23 "/="
24 "%"
25 "%="
26 "<"
27 "<="
28 "<<"
29 "<<="
30 "="
31 "=="
32 "==="
33 "!"
34 "!="
35 "!=="
36 "=>"
37 ">"
38 ">="
39 ">>"
40 ">>="
41 ">>>"
42 ">>>="
43 "~"
44 "^"
45 "&"
46 "|"
47 "^="
48 "&="
49 "|="
50 "&&"
51 "||"
52 "??"
53 "&&="
54 "||="
55 "??="
56 "..."
57 ] @operator
58
59 (ternary_expression ["?" ":"] @operator)
60
61 [
62 "("
63 ")"
64 "["
65 "]"
66 "{"
67 "}"
68 ] @punctuation.bracket
69
70 (template_substitution
71 "${" @punctuation.special
72 "}" @punctuation.special) @embedded
73
74 [
75 "async"
76 "debugger"
77 "extends"
78 "from"
79 "get"
80 "new"
81 "set"
82 "target"
83 "with"
84 ] @keyword
85
86 [
87 "of"
88 "as"
89 "in"
90 "delete"
91 "typeof"
92 "instanceof"
93 "void"
94 ] @keyword.operator
95
96 [
97 "function"
98 ] @keyword.function
99
100 [
101 "class"
102 "let"
103 "var"
104 ] @keyword.storage.type
105
106 [
107 "const"
108 "static"
109 ] @keyword.storage.modifier
110
111 [
112 "default"
113 "yield"
114 "finally"
115 "do"
116 "await"
117 ] @keyword.control
118
119 [
120 "if"
121 "else"
122 "switch"
123 "case"
124 ] @keyword.control.conditional
125
126 [
127 "while"
128 "for"
129 ] @keyword.control.repeat
130
131 [
132 "import"
133 "export"
134 ] @keyword.control.import
135
136 [
137 "return"
138 "break"
139 "continue"
140 ] @keyword.control.return
141
142 [
143 "throw"
144 "try"
145 "catch"
146 ] @keyword.control.exception
147
148 ; Variables
149 ;----------
150
151 (identifier) @variable
152
153 ; Properties
154 ;-----------
155
156 (property_identifier) @variable.other.member
157 (private_property_identifier) @variable.other.member.private
158 (shorthand_property_identifier) @variable.other.member
159 (shorthand_property_identifier_pattern) @variable.other.member
160
161 ; Function and method definitions
162 ;--------------------------------
163
164 (function_expression
165 name: (identifier) @function)
166 (function_declaration
167 name: (identifier) @function)
168 (method_definition
169 name: (property_identifier) @function.method)
170 (method_definition
171 name: (private_property_identifier) @function.method.private)
172
173 (pair
174 key: (property_identifier) @function.method
175 value: [(function_expression) (arrow_function)])
176 (pair
177 key: (private_property_identifier) @function.method.private
178 value: [(function_expression) (arrow_function)])
179
180 (assignment_expression
181 left: (member_expression
182 property: (property_identifier) @function.method)
183 right: [(function_expression) (arrow_function)])
184 (assignment_expression
185 left: (member_expression
186 property: (private_property_identifier) @function.method.private)
187 right: [(function_expression) (arrow_function)])
188
189 (variable_declarator
190 name: (identifier) @function
191 value: [(function_expression) (arrow_function)])
192
193 (assignment_expression
194 left: (identifier) @function
195 right: [(function_expression) (arrow_function)])
196
197 ; Function and method parameters
198 ;-------------------------------
199
200 ; Arrow function parameters in the form `p => ...` are supported by both
201 ; javascript and typescript grammars without conflicts.
202 (arrow_function
203 parameter: (identifier) @variable.parameter)
204
205 ; Function and method calls
206 ;--------------------------
207
208 (call_expression
209 function: (identifier) @function)
210
211 (call_expression
212 function: (member_expression
213 property: (property_identifier) @function.method))
214 (call_expression
215 function: (member_expression
216 property: (private_property_identifier) @function.method.private))
217
218 ; Literals
219 ;---------
220
221 (this) @variable.builtin
222 (super) @variable.builtin
223
224 [
225 (null)
226 (undefined)
227 ] @constant.builtin
228
229 [
230 (true)
231 (false)
232 ] @constant.builtin.boolean
233
234 (comment) @comment
235
236 [
237 (string)
238 (template_string)
239 ] @string
240
241 (escape_sequence) @constant.character.escape
242
243 (regex) @string.regexp
244
245 ; future-proof fall-back, and `TypedArray` values (looks like float, but is int)
246 (number) @constant.numeric
247 ; https://tc39.es/ecma262/multipage/ecmascript-language-lexical-grammar.html#prod-NumericLiteral
248 ((number) @constant.numeric.float
249 (#match? @constant.numeric.float "[^n]$"))
250 ((number) @constant.numeric.integer
251 (#match? @constant.numeric.integer "^[^.][^.\-]*n$"))
252
253
254 ; Special identifiers
255 ;--------------------
256
257 ((identifier) @constructor
258 (#match? @constructor "^[A-Z]"))
259
260 ([
261 (identifier)
262 (shorthand_property_identifier)
263 (shorthand_property_identifier_pattern)
264 ] @constant
265 (#match? @constant "^[A-Z_][A-Z\\d_]+$"))
266
267 ; Built-in constructors / types
268 ((identifier) @type.builtin
269 (#any-of? @type.builtin
270 "Object" "Function" "Boolean" "Symbol" "Number" "BigInt" "String" "RegExp"
271 "Array" "Map" "Set" "WeakMap" "WeakSet" "WeakRef" "Promise" "Proxy" "Date"
272 "ArrayBuffer" "SharedArrayBuffer" "DataView"
273 "Int8Array" "Uint8Array" "Uint8ClampedArray" "Int16Array" "Uint16Array"
274 "Int32Array" "Uint32Array" "Float32Array" "Float64Array"
275 "BigInt64Array" "BigUint64Array"
276 "Error" "EvalError" "RangeError" "ReferenceError" "SyntaxError" "TypeError"
277 "URIError" "AggregateError")
278 (#is-not? local))
279
280 ((identifier) @variable.builtin
281 (#match? @variable.builtin "^(arguments|module|console|window|document|globalThis|Math|JSON|Reflect|Intl)$")
282 (#is-not? local))
283
284 (call_expression
285 (identifier) @function.builtin
286 (#any-of? @function.builtin
287 "eval"
288 "fetch"
289 "isFinite"
290 "isNaN"
291 "parseFloat"
292 "parseInt"
293 "decodeURI"
294 "decodeURIComponent"
295 "encodeURI"
296 "encodeURIComponent"
297 "require"
298 "alert"
299 "prompt"
300 "btoa"
301 "atob"
302 "confirm"
303 "structuredClone"
304 "setTimeout"
305 "clearTimeout"
306 "setInterval"
307 "clearInterval"
308 "queueMicrotask")
309 (#is-not? local))
310
311 ; Shebang
312 ;--------
313
314 (hash_bang_line) @keyword.directive
315
316 ; Labels
317 ;-------
318
319 (statement_identifier) @label
320
321 ; Decorators
322 ;-----------
323
324 (decorator "@" @attribute)
325 (decorator (identifier) @attribute)
326 (decorator
327 (call_expression
328 function: (identifier) @attribute))
329 (decorator
330 (member_expression
331 property: (property_identifier) @attribute))
332 (decorator
333 (call_expression
334 function: (member_expression
335 property: (property_identifier) @attribute)))
336
337 ; Namespace imports/exports: `import * as ns` / `export * as ns`
338 ;----------------------------------------------------------------
339
340 (namespace_import (identifier) @namespace)
341 (namespace_export (identifier) @namespace)