Debian Codegraph @

data/syntax/typescript.xml

raw
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE language
3 [
4 <!ENTITY identifier "[a-zA-Z_$[:^ascii:]][\w$[:^ascii:]]*+">
5 <!ENTITY numSuffix "(?=n?(?:[^\w]|$))">
6 <!ENTITY objectOp "[\?!]?">
7 <!ENTITY objectPoint "\s*&objectOp;\.">
8 <!ENTITY endLine "\s*(?:$|//|(?:/\*.*\*/\s*)+(?:$|//))">
9 <!ENTITY parameter "&identifier;(?=\s*&objectOp;:)">
10
11 <!ENTITY utilityTypes "\b(?:Partial|Readonly|Record|Pick|Omit|Exclude|Extract|NonNullable|ReturnType|InstanceType|Required|ThisType)(?=\s*&lt;)">
12 <!-- function<...>( or function( -->
13 <!ENTITY functionSuffix "(?=\s*(?:&lt;(?:\{(?:[^\{\}]|\{[^\{\}]*\})*\}|\((?:[^\(\)]|\([^\(\)]*\))*\)|\[(?:[^\[\]]|\[[^\[\]]*\])*\]|'(?:\\.|[^'])*'|&quot;(?:\\.|[^&quot;])*&quot;|`(?:\\.|[^`])*`|[^&lt;&gt;]|&lt;.*&gt;)*&gt;)?\()">
14
15 <!ENTITY codeContent "&quot;(?:[^&quot;]|\\.)*&quot;|'(?:[^']|\\.)*'|`(?:[^`]|\\.)`|/\*.*\*/|/(?:[^/\\\[]|\\.|\[(?:[^\]\\]|\\.)+\])+/">
16 ]>
17
18 <!--
19 ====================================================================
20
21 This file is part of the KDE's KSyntaxHighlighting framework.
22
23 Copyright 2018-2020 Nibaldo González S. ([email protected])
24
25 This Source Code Form is subject to the terms of the MIT License.
26 If a copy of the license was not distributed with this file,
27 You can obtain one at: https://opensource.org/licenses/MIT
28
29 ====================================================================
30
31 This file is an extension of the JavaScript highlighter
32 (javascript.xml, Version 14 and higher).
33 Based on the TypeScript grammar files,
34 available at: https://github.com/Microsoft/TypeScript-TmLanguage
35
36 NOTE: TypeScript directives are highlighted by "doxygen.xml",
37 included in the JavaScript highlighter.
38 Ex:
39 /// <reference no-default-lib="true"/>
40
41 Tags: reference, amd-dependency, amd-module
42 Attributes: path, types, no-default-lib, name
43
44 Change log:
45 * v11 [2020-06-03]: Improve tagged template literals.
46 * v10 [2020-04-13]: Add the 'awaited' type operator.
47 * v9 [2020-02-23]: Add private-named instance fields and type-only imports/exports.
48 Improve conditional expressions.
49 * v8 [2019-12-12]: Add "bigint" primitive type.
50 * v7 [2019-11-20]: Move keywords of built-in object to "javascript.xml" and adapt.
51 * v6 [2019-10-01]: Add "asserts" keyword in type predicates.
52 Highlight types after the "as" keyword.
53 * v5 [2019-08-30]: Avoid that ?: be used as conditional expressions.
54 * v4 [2019-07-16]: Fixed highlighting of keywords before ":" in conditional expressions.
55 * v3 [2019-02-18]: Add support to bigint and the "is" keyword.
56 Fixes keyword delimiters. Don't highlight regex
57 after "]" and ")". Multiple fixes and improvements.
58 * v2 [2018-12-29]: Don't highlight built-in classes as functions,
59 fix float-points, improve types detection and other fixes.
60 * v1 [2018-11-18]: Initial version
61 -->
62
63 <language name="TypeScript"
64 version="16"
65 kateversion="5.53"
66 section="Scripts"
67 extensions="*.ts;*.mts;*.cts"
68 priority="9"
69 mimetype="text/typescript;application/typescript;text/x-typescript;application/x-typescript"
70 indenter="cstyle"
71 author="Nibaldo González ([email protected])"
72 license="MIT">
73
74 <highlighting>
75
76 <!-- Include all JavaScript keywords! -->
77 <list name="controlflow">
78 <include>controlflow##JavaScript</include>
79 <item>goto</item>
80 </list>
81 <list name="keywords">
82 <include>keywords##JavaScript</include>
83 </list>
84 <list name="reserved">
85 <include>reserved##JavaScript</include>
86 <item>type</item>
87 <item>arguments</item>
88 <!-- Class -->
89 <item>declare</item> <!-- storage modifier -->
90 <item>readonly</item>
91 <item>abstract</item>
92 <item>constructor</item>
93 <item>get</item>
94 <item>set</item>
95 <!-- Also:
96 public, protected, private, async, super, new, static -->
97 </list>
98 <list name="module">
99 <include>module##JavaScript</include>
100 </list>
101 <list name="primitives">
102 <include>primitives##JavaScript</include>
103 <!-- Types Built-in -->
104 <item>object</item>
105 <!-- Also:
106 this, true, false, undefined, null -->
107 </list>
108
109 <list name="control_export_types">
110 <!-- storage.type.namespace.ts -->
111 <item>namespace</item>
112 <item>module</item>
113 </list>
114 <list name="types_operator_expression">
115 <item>keyof</item>
116 <item>infer</item>
117 <item>awaited</item>
118 <!-- Also: typeof, readonly -->
119 </list>
120 <!-- Datatypes & Primitive Types -->
121 <list name="types">
122 <item>string</item>
123 <item>number</item>
124 <item>bigint</item>
125 <item>boolean</item>
126 <item>symbol</item>
127 <item>any</item>
128 <item>void</item>
129 <item>never</item>
130 <item>unknown</item>
131
132 <item>undefined</item>
133 <item>null</item>
134 <item>object</item>
135 </list>
136
137 <!-- Built-in Classes, Functions & Constants -->
138
139 <list name="class_builtin">
140 <include>class_builtin##JavaScript</include>
141 </list>
142 <!-- DOM Classes -->
143 <list name="class_dom">
144 <include>class_dom##JavaScript</include>
145 </list>
146 <!-- Node.js Classes -->
147 <list name="class_node">
148 <include>class_node##JavaScript</include>
149 </list>
150
151 <!-- General Properties of Classes -->
152 <list name="variable_property">
153 <include>variable_property##JavaScript</include>
154 </list>
155 <!-- General Built-in Functions -->
156 <list name="functions">
157 <include>functions##JavaScript</include>
158 </list>
159
160 <!-- Functions of "console" -->
161 <list name="console_functions">
162 <include>console_functions##JavaScript</include>
163 </list>
164 <!-- Properties of "process" -->
165 <list name="process_property">
166 <include>process_property##JavaScript</include>
167 </list>
168 <!-- Functions of "process" -->
169 <list name="process_functions">
170 <include>process_functions##JavaScript</include>
171 </list>
172
173 <!-- Constants of Number Class -->
174 <list name="number_constant">
175 <include>number_constant##JavaScript</include>
176 </list>
177 <!-- Constants of Math Class-->
178 <list name="math_constant">
179 <include>math_constant##JavaScript</include>
180 </list>
181 <!-- Methods of Math Class -->
182 <list name="math_functions">
183 <include>math_functions##JavaScript</include>
184 </list>
185 <!-- Methods of JSON Class -->
186 <list name="json_functions">
187 <include>json_functions##JavaScript</include>
188 </list>
189 <!-- Methods of Promise Class -->
190 <list name="promise_functions">
191 <include>promise_functions##JavaScript</include>
192 </list>
193
194 <!-- Node.js Variables -->
195 <list name="node_variable">
196 <include>node_variable##JavaScript</include>
197 </list>
198 <!-- DOM Variables -->
199 <list name="dom_variable">
200 <include>dom_variable##JavaScript</include>
201 </list>
202 <!-- DOM Constants -->
203 <list name="dom_constant">
204 <include>dom_constant##JavaScript</include>
205 </list>
206
207 <!-- For Autocomplete Keywords -->
208 <!-- Properties of DOM Classes -->
209 <list name="dom_property">
210 <include>dom_property##JavaScript</include>
211 </list>
212 <!-- Methods of DOM Classes -->
213 <list name="dom_functions">
214 <include>dom_functions##JavaScript</include>
215 </list>
216 <!-- Event Handler -->
217 <list name="eventhandler_property">
218 <include>eventhandler_property##JavaScript</include>
219 </list>
220 <!-- Others Methods of Classes -->
221 <list name="function_common">
222 <include>function_common##JavaScript</include>
223 </list>
224
225 <contexts>
226
227 <context name="Shebang" attribute="Normal Text" lineEndContext="Normal" lineEmptyContext="Normal" fallthrough="true" fallthroughContext="Normal">
228 <Detect2Chars context="ShebangLine" attribute="Comment" char="#" char1="!" column="0" />
229 </context>
230 <context name="ShebangLine" attribute="Comment" lineEndContext="#pop!Normal" />
231
232 <context name="Normal" attribute="Normal Text" lineEndContext="#stay">
233 <IncludeRules context="Normal Pt1" />
234
235 <!-- NOTE & TODO: The identifiers before ":" are highlighted as "dsNormal".
236 These identifiers should be highlighted in a different way depending on the
237 context, for example, in the declaration of classes or interfaces, in sets, the
238 parameters of a function, or after the keywords: "const", "var", "let" & "enum". -->
239 <RegExpr context="#stay" attribute="Parameter" String="&parameter;" />
240
241 <IncludeRules context="Normal Pt2" />
242 </context>
243
244 <context name="Normal Pt1" attribute="Normal Text" lineEndContext="#stay">
245 <StringDetect context="#stay" attribute="Symbol" String="..." />
246 <IncludeRules context="FindNumbers" />
247 <IncludeRules context="FindStrings" />
248
249 <!-- Abstract -->
250 <RegExpr context="#stay" attribute="Reserved" String="\babstract(?=\s+(?:class|interface)\b)" />
251 <!-- New -->
252 <RegExpr context="NewTarget" attribute="Keyword" String="\bnew(?=&objectPoint;\s*target\b)" />
253 <RegExpr context="MemberObject" attribute="Objects" String="\bnew(?=&objectOp;\.)" />
254 <WordDetect context="#stay" attribute="Keyword" String="new" />
255
256 <!-- Keywords: control flow -->
257 <keyword context="#stay" attribute="ControlFlow" String="controlflow" />
258 <RegExpr context="#stay" attribute="ControlFlow" String="\bdefault(?=\s*&objectOp;:)" />
259 </context>
260 <context name="Normal Pt2" attribute="Normal Text" lineEndContext="#stay">
261 <!-- Keywords -->
262 <WordDetect context="TypeDeclaration" attribute="Reserved" String="type" />
263 <WordDetect context="FunctionDeclaration" attribute="Keyword" String="function" />
264 <keyword context="#stay" attribute="Keyword" String="keywords" /> <!-- NoRegExp? -->
265 <keyword context="#stay" attribute="Reserved" String="reserved" />
266
267 <!-- Utility Types -->
268 <RegExpr context="#stay" attribute="Built-in Objects" String="&utilityTypes;" />
269 <!-- Built-in Classes -->
270 <IncludeRules context="BuiltInClasses" />
271 <IncludeRules context="BuiltInConstants" />
272 <!-- Objects -->
273 <RegExpr context="MemberObject" attribute="Objects" String="&identifier;(?=&objectPoint;)" />
274 <DetectChar context="MemberObject" attribute="Symbol" char="." />
275
276 <RegExpr context="Types" attribute="Module" String="\bas(?=\s)" />
277 <!-- Import -->
278 <WordDetect context="Import" attribute="Module" String="import" />
279 <RegExpr context="#stay" attribute="Module" String="\bexport\s+type\b" />
280 <!-- Export types -->
281 <keyword context="ControlExport" attribute="Module" String="control_export_types" />
282 <!-- Keywords -->
283 <keyword context="#stay" attribute="Module" String="module" />
284 <keyword context="NoRegExp" attribute="Keyword" String="primitives" />
285 <keyword context="#stay" attribute="Keyword" String="types_operator_expression" />
286
287 <!-- Functions: function(...) and function<...>(...) -->
288 <RegExpr context="Function" attribute="Function Name" String="(&identifier;)&functionSuffix;" lookAhead="true" />
289 <!-- Tagged Template Literals -->
290 <RegExpr context="#stay" attribute="Function Name" String="&identifier;(?=\s*`)" />
291
292 <!-- Symbols & Operators -->
293 <!-- NOTE: - The brackets {}()[] are highlighted as Normal Text.
294 - Bracket highlighting rules must be explicitly included here
295 for the "Animate Bracket Highlighting" feature to work properly. -->
296 <DetectChar context="Object" attribute="Normal Text" char="{" beginRegion="Brace" />
297 <DetectChar context="#stay" attribute="Normal Text" char="[" beginRegion="List" />
298 <DetectChar context="NoRegExp" attribute="Normal Text" char="]" endRegion="List" />
299 <DetectChar context="#stay" attribute="Normal Text" char="(" />
300 <DetectChar context="NoRegExp" attribute="Normal Text" char=")" />
301
302 <Detect2Chars context="#stay" attribute="Symbol" char="?" char1="?" /> <!-- Null operator -->
303 <!-- Conditional Expressions:
304 CASE 1: '?' ... <identifier> ':'
305 CASE 2: '?' ... ( '||' | '&&' ) <end-line>
306 CASE 3: '?' (<identifier>)? <end-line>
307 -->
308 <RegExpr context="ConditionalExpression" attribute="Symbol" String="\?(?=\s*(?:(?:[^/&quot;'`\s\?:\.;,\=\}\]\)]|&codeContent;)(?:[^/&quot;'`]|&codeContent;)*)?&identifier;\s*(?:/\*.*\*/\s*)*:|(?:&amp;&amp;|\|\||\s*(?:/\*.*\*/\s*)*&identifier;)?&endLine;)" minimal="true" />
309
310 <!-- Type Parameter: Highlight types after ":" and between "<" and ">" -->
311 <DetectChar context="Types" attribute="Symbol" char=":" />
312 <RegExpr context="TypesAngleBracket" attribute="Symbol" String="&lt;(?=(?:&identifier;|[\[\{\(&lt;]).*&gt;)" />
313
314 <IncludeRules context="JSBase##JavaScript" />
315 </context>
316
317 <!-- Conditional Expressions: a ? b : c -->
318 <!-- Highlight keywords before ":" in conditional expressions. -->
319 <context name="ConditionalExpression" attribute="Normal Text" lineEndContext="#stay">
320 <!-- NOTE: Don't start the "Types" context. See the context "Default Types". -->
321 <DetectChar context="#pop" attribute="Symbol" char=":" />
322 <IncludeRules context="ConditionalExpressionEnd" />
323 <DetectChar context="#stay" attribute="Symbol" char="?" />
324
325 <IncludeRules context="FindConditionalExpressionBrackets" />
326 <IncludeRules context="Normal-ParametersOverridden" />
327 </context>
328 <context name="Normal-ParametersOverridden" attribute="Normal Text" lineEndContext="#stay">
329 <IncludeRules context="Normal Pt1" />
330 <IncludeRules context="Normal Pt2" />
331 <!-- unrecheable by Regex=&identifier; in "JSBase##JavaScript" included by "Normal Pt2"
332 <RegExpr context="#stay" attribute="Parameter" String="&parameter;" />-->
333 </context>
334 <context name="ConditionalExpressionEnd" attribute="Normal Text" lineEndContext="#stay">
335 <AnyChar context="#pop" String=";,}])" lookAhead="true" />
336 <RegExpr context="#pop" String="\=(?!&gt;)" lookAhead="true" />
337 <!-- For TypeScript code embedded in HTML and Markdown -->
338 <StringDetect context="#pop" String="```" lookAhead="true" firstNonSpace="true" />
339 <StringDetect context="#pop" String="~~~" lookAhead="true" firstNonSpace="true" />
340 <RegExpr context="#pop" String="&lt;/script\s*(?:&gt;|$)" insensitive="true" lookAhead="true" />
341 </context>
342 <context name="FindConditionalExpressionBrackets" attribute="Normal Text" lineEndContext="#stay">
343 <DetectChar context="ConditionalExpressionRoundBracket" attribute="Normal Text" char="(" />
344 <DetectChar context="ConditionalExpressionSquareBracket" attribute="Symbol" char="[" beginRegion="List" />
345 </context>
346 <context name="ConditionalExpressionRoundBracket" attribute="Normal Text" lineEndContext="#stay">
347 <DetectChar context="#pop!NoRegExp" attribute="Normal Text" char=")" />
348 <IncludeRules context="FindConditionalExpressionBrackets" />
349 <IncludeRules context="Normal" />
350 </context>
351 <context name="ConditionalExpressionSquareBracket" attribute="Normal Text" lineEndContext="#stay">
352 <DetectChar context="#pop!NoRegExp" attribute="Symbol" char="]" endRegion="List" />
353 <IncludeRules context="FindConditionalExpressionBrackets" />
354 <IncludeRules context="Normal" />
355 </context>
356
357 <!-- Object, within { ... } -->
358 <context name="Object" attribute="Normal Text" lineEndContext="#stay">
359 <DetectChar context="#pop" attribute="Normal Text" char="}" endRegion="Brace" />
360 <keyword context="NoRegExp" attribute="Keyword" String="keywords" />
361 <!-- Highlight types in the following line.
362 NOTE: Using the "NoRegExp" context can cause this to apply to multiple lines. -->
363 <RegExpr context="TypesNewLine" attribute="Symbol" String=":(?=&endLine;)" minimal="true" />
364 <IncludeRules context="Normal" />
365 </context>
366
367 <!-- Avoid highlighting regular expressions. -->
368 <context name="NoRegExp" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop">
369 <IncludeRules context="NoRegExp##JavaScript" />
370 </context>
371 <!-- Avoid highlighting regular expressions on a single line. -->
372 <context name="NoRegExpSameLine" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
373 <IncludeRules context="NoRegExp##JavaScript" />
374 </context>
375
376 <!-- Numbers -->
377 <context name="FindNumbers" attribute="Normal Text" lineEndContext="#stay">
378 <RegExpr context="NoRegExp" attribute="Hexadecimal" String="\b0[xX][\da-fA-F][\da-fA-F_]*&numSuffix;" />
379 <RegExpr context="NoRegExp" attribute="Binary" String="\b0[bB][01][01_]*&numSuffix;" />
380 <RegExpr context="NoRegExp" attribute="Float" String="(?:\b\d[\d_]*\.?|(?:\b\d[\d_]*)?\.\d[\d_]*)[eE][\+\-]?\d[\d_]*&numSuffix;|(?:\.\d[\d_]*|\b\d[\d_]*\.(?:\d[\d_]*)?)&numSuffix;" />
381 <RegExpr context="NoRegExp" attribute="Octal" String="\b0[oO]?[0-7][0-7_]*&numSuffix;" />
382 <RegExpr context="NoRegExp" attribute="Decimal" String="\b\d[\d_]*&numSuffix;" />
383 </context>
384
385 <!-- Function Name -->
386 <context name="Function" attribute="Normal Text" lineEndContext="#pop">
387 <keyword context="#pop" attribute="Function (Built-in)" String="functions" />
388 <StringDetect context="#pop" attribute="Function Name" String="%1" dynamic="true" />
389 <AnyChar context="#pop" String="(&lt;&gt;" lookAhead="true" />
390 </context>
391 <context name="FunctionDeclaration" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop">
392 <DetectSpaces />
393 <RegExpr context="#pop" attribute="Function Declaration" String="&identifier;&functionSuffix;" /> <!-- NoRegExp -->
394 <IncludeRules context="FindComments##JavaScript" />
395 </context>
396
397 <!-- Strings -->
398 <context name="FindStrings" attribute="Normal Text" lineEndContext="#stay">
399 <DetectChar context="Template" attribute="Template" char="`" beginRegion="Template" />
400 <IncludeRules context="FindStrings##JavaScript" />
401 </context>
402 <context name="Template" attribute="Template" lineEndContext="#stay">
403 <IncludeRules context="Escape##JavaScript" />
404 <Detect2Chars context="Substitution" attribute="Substitution" char="$" char1="{" />
405 <DetectChar context="RegExpAfterString##JavaScript" attribute="Template" char="`" endRegion="Template" />
406 </context>
407 <context name="Substitution" attribute="Normal Text" lineEndContext="#stay">
408 <DetectChar context="#pop" attribute="Substitution" char="}" />
409 <IncludeRules context="Normal" />
410 </context>
411
412 <!-- Type Declaration: Highlight types after the "type" keyword -->
413
414 <context name="TypeDeclaration" attribute="Normal Text" lineEndContext="#stay">
415 <DetectSpaces />
416 <AnyChar context="#pop" String=";,{})]" lookAhead="true" />
417 <IncludeRules context="TypesFindBrackets" />
418 <IncludeRules context="DefaultTypes" />
419 <IncludeRules context="Normal" />
420 </context>
421
422 <!-- Type Parameter: Highlight types after ":" -->
423
424 <context name="Types" attribute="Normal Text" lineEndContext="#pop">
425 <IncludeRules context="FixPopLineEndContext" />
426 <IncludeRules context="TypesCommon" />
427 </context>
428 <context name="TypesCommon" attribute="Normal Text" lineEndContext="#pop">
429 <DetectSpaces />
430 <IncludeRules context="TypesEnd" />
431 <!-- New line after "|" or "&".
432 IMPORTANT: If you modify this rule, do so in "typescript-react.xml"! -->
433 <RegExpr context="#pop!TypesNewLine" attribute="Symbol" String="[\|&amp;](?=&endLine;)" minimal="true" />
434
435 <IncludeRules context="TypesFindBrackets" />
436 <IncludeRules context="DefaultTypes" />
437 <IncludeRules context="Normal-ParametersOverridden" />
438 </context>
439 <!-- NOTE: Context used by "typescript-react.xml" -->
440 <context name="TypesEnd" attribute="Normal Text" lineEndContext="#stay">
441 <AnyChar context="#pop" String=";,}])" lookAhead="true" />
442 <RegExpr context="#pop" String="\=(?!&gt;)" lookAhead="true" />
443 <Detect2Chars context="#pop" char="/" char1="/" lookAhead="true" />
444 </context>
445 <context name="TypesNewLine" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!TypesCommon">
446 <DetectSpaces />
447 <IncludeRules context="FindComments##JavaScript" />
448 </context>
449
450 <!-- NOTE: The "NoRegExp" context invalidates lineEndContext="#pop",
451 therefore the following rule is necessary -->
452 <context name="FixPopLineEndContext" attribute="Normal Text" lineEndContext="#stay">
453 <RegExpr context="#pop" String="\S" firstNonSpace="true" lookAhead="true" />
454 </context>
455
456 <!-- Default: Type Parameter, Type Declaration, Angle Brackets -->
457
458 <context name="DefaultTypes" attribute="Normal Text" lineEndContext="#stay">
459 <!-- Types Keywords -->
460 <keyword context="NoRegExpSameLine" attribute="Types" String="types" />
461 <!-- Assertions -->
462 <WordDetect context="NoRegExpSameLine" attribute="Keyword" String="asserts" />
463 <!-- Type Guards -->
464 <WordDetect context="NoRegExpSameLine" attribute="Keyword" String="is" />
465
466 <!-- FIXME: For a strange reason, the keywords before "}" are not highlighted.
467 This rule fixes it provisionally. -->
468 <RegExpr context="#stay" attribute="Types" String="\b(?:string|number|bigint|boolean|symbol|any|void|never|unknown|undefined|null|object)(?=\})" />
469
470 <!-- Don't start this context again and don't start the "ConditionalExpression" context -->
471 <AnyChar context="#stay" attribute="Symbol" String=":?" />
472 <WordDetect context="#stay" attribute="Module" String="as" />
473 </context>
474 <context name="TypesFindBrackets" attribute="Normal Text" lineEndContext="#stay">
475 <DetectChar context="TypesSquareBracket" attribute="Normal Text" char="[" beginRegion="List" />
476 <DetectChar context="TypesCurlyBracket" attribute="Normal Text" char="{" beginRegion="Brace" />
477 <DetectChar context="TypesRoundBracket" attribute="Normal Text" char="(" />
478 </context>
479
480 <context name="TypesSquareBracket" attribute="Normal Text" lineEndContext="#stay">
481 <DetectChar context="#pop!NoRegExp" attribute="Normal Text" char="]" endRegion="List" />
482 <IncludeRules context="TypesFindBrackets" />
483 <IncludeRules context="DefaultTypes" />
484 <IncludeRules context="Normal" />
485 </context>
486 <context name="TypesCurlyBracket" attribute="Normal Text" lineEndContext="#pop!Object">
487 <DetectChar context="#pop" attribute="Normal Text" char="}" endRegion="Brace" />
488 <RegExpr context="#pop!Object" String="\S" firstNonSpace="true" lookAhead="true" /> <!-- FixPopLineEndContext -->
489 <IncludeRules context="TypesFindBrackets" />
490 <IncludeRules context="DefaultTypes" />
491 <IncludeRules context="Object" />
492 </context>
493 <context name="TypesRoundBracket" attribute="Normal Text" lineEndContext="#pop">
494 <DetectChar context="#pop!NoRegExp" attribute="Normal Text" char=")" />
495 <IncludeRules context="FixPopLineEndContext" />
496 <IncludeRules context="TypesFindBrackets" />
497 <IncludeRules context="DefaultTypes" />
498 <IncludeRules context="Normal" />
499 </context>
500
501 <context name="TypesAngleBracket" attribute="Normal Text" lineEndContext="#pop">
502 <DetectChar context="#pop" attribute="Symbol" char="&gt;" />
503 <IncludeRules context="TypesAngleBracketEnd" />
504 <IncludeRules context="FixPopLineEndContext" />
505 <IncludeRules context="TypesFindBrackets" />
506 <IncludeRules context="DefaultTypes" />
507 <IncludeRules context="Normal" />
508 </context>
509 <!-- NOTE: Context used by "typescript-react.xml" -->
510 <context name="TypesAngleBracketEnd" attribute="Normal Text" lineEndContext="#stay">
511 <AnyChar context="#pop" String="})];" lookAhead="true" />
512 </context>
513
514 <!-- new.target -->
515 <context name="NewTarget" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
516 <DetectSpaces />
517 <AnyChar context="#stay" attribute="Symbol" String=".?!" />
518 <WordDetect context="#pop!NoRegExp" attribute="Keyword" String="target" />
519 </context>
520
521 <!-- After keyword list "control_export_types" -->
522 <context name="ControlExport" attribute="Normal Text" lineEndContext="#pop">
523 <AnyChar context="#pop" attribute="Normal Text" String="{;" lookAhead="true" />
524 <IncludeRules context="FindStrings" />
525 <RegExpr context="#stay" attribute="Types" String="&identifier;" />
526 <IncludeRules context="FindComments##JavaScript" />
527 </context>
528
529 <!-- "import" keyword -->
530 <context name="Import" attribute="Normal Text" lineEndContext="#pop">
531 <DetectChar context="#pop!ImportRequireKey" attribute="Symbol" char="=" />
532 <!-- import type ... -->
533 <WordDetect context="#stay" attribute="Module" String="type" />
534 <!-- importmeta_property -->
535 <WordDetect context="#pop!NoRegExp" attribute="Keyword" String="meta" />
536 <!-- Fix context NoRegExp (#pop in new line) -->
537 <RegExpr context="#pop" String="." lookAhead="true" firstNonSpace="true" />
538 <AnyChar context="#pop" String="{}()[];," lookAhead="true" />
539 <IncludeRules context="Normal" />
540 </context>
541 <context name="ImportRequireKey" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
542 <RegExpr context="#stay" attribute="Keyword" String="\s*require\s*(?=\()" />
543 <DetectChar context="ImportRequire" attribute="Normal Text" char="(" beginRegion="import" />
544 </context>
545 <context name="ImportRequire" attribute="Normal Text" lineEndContext="#stay">
546 <DetectChar context="#pop#pop" attribute="Normal Text" char=")" endRegion="import" />
547 <IncludeRules context="FindStrings" />
548 <IncludeRules context="FindNumbers" />
549 <IncludeRules context="FindComments##JavaScript" />
550 </context>
551
552 <!-- Member Objects -->
553
554 <context name="MemberObject" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
555 <IncludeRules context="DefaultMemberObject" />
556 <!-- Common functions and properties, only for autocomplete keywords -->
557 <keyword context="#pop!NoRegExp" attribute="Object Member" String="dom_property" />
558 <keyword context="#pop!NoRegExp" attribute="Function Name" String="dom_functions" />
559 <keyword context="#pop!NoRegExp" attribute="Object Member" String="eventhandler_property" />
560 <keyword context="#pop!NoRegExp" attribute="Function Name" String="function_common" />
561 </context>
562
563 <context name="DefaultMemberObject" attribute="Normal Text" lineEndContext="#pop">
564 <IncludeRules context="FixPointMemberObject" />
565 <DetectChar context="#stay" attribute="Symbol" char="." />
566 <Detect2Chars context="#stay" attribute="Symbol" char="?" char1="." />
567 <Detect2Chars context="#stay" attribute="Symbol" char="!" char1="." />
568
569 <!-- The order of these rules is important: 1) Functions. 2) Constants & Properties. 3) Obj. Members. -->
570 <!-- function(...) and function<...>(...) -->
571 <RegExpr context="#pop" attribute="Function Name" String="&identifier;&functionSuffix;" />
572 <!-- Tagged Template Literals -->
573 <RegExpr context="#pop" String="&identifier;\s*`" lookAhead="true" />
574 <!-- Generic constants and properties -->
575 <keyword context="#pop!NoRegExp" attribute="Object Property (Built-in)" String="variable_property" />
576 <keyword context="#pop!NoRegExp" attribute="Constant" String="dom_constant" />
577
578 <RegExpr context="#stay" attribute="Normal Text" String="#(?=&identifier;)" /> <!-- Private-Named Instance Fields -->
579 <RegExpr context="#stay" attribute="Object Member" String="&identifier;(?=&objectPoint;)" />
580 <RegExpr context="#pop!NoRegExp" attribute="Object Member" String="&identifier;" />
581 <IncludeRules context="NoRegExp" />
582
583 <!-- Generic functions -->
584 <keyword context="#pop!NoRegExp" attribute="Function Name" String="functions" />
585 </context>
586 <context name="FixPointMemberObject" attribute="Normal Text" lineEndContext="#pop">
587 <StringDetect context="#pop" attribute="Symbol" String="?..." />
588 <StringDetect context="#pop" attribute="Symbol" String="!..." />
589 <StringDetect context="#pop" attribute="Symbol" String="..." />
590 </context>
591
592
593 <!-- Built-in Classes -->
594 <!-- Keep in sync with javascript.xml -->
595
596 <context name="BuiltInClasses" attribute="Normal Text" lineEndContext="#stay">
597 <WordDetect context="FindMemberObjectMath" attribute="Built-in Objects" String="Math" />
598 <WordDetect context="FindMemberObjectNumber" attribute="Built-in Objects" String="Number" />
599 <WordDetect context="FindMemberObjectPromise" attribute="Built-in Objects" String="Promise" />
600 <WordDetect context="FindMemberObjectJSON" attribute="Built-in Objects" String="JSON" />
601 <WordDetect context="FindMemberObjectConsole" attribute="Built-in Objects" String="console" />
602 <WordDetect context="FindMemberObjectProcess" attribute="Built-in Objects" String="process" />
603
604 <keyword context="NoRegExp" attribute="Built-in Objects" String="class_builtin" />
605 <keyword context="NoRegExp" attribute="Built-in Objects" String="class_dom" />
606 <keyword context="FindMemberObjectDOM" attribute="Built-in Objects" String="dom_variable" />
607 <keyword context="NoRegExp" attribute="Built-in Objects" String="class_node" />
608 <keyword context="NoRegExp" attribute="Built-in Objects" String="node_variable" />
609 </context>
610 <!-- These constants are highlighted in "Normal" -->
611 <context name="BuiltInConstants" attribute="Normal Text" lineEndContext="#stay">
612 <keyword context="NoRegExp" attribute="Constant" String="math_constant" />
613 <keyword context="NoRegExp" attribute="Constant" String="number_constant" />
614 <keyword context="NoRegExp" attribute="Constant" String="dom_constant" />
615 </context>
616
617 <!-- DOM Variable -->
618 <context name="FindMemberObjectDOM" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!NoRegExp">
619 <DetectSpaces />
620 <IncludeRules context="FixPointMemberObject" />
621 <DetectChar context="#pop!MemberObjectDOM" attribute="Symbol" char="." />
622 <Detect2Chars context="#pop!MemberObjectDOM" attribute="Symbol" char="?" char1="." />
623 <Detect2Chars context="#pop!MemberObjectDOM" attribute="Symbol" char="!" char1="." />
624 </context>
625 <context name="MemberObjectDOM" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
626 <keyword context="#pop!FindMemberObjectDOM" attribute="Object Property (Built-in)" String="dom_property" />
627 <keyword context="#pop!FindMemberObjectDOM" attribute="Object Method (Built-in)" String="dom_functions" />
628 <IncludeRules context="DefaultMemberObject" />
629 <!-- Only for autocomplete -->
630 <keyword context="#pop!NoRegExp" attribute="Object Member" String="eventhandler_property" />
631 <keyword context="#pop!NoRegExp" attribute="Function Name" String="function_common" />
632 </context>
633 <!-- Math Class -->
634 <context name="FindMemberObjectMath" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!NoRegExp">
635 <DetectSpaces />
636 <IncludeRules context="FixPointMemberObject" />
637 <DetectChar context="#pop!MemberObjectMath" attribute="Symbol" char="." />
638 <Detect2Chars context="#pop!MemberObjectMath" attribute="Symbol" char="?" char1="." />
639 <Detect2Chars context="#pop!MemberObjectMath" attribute="Symbol" char="!" char1="." />
640 </context>
641 <context name="MemberObjectMath" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
642 <keyword context="#pop!NoRegExp" attribute="Constant" String="math_constant" />
643 <keyword context="#pop!NoRegExp" attribute="Object Method (Built-in)" String="math_functions" />
644 <IncludeRules context="DefaultMemberObject" />
645 </context>
646 <!-- Number Class -->
647 <context name="FindMemberObjectNumber" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!NoRegExp">
648 <DetectSpaces />
649 <IncludeRules context="FixPointMemberObject" />
650 <DetectChar context="#pop!MemberObjectNumber" attribute="Symbol" char="." />
651 <Detect2Chars context="#pop!MemberObjectNumber" attribute="Symbol" char="?" char1="." />
652 <Detect2Chars context="#pop!MemberObjectNumber" attribute="Symbol" char="!" char1="." />
653 </context>
654 <context name="MemberObjectNumber" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
655 <keyword context="#pop!NoRegExp" attribute="Constant" String="number_constant" />
656 <IncludeRules context="DefaultMemberObject" />
657 </context>
658 <!-- Promise Class -->
659 <context name="FindMemberObjectPromise" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!NoRegExp">
660 <DetectSpaces />
661 <IncludeRules context="FixPointMemberObject" />
662 <DetectChar context="#pop!MemberObjectPromise" attribute="Symbol" char="." />
663 <Detect2Chars context="#pop!MemberObjectPromise" attribute="Symbol" char="?" char1="." />
664 <Detect2Chars context="#pop!MemberObjectPromise" attribute="Symbol" char="!" char1="." />
665 </context>
666 <context name="MemberObjectPromise" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
667 <keyword context="#pop!NoRegExp" attribute="Object Method (Built-in)" String="promise_functions" />
668 <IncludeRules context="DefaultMemberObject" />
669 </context>
670 <!-- JSON Class -->
671 <context name="FindMemberObjectJSON" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!NoRegExp">
672 <DetectSpaces />
673 <IncludeRules context="FixPointMemberObject" />
674 <DetectChar context="#pop!MemberObjectJSON" attribute="Symbol" char="." />
675 <Detect2Chars context="#pop!MemberObjectJSON" attribute="Symbol" char="?" char1="." />
676 <Detect2Chars context="#pop!MemberObjectJSON" attribute="Symbol" char="!" char1="." />
677 </context>
678 <context name="MemberObjectJSON" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
679 <keyword context="#pop!NoRegExp" attribute="Object Method (Built-in)" String="json_functions" />
680 <IncludeRules context="DefaultMemberObject" />
681 </context>
682 <!-- Console Object -->
683 <context name="FindMemberObjectConsole" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!NoRegExp">
684 <DetectSpaces />
685 <IncludeRules context="FixPointMemberObject" />
686 <DetectChar context="#pop!MemberObjectConsole" attribute="Symbol" char="." />
687 <Detect2Chars context="#pop!MemberObjectConsole" attribute="Symbol" char="?" char1="." />
688 <Detect2Chars context="#pop!MemberObjectConsole" attribute="Symbol" char="!" char1="." />
689 </context>
690 <context name="MemberObjectConsole" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
691 <keyword context="#pop!NoRegExp" attribute="Object Method (Built-in)" String="console_functions" />
692 <IncludeRules context="DefaultMemberObject" />
693 </context>
694 <!-- Process Object -->
695 <context name="FindMemberObjectProcess" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!NoRegExp">
696 <DetectSpaces />
697 <IncludeRules context="FixPointMemberObject" />
698 <DetectChar context="#pop!MemberObjectProcess" attribute="Symbol" char="." />
699 <Detect2Chars context="#pop!MemberObjectProcess" attribute="Symbol" char="?" char1="." />
700 <Detect2Chars context="#pop!MemberObjectProcess" attribute="Symbol" char="!" char1="." />
701 </context>
702 <context name="MemberObjectProcess" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
703 <keyword context="#pop!NoRegExp" attribute="Object Method (Built-in)" String="process_functions" />
704 <keyword context="#pop!NoRegExp" attribute="Object Property (Built-in)" String="process_property" />
705 <IncludeRules context="DefaultMemberObject" />
706 </context>
707
708 </contexts>
709
710 <itemDatas>
711 <itemData name="Normal Text" defStyleNum="dsNormal" spellChecking="false" />
712 <itemData name="Keyword" defStyleNum="dsKeyword" spellChecking="false" />
713 <itemData name="ControlFlow" defStyleNum="dsControlFlow" spellChecking="false" />
714 <itemData name="Reserved" defStyleNum="dsKeyword" italic="true" spellChecking="false" />
715 <itemData name="Module" defStyleNum="dsImport" spellChecking="false" />
716 <itemData name="Objects" defStyleNum="dsNormal" spellChecking="false" />
717 <itemData name="Object Member" defStyleNum="dsAttribute" spellChecking="false" />
718 <itemData name="Function Name" defStyleNum="dsFunction" spellChecking="false" />
719 <itemData name="Function Declaration" defStyleNum="dsFunction" spellChecking="false" />
720 <itemData name="Built-in Objects" defStyleNum="dsBuiltIn" spellChecking="false" />
721 <itemData name="Object Property (Built-in)" defStyleNum="dsAttribute" italic="1" spellChecking="false" />
722 <itemData name="Object Method (Built-in)" defStyleNum="dsFunction" italic="1" spellChecking="false" />
723 <itemData name="Function (Built-in)" defStyleNum="dsPreprocessor" spellChecking="false" />
724 <itemData name="Constant" defStyleNum="dsConstant" spellChecking="false" />
725 <itemData name="Types" defStyleNum="dsDataType" spellChecking="false" />
726 <itemData name="Parameter" defStyleNum="dsNormal" spellChecking="false" />
727
728 <itemData name="Decimal" defStyleNum="dsDecVal" spellChecking="false" />
729 <itemData name="Octal" defStyleNum="dsBaseN" spellChecking="false" />
730 <itemData name="Hexadecimal" defStyleNum="dsBaseN" spellChecking="false" />
731 <itemData name="Binary" defStyleNum="dsBaseN" spellChecking="false" />
732 <itemData name="Float" defStyleNum="dsFloat" spellChecking="false" />
733 <itemData name="Template" defStyleNum="dsVerbatimString" />
734 <itemData name="Substitution" defStyleNum="dsSpecialChar" spellChecking="false" />
735
736 <itemData name="Comment" defStyleNum="dsComment" />
737 <itemData name="Symbol" defStyleNum="dsOperator" spellChecking="false" />
738 </itemDatas>
739
740 </highlighting>
741
742 <general>
743 <comments>
744 <comment name="singleLine" start="//" position="afterwhitespace" />
745 <comment name="multiLine" start="/*" end="*/" />
746 </comments>
747 <keywords casesensitive="1" additionalDeliminator="&quot;&apos;`" weakDeliminator="$" />
748 </general>
749
750 </language>
751 <!-- kate: replace-tabs off; tab-width 3; indent-width 3; remove-trailing-spaces mod; dynamic-word-wrap off; -->