Warning, /frameworks/syntax-highlighting/data/syntax/typescript.xml is written in an unsupported language. File is not indexed.

0001 <?xml version="1.0" encoding="UTF-8"?>
0002 <!DOCTYPE language
0003 [
0004         <!ENTITY identifier     "[a-zA-Z_$[:^ascii:]][\w$[:^ascii:]]*+">
0005         <!ENTITY numSuffix      "(?=n?(?:[^\w]|$))">
0006         <!ENTITY objectOp       "[\?!]?">
0007         <!ENTITY objectPoint    "\s*&objectOp;\.">
0008         <!ENTITY endLine        "\s*(?:$|//|(?:/\*.*\*/\s*)+(?:$|//))">
0009         <!ENTITY parameter      "&identifier;(?=\s*&objectOp;:)">
0010 
0011         <!ENTITY utilityTypes   "\b(?:Partial|Readonly|Record|Pick|Omit|Exclude|Extract|NonNullable|ReturnType|InstanceType|Required|ThisType)(?=\s*&lt;)">
0012         <!-- function<...>( or function( -->
0013         <!ENTITY functionSuffix "(?=\s*(?:&lt;(?:\{(?:[^\{\}]|\{[^\{\}]*\})*\}|\((?:[^\(\)]|\([^\(\)]*\))*\)|\[(?:[^\[\]]|\[[^\[\]]*\])*\]|'(?:\\.|[^'])*'|&quot;(?:\\.|[^&quot;])*&quot;|`(?:\\.|[^`])*`|[^&lt;&gt;]|&lt;.*&gt;)*&gt;)?\()">
0014 
0015         <!ENTITY codeContent    "&quot;(?:[^&quot;]|\\.)*&quot;|'(?:[^']|\\.)*'|`(?:[^`]|\\.)`|/\*.*\*/|/(?:[^/\\\[]|\\.|\[(?:[^\]\\]|\\.)+\])+/">
0016 ]>
0017 
0018 <!--
0019     ====================================================================
0020 
0021       This file is part of the KDE's KSyntaxHighlighting framework.
0022 
0023       Copyright 2018-2020 Nibaldo González S. (nibgonz@gmail.com)
0024 
0025       This Source Code Form is subject to the terms of the MIT License.
0026       If a copy of the license was not distributed with this file,
0027       You can obtain one at: https://opensource.org/licenses/MIT
0028 
0029     ====================================================================
0030 
0031     This file is an extension of the JavaScript highlighter
0032     (javascript.xml, Version 14 and higher).
0033     Based on the TypeScript grammar files,
0034     available at: https://github.com/Microsoft/TypeScript-TmLanguage
0035 
0036     NOTE: TypeScript directives are highlighted by "doxygen.xml",
0037     included in the JavaScript highlighter.
0038     Ex:
0039       /// <reference no-default-lib="true"/>
0040 
0041       Tags: reference, amd-dependency, amd-module
0042       Attributes: path, types, no-default-lib, name
0043 
0044     Change log:
0045      * v11 [2020-06-03]: Improve tagged template literals.
0046      * v10 [2020-04-13]: Add the 'awaited' type operator.
0047      * v9 [2020-02-23]: Add private-named instance fields and type-only imports/exports.
0048                         Improve conditional expressions.
0049      * v8 [2019-12-12]: Add "bigint" primitive type.
0050      * v7 [2019-11-20]: Move keywords of built-in object to "javascript.xml" and adapt.
0051      * v6 [2019-10-01]: Add "asserts" keyword in type predicates.
0052                         Highlight types after the "as" keyword.
0053      * v5 [2019-08-30]: Avoid that ?: be used as conditional expressions.
0054      * v4 [2019-07-16]: Fixed highlighting of keywords before ":" in conditional expressions.
0055      * v3 [2019-02-18]: Add support to bigint and the "is" keyword.
0056                         Fixes keyword delimiters. Don't highlight regex
0057                         after "]" and ")". Multiple fixes and improvements.
0058      * v2 [2018-12-29]: Don't highlight built-in classes as functions,
0059                         fix float-points, improve types detection and other fixes.
0060      * v1 [2018-11-18]: Initial version
0061 -->
0062 
0063 <language name="TypeScript"
0064           version="16"
0065           kateversion="5.53"
0066           section="Scripts"
0067           extensions="*.ts;*.mts;*.cts"
0068           priority="9"
0069           mimetype="text/typescript;application/typescript;text/x-typescript;application/x-typescript"
0070           indenter="cstyle"
0071           author="Nibaldo González (nibgonz@gmail.com)"
0072           license="MIT">
0073 
0074 <highlighting>
0075 
0076         <!-- Include all JavaScript keywords! -->
0077         <list name="controlflow">
0078                 <include>controlflow##JavaScript</include>
0079                 <item>goto</item>
0080         </list>
0081         <list name="keywords">
0082                 <include>keywords##JavaScript</include>
0083         </list>
0084         <list name="reserved">
0085                 <include>reserved##JavaScript</include>
0086                 <item>type</item>
0087                 <item>arguments</item>
0088                 <!-- Class -->
0089                 <item>declare</item> <!-- storage modifier -->
0090                 <item>readonly</item>
0091                 <item>abstract</item>
0092                 <item>constructor</item>
0093                 <item>get</item>
0094                 <item>set</item>
0095                 <!-- Also:
0096                      public, protected, private, async, super, new, static -->
0097         </list>
0098         <list name="module">
0099                 <include>module##JavaScript</include>
0100         </list>
0101         <list name="primitives">
0102                 <include>primitives##JavaScript</include>
0103                 <!-- Types Built-in -->
0104                 <item>object</item>
0105                 <!-- Also:
0106                      this, true, false, undefined, null -->
0107         </list>
0108 
0109         <list name="control_export_types">
0110                 <!-- storage.type.namespace.ts -->
0111                 <item>namespace</item>
0112                 <item>module</item>
0113         </list>
0114         <list name="types_operator_expression">
0115                 <item>keyof</item>
0116                 <item>infer</item>
0117                 <item>awaited</item>
0118                 <!-- Also: typeof, readonly -->
0119         </list>
0120         <!-- Datatypes & Primitive Types -->
0121         <list name="types">
0122                 <item>string</item>
0123                 <item>number</item>
0124                 <item>bigint</item>
0125                 <item>boolean</item>
0126                 <item>symbol</item>
0127                 <item>any</item>
0128                 <item>void</item>
0129                 <item>never</item>
0130                 <item>unknown</item>
0131 
0132                 <item>undefined</item>
0133                 <item>null</item>
0134                 <item>object</item>
0135         </list>
0136 
0137         <!-- Built-in Classes, Functions & Constants -->
0138 
0139         <list name="class_builtin">
0140                 <include>class_builtin##JavaScript</include>
0141         </list>
0142         <!-- DOM Classes -->
0143         <list name="class_dom">
0144                 <include>class_dom##JavaScript</include>
0145         </list>
0146         <!-- Node.js Classes -->
0147         <list name="class_node">
0148                 <include>class_node##JavaScript</include>
0149         </list>
0150 
0151         <!-- General Properties of Classes -->
0152         <list name="variable_property">
0153                 <include>variable_property##JavaScript</include>
0154         </list>
0155         <!-- General Built-in Functions -->
0156         <list name="functions">
0157                 <include>functions##JavaScript</include>
0158         </list>
0159 
0160         <!-- Functions of "console" -->
0161         <list name="console_functions">
0162                 <include>console_functions##JavaScript</include>
0163         </list>
0164         <!-- Properties of "process" -->
0165         <list name="process_property">
0166                 <include>process_property##JavaScript</include>
0167         </list>
0168         <!-- Functions of "process" -->
0169         <list name="process_functions">
0170                 <include>process_functions##JavaScript</include>
0171         </list>
0172 
0173         <!-- Constants of Number Class -->
0174         <list name="number_constant">
0175                 <include>number_constant##JavaScript</include>
0176         </list>
0177         <!-- Constants of Math Class-->
0178         <list name="math_constant">
0179                 <include>math_constant##JavaScript</include>
0180         </list>
0181         <!-- Methods of Math Class -->
0182         <list name="math_functions">
0183                 <include>math_functions##JavaScript</include>
0184         </list>
0185         <!-- Methods of JSON Class -->
0186         <list name="json_functions">
0187                 <include>json_functions##JavaScript</include>
0188         </list>
0189         <!-- Methods of Promise Class -->
0190         <list name="promise_functions">
0191                 <include>promise_functions##JavaScript</include>
0192         </list>
0193 
0194         <!-- Node.js Variables -->
0195         <list name="node_variable">
0196                 <include>node_variable##JavaScript</include>
0197         </list>
0198         <!-- DOM Variables -->
0199         <list name="dom_variable">
0200                 <include>dom_variable##JavaScript</include>
0201         </list>
0202         <!-- DOM Constants -->
0203         <list name="dom_constant">
0204                 <include>dom_constant##JavaScript</include>
0205         </list>
0206 
0207         <!-- For Autocomplete Keywords -->
0208         <!-- Properties of DOM Classes -->
0209         <list name="dom_property">
0210                 <include>dom_property##JavaScript</include>
0211         </list>
0212         <!-- Methods of DOM Classes -->
0213         <list name="dom_functions">
0214                 <include>dom_functions##JavaScript</include>
0215         </list>
0216         <!-- Event Handler -->
0217         <list name="eventhandler_property">
0218                 <include>eventhandler_property##JavaScript</include>
0219         </list>
0220         <!-- Others Methods of Classes -->
0221         <list name="function_common">
0222                 <include>function_common##JavaScript</include>
0223         </list>
0224 
0225         <contexts>
0226 
0227                 <context name="Shebang" attribute="Normal Text" lineEndContext="Normal" lineEmptyContext="Normal" fallthrough="true" fallthroughContext="Normal">
0228                         <Detect2Chars context="ShebangLine" attribute="Comment" char="#" char1="!" column="0" />
0229                 </context>
0230                 <context name="ShebangLine" attribute="Comment" lineEndContext="#pop!Normal" />
0231 
0232                 <context name="Normal" attribute="Normal Text" lineEndContext="#stay">
0233                         <IncludeRules context="Normal Pt1" />
0234 
0235                         <!-- NOTE & TODO: The identifiers before ":" are highlighted as "dsNormal".
0236                              These identifiers should be highlighted in a different way depending on the
0237                              context, for example, in the declaration of classes or interfaces, in sets, the
0238                              parameters of a function, or after the keywords: "const", "var", "let" & "enum". -->
0239                         <RegExpr context="#stay" attribute="Parameter" String="&parameter;" />
0240 
0241                         <IncludeRules context="Normal Pt2" />
0242                 </context>
0243 
0244                 <context name="Normal Pt1" attribute="Normal Text" lineEndContext="#stay">
0245                         <StringDetect context="#stay" attribute="Symbol" String="..." />
0246                         <IncludeRules context="FindNumbers" />
0247                         <IncludeRules context="FindStrings" />
0248 
0249                         <!-- Abstract -->
0250                         <RegExpr context="#stay" attribute="Reserved" String="\babstract(?=\s+(?:class|interface)\b)" />
0251                         <!-- New -->
0252                         <RegExpr context="NewTarget" attribute="Keyword" String="\bnew(?=&objectPoint;\s*target\b)" />
0253                         <RegExpr context="MemberObject" attribute="Objects" String="\bnew(?=&objectOp;\.)" />
0254                         <WordDetect context="#stay" attribute="Keyword" String="new" />
0255 
0256                         <!-- Keywords: control flow -->
0257                         <keyword context="#stay" attribute="ControlFlow" String="controlflow" />
0258                         <RegExpr context="#stay" attribute="ControlFlow" String="\bdefault(?=\s*&objectOp;:)" />
0259                 </context>
0260                 <context name="Normal Pt2" attribute="Normal Text" lineEndContext="#stay">
0261                         <!-- Keywords -->
0262                         <WordDetect context="TypeDeclaration" attribute="Reserved" String="type" />
0263                         <WordDetect context="FunctionDeclaration" attribute="Keyword" String="function" />
0264                         <keyword context="#stay" attribute="Keyword" String="keywords" /> <!-- NoRegExp? -->
0265                         <keyword context="#stay" attribute="Reserved" String="reserved" />
0266 
0267                         <!-- Utility Types -->
0268                         <RegExpr context="#stay" attribute="Built-in Objects" String="&utilityTypes;" />
0269                         <!-- Built-in Classes -->
0270                         <IncludeRules context="BuiltInClasses" />
0271                         <IncludeRules context="BuiltInConstants" />
0272                         <!-- Objects -->
0273                         <RegExpr context="MemberObject" attribute="Objects" String="&identifier;(?=&objectPoint;)" />
0274                         <DetectChar context="MemberObject" attribute="Symbol" char="." />
0275 
0276                         <RegExpr context="Types" attribute="Module" String="\bas(?=\s)" />
0277                         <!-- Import -->
0278                         <WordDetect context="Import" attribute="Module" String="import" />
0279                         <RegExpr context="#stay" attribute="Module" String="\bexport\s+type\b" />
0280                         <!-- Export types -->
0281                         <keyword context="ControlExport" attribute="Module" String="control_export_types" />
0282                         <!-- Keywords -->
0283                         <keyword context="#stay" attribute="Module" String="module" />
0284                         <keyword context="NoRegExp" attribute="Keyword" String="primitives" />
0285                         <keyword context="#stay" attribute="Keyword" String="types_operator_expression" />
0286 
0287                         <!-- Functions: function(...) and function<...>(...) -->
0288                         <RegExpr context="Function" attribute="Function Name" String="(&identifier;)&functionSuffix;" lookAhead="true" />
0289                         <!-- Tagged Template Literals -->
0290                         <RegExpr context="#stay" attribute="Function Name" String="&identifier;(?=\s*`)" />
0291 
0292                         <!-- Symbols & Operators -->
0293                         <!-- NOTE: - The brackets {}()[] are highlighted as Normal Text.
0294                                    - Bracket highlighting rules must be explicitly included here
0295                                      for the "Animate Bracket Highlighting" feature to work properly. -->
0296                         <DetectChar context="Object" attribute="Normal Text" char="{" beginRegion="Brace" />
0297                         <DetectChar context="#stay" attribute="Normal Text" char="[" beginRegion="List" />
0298                         <DetectChar context="NoRegExp" attribute="Normal Text" char="]" endRegion="List" />
0299                         <DetectChar context="#stay" attribute="Normal Text" char="(" />
0300                         <DetectChar context="NoRegExp" attribute="Normal Text" char=")" />
0301 
0302                         <Detect2Chars context="#stay" attribute="Symbol" char="?" char1="?" /> <!-- Null operator -->
0303                         <!-- Conditional Expressions:
0304                                CASE 1:  '?' ... <identifier> ':'
0305                                CASE 2:  '?' ... ( '||' | '&&' ) <end-line>
0306                                CASE 3:  '?' (<identifier>)? <end-line>
0307                         -->
0308                         <RegExpr context="ConditionalExpression" attribute="Symbol" String="\?(?=\s*(?:(?:[^/&quot;'`\s\?:\.;,\=\}\]\)]|&codeContent;)(?:[^/&quot;'`]|&codeContent;)*)?&identifier;\s*(?:/\*.*\*/\s*)*:|(?:&amp;&amp;|\|\||\s*(?:/\*.*\*/\s*)*&identifier;)?&endLine;)" minimal="true" />
0309 
0310                         <!-- Type Parameter: Highlight types after ":" and between "<" and ">" -->
0311                         <DetectChar context="Types" attribute="Symbol" char=":" />
0312                         <RegExpr context="TypesAngleBracket" attribute="Symbol" String="&lt;(?=(?:&identifier;|[\[\{\(&lt;]).*&gt;)" />
0313 
0314                         <IncludeRules context="JSBase##JavaScript" />
0315                 </context>
0316 
0317                 <!-- Conditional Expressions: a ? b : c -->
0318                 <!-- Highlight keywords before ":" in conditional expressions. -->
0319                 <context name="ConditionalExpression" attribute="Normal Text" lineEndContext="#stay">
0320                         <!-- NOTE: Don't start the "Types" context. See the context "Default Types". -->
0321                         <DetectChar context="#pop" attribute="Symbol" char=":" />
0322                         <IncludeRules context="ConditionalExpressionEnd" />
0323                         <DetectChar context="#stay" attribute="Symbol" char="?" />
0324 
0325                         <IncludeRules context="FindConditionalExpressionBrackets" />
0326                         <IncludeRules context="Normal-ParametersOverridden" />
0327                 </context>
0328                 <context name="Normal-ParametersOverridden" attribute="Normal Text" lineEndContext="#stay">
0329                         <IncludeRules context="Normal Pt1" />
0330                         <IncludeRules context="Normal Pt2" />
0331                         <!-- unrecheable by Regex=&identifier; in "JSBase##JavaScript" included by "Normal Pt2"
0332                         <RegExpr context="#stay" attribute="Parameter" String="&parameter;" />-->
0333                 </context>
0334                 <context name="ConditionalExpressionEnd" attribute="Normal Text" lineEndContext="#stay">
0335                         <AnyChar context="#pop" String=";,}])" lookAhead="true" />
0336                         <RegExpr context="#pop" String="\=(?!&gt;)" lookAhead="true" />
0337                         <!-- For TypeScript code embedded in HTML and Markdown -->
0338                         <StringDetect context="#pop" String="```" lookAhead="true" firstNonSpace="true" />
0339                         <StringDetect context="#pop" String="~~~" lookAhead="true" firstNonSpace="true" />
0340                         <RegExpr context="#pop" String="&lt;/script\s*(?:&gt;|$)" insensitive="true" lookAhead="true" />
0341                 </context>
0342                 <context name="FindConditionalExpressionBrackets" attribute="Normal Text" lineEndContext="#stay">
0343                         <DetectChar context="ConditionalExpressionRoundBracket" attribute="Normal Text" char="(" />
0344                         <DetectChar context="ConditionalExpressionSquareBracket" attribute="Symbol" char="[" beginRegion="List" />
0345                 </context>
0346                 <context name="ConditionalExpressionRoundBracket" attribute="Normal Text" lineEndContext="#stay">
0347                         <DetectChar context="#pop!NoRegExp" attribute="Normal Text" char=")" />
0348                         <IncludeRules context="FindConditionalExpressionBrackets" />
0349                         <IncludeRules context="Normal" />
0350                 </context>
0351                 <context name="ConditionalExpressionSquareBracket" attribute="Normal Text" lineEndContext="#stay">
0352                         <DetectChar context="#pop!NoRegExp" attribute="Symbol" char="]" endRegion="List" />
0353                         <IncludeRules context="FindConditionalExpressionBrackets" />
0354                         <IncludeRules context="Normal" />
0355                 </context>
0356 
0357                 <!-- Object, within { ... } -->
0358                 <context name="Object" attribute="Normal Text" lineEndContext="#stay">
0359                         <DetectChar context="#pop" attribute="Normal Text" char="}" endRegion="Brace" />
0360                         <keyword context="NoRegExp" attribute="Keyword" String="keywords" />
0361                         <!-- Highlight types in the following line.
0362                              NOTE: Using the "NoRegExp" context can cause this to apply to multiple lines. -->
0363                         <RegExpr context="TypesNewLine" attribute="Symbol" String=":(?=&endLine;)" minimal="true" />
0364                         <IncludeRules context="Normal" />
0365                 </context>
0366 
0367                 <!-- Avoid highlighting regular expressions. -->
0368                 <context name="NoRegExp" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop">
0369                         <IncludeRules context="NoRegExp##JavaScript" />
0370                 </context>
0371                 <!-- Avoid highlighting regular expressions on a single line. -->
0372                 <context name="NoRegExpSameLine" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
0373                         <IncludeRules context="NoRegExp##JavaScript" />
0374                 </context>
0375 
0376                 <!-- Numbers -->
0377                 <context name="FindNumbers" attribute="Normal Text" lineEndContext="#stay">
0378                         <RegExpr context="NoRegExp" attribute="Hexadecimal" String="\b0[xX][\da-fA-F][\da-fA-F_]*&numSuffix;" />
0379                         <RegExpr context="NoRegExp" attribute="Binary" String="\b0[bB][01][01_]*&numSuffix;" />
0380                         <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;" />
0381                         <RegExpr context="NoRegExp" attribute="Octal" String="\b0[oO]?[0-7][0-7_]*&numSuffix;" />
0382                         <RegExpr context="NoRegExp" attribute="Decimal" String="\b\d[\d_]*&numSuffix;" />
0383                 </context>
0384 
0385                 <!-- Function Name -->
0386                 <context name="Function" attribute="Normal Text" lineEndContext="#pop">
0387                         <keyword context="#pop" attribute="Function (Built-in)" String="functions" />
0388                         <StringDetect context="#pop" attribute="Function Name" String="%1" dynamic="true" />
0389                         <AnyChar context="#pop" String="(&lt;&gt;" lookAhead="true" />
0390                 </context>
0391                 <context name="FunctionDeclaration" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop">
0392                         <DetectSpaces />
0393                         <RegExpr context="#pop" attribute="Function Declaration" String="&identifier;&functionSuffix;" /> <!-- NoRegExp -->
0394                         <IncludeRules context="FindComments##JavaScript" />
0395                 </context>
0396 
0397                 <!-- Strings -->
0398                 <context name="FindStrings" attribute="Normal Text" lineEndContext="#stay">
0399                         <DetectChar context="Template" attribute="Template" char="`" beginRegion="Template" />
0400                         <IncludeRules context="FindStrings##JavaScript" />
0401                 </context>
0402                 <context name="Template" attribute="Template" lineEndContext="#stay">
0403                         <IncludeRules context="Escape##JavaScript" />
0404                         <Detect2Chars context="Substitution" attribute="Substitution" char="$" char1="{" />
0405                         <DetectChar context="RegExpAfterString##JavaScript" attribute="Template" char="`" endRegion="Template" />
0406                 </context>
0407                 <context name="Substitution" attribute="Normal Text" lineEndContext="#stay">
0408                         <DetectChar context="#pop" attribute="Substitution" char="}" />
0409                         <IncludeRules context="Normal" />
0410                 </context>
0411 
0412                 <!-- Type Declaration: Highlight types after the "type" keyword -->
0413 
0414                 <context name="TypeDeclaration" attribute="Normal Text" lineEndContext="#stay">
0415                         <DetectSpaces />
0416                         <AnyChar context="#pop" String=";,{})]" lookAhead="true" />
0417                         <IncludeRules context="TypesFindBrackets" />
0418                         <IncludeRules context="DefaultTypes" />
0419                         <IncludeRules context="Normal" />
0420                 </context>
0421 
0422                 <!-- Type Parameter: Highlight types after ":" -->
0423 
0424                 <context name="Types" attribute="Normal Text" lineEndContext="#pop">
0425                         <IncludeRules context="FixPopLineEndContext" />
0426                         <IncludeRules context="TypesCommon" />
0427                 </context>
0428                 <context name="TypesCommon" attribute="Normal Text" lineEndContext="#pop">
0429                         <DetectSpaces />
0430                         <IncludeRules context="TypesEnd" />
0431                         <!-- New line after "|" or "&".
0432                              IMPORTANT: If you modify this rule, do so in "typescript-react.xml"! -->
0433                         <RegExpr context="#pop!TypesNewLine" attribute="Symbol" String="[\|&amp;](?=&endLine;)" minimal="true" />
0434 
0435                         <IncludeRules context="TypesFindBrackets" />
0436                         <IncludeRules context="DefaultTypes" />
0437                         <IncludeRules context="Normal-ParametersOverridden" />
0438                 </context>
0439                 <!-- NOTE: Context used by "typescript-react.xml" -->
0440                 <context name="TypesEnd" attribute="Normal Text" lineEndContext="#stay">
0441                         <AnyChar context="#pop" String=";,}])" lookAhead="true" />
0442                         <RegExpr context="#pop" String="\=(?!&gt;)" lookAhead="true" />
0443                         <Detect2Chars context="#pop" char="/" char1="/" lookAhead="true" />
0444                 </context>
0445                 <context name="TypesNewLine" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!TypesCommon">
0446                         <DetectSpaces />
0447                         <IncludeRules context="FindComments##JavaScript" />
0448                 </context>
0449 
0450                 <!-- NOTE: The "NoRegExp" context invalidates lineEndContext="#pop",
0451                      therefore the following rule is necessary -->
0452                 <context name="FixPopLineEndContext" attribute="Normal Text" lineEndContext="#stay">
0453                         <RegExpr context="#pop" String="\S" firstNonSpace="true" lookAhead="true" />
0454                 </context>
0455 
0456                 <!-- Default: Type Parameter, Type Declaration, Angle Brackets -->
0457 
0458                 <context name="DefaultTypes" attribute="Normal Text" lineEndContext="#stay">
0459                         <!-- Types Keywords -->
0460                         <keyword context="NoRegExpSameLine" attribute="Types" String="types" />
0461                         <!-- Assertions -->
0462                         <WordDetect context="NoRegExpSameLine" attribute="Keyword" String="asserts" />
0463                         <!-- Type Guards -->
0464                         <WordDetect context="NoRegExpSameLine" attribute="Keyword" String="is" />
0465 
0466                         <!-- FIXME: For a strange reason, the keywords before "}" are not highlighted.
0467                              This rule fixes it provisionally. -->
0468                         <RegExpr context="#stay" attribute="Types" String="\b(?:string|number|bigint|boolean|symbol|any|void|never|unknown|undefined|null|object)(?=\})" />
0469 
0470                         <!-- Don't start this context again and don't start the "ConditionalExpression" context -->
0471                         <AnyChar context="#stay" attribute="Symbol" String=":?" />
0472                         <WordDetect context="#stay" attribute="Module" String="as" />
0473                 </context>
0474                 <context name="TypesFindBrackets" attribute="Normal Text" lineEndContext="#stay">
0475                         <DetectChar context="TypesSquareBracket" attribute="Normal Text" char="[" beginRegion="List" />
0476                         <DetectChar context="TypesCurlyBracket" attribute="Normal Text" char="{" beginRegion="Brace" />
0477                         <DetectChar context="TypesRoundBracket" attribute="Normal Text" char="(" />
0478                 </context>
0479 
0480                 <context name="TypesSquareBracket" attribute="Normal Text" lineEndContext="#stay">
0481                         <DetectChar context="#pop!NoRegExp" attribute="Normal Text" char="]" endRegion="List" />
0482                         <IncludeRules context="TypesFindBrackets" />
0483                         <IncludeRules context="DefaultTypes" />
0484                         <IncludeRules context="Normal" />
0485                 </context>
0486                 <context name="TypesCurlyBracket" attribute="Normal Text" lineEndContext="#pop!Object">
0487                         <DetectChar context="#pop" attribute="Normal Text" char="}" endRegion="Brace" />
0488                         <RegExpr context="#pop!Object" String="\S" firstNonSpace="true" lookAhead="true" /> <!-- FixPopLineEndContext -->
0489                         <IncludeRules context="TypesFindBrackets" />
0490                         <IncludeRules context="DefaultTypes" />
0491                         <IncludeRules context="Object" />
0492                 </context>
0493                 <context name="TypesRoundBracket" attribute="Normal Text" lineEndContext="#pop">
0494                         <DetectChar context="#pop!NoRegExp" attribute="Normal Text" char=")" />
0495                         <IncludeRules context="FixPopLineEndContext" />
0496                         <IncludeRules context="TypesFindBrackets" />
0497                         <IncludeRules context="DefaultTypes" />
0498                         <IncludeRules context="Normal" />
0499                 </context>
0500 
0501                 <context name="TypesAngleBracket" attribute="Normal Text" lineEndContext="#pop">
0502                         <DetectChar context="#pop" attribute="Symbol" char="&gt;" />
0503                         <IncludeRules context="TypesAngleBracketEnd" />
0504                         <IncludeRules context="FixPopLineEndContext" />
0505                         <IncludeRules context="TypesFindBrackets" />
0506                         <IncludeRules context="DefaultTypes" />
0507                         <IncludeRules context="Normal" />
0508                 </context>
0509                 <!-- NOTE: Context used by "typescript-react.xml" -->
0510                 <context name="TypesAngleBracketEnd" attribute="Normal Text" lineEndContext="#stay">
0511                         <AnyChar context="#pop" String="})];" lookAhead="true" />
0512                 </context>
0513 
0514                 <!-- new.target -->
0515                 <context name="NewTarget" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
0516                         <DetectSpaces />
0517                         <AnyChar context="#stay" attribute="Symbol" String=".?!" />
0518                         <WordDetect context="#pop!NoRegExp" attribute="Keyword" String="target" />
0519                 </context>
0520 
0521                 <!-- After keyword list "control_export_types" -->
0522                 <context name="ControlExport" attribute="Normal Text" lineEndContext="#pop">
0523                         <AnyChar context="#pop" attribute="Normal Text" String="{;" lookAhead="true" />
0524                         <IncludeRules context="FindStrings" />
0525                         <RegExpr context="#stay" attribute="Types" String="&identifier;" />
0526                         <IncludeRules context="FindComments##JavaScript" />
0527                 </context>
0528 
0529                 <!-- "import" keyword -->
0530                 <context name="Import" attribute="Normal Text" lineEndContext="#pop">
0531                         <DetectChar context="#pop!ImportRequireKey" attribute="Symbol" char="=" />
0532                         <!-- import type ... -->
0533                         <WordDetect context="#stay" attribute="Module" String="type" />
0534                         <!-- importmeta_property -->
0535                         <WordDetect context="#pop!NoRegExp" attribute="Keyword" String="meta" />
0536                         <!-- Fix context NoRegExp (#pop in new line) -->
0537                         <RegExpr context="#pop" String="." lookAhead="true" firstNonSpace="true" />
0538                         <AnyChar context="#pop" String="{}()[];," lookAhead="true" />
0539                         <IncludeRules context="Normal" />
0540                 </context>
0541                 <context name="ImportRequireKey" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
0542                         <RegExpr context="#stay" attribute="Keyword" String="\s*require\s*(?=\()" />
0543                         <DetectChar context="ImportRequire" attribute="Normal Text" char="(" beginRegion="import" />
0544                 </context>
0545                 <context name="ImportRequire" attribute="Normal Text" lineEndContext="#stay">
0546                         <DetectChar context="#pop#pop" attribute="Normal Text" char=")" endRegion="import" />
0547                         <IncludeRules context="FindStrings" />
0548                         <IncludeRules context="FindNumbers" />
0549                         <IncludeRules context="FindComments##JavaScript" />
0550                 </context>
0551 
0552                 <!-- Member Objects -->
0553 
0554                 <context name="MemberObject" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
0555                         <IncludeRules context="DefaultMemberObject" />
0556                         <!-- Common functions and properties, only for autocomplete keywords -->
0557                         <keyword context="#pop!NoRegExp" attribute="Object Member" String="dom_property" />
0558                         <keyword context="#pop!NoRegExp" attribute="Function Name" String="dom_functions" />
0559                         <keyword context="#pop!NoRegExp" attribute="Object Member" String="eventhandler_property" />
0560                         <keyword context="#pop!NoRegExp" attribute="Function Name" String="function_common" />
0561                 </context>
0562 
0563                 <context name="DefaultMemberObject" attribute="Normal Text" lineEndContext="#pop">
0564                         <IncludeRules context="FixPointMemberObject" />
0565                         <DetectChar context="#stay" attribute="Symbol" char="." />
0566                         <Detect2Chars context="#stay" attribute="Symbol" char="?" char1="." />
0567                         <Detect2Chars context="#stay" attribute="Symbol" char="!" char1="." />
0568 
0569                         <!-- The order of these rules is important: 1) Functions. 2) Constants & Properties. 3) Obj. Members. -->
0570                         <!-- function(...) and function<...>(...) -->
0571                         <RegExpr context="#pop" attribute="Function Name" String="&identifier;&functionSuffix;" />
0572                         <!-- Tagged Template Literals -->
0573                         <RegExpr context="#pop" String="&identifier;\s*`" lookAhead="true" />
0574                         <!-- Generic constants and properties -->
0575                         <keyword context="#pop!NoRegExp" attribute="Object Property (Built-in)" String="variable_property" />
0576                         <keyword context="#pop!NoRegExp" attribute="Constant" String="dom_constant" />
0577 
0578                         <RegExpr context="#stay" attribute="Normal Text" String="#(?=&identifier;)" /> <!-- Private-Named Instance Fields -->
0579                         <RegExpr context="#stay" attribute="Object Member" String="&identifier;(?=&objectPoint;)" />
0580                         <RegExpr context="#pop!NoRegExp" attribute="Object Member" String="&identifier;" />
0581                         <IncludeRules context="NoRegExp" />
0582 
0583                         <!-- Generic functions -->
0584                         <keyword context="#pop!NoRegExp" attribute="Function Name" String="functions" />
0585                 </context>
0586                 <context name="FixPointMemberObject" attribute="Normal Text" lineEndContext="#pop">
0587                         <StringDetect context="#pop" attribute="Symbol" String="?..." />
0588                         <StringDetect context="#pop" attribute="Symbol" String="!..." />
0589                         <StringDetect context="#pop" attribute="Symbol" String="..." />
0590                 </context>
0591 
0592 
0593                 <!-- Built-in Classes -->
0594                 <!-- Keep in sync with javascript.xml -->
0595 
0596                 <context name="BuiltInClasses" attribute="Normal Text" lineEndContext="#stay">
0597                         <WordDetect context="FindMemberObjectMath" attribute="Built-in Objects" String="Math" />
0598                         <WordDetect context="FindMemberObjectNumber" attribute="Built-in Objects" String="Number" />
0599                         <WordDetect context="FindMemberObjectPromise" attribute="Built-in Objects" String="Promise" />
0600                         <WordDetect context="FindMemberObjectJSON" attribute="Built-in Objects" String="JSON" />
0601                         <WordDetect context="FindMemberObjectConsole" attribute="Built-in Objects" String="console" />
0602                         <WordDetect context="FindMemberObjectProcess" attribute="Built-in Objects" String="process" />
0603 
0604                         <keyword context="NoRegExp" attribute="Built-in Objects" String="class_builtin" />
0605                         <keyword context="NoRegExp" attribute="Built-in Objects" String="class_dom" />
0606                         <keyword context="FindMemberObjectDOM" attribute="Built-in Objects" String="dom_variable" />
0607                         <keyword context="NoRegExp" attribute="Built-in Objects" String="class_node" />
0608                         <keyword context="NoRegExp" attribute="Built-in Objects" String="node_variable" />
0609                 </context>
0610                 <!-- These constants are highlighted in "Normal" -->
0611                 <context name="BuiltInConstants" attribute="Normal Text" lineEndContext="#stay">
0612                         <keyword context="NoRegExp" attribute="Constant" String="math_constant" />
0613                         <keyword context="NoRegExp" attribute="Constant" String="number_constant" />
0614                         <keyword context="NoRegExp" attribute="Constant" String="dom_constant" />
0615                 </context>
0616 
0617                 <!-- DOM Variable -->
0618                 <context name="FindMemberObjectDOM" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!NoRegExp">
0619                         <DetectSpaces />
0620                         <IncludeRules context="FixPointMemberObject" />
0621                         <DetectChar context="#pop!MemberObjectDOM" attribute="Symbol" char="." />
0622                         <Detect2Chars context="#pop!MemberObjectDOM" attribute="Symbol" char="?" char1="." />
0623                         <Detect2Chars context="#pop!MemberObjectDOM" attribute="Symbol" char="!" char1="." />
0624                 </context>
0625                 <context name="MemberObjectDOM" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
0626                         <keyword context="#pop!FindMemberObjectDOM" attribute="Object Property (Built-in)" String="dom_property" />
0627                         <keyword context="#pop!FindMemberObjectDOM" attribute="Object Method (Built-in)" String="dom_functions" />
0628                         <IncludeRules context="DefaultMemberObject" />
0629                         <!-- Only for autocomplete -->
0630                         <keyword context="#pop!NoRegExp" attribute="Object Member" String="eventhandler_property" />
0631                         <keyword context="#pop!NoRegExp" attribute="Function Name" String="function_common" />
0632                 </context>
0633                 <!-- Math Class -->
0634                 <context name="FindMemberObjectMath" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!NoRegExp">
0635                         <DetectSpaces />
0636                         <IncludeRules context="FixPointMemberObject" />
0637                         <DetectChar context="#pop!MemberObjectMath" attribute="Symbol" char="." />
0638                         <Detect2Chars context="#pop!MemberObjectMath" attribute="Symbol" char="?" char1="." />
0639                         <Detect2Chars context="#pop!MemberObjectMath" attribute="Symbol" char="!" char1="." />
0640                 </context>
0641                 <context name="MemberObjectMath" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
0642                         <keyword context="#pop!NoRegExp" attribute="Constant" String="math_constant" />
0643                         <keyword context="#pop!NoRegExp" attribute="Object Method (Built-in)" String="math_functions" />
0644                         <IncludeRules context="DefaultMemberObject" />
0645                 </context>
0646                 <!-- Number Class -->
0647                 <context name="FindMemberObjectNumber" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!NoRegExp">
0648                         <DetectSpaces />
0649                         <IncludeRules context="FixPointMemberObject" />
0650                         <DetectChar context="#pop!MemberObjectNumber" attribute="Symbol" char="." />
0651                         <Detect2Chars context="#pop!MemberObjectNumber" attribute="Symbol" char="?" char1="." />
0652                         <Detect2Chars context="#pop!MemberObjectNumber" attribute="Symbol" char="!" char1="." />
0653                 </context>
0654                 <context name="MemberObjectNumber" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
0655                         <keyword context="#pop!NoRegExp" attribute="Constant" String="number_constant" />
0656                         <IncludeRules context="DefaultMemberObject" />
0657                 </context>
0658                 <!-- Promise Class -->
0659                 <context name="FindMemberObjectPromise" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!NoRegExp">
0660                         <DetectSpaces />
0661                         <IncludeRules context="FixPointMemberObject" />
0662                         <DetectChar context="#pop!MemberObjectPromise" attribute="Symbol" char="." />
0663                         <Detect2Chars context="#pop!MemberObjectPromise" attribute="Symbol" char="?" char1="." />
0664                         <Detect2Chars context="#pop!MemberObjectPromise" attribute="Symbol" char="!" char1="." />
0665                 </context>
0666                 <context name="MemberObjectPromise" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
0667                         <keyword context="#pop!NoRegExp" attribute="Object Method (Built-in)" String="promise_functions" />
0668                         <IncludeRules context="DefaultMemberObject" />
0669                 </context>
0670                 <!-- JSON Class -->
0671                 <context name="FindMemberObjectJSON" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!NoRegExp">
0672                         <DetectSpaces />
0673                         <IncludeRules context="FixPointMemberObject" />
0674                         <DetectChar context="#pop!MemberObjectJSON" attribute="Symbol" char="." />
0675                         <Detect2Chars context="#pop!MemberObjectJSON" attribute="Symbol" char="?" char1="." />
0676                         <Detect2Chars context="#pop!MemberObjectJSON" attribute="Symbol" char="!" char1="." />
0677                 </context>
0678                 <context name="MemberObjectJSON" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
0679                         <keyword context="#pop!NoRegExp" attribute="Object Method (Built-in)" String="json_functions" />
0680                         <IncludeRules context="DefaultMemberObject" />
0681                 </context>
0682                 <!-- Console Object -->
0683                 <context name="FindMemberObjectConsole" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!NoRegExp">
0684                         <DetectSpaces />
0685                         <IncludeRules context="FixPointMemberObject" />
0686                         <DetectChar context="#pop!MemberObjectConsole" attribute="Symbol" char="." />
0687                         <Detect2Chars context="#pop!MemberObjectConsole" attribute="Symbol" char="?" char1="." />
0688                         <Detect2Chars context="#pop!MemberObjectConsole" attribute="Symbol" char="!" char1="." />
0689                 </context>
0690                 <context name="MemberObjectConsole" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
0691                         <keyword context="#pop!NoRegExp" attribute="Object Method (Built-in)" String="console_functions" />
0692                         <IncludeRules context="DefaultMemberObject" />
0693                 </context>
0694                 <!-- Process Object -->
0695                 <context name="FindMemberObjectProcess" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!NoRegExp">
0696                         <DetectSpaces />
0697                         <IncludeRules context="FixPointMemberObject" />
0698                         <DetectChar context="#pop!MemberObjectProcess" attribute="Symbol" char="." />
0699                         <Detect2Chars context="#pop!MemberObjectProcess" attribute="Symbol" char="?" char1="." />
0700                         <Detect2Chars context="#pop!MemberObjectProcess" attribute="Symbol" char="!" char1="." />
0701                 </context>
0702                 <context name="MemberObjectProcess" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
0703                         <keyword context="#pop!NoRegExp" attribute="Object Method (Built-in)" String="process_functions" />
0704                         <keyword context="#pop!NoRegExp" attribute="Object Property (Built-in)" String="process_property" />
0705                         <IncludeRules context="DefaultMemberObject" />
0706                 </context>
0707 
0708         </contexts>
0709 
0710         <itemDatas>
0711                 <itemData name="Normal Text"      defStyleNum="dsNormal" spellChecking="false" />
0712                 <itemData name="Keyword"          defStyleNum="dsKeyword" spellChecking="false" />
0713                 <itemData name="ControlFlow"      defStyleNum="dsControlFlow" spellChecking="false" />
0714                 <itemData name="Reserved"         defStyleNum="dsKeyword" italic="true" spellChecking="false" />
0715                 <itemData name="Module"           defStyleNum="dsImport" spellChecking="false" />
0716                 <itemData name="Objects"          defStyleNum="dsNormal" spellChecking="false" />
0717                 <itemData name="Object Member"    defStyleNum="dsAttribute" spellChecking="false" />
0718                 <itemData name="Function Name"    defStyleNum="dsFunction" spellChecking="false" />
0719                 <itemData name="Function Declaration" defStyleNum="dsFunction" spellChecking="false" />
0720                 <itemData name="Built-in Objects" defStyleNum="dsBuiltIn" spellChecking="false" />
0721                 <itemData name="Object Property (Built-in)" defStyleNum="dsAttribute" italic="1" spellChecking="false" />
0722                 <itemData name="Object Method (Built-in)" defStyleNum="dsFunction" italic="1" spellChecking="false" />
0723                 <itemData name="Function (Built-in)" defStyleNum="dsPreprocessor" spellChecking="false" />
0724                 <itemData name="Constant"         defStyleNum="dsConstant" spellChecking="false" />
0725                 <itemData name="Types"            defStyleNum="dsDataType" spellChecking="false" />
0726                 <itemData name="Parameter"        defStyleNum="dsNormal" spellChecking="false" />
0727 
0728                 <itemData name="Decimal"      defStyleNum="dsDecVal" spellChecking="false" />
0729                 <itemData name="Octal"        defStyleNum="dsBaseN" spellChecking="false" />
0730                 <itemData name="Hexadecimal"  defStyleNum="dsBaseN" spellChecking="false" />
0731                 <itemData name="Binary"       defStyleNum="dsBaseN" spellChecking="false" />
0732                 <itemData name="Float"        defStyleNum="dsFloat" spellChecking="false" />
0733                 <itemData name="Template"     defStyleNum="dsVerbatimString" />
0734                 <itemData name="Substitution" defStyleNum="dsSpecialChar" spellChecking="false" />
0735 
0736                 <itemData name="Comment"      defStyleNum="dsComment" />
0737                 <itemData name="Symbol"       defStyleNum="dsOperator" spellChecking="false" />
0738         </itemDatas>
0739 
0740 </highlighting>
0741 
0742 <general>
0743         <comments>
0744                 <comment name="singleLine" start="//" position="afterwhitespace" />
0745                 <comment name="multiLine" start="/*" end="*/" />
0746         </comments>
0747         <keywords casesensitive="1" additionalDeliminator="&quot;&apos;`" weakDeliminator="$" />
0748 </general>
0749 
0750 </language>
0751 <!-- kate: replace-tabs off; tab-width 3; indent-width 3; remove-trailing-spaces mod; dynamic-word-wrap off; -->