diff options
Diffstat (limited to 'assets/syntaxes/02_Extra/TypeScript.sublime-syntax')
-rw-r--r-- | assets/syntaxes/02_Extra/TypeScript.sublime-syntax | 3340 |
1 files changed, 3340 insertions, 0 deletions
diff --git a/assets/syntaxes/02_Extra/TypeScript.sublime-syntax b/assets/syntaxes/02_Extra/TypeScript.sublime-syntax new file mode 100644 index 00000000..b491d3ba --- /dev/null +++ b/assets/syntaxes/02_Extra/TypeScript.sublime-syntax @@ -0,0 +1,3340 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: TypeScript +file_extensions: + - ts +scope: source.ts +contexts: + main: + - include: directives + - include: statements + - match: \A(#!).*(?=$) + scope: comment.line.shebang.ts + captures: + 1: punctuation.definition.comment.ts + comment: + - match: /\*\*(?!/) + captures: + 0: punctuation.definition.comment.ts + push: + - meta_scope: comment.block.documentation.ts + - match: \*/ + captures: + 0: punctuation.definition.comment.ts + pop: true + - include: docblock + - match: (/\*)(?:\s*((@)internal)(?=\s|(\*/)))? + captures: + 1: punctuation.definition.comment.ts + 2: storage.type.internaldeclaration.ts + 3: punctuation.decorator.internaldeclaration.ts + push: + - meta_scope: comment.block.ts + - match: \*/ + captures: + 0: punctuation.definition.comment.ts + pop: true + - match: '(^[ \t]+)?((//)(?:\s*((@)internal)(?=\s|$))?)' + captures: + 1: punctuation.whitespace.comment.leading.ts + 2: comment.line.double-slash.ts + 3: punctuation.definition.comment.ts + 4: storage.type.internaldeclaration.ts + 5: punctuation.decorator.internaldeclaration.ts + push: + - meta_content_scope: comment.line.double-slash.ts + - match: (?=$) + pop: true + access-modifier: + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(abstract|public|protected|private|readonly|static|declare)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))' + scope: storage.modifier.ts + after-operator-block-as-object-literal: + - match: '(?<!\+\+|--)(?<=[:=(,\[?+!>]|^await|[^\._$[:alnum:]]await|^return|[^\._$[:alnum:]]return|^yield|[^\._$[:alnum:]]yield|^throw|[^\._$[:alnum:]]throw|^in|[^\._$[:alnum:]]in|^of|[^\._$[:alnum:]]of|^typeof|[^\._$[:alnum:]]typeof|&&|\|\||\*)\s*(\{)' + captures: + 1: punctuation.definition.block.ts + push: + - meta_scope: meta.objectliteral.ts + - match: '\}' + captures: + 0: punctuation.definition.block.ts + pop: true + - include: object-member + array-binding-pattern: + - match: '(?:(\.\.\.)\s*)?(\[)' + captures: + 1: keyword.operator.rest.ts + 2: punctuation.definition.binding-pattern.array.ts + push: + - match: '\]' + captures: + 0: punctuation.definition.binding-pattern.array.ts + pop: true + - include: binding-element + - include: punctuation-comma + array-binding-pattern-const: + - match: '(?:(\.\.\.)\s*)?(\[)' + captures: + 1: keyword.operator.rest.ts + 2: punctuation.definition.binding-pattern.array.ts + push: + - match: '\]' + captures: + 0: punctuation.definition.binding-pattern.array.ts + pop: true + - include: binding-element-const + - include: punctuation-comma + array-literal: + - match: '\s*(\[)' + captures: + 1: meta.brace.square.ts + push: + - meta_scope: meta.array.literal.ts + - match: '\]' + captures: + 0: meta.brace.square.ts + pop: true + - include: expression + - include: punctuation-comma + arrow-function: + - match: '(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(\basync)\s+)?([_$[:alpha:]][_$[:alnum:]]*)\s*(?==>)' + scope: meta.arrow.ts + captures: + 1: storage.modifier.async.ts + 2: variable.parameter.ts + - match: |- + (?x) (?: + (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(\basync) + )? ((?<![})!\]])\s* + (?= + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + ) + ) + captures: + 1: storage.modifier.async.ts + push: + - meta_scope: meta.arrow.ts + - match: '(?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))' + pop: true + - include: comment + - include: type-parameters + - include: function-parameters + - include: arrow-return-type + - include: possibly-arrow-return-type + - match: "=>" + captures: + 0: storage.type.function.arrow.ts + push: + - meta_scope: meta.arrow.ts + - match: '((?<=\}|\S)(?<!=>)|((?!\{)(?=\S)))(?!\/[\/\*])' + pop: true + - include: single-line-comment-consuming-line-ending + - include: decl-block + - include: expression + arrow-return-type: + - match: (?<=\))\s*(:) + captures: + 1: keyword.operator.type.annotation.ts + push: + - meta_scope: meta.return.type.arrow.ts + - match: '(?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))' + pop: true + - include: arrow-return-type-body + arrow-return-type-body: + - match: '(?<=[:])(?=\s*\{)' + push: + - match: '(?<=\})' + pop: true + - include: type-object + - include: type-predicate-operator + - include: type + async-modifier: + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(async)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))' + scope: storage.modifier.async.ts + binding-element: + - include: comment + - include: string + - include: numeric-literal + - include: regex + - include: object-binding-pattern + - include: array-binding-pattern + - include: destructuring-variable-rest + - include: variable-initializer + binding-element-const: + - include: comment + - include: string + - include: numeric-literal + - include: regex + - include: object-binding-pattern-const + - include: array-binding-pattern-const + - include: destructuring-variable-rest-const + - include: variable-initializer + boolean-literal: + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))true(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))' + scope: constant.language.boolean.true.ts + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))false(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))' + scope: constant.language.boolean.false.ts + brackets: + - match: "{" + push: + - match: '}|(?=\*/)' + pop: true + - include: brackets + - match: '\[' + push: + - match: '\]|(?=\*/)' + pop: true + - include: brackets + cast: + - match: \s*(<)\s*(const)\s*(>) + scope: cast.expr.ts + captures: + 1: meta.brace.angle.ts + 2: storage.modifier.ts + 3: meta.brace.angle.ts + - match: '(?:(?<!\+\+|--)(?<=^return|[^\._$[:alnum:]]return|^throw|[^\._$[:alnum:]]throw|^yield|[^\._$[:alnum:]]yield|^await|[^\._$[:alnum:]]await|^default|[^\._$[:alnum:]]default|[=(,:>*?\&\|\^]|[^_$[:alnum:]](?:\+\+|\-\-)|[^\+]\+|[^\-]\-))\s*(<)(?!<?\=)(?!\s*$)' + captures: + 1: meta.brace.angle.ts + push: + - meta_scope: cast.expr.ts + - match: (\>) + captures: + 1: meta.brace.angle.ts + pop: true + - include: type + - match: '(?:(?<=^))\s*(<)(?=[_$[:alpha:]][_$[:alnum:]]*\s*>)' + captures: + 1: meta.brace.angle.ts + push: + - meta_scope: cast.expr.ts + - match: (\>) + captures: + 1: meta.brace.angle.ts + pop: true + - include: type + class-declaration: + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(?:(abstract)\s+)?\b(class)\b(?=\s+|/[/*])' + captures: + 1: keyword.control.export.ts + 2: storage.modifier.ts + 3: storage.modifier.ts + 4: storage.type.class.ts + push: + - meta_scope: meta.class.ts + - match: '(?<=\})' + pop: true + - include: class-declaration-or-expression-patterns + class-declaration-or-expression-patterns: + - include: comment + - include: class-or-interface-heritage + - match: "[_$[:alpha:]][_$[:alnum:]]*" + captures: + 0: entity.name.type.class.ts + - include: type-parameters + - include: class-or-interface-body + class-expression: + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(abstract)\s+)?(class)\b(?=\s+|[<{]|\/[\/*])' + captures: + 1: storage.modifier.ts + 2: storage.type.class.ts + push: + - meta_scope: meta.class.ts + - match: '(?<=\})' + pop: true + - include: class-declaration-or-expression-patterns + class-or-interface-body: + - match: '\{' + captures: + 0: punctuation.definition.block.ts + push: + - match: '\}' + captures: + 0: punctuation.definition.block.ts + pop: true + - include: comment + - include: decorator + - match: (?<=:)\s* + push: + - match: '(?=\s|[;),}\]:\-\+]|;|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))' + pop: true + - include: expression + - include: method-declaration + - include: indexer-declaration + - include: field-declaration + - include: string + - include: type-annotation + - include: variable-initializer + - include: access-modifier + - include: property-accessor + - include: async-modifier + - include: after-operator-block-as-object-literal + - include: decl-block + - include: expression + - include: punctuation-comma + - include: punctuation-semicolon + class-or-interface-heritage: + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:\b(extends|implements)\b)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))' + captures: + 1: storage.modifier.ts + push: + - match: '(?=\{)' + pop: true + - include: comment + - include: class-or-interface-heritage + - include: type-parameters + - include: expressionWithoutIdentifiers + - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?:(\.)|(\?\.(?!\s*[[:digit:]])))(?=\s*[_$[:alpha:]][_$[:alnum:]]*(\s*\??\.\s*[_$[:alpha:]][_$[:alnum:]]*)*\s*)' + captures: + 1: entity.name.type.module.ts + 2: punctuation.accessor.ts + 3: punctuation.accessor.optional.ts + - match: "([_$[:alpha:]][_$[:alnum:]]*)" + captures: + 1: entity.other.inherited-class.ts + - include: expressionPunctuations + control-statement: + - include: switch-statement + - include: for-loop + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(catch|finally|throw|try)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))' + scope: keyword.control.trycatch.ts + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(break|continue|goto)\s+([_$[:alpha:]][_$[:alnum:]]*)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))' + captures: + 1: keyword.control.loop.ts + 2: entity.name.label.ts + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(break|continue|do|goto|while)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))' + scope: keyword.control.loop.ts + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(return)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))' + scope: keyword.control.flow.ts + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(case|default|switch)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))' + scope: keyword.control.switch.ts + - include: if-statement + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(else|if)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))' + scope: keyword.control.conditional.ts + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(with)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))' + scope: keyword.control.with.ts + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(package)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))' + scope: keyword.control.ts + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(debugger)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))' + scope: keyword.other.debugger.ts + decl-block: + - match: '\{' + captures: + 0: punctuation.definition.block.ts + push: + - meta_scope: meta.block.ts + - match: '\}' + captures: + 0: punctuation.definition.block.ts + pop: true + - include: statements + declaration: + - include: decorator + - include: var-expr + - include: function-declaration + - include: class-declaration + - include: interface-declaration + - include: enum-declaration + - include: namespace-declaration + - include: type-alias-declaration + - include: import-equals-declaration + - include: import-declaration + - include: export-declaration + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(declare|export)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))' + scope: storage.modifier.ts + decorator: + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))\@' + captures: + 0: punctuation.decorator.ts + push: + - meta_scope: meta.decorator.ts + - match: (?=\s) + pop: true + - include: expression + destructuring-const: + - match: '(?<!=|:|^of|[^\._$[:alnum:]]of|^in|[^\._$[:alnum:]]in)\s*(?=\{)' + push: + - meta_scope: meta.object-binding-pattern-variable.ts + - match: '(?=$|^|[;,=}]|((?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(of|in)\s+))' + pop: true + - include: object-binding-pattern-const + - include: type-annotation + - include: comment + - match: '(?<!=|:|^of|[^\._$[:alnum:]]of|^in|[^\._$[:alnum:]]in)\s*(?=\[)' + push: + - meta_scope: meta.array-binding-pattern-variable.ts + - match: '(?=$|^|[;,=}]|((?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(of|in)\s+))' + pop: true + - include: array-binding-pattern-const + - include: type-annotation + - include: comment + destructuring-parameter: + - match: '(?<!=|:)\s*(?:(\.\.\.)\s*)?(\{)' + captures: + 1: keyword.operator.rest.ts + 2: punctuation.definition.binding-pattern.object.ts + push: + - meta_scope: meta.parameter.object-binding-pattern.ts + - match: '\}' + captures: + 0: punctuation.definition.binding-pattern.object.ts + pop: true + - include: parameter-object-binding-element + - match: '(?<!=|:)\s*(?:(\.\.\.)\s*)?(\[)' + captures: + 1: keyword.operator.rest.ts + 2: punctuation.definition.binding-pattern.array.ts + push: + - meta_scope: meta.paramter.array-binding-pattern.ts + - match: '\]' + captures: + 0: punctuation.definition.binding-pattern.array.ts + pop: true + - include: parameter-binding-element + - include: punctuation-comma + destructuring-parameter-rest: + - match: '(?:(\.\.\.)\s*)?([_$[:alpha:]][_$[:alnum:]]*)' + captures: + 1: keyword.operator.rest.ts + 2: variable.parameter.ts + destructuring-variable: + - match: '(?<!=|:|^of|[^\._$[:alnum:]]of|^in|[^\._$[:alnum:]]in)\s*(?=\{)' + push: + - meta_scope: meta.object-binding-pattern-variable.ts + - match: '(?=$|^|[;,=}]|((?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(of|in)\s+))' + pop: true + - include: object-binding-pattern + - include: type-annotation + - include: comment + - match: '(?<!=|:|^of|[^\._$[:alnum:]]of|^in|[^\._$[:alnum:]]in)\s*(?=\[)' + push: + - meta_scope: meta.array-binding-pattern-variable.ts + - match: '(?=$|^|[;,=}]|((?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(of|in)\s+))' + pop: true + - include: array-binding-pattern + - include: type-annotation + - include: comment + destructuring-variable-rest: + - match: '(?:(\.\.\.)\s*)?([_$[:alpha:]][_$[:alnum:]]*)' + captures: + 1: keyword.operator.rest.ts + 2: meta.definition.variable.ts variable.other.readwrite.ts + destructuring-variable-rest-const: + - match: '(?:(\.\.\.)\s*)?([_$[:alpha:]][_$[:alnum:]]*)' + captures: + 1: keyword.operator.rest.ts + 2: meta.definition.variable.ts variable.other.constant.ts + directives: + - match: '^(///)\s*(?=<(reference|amd-dependency|amd-module)(\s+(path|types|no-default-lib|lib|name)\s*=\s*((\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`)))+\s*/>\s*$)' + captures: + 1: punctuation.definition.comment.ts + push: + - meta_scope: comment.line.triple-slash.directive.ts + - match: (?=$) + pop: true + - match: (<)(reference|amd-dependency|amd-module) + captures: + 1: punctuation.definition.tag.directive.ts + 2: entity.name.tag.directive.ts + push: + - meta_scope: meta.tag.ts + - match: /> + captures: + 0: punctuation.definition.tag.directive.ts + pop: true + - match: path|types|no-default-lib|lib|name + scope: entity.other.attribute-name.directive.ts + - match: "=" + scope: keyword.operator.assignment.ts + - include: string + docblock: + - match: |- + (?x) + ((@)(?:access|api)) + \s+ + (private|protected|public) + \b + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: constant.language.access-type.jsdoc + - match: |- + (?x) + ((@)author) + \s+ + ( + [^@\s<>*/] + (?:[^@<>*/]|\*[^/])* + ) + (?: + \s* + (<) + ([^>\s]+) + (>) + )? + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: entity.name.type.instance.jsdoc + 4: punctuation.definition.bracket.angle.begin.jsdoc + 5: constant.other.email.link.underline.jsdoc + 6: punctuation.definition.bracket.angle.end.jsdoc + - match: |- + (?x) + ((@)borrows) \s+ + ((?:[^@\s*/]|\*[^/])+) # <that namepath> + \s+ (as) \s+ # as + ((?:[^@\s*/]|\*[^/])+) # <this namepath> + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: entity.name.type.instance.jsdoc + 4: keyword.operator.control.jsdoc + 5: entity.name.type.instance.jsdoc + - match: ((@)example)\s+ + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + push: + - meta_scope: meta.example.jsdoc + - match: (?=@|\*/) + pop: true + - match: ^\s\*\s+ + - match: \G(<)caption(>) + captures: + 0: entity.name.tag.inline.jsdoc + 1: punctuation.definition.bracket.angle.begin.jsdoc + 2: punctuation.definition.bracket.angle.end.jsdoc + push: + - meta_content_scope: constant.other.description.jsdoc + - match: (</)caption(>)|(?=\*/) + captures: + 0: entity.name.tag.inline.jsdoc + 1: punctuation.definition.bracket.angle.begin.jsdoc + 2: punctuation.definition.bracket.angle.end.jsdoc + pop: true + - match: '[^\s@*](?:[^*]|\*[^/])*' + captures: + 0: source.embedded.ts + - match: (?x) ((@)kind) \s+ (class|constant|event|external|file|function|member|mixin|module|namespace|typedef) \b + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: constant.language.symbol-type.jsdoc + - match: |- + (?x) + ((@)see) + \s+ + (?: + # URL + ( + (?=https?://) + (?:[^\s*]|\*[^/])+ + ) + | + # JSDoc namepath + ( + (?! + # Avoid matching bare URIs (also acceptable as links) + https?:// + | + # Avoid matching {@inline tags}; we match those below + (?:\[[^\[\]]*\])? # Possible description [preceding]{@tag} + {@(?:link|linkcode|linkplain|tutorial)\b + ) + # Matched namepath + (?:[^@\s*/]|\*[^/])+ + ) + ) + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: variable.other.link.underline.jsdoc + 4: entity.name.type.instance.jsdoc + - match: |- + (?x) + ((@)template) + \s+ + # One or more valid identifiers + ( + [A-Za-z_$] # First character: non-numeric word character + [\w$.\[\]]* # Rest of identifier + (?: # Possible list of additional identifiers + \s* , \s* + [A-Za-z_$] + [\w$.\[\]]* + )* + ) + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: variable.other.jsdoc + - match: |- + (?x) + ( + (@) + (?:arg|argument|const|constant|member|namespace|param|var) + ) + \s+ + ( + [A-Za-z_$] + [\w$.\[\]]* + ) + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: variable.other.jsdoc + - match: '((@)typedef)\s+(?={)' + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + push: + - match: '(?=\s|\*/|[^{}\[\]A-Za-z_$])' + pop: true + - include: jsdoctype + - match: '(?:[^@\s*/]|\*[^/])+' + scope: entity.name.type.instance.jsdoc + - match: '((@)(?:arg|argument|const|constant|member|namespace|param|prop|property|var))\s+(?={)' + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + push: + - match: '(?=\s|\*/|[^{}\[\]A-Za-z_$])' + pop: true + - include: jsdoctype + - match: '([A-Za-z_$][\w$.\[\]]*)' + scope: variable.other.jsdoc + - match: |- + (?x) + (\[)\s* + [\w$]+ + (?: + (?:\[\])? # Foo[ ].bar properties within an array + \. # Foo.Bar namespaced parameter + [\w$]+ + )* + (?: + \s* + (=) # [foo=bar] Default parameter value + \s* + ( + # The inner regexes are to stop the match early at */ and to not stop at escaped quotes + (?> + "(?:(?:\*(?!/))|(?:\\(?!"))|[^*\\])*?" | # [foo="bar"] Double-quoted + '(?:(?:\*(?!/))|(?:\\(?!'))|[^*\\])*?' | # [foo='bar'] Single-quoted + \[ (?:(?:\*(?!/))|[^*])*? \] | # [foo=[1,2]] Array literal + (?:(?:\*(?!/))|\s(?!\s*\])|\[.*?(?:\]|(?=\*/))|[^*\s\[\]])* # Everything else + )* + ) + )? + \s*(?:(\])((?:[^*\s]|\*[^\s/])+)?|(?=\*/)) + scope: variable.other.jsdoc + captures: + 1: punctuation.definition.optional-value.begin.bracket.square.jsdoc + 2: keyword.operator.assignment.jsdoc + 3: source.embedded.ts + 4: punctuation.definition.optional-value.end.bracket.square.jsdoc + 5: invalid.illegal.syntax.jsdoc + - match: |- + (?x) + ( + (@) + (?:define|enum|exception|export|extends|lends|implements|modifies + |namespace|private|protected|returns?|suppress|this|throws|type + |yields?) + ) + \s+(?={) + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + push: + - match: '(?=\s|\*/|[^{}\[\]A-Za-z_$])' + pop: true + - include: jsdoctype + - match: |- + (?x) + ( + (@) + (?:alias|augments|callback|constructs|emits|event|fires|exports? + |extends|external|function|func|host|lends|listens|interface|memberof!? + |method|module|mixes|mixin|name|requires|see|this|typedef|uses) + ) + \s+ + ( + (?: + [^{}@\s*] | \*[^/] + )+ + ) + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: entity.name.type.instance.jsdoc + - match: '((@)(?:default(?:value)?|license|version))\s+(([''''"]))' + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: variable.other.jsdoc + 4: punctuation.definition.string.begin.jsdoc + push: + - meta_content_scope: variable.other.jsdoc + - match: (\3)|(?=$|\*/) + captures: + 0: variable.other.jsdoc + 1: punctuation.definition.string.end.jsdoc + pop: true + - match: '((@)(?:default(?:value)?|license|tutorial|variation|version))\s+([^\s*]+)' + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: variable.other.jsdoc + - match: '(?x) (@) (?:abstract|access|alias|api|arg|argument|async|attribute|augments|author|beta|borrows|bubbles |callback|chainable|class|classdesc|code|config|const|constant|constructor|constructs|copyright |default|defaultvalue|define|deprecated|desc|description|dict|emits|enum|event|example|exception |exports?|extends|extension(?:_?for)?|external|externs|file|fileoverview|final|fires|for|func |function|generator|global|hideconstructor|host|ignore|implements|implicitCast|inherit[Dd]oc |inner|instance|interface|internal|kind|lends|license|listens|main|member|memberof!?|method |mixes|mixins?|modifies|module|name|namespace|noalias|nocollapse|nocompile|nosideeffects |override|overview|package|param|polymer(?:Behavior)?|preserve|private|prop|property|protected |public|read[Oo]nly|record|require[ds]|returns?|see|since|static|struct|submodule|summary |suppress|template|this|throws|todo|tutorial|type|typedef|unrestricted|uses|var|variation |version|virtual|writeOnce|yields?) \b' + scope: storage.type.class.jsdoc + captures: + 1: punctuation.definition.block.tag.jsdoc + - include: inline-tags + - match: '((@)(?:[_$[:alpha:]][_$[:alnum:]]*))(?=\s+)' + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + enum-declaration: + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?(?:\b(const)\s+)?\b(enum)\s+([_$[:alpha:]][_$[:alnum:]]*)' + captures: + 1: keyword.control.export.ts + 2: storage.modifier.ts + 3: storage.modifier.ts + 4: storage.type.enum.ts + 5: entity.name.type.enum.ts + push: + - meta_scope: meta.enum.declaration.ts + - match: '(?<=\})' + pop: true + - include: comment + - match: '\{' + captures: + 0: punctuation.definition.block.ts + push: + - match: '\}' + captures: + 0: punctuation.definition.block.ts + pop: true + - include: comment + - match: "([_$[:alpha:]][_$[:alnum:]]*)" + captures: + 0: variable.other.enummember.ts + push: + - match: '(?=,|\}|$)' + pop: true + - include: comment + - include: variable-initializer + - match: '(?=((\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`)|(\[([^\[\]]|\[[^\[\]]*\])+\])))' + push: + - match: '(?=,|\}|$)' + pop: true + - include: string + - include: array-literal + - include: comment + - include: variable-initializer + - include: punctuation-comma + export-declaration: + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(export)\s+(as)\s+(namespace)\s+([_$[:alpha:]][_$[:alnum:]]*)' + captures: + 1: keyword.control.export.ts + 2: keyword.control.as.ts + 3: storage.type.namespace.ts + 4: entity.name.type.module.ts + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(export)(?:\s+(type))?(?:(?:\s*(=))|(?:\s+(default)(?=\s+)))' + captures: + 1: keyword.control.export.ts + 2: keyword.control.type.ts + 3: keyword.operator.assignment.ts + 4: keyword.control.default.ts + push: + - meta_scope: meta.export.default.ts + - match: (?=$|;|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b)) + pop: true + - include: interface-declaration + - include: expression + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(export)(?:\s+(type))?\b(?!(\$)|(\s*:))((?=\s*[\{*])|((?=\s*[_$[:alpha:]][_$[:alnum:]]*(\s|,))(?!\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b)))' + captures: + 1: keyword.control.export.ts + 2: keyword.control.type.ts + push: + - meta_scope: meta.export.ts + - match: (?=$|;|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b)) + pop: true + - include: import-export-declaration + expression: + - include: expressionWithoutIdentifiers + - include: identifiers + - include: expressionPunctuations + expression-inside-possibly-arrow-parens: + - include: expressionWithoutIdentifiers + - include: comment + - include: string + - include: decorator + - include: destructuring-parameter + - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(public|protected|private|readonly)\s+(?=(public|protected|private|readonly)\s+)' + captures: + 1: storage.modifier.ts + - match: |- + (?x)(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*(\??)(?=\s* + # function assignment | + (=\s*( + ((async\s+)?( + (function\s*[(<*]) | + (function\s+) | + ([_$[:alpha:]][_$[:alnum:]]*\s*=>) + )) | + ((async\s*)?( + ((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + )) | + # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) => + (:\s*( + (<) | + ([(]\s*( + ([)]) | + (\.\.\.) | + ([_$[:alnum:]]+\s*( + ([:,?=])| + ([)]\s*=>) + )) + )) + )) | + (:\s*(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))Function(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))) | + (:\s*((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) | + (:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*( + ((async\s+)?( + (function\s*[(<*]) | + (function\s+) | + ([_$[:alpha:]][_$[:alnum:]]*\s*=>) + )) | + ((async\s*)?( + ((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\( |