@wooorm/starry-night
Version:
Syntax highlighting, like GitHub
1,156 lines (1,155 loc) • 101 kB
JavaScript
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/jest-community/vscode-jest>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.snap'],
names: ['jest-snapshot'],
patterns: [
{include: '#directives'},
{include: '#statements'},
{
captures: {1: {name: 'punctuation.definition.comment.ts'}},
match: '\\A(#!).*(?=$)',
name: 'comment.line.shebang.ts'
}
],
repository: {
'access-modifier': {
match:
'(?<!\\.|\\$)\\b(abstract|public|protected|private|readonly|static)\\b(?!\\$)',
name: 'storage.modifier.tsx'
},
'after-operator-block': {
begin:
'(?<=[=(,\\[?+!]|await|return|yield|throw|in|of|typeof|&&|\\|\\||\\*)\\s*(\\{)',
beginCaptures: {1: {name: 'punctuation.definition.block.tsx'}},
end: '\\}',
endCaptures: {0: {name: 'punctuation.definition.block.tsx'}},
name: 'meta.objectliteral.tsx',
patterns: [{include: '#object-member'}]
},
'array-binding-pattern': {
begin: '(?:(\\.\\.\\.)\\s*)?(\\[)',
beginCaptures: {
1: {name: 'keyword.operator.rest.tsx'},
2: {name: 'punctuation.definition.binding-pattern.array.tsx'}
},
end: '\\]',
endCaptures: {
0: {name: 'punctuation.definition.binding-pattern.array.tsx'}
},
patterns: [{include: '#binding-element'}, {include: '#punctuation-comma'}]
},
'array-literal': {
begin: '\\[',
beginCaptures: {0: {name: 'meta.brace.square.tsx'}},
end: '\\]',
endCaptures: {0: {name: 'meta.brace.square.tsx'}},
name: 'meta.array.literal.tsx',
patterns: [{include: '#expression'}, {include: '#punctuation-comma'}]
},
'arrow-function': {
patterns: [
{
captures: {1: {name: 'storage.modifier.async.tsx'}},
match: '(?<!\\.|\\$)(\\basync)(?=\\s*[<(])',
name: 'meta.arrow.tsx'
},
{
captures: {
1: {name: 'storage.modifier.async.tsx'},
2: {name: 'variable.parameter.tsx'}
},
match:
'(?:(?<!\\.|\\$)(\\basync)\\s*)?([_$[:alpha:]][_$[:alnum:]]*)\\s*(?==>)',
name: 'meta.arrow.tsx'
},
{
begin:
'(?x)\\s*(?=(<([^<>]|\\<[^<>]+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)',
end: '(?==>)',
name: 'meta.arrow.tsx',
patterns: [
{include: '#comment'},
{include: '#type-parameters'},
{include: '#function-parameters'},
{include: '#arrow-return-type'}
]
},
{
begin: '=>',
beginCaptures: {0: {name: 'storage.type.function.arrow.tsx'}},
end: '(?<=\\})|((?!\\{)(?=\\S))',
name: 'meta.arrow.tsx',
patterns: [{include: '#decl-block'}, {include: '#expression'}]
}
]
},
'arrow-return-type': {
begin: '(?<=\\))\\s*(:)',
beginCaptures: {1: {name: 'keyword.operator.type.annotation.tsx'}},
end: '(?<!:)((?=$)|(?==>|;|//))',
name: 'meta.return.type.arrow.tsx',
patterns: [{include: '#type-predicate-operator'}, {include: '#type'}]
},
'binding-element': {
patterns: [
{include: '#comment'},
{include: '#object-binding-pattern'},
{include: '#array-binding-pattern'},
{include: '#destructuring-variable-rest'},
{include: '#variable-initializer'}
]
},
'boolean-literal': {
patterns: [
{
match: '(?<!\\.|\\$)\\btrue\\b(?!\\$)',
name: 'constant.language.boolean.true.tsx'
},
{
match: '(?<!\\.|\\$)\\bfalse\\b(?!\\$)',
name: 'constant.language.boolean.false.tsx'
}
]
},
'case-clause': {
begin: '(?<!\\.|\\$)\\b(case|default(?=:))\\b(?!\\$)',
beginCaptures: {1: {name: 'keyword.control.switch.tsx'}},
end: ':',
endCaptures: {
0: {name: 'punctuation.definition.section.case-statement.tsx'}
},
name: 'case-clause.expr.tsx',
patterns: [{include: '#expression'}]
},
cast: {patterns: [{include: '#jsx'}]},
'class-or-interface-body': {
begin: '\\{',
beginCaptures: {0: {name: 'punctuation.definition.block.tsx'}},
end: '\\}',
endCaptures: {0: {name: 'punctuation.definition.block.tsx'}},
patterns: [
{include: '#string'},
{include: '#comment'},
{include: '#decorator'},
{include: '#method-declaration'},
{include: '#indexer-declaration'},
{include: '#field-declaration'},
{include: '#type-annotation'},
{include: '#variable-initializer'},
{include: '#access-modifier'},
{include: '#property-accessor'},
{include: '#expression'},
{include: '#punctuation-comma'},
{include: '#punctuation-semicolon'}
]
},
'class-or-interface-declaration': {
begin:
'(?<!\\.|\\$)\\b(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(?:(class)|(interface))\\b',
beginCaptures: {
1: {name: 'keyword.control.export.tsx'},
2: {name: 'storage.modifier.tsx'},
3: {name: 'storage.type.class.tsx'},
4: {name: 'storage.type.interface.tsx'}
},
end: '(?<=\\})',
endCaptures: {1: {name: 'punctuation.definition.block.tsx'}},
name: 'meta.class.tsx',
patterns: [
{include: '#comment'},
{include: '#class-or-interface-heritage'},
{
captures: {0: {name: 'entity.name.type.class.tsx'}},
match: '[_$[:alpha:]][_$[:alnum:]]*'
},
{include: '#type-parameters'},
{include: '#class-or-interface-body'}
]
},
'class-or-interface-heritage': {
begin: '(?<!\\.|\\$)(?:\\b(extends|implements)\\b)(?!\\$)',
beginCaptures: {1: {name: 'storage.modifier.tsx'}},
end: '(?=\\{)',
endCaptures: {1: {name: 'punctuation.definition.block.tsx'}},
patterns: [
{include: '#comment'},
{include: '#class-or-interface-heritage'},
{include: '#type-parameters'},
{
captures: {
1: {name: 'entity.name.type.module.tsx'},
2: {name: 'punctuation.accessor.tsx'}
},
match:
'([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\.)(?=\\s*[_$[:alpha:]][_$[:alnum:]]*(\\s*\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)*\\s*([,<{]|extends|implements|//|/\\*))'
},
{
captures: {1: {name: 'entity.other.inherited-class.tsx'}},
match:
'([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*([,<{]|extends|implements|//|/\\*))'
},
{include: '#expression'}
]
},
comment: {
patterns: [
{
begin: '/\\*\\*(?!/)',
beginCaptures: {0: {name: 'punctuation.definition.comment.tsx'}},
end: '\\*/',
endCaptures: {0: {name: 'punctuation.definition.comment.tsx'}},
name: 'comment.block.documentation.tsx',
patterns: [{include: '#docblock'}]
},
{
begin: '/\\*',
beginCaptures: {0: {name: 'punctuation.definition.comment.tsx'}},
end: '\\*/',
endCaptures: {0: {name: 'punctuation.definition.comment.tsx'}},
name: 'comment.block.tsx'
},
{
begin: '(^[ \\t]+)?(?=//)',
beginCaptures: {
1: {name: 'punctuation.whitespace.comment.leading.tsx'}
},
end: '(?=$)',
patterns: [
{
begin: '//',
beginCaptures: {0: {name: 'punctuation.definition.comment.tsx'}},
end: '(?=$)',
name: 'comment.line.double-slash.tsx'
}
]
}
]
},
'control-statement': {
patterns: [
{
match: '(?<!\\.|\\$)\\b(catch|finally|throw|try)\\b(?!\\$)',
name: 'keyword.control.trycatch.tsx'
},
{
match: '(?<!\\.|\\$)\\b(break|continue|do|goto|while)\\b(?!\\$)',
name: 'keyword.control.loop.tsx'
},
{
match: '(?<!\\.|\\$)\\b(return)\\b(?!\\$)',
name: 'keyword.control.flow.tsx'
},
{
captures: {
1: {name: 'keyword.control.flow.tsx'},
2: {name: 'keyword.generator.asterisk.tsx'}
},
match: '(?<!\\.|\\$)\\b(yield)\\b(?!\\$)(?:\\s*(\\*))?'
},
{
match: '(?<!\\.|\\$)\\b(case|default|switch)\\b(?!\\$)',
name: 'keyword.control.switch.tsx'
},
{
match: '(?<!\\.|\\$)\\b(else|if)\\b(?!\\$)',
name: 'keyword.control.conditional.tsx'
},
{
match: '(?<!\\.|\\$)\\b(with)\\b(?!\\$)',
name: 'keyword.control.with.tsx'
},
{
match: '(?<!\\.|\\$)\\b(debugger)\\b(?!\\$)',
name: 'keyword.other.debugger.tsx'
},
{
match: '(?<!\\.|\\$)\\b(declare)\\b(?!\\$)',
name: 'storage.modifier.tsx'
}
]
},
'decl-block': {
begin: '\\{',
beginCaptures: {0: {name: 'punctuation.definition.block.tsx'}},
end: '\\}',
endCaptures: {0: {name: 'punctuation.definition.block.tsx'}},
name: 'meta.block.tsx',
patterns: [{include: '#statements'}]
},
declaration: {
name: 'meta.declaration.tsx',
patterns: [
{include: '#decorator'},
{include: '#var-expr'},
{include: '#function-declaration'},
{include: '#class-or-interface-declaration'},
{include: '#type-declaration'},
{include: '#enum-declaration'},
{include: '#namespace-declaration'},
{include: '#import-equals-declaration'},
{include: '#import-declaration'},
{include: '#export-declaration'}
]
},
decorator: {
begin: '(?<!\\.|\\$)\\@',
beginCaptures: {0: {name: 'punctuation.decorator.tsx'}},
end: '(?=\\s)',
name: 'meta.decorator.tsx',
patterns: [{include: '#expression'}]
},
'destructuring-parameter': {
patterns: [
{
begin: '(?<!=|:)\\s*(\\{)',
beginCaptures: {
1: {name: 'punctuation.definition.binding-pattern.object.tsx'}
},
end: '\\}',
endCaptures: {
0: {name: 'punctuation.definition.binding-pattern.object.tsx'}
},
name: 'meta.parameter.object-binding-pattern.tsx',
patterns: [{include: '#parameter-object-binding-element'}]
},
{
begin: '(?<!=|:)\\s*(\\[)',
beginCaptures: {
1: {name: 'punctuation.definition.binding-pattern.array.tsx'}
},
end: '\\]',
endCaptures: {
0: {name: 'punctuation.definition.binding-pattern.array.tsx'}
},
name: 'meta.paramter.array-binding-pattern.tsx',
patterns: [
{include: '#parameter-binding-element'},
{include: '#punctuation-comma'}
]
}
]
},
'destructuring-parameter-rest': {
captures: {
1: {name: 'keyword.operator.rest.tsx'},
2: {name: 'variable.parameter.tsx'}
},
match: '(?:(\\.\\.\\.)\\s*)?([_$[:alpha:]][_$[:alnum:]]*)'
},
'destructuring-variable': {
patterns: [
{
begin: '(?<!=|:|of|in)\\s*(?=\\{)',
end: '(?=$|[;,=}]|(\\s+(of|in)\\s+))',
name: 'meta.object-binding-pattern-variable.tsx',
patterns: [
{include: '#object-binding-pattern'},
{include: '#type-annotation'},
{include: '#comment'}
]
},
{
begin: '(?<!=|:|of|in)\\s*(?=\\[)',
end: '(?=$|[;,=}]|(\\s+(of|in)\\s+))',
name: 'meta.array-binding-pattern-variable.tsx',
patterns: [
{include: '#array-binding-pattern'},
{include: '#type-annotation'},
{include: '#comment'}
]
}
]
},
'destructuring-variable-rest': {
captures: {
1: {name: 'keyword.operator.rest.tsx'},
2: {name: 'meta.definition.variable.tsx variable.other.readwrite.tsx'}
},
match: '(?:(\\.\\.\\.)\\s*)?([_$[:alpha:]][_$[:alnum:]]*)'
},
directives: {
begin:
'^(///)\\s*(?=<(reference|amd-dependency|amd-module)(\\s+(path|types|no-default-lib|name)\\s*=\\s*((\\\'[^\']*\\\')|(\\"[^"]*\\")))+\\s*/>\\s*$)',
beginCaptures: {1: {name: 'punctuation.definition.comment.tsx'}},
end: '(?=$)',
name: 'comment.line.triple-slash.directive.tsx',
patterns: [
{
begin: '(<)(reference|amd-dependency|amd-module)',
beginCaptures: {
1: {name: 'punctuation.definition.tag.directive.tsx'},
2: {name: 'entity.name.tag.directive.tsx'}
},
end: '/>',
endCaptures: {0: {name: 'punctuation.definition.tag.directive.tsx'}},
name: 'meta.tag.tsx',
patterns: [
{
match: 'path|types|no-default-lib|name',
name: 'entity.other.attribute-name.directive.tsx'
},
{match: '=', name: 'keyword.operator.assignment.tsx'},
{include: '#string'}
]
}
]
},
docblock: {
patterns: [
{
match:
'(?x)(?<!\\w)@(\n abstract|access|alias|arg|argument|async|attribute|augments|author|beta|borrows|bubbes|callback|chainable|class\n |classdesc|code|config|const|constant|constructor|constructs|copyright|default|defaultvalue|define|deprecated|desc\n |description|dict|emits|enum|event|example|exports?|extends|extension|extension_for|extensionfor|external|file\n |fileoverview|final|fires|for|function|global|host|ignore|implements|implicitCast|inherit[Dd]oc|inner|instance\n |interface|kind|lends|license|listens|main|member|memberof|method|mixex|mixins?|modifies|module|name|namespace\n |noalias|nocollapse|nocompile|nosideeffects|override|overview|package|param|preserve|private|prop|property\n |protected|public|read[Oo]nly|record|require[ds]|returns?|see|since|static|struct|submodule|summary|suppress\n |template|this|throws|todo|type|typedef|unrestricted|uses|var|variation|version|virtual|writeOnce)\\b',
name: 'storage.type.class.jsdoc'
},
{
captures: {
0: {name: 'entity.name.type.instance.jsdoc'},
1: {name: 'constant.other.description.jsdoc'},
2: {name: 'storage.type.class.jsdoc'},
3: {name: 'variable.other.description.jsdoc'}
},
match:
'(?x)\n(\n \\[\n [^\\]]+ # Optional [link text] preceding {@link syntax}\n \\]\n\n (?! # Check to avoid highlighting two sets of link text\n {\n @\\w+ # Tagname\n \\s+\n [^\\s|}]+ # Namepath/URL\n [\\s|] # Whitespace or bar delimiting description\n [^}]*\n }\n )\n)?\n\n(?:\n {\n (\n @\n (?: link # Name of tag\n | linkcode\n | linkplain\n | tutorial\n )\n )\n\n \\s+\n\n ([^\\s|}]+) # Namepath or URL\n\n (?: # Optional link text following link target\n [\\s|] # Bar or space separating target and text\n [^}]* # Actual text\n )?\n }\n)',
name: 'other.meta.jsdoc'
},
{
captures: {
0: {name: 'other.meta.jsdoc'},
1: {name: 'entity.name.type.instance.jsdoc'},
2: {name: 'variable.other.jsdoc'},
3: {name: 'other.description.jsdoc'}
},
match:
'(?x)\n\n(?:(?<=@param)|(?<=@arg)|(?<=@argument)|(?<=@type)|(?<=@property)|(?<=@prop))\n\n\\s+\n\n({(?:\n \\* | # {*} any type\n \\? | # {?} unknown type\n\n (?:\n (?: # Check for a prefix\n \\? | # {?string} nullable type\n ! | # {!string} non-nullable type\n \\.{3} # {...string} variable number of parameters\n )?\n\n (?:\n (?:\n function # {function(string, number)} function type\n \\s*\n \\(\n \\s*\n (?:\n [a-zA-Z_$][\\w$]*\n (?:\n \\s*,\\s*\n [a-zA-Z_$][\\w$]*\n )*\n )?\n \\s*\n \\)\n (?: # {function(): string} function return type\n \\s*:\\s*\n [a-zA-Z_$][\\w$]*\n )?\n )?\n |\n (?:\n \\( # Opening bracket of multiple types with parenthesis {(string|number)}\n [a-zA-Z_$]+\n (?:\n (?:\n [\\w$]*\n (?:\\[\\])? # {(string[]|number)} type application, an array of strings or a number\n ) |\n \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array<string>} or {Object<string, number>} type application (optional .)\n )\n (?:\n [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback\n [a-zA-Z_$]+\n (?:\n (?:\n [\\w$]*\n (?:\\[\\])? # {(string|number[])} type application, a string or an array of numbers\n ) |\n \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array<string>} or {Object<string, number>} type application (optional .)\n )\n )*\n \\) |\n [a-zA-Z_$]+\n (?:\n (?:\n [\\w$]*\n (?:\\[\\])? # {(string|number[])} type application, a string or an array of numbers\n ) |\n \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array<string>} or {Object<string, number>} type application (optional .)\n )\n (?:\n [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback\n [a-zA-Z_$]+\n (?:\n [\\w$]* |\n \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array<string>} or {Object<string, number>} type application (optional .)\n )\n )*\n )\n )\n # Check for suffix\n (?:\\[\\])? # {string[]} type application, an array of strings\n =? # {string=} optional parameter\n )\n)})\n\n\\s+\n\n(\n \\[ # [foo] optional parameter\n \\s*\n (?:\n [a-zA-Z_$][\\w$]*\n (?:\n (?:\\[\\])? # Foo[].bar properties within an array\n \\. # Foo.Bar namespaced parameter\n [a-zA-Z_$][\\w$]*\n )*\n (?:\n \\s*\n = # [foo=bar] Default parameter value\n \\s*\n [\\w$\\s]*\n )?\n )\n \\s*\n \\] |\n (?:\n [a-zA-Z_$][\\w$]*\n (?:\n (?:\\[\\])? # Foo[].bar properties within an array\n \\. # Foo.Bar namespaced parameter\n [a-zA-Z_$][\\w$]*\n )*\n )?\n)\n\n\\s+\n\n(?:-\\s+)? # optional hyphen before the description\n\n((?:(?!\\*\\/).)*) # The type description'
},
{
captures: {
0: {name: 'other.meta.jsdoc'},
1: {name: 'entity.name.type.instance.jsdoc'},
2: {name: 'other.description.jsdoc'}
},
match:
'(?x)\n\n({(?:\n \\* | # {*} any type\n \\? | # {?} unknown type\n\n (?:\n (?: # Check for a prefix\n \\? | # {?string} nullable type\n ! | # {!string} non-nullable type\n \\.{3} # {...string} variable number of parameters\n )?\n\n (?:\n (?:\n function # {function(string, number)} function type\n \\s*\n \\(\n \\s*\n (?:\n [a-zA-Z_$][\\w$]*\n (?:\n \\s*,\\s*\n [a-zA-Z_$][\\w$]*\n )*\n )?\n \\s*\n \\)\n (?: # {function(): string} function return type\n \\s*:\\s*\n [a-zA-Z_$][\\w$]*\n )?\n )?\n |\n (?:\n \\( # Opening bracket of multiple types with parenthesis {(string|number)}\n [a-zA-Z_$]+\n (?:\n [\\w$]* |\n \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array<string>} or {Object<string, number>} type application (optional .)\n )\n (?:\n [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback\n [a-zA-Z_$]+\n (?:\n [\\w$]* |\n \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array<string>} or {Object<string, number>} type application (optional .)\n )\n )*\n \\) |\n [a-zA-Z_$]+\n (?:\n [\\w$]* |\n \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array<string>} or {Object<string, number>} type application (optional .)\n )\n (?:\n [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback\n [a-zA-Z_$]+\n (?:\n [\\w$]* |\n \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array<string>} or {Object<string, number>} type application (optional .)\n )\n )*\n )\n )\n # Check for suffix\n (?:\\[\\])? # {string[]} type application, an array of strings\n =? # {string=} optional parameter\n )\n)})\n\n\\s+\n\n(?:-\\s+)? # optional hyphen before the description\n\n((?:(?!\\*\\/).)*) # The type description'
}
]
},
'enum-declaration': {
begin:
'(?<!\\.|\\$)(?:(\\bexport)\\s+)?(?:\\b(const)\\s+)?\\b(enum)\\s+([_$[:alpha:]][_$[:alnum:]]*)',
beginCaptures: {
1: {name: 'keyword.control.export.tsx'},
2: {name: 'storage.modifier.tsx'},
3: {name: 'storage.type.enum.tsx'},
4: {name: 'entity.name.type.enum.tsx'}
},
end: '(?<=\\})',
name: 'meta.enum.declaration.tsx',
patterns: [
{include: '#comment'},
{
begin: '\\{',
beginCaptures: {0: {name: 'punctuation.definition.block.tsx'}},
end: '\\}',
endCaptures: {0: {name: 'punctuation.definition.block.tsx'}},
patterns: [
{include: '#comment'},
{
begin: '([_$[:alpha:]][_$[:alnum:]]*)',
beginCaptures: {0: {name: 'variable.other.enummember.tsx'}},
end: '(?=,|\\}|$)',
patterns: [
{include: '#comment'},
{include: '#variable-initializer'}
]
},
{
begin:
'(?=((\\\'[^\']*\\\')|(\\"[^"]*\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\])))',
end: '(?=,|\\}|$)',
patterns: [
{include: '#string'},
{include: '#array-literal'},
{include: '#comment'},
{include: '#variable-initializer'}
]
},
{include: '#punctuation-comma'}
]
}
]
},
'export-declaration': {
patterns: [
{
captures: {
1: {name: 'keyword.control.export.tsx'},
2: {name: 'keyword.control.as.tsx'},
3: {name: 'storage.type.namespace.tsx'},
4: {name: 'entity.name.type.module.tsx'}
},
match:
'(?<!\\.|\\$)\\b(export)\\s+(as)\\s+(namespace)\\s+([_$[:alpha:]][_$[:alnum:]]*)'
},
{
begin:
'(?<!\\.|\\$)\\b(export)(?:(?:\\s*(=))|(?:\\s+(default)(?=\\s+)))',
beginCaptures: {
1: {name: 'keyword.control.export.tsx'},
2: {name: 'keyword.operator.assignment.tsx'},
3: {name: 'keyword.control.default.tsx'}
},
end: '(?=;|\\bexport\\b|\\bfunction\\b|\\bclass\\b|\\binterface\\b|\\blet\\b|\\bvar\\b|\\bconst\\b|\\bimport\\b|\\benum\\b|\\bnamespace\\b|\\bmodule\\b|\\btype\\b|\\babstract\\b|\\bdeclare\\b|\\basync\\b|$)',
name: 'meta.export.default.tsx',
patterns: [{include: '#expression'}]
},
{
begin: '(?<!\\.|\\$)\\b(export)(?!(\\s*:)|(\\$))\\b',
beginCaptures: {0: {name: 'keyword.control.export.tsx'}},
end: '(?=;|\\bexport\\b|\\bfunction\\b|\\bclass\\b|\\binterface\\b|\\blet\\b|\\bvar\\b|\\bconst\\b|\\bimport\\b|\\benum\\b|\\bnamespace\\b|\\bmodule\\b|\\btype\\b|\\babstract\\b|\\bdeclare\\b|\\basync\\b|$)',
name: 'meta.export.tsx',
patterns: [{include: '#import-export-declaration'}]
}
]
},
expression: {
name: 'meta.expression.tsx',
patterns: [
{include: '#jsx'},
{include: '#string'},
{include: '#regex'},
{include: '#template'},
{include: '#comment'},
{include: '#literal'},
{include: '#function-declaration'},
{include: '#class-or-interface-declaration'},
{include: '#arrow-function'},
{include: '#cast'},
{include: '#ternary-expression'},
{include: '#new-expr'},
{include: '#object-literal'},
{include: '#expression-operators'},
{include: '#function-call'},
{include: '#support-objects'},
{include: '#identifiers'},
{include: '#paren-expression'},
{include: '#punctuation-comma'},
{include: '#punctuation-accessor'}
]
},
'expression-operators': {
patterns: [
{
match: '(?<!\\.|\\$)\\b(await)\\b(?!\\$)',
name: 'keyword.control.flow.tsx'
},
{
match: '(?<!\\.|\\$)\\bdelete\\b(?!\\$)',
name: 'keyword.operator.expression.delete.tsx'
},
{
match: '(?<!\\.|\\$)\\bin\\b(?!\\$)',
name: 'keyword.operator.expression.in.tsx'
},
{
match: '(?<!\\.|\\$)\\bof\\b(?!\\$)',
name: 'keyword.operator.expression.of.tsx'
},
{
match: '(?<!\\.|\\$)\\binstanceof\\b(?!\\$)',
name: 'keyword.operator.expression.instanceof.tsx'
},
{
match: '(?<!\\.|\\$)\\bnew\\b(?!\\$)',
name: 'keyword.operator.new.tsx'
},
{include: '#typeof-operator'},
{
match: '(?<!\\.|\\$)\\bvoid\\b(?!\\$)',
name: 'keyword.operator.expression.void.tsx'
},
{
begin: '(?<!\\.|\\$)\\bas\\b(?!\\$)',
beginCaptures: {0: {name: 'keyword.control.as.tsx'}},
end: '(?=$|[;,:})\\]])',
patterns: [{include: '#type'}]
},
{match: '\\.\\.\\.', name: 'keyword.operator.spread.tsx'},
{
match: '\\*=|(?<!\\()/=|%=|\\+=|\\-=',
name: 'keyword.operator.assignment.compound.tsx'
},
{
match: '\\&=|\\^=|<<=|>>=|>>>=|\\|=',
name: 'keyword.operator.assignment.compound.bitwise.tsx'
},
{match: '<<|>>>|>>', name: 'keyword.operator.bitwise.shift.tsx'},
{match: '===|!==|==|!=', name: 'keyword.operator.comparison.tsx'},
{match: '<=|>=|<>|<|>', name: 'keyword.operator.relational.tsx'},
{match: '\\!|&&|\\|\\|', name: 'keyword.operator.logical.tsx'},
{match: '\\&|~|\\^|\\|', name: 'keyword.operator.bitwise.tsx'},
{match: '\\=', name: 'keyword.operator.assignment.tsx'},
{match: '--', name: 'keyword.operator.decrement.tsx'},
{match: '\\+\\+', name: 'keyword.operator.increment.tsx'},
{match: '%|\\*|/|-|\\+', name: 'keyword.operator.arithmetic.tsx'},
{
captures: {1: {name: 'keyword.operator.arithmetic.tsx'}},
match: '(?<=[_$[:alnum:]])\\s*(/)(?![/*])'
}
]
},
'field-declaration': {
begin:
'(?<!\\()(?:(?<!\\.|\\$)\\b(readonly)\\s+)?(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\\'[^\']*\\\')|(\\"[^"]*\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))',
beginCaptures: {1: {name: 'storage.modifier.tsx'}},
end: '(?=\\}|;|,|$)|(?<=\\})',
name: 'meta.field.declaration.tsx',
patterns: [
{include: '#variable-initializer'},
{
begin:
'(?=((?:[_$[:alpha:]][_$[:alnum:]]*)|(?:\\\'[^\']*\\\')|(?:\\"[^"]*\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))',
end: '(?=[};,=]|$)|(?<=\\})',
patterns: [
{include: '#type-annotation'},
{include: '#string'},
{include: '#array-literal'},
{include: '#comment'},
{
match:
'(?x)([_$[:alpha:]][_$[:alnum:]]*)(?=(\\?\\s*)?\\s*\n (=\\s*(\n (async\\s+) |\n (function\\s*[(<]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>) |\n ((<([^<>]|\\<[^<>]+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>))\n ) |\n (:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n )))\n )\n)',
name: 'meta.definition.property.tsx entity.name.function.tsx'
},
{
match: '[_$[:alpha:]][_$[:alnum:]]*',
name: 'meta.definition.property.tsx variable.object.property.tsx'
},
{match: '\\?', name: 'keyword.operator.optional.tsx'}
]
}
]
},
'for-loop': {
begin: '(?<!\\.|\\$)\\b(for)\\s*(\\()',
beginCaptures: {
1: {name: 'keyword.control.loop.tsx'},
2: {name: 'meta.brace.round.tsx'}
},
end: '\\)',
endCaptures: {0: {name: 'meta.brace.round.tsx'}},
patterns: [
{include: '#var-expr'},
{include: '#expression'},
{include: '#punctuation-semicolon'}
]
},
'function-call': {
begin:
'(?=(\\.\\s*)?([_$[:alpha:]][_$[:alnum:]]*)\\s*(<([^<>]|\\<[^<>]+\\>)+>\\s*)?\\()',
end: '(?<=\\))(?!(\\.\\s*)?([_$[:alpha:]][_$[:alnum:]]*)\\s*(<([^<>]|\\<[^<>]+\\>)+>\\s*)?\\()',
patterns: [
{include: '#support-objects'},
{match: '\\.', name: 'punctuation.accessor.tsx'},
{
match: '([_$[:alpha:]][_$[:alnum:]]*)',
name: 'entity.name.function.tsx'
},
{include: '#comment'},
{
begin: '\\<',
beginCaptures: {
0: {name: 'punctuation.definition.typeparameters.begin.tsx'}
},
end: '\\>',
endCaptures: {
0: {name: 'punctuation.definition.typeparameters.end.tsx'}
},
name: 'meta.type.parameters.tsx',
patterns: [{include: '#type'}, {include: '#punctuation-comma'}]
},
{include: '#paren-expression'}
]
},
'function-declaration': {
begin:
'(?<!\\.|\\$)\\b(?:(export)\\s+)?(?:(async)\\s+)?(function\\b)(?:\\s*(\\*))?(?:(?:\\s+|(?<=\\*))([_$[:alpha:]][_$[:alnum:]]*))?\\s*',
beginCaptures: {
1: {name: 'keyword.control.export.tsx'},
2: {name: 'storage.modifier.async.tsx'},
3: {name: 'storage.type.function.tsx'},
4: {name: 'keyword.generator.asterisk.tsx'},
5: {name: 'meta.definition.function.tsx entity.name.function.tsx'}
},
end: '(?=;|\\})|(?<=\\})',
name: 'meta.function.tsx',
patterns: [
{include: '#comment'},
{include: '#type-parameters'},
{include: '#function-parameters'},
{include: '#return-type'},
{include: '#function-overload-declaration'},
{include: '#decl-block'}
]
},
'function-overload-declaration': {
captures: {
1: {name: 'keyword.control.export.tsx'},
2: {name: 'storage.modifier.async.tsx'},
3: {name: 'storage.type.function.tsx'},
4: {name: 'keyword.generator.asterisk.tsx'},
5: {name: 'meta.definition.function.tsx entity.name.function.tsx'}
},
match:
'(?<!\\.|\\$)\\b(?:(export)\\s+)?(?:(async)\\s+)?(function\\b)(?:\\s*(\\*))?(?:(?:\\s+|(?<=\\*))([_$[:alpha:]][_$[:alnum:]]*))?\\s*',
name: 'meta.function.overload.tsx'
},
'function-parameters': {
begin: '\\(',
beginCaptures: {0: {name: 'punctuation.definition.parameters.begin.tsx'}},
end: '\\)',
endCaptures: {0: {name: 'punctuation.definition.parameters.end.tsx'}},
name: 'meta.parameters.tsx',
patterns: [
{include: '#comment'},
{include: '#decorator'},
{include: '#destructuring-parameter'},
{include: '#parameter-name'},
{include: '#type-annotation'},
{include: '#variable-initializer'},
{match: ',', name: 'punctuation.separator.parameter.tsx'}
]
},
identifiers: {
patterns: [
{
match:
'([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*\\.\\s*prototype\\b(?!\\$))',
name: 'support.class.tsx'
},
{
captures: {
1: {name: 'punctuation.accessor.tsx'},
2: {name: 'constant.other.object.property.tsx'},
3: {name: 'variable.other.object.property.tsx'}
},
match:
'(?x)(\\.)\\s*(?:\n ([[:upper:]][_$[:digit:][:upper:]]*) |\n ([_$[:alpha:]][_$[:alnum:]]*)\n)(?=\\s*\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)'
},
{
captures: {
1: {name: 'punctuation.accessor.tsx'},
2: {name: 'entity.name.function.tsx'}
},
match:
'(?x)(?:(\\.)\\s*)?([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*=\\s*(\n (async\\s+)|(function\\s*[(<])|(function\\s+)|\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)|\n ((<([^<>]|\\<[^<>]+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)))'
},
{
captures: {
1: {name: 'punctuation.accessor.tsx'},
2: {name: 'constant.other.property.tsx'}
},
match:
'(\\.)\\s*([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])'
},
{
captures: {
1: {name: 'punctuation.accessor.tsx'},
2: {name: 'variable.other.property.tsx'}
},
match: '(\\.)\\s*([_$[:alpha:]][_$[:alnum:]]*)'
},
{
captures: {
1: {name: 'constant.other.object.tsx'},
2: {name: 'variable.other.object.tsx'}
},
match:
'(?x)(?:\n ([[:upper:]][_$[:digit:][:upper:]]*) |\n ([_$[:alpha:]][_$[:alnum:]]*)\n)(?=\\s*\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)'
},
{
match: '([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])',
name: 'constant.other.tsx'
},
{
match: '[_$[:alpha:]][_$[:alnum:]]*',
name: 'variable.other.readwrite.tsx'
}
]
},
'import-declaration': {
begin: '(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(import)(?!(\\s*:)|(\\$))\\b',
beginCaptures: {
1: {name: 'keyword.control.export.tsx'},
2: {name: 'keyword.control.import.tsx'}
},
end: '(?=;|$)',
name: 'meta.import.tsx',
patterns: [{include: '#import-export-declaration'}]
},
'import-equals-declaration': {
patterns: [
{
begin:
'(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(import)\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*(=)\\s*(require)\\s*(\\()',
beginCaptures: {
1: {name: 'keyword.control.export.tsx'},
2: {name: 'keyword.control.import.tsx'},
3: {name: 'variable.other.readwrite.alias.tsx'},
4: {name: 'keyword.operator.assignment.tsx'},
5: {name: 'keyword.control.require.tsx'},
6: {name: 'meta.brace.round.tsx'}
},
end: '\\)',
endCaptures: {0: {name: 'meta.brace.round.tsx'}},
name: 'meta.import-equals.external.tsx',
patterns: [{include: '#comment'}, {include: '#string'}]
},
{
begin:
'(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(import)\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*(=)\\s*(?!require\\b)',
beginCaptures: {
1: {name: 'keyword.control.export.tsx'},
2: {name: 'keyword.control.import.tsx'},
3: {name: 'variable.other.readwrite.alias.tsx'},
4: {name: 'keyword.operator.assignment.tsx'}
},
end: '(?=;|$)',
name: 'meta.import-equals.internal.tsx',
patterns: [
{include: '#comment'},
{
captures: {
1: {name: 'entity.name.type.module.tsx'},
2: {name: 'punctuation.accessor.tsx'}
},
match: '([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\.)'
},
{
match: '([_$[:alpha:]][_$[:alnum:]]*)',
name: 'variable.other.readwrite.tsx'
}
]
}
]
},
'import-export-block': {
begin: '\\{',
beginCaptures: {0: {name: 'punctuation.definition.block.tsx'}},
end: '\\}',
endCaptures: {0: {name: 'punctuation.definition.block.tsx'}},
name: 'meta.block.tsx',
patterns: [{include: '#import-export-clause'}]
},
'import-export-clause': {
patterns: [
{include: '#comment'},
{
captures: {
1: {name: 'keyword.control.default.tsx'},
2: {name: 'constant.language.import-export-all.tsx'},
3: {name: 'variable.other.readwrite.tsx'},
4: {name: 'keyword.control.as.tsx'},
5: {name: 'invalid.illegal.tsx'},
6: {name: 'variable.other.readwrite.alias.tsx'}
},
match:
'(?x) (?: \\b(default)\\b | (\\*) | ([_$[:alpha:]][_$[:alnum:]]*)) \\s+ \n (as) \\s+ (?: (\\b default \\b | \\*) | ([_$[:alpha:]][_$[:alnum:]]*))'
},
{include: '#punctuation-comma'},
{match: '\\*', name: 'constant.language.import-export-all.tsx'},
{match: '\\b(default)\\b', name: 'keyword.control.default.tsx'},
{
match: '([_$[:alpha:]][_$[:alnum:]]*)',
name: 'variable.other.readwrite.alias.tsx'
}
]
},
'import-export-declaration': {
patterns: [
{include: '#comment'},
{include: '#string'},
{include: '#import-export-block'},
{match: '\\bfrom\\b', name: 'keyword.control.from.tsx'},
{include: '#import-export-clause'}
]
},
'indexer-declaration': {
begin:
'(?:(?<!\\.|\\$)\\b(readonly)\\s*)?(\\[)\\s*([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=:)',
beginCaptures: {
1: {name: 'storage.modifier.tsx'},
2: {name: 'meta.brace.square.tsx'},
3: {name: 'variable.parameter.tsx'}
},
end: '(\\])\\s*(\\?\\s*)?|$',
endCaptures: {
1: {name: 'meta.brace.square.tsx'},
2: {name: 'keyword.operator.optional.tsx'}
},
name: 'meta.indexer.declaration.tsx',
patterns: [{include: '#type-annotation'}]
},
'indexer-mapped-type-declaration': {
begin:
'(?:(?<!\\.|\\$)\\b(readonly)\\s*)?(\\[)\\s*([_$[:alpha:]][_$[:alnum:]]*)\\s+(in)\\s+',
beginCaptures: {
1: {name: 'storage.modifier.tsx'},
2: {name: 'meta.brace.square.tsx'},
3: {name: 'entity.name.type.tsx'},
4: {name: 'keyword.operator.expression.in.tsx'}
},
end: '(\\])\\s*(\\?\\s*)?|$',
endCaptures: {
1: {name: 'meta.brace.square.tsx'},
2: {name: 'keyword.operator.optional.tsx'}
},
name: 'meta.indexer.mappedtype.declaration.tsx',
patterns: [{include: '#type'}]
},
jsx: {
patterns: [
{include: '#jsx-tag-without-attributes'},
{include: '#jsx-tag-in-expression'},
{include: '#jsx-tag-invalid'}
]
},
'jsx-child-tag': {
begin:
'(?x)\n (?=(<)\\s*\n ([_$a-zA-Z][-$\\w.]*(?<!\\.|-))\n (?=\\s+(?!\\?)|/?>))',
end: '(/>)|(?:(</)\\s*([_$a-zA-Z][-$\\w.]*(?<!\\.|-))\\s*(>))',
endCaptures: {
0: {name: 'meta.tag.tsx'},
1: {name: 'punctuation.definition.tag.end.tsx'},
2: {name: 'punctuation.definition.tag.begin.tsx'},
3: {name: 'entity.name.tag.tsx'},
4: {name: 'punctuation.definition.tag.end.tsx'}
},
patterns: [{include: '#jsx-tag'}]
},
'jsx-children': {
patterns: [
{include: '#jsx-tag-without-attributes'},
{include: '#jsx-child-tag'},
{include: '#jsx-tag-invalid'},
{include: '#jsx-evaluated-code'},
{include: '#jsx-entities'}
]
},
'jsx-entities': {
patterns: [
{
captures: {
1: {name: 'punctuation.definition.entity.tsx'},
3: {name: 'punctuation.definition.entity.tsx'}
},
match: '(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;)',
name: 'constant.character.entity.tsx'
},
{match: '&', name: 'invalid.illegal.bad-ampersand.tsx'}
]
},
'jsx-evaluated-code': {
begin: '\\{',
beginCaptures: {0: {name: 'punctuation.section.embedded.begin.tsx'}},
end: '\\}',
endCaptures: {0: {name: 'punctuation.section.embedded.end.tsx'}},
name: 'meta.embedded.expression.tsx',
patterns: [{include: '#expression'}]
},
'jsx-string-double-quoted': {
begin: '"',
beginCaptures: {0: {name: 'punctuation.definition.string.begin.tsx'}},
end: '"',
endCaptures: {0: {name: 'punctuation.definition.string.end.tsx'}},
name: 'string.quoted.double.tsx',
patterns: [{include: '#jsx-entities'}]
},
'jsx-string-single-quoted': {
begin: "'",
beginCaptures: {0: {name: 'punctuation.definition.string.begin.tsx'}},
end: "'",
endCaptures: {0: {name: 'punctuation.definition.string.end.tsx'}},
name: 'string.quoted.single.tsx',
patterns: [{include: '#jsx-entities'}]
},
'jsx-tag': {
begin:
'(?x)\n (?=(<)\\s*\n ([_$a-zA-Z][-$\\w.]*(?<!\\.|-))\n (?=\\s+(?!\\?)|/?>))',
end: '(?=(/>)|(?:(</)\\s*([_$a-zA-Z][-$\\w.]*(?<!\\.|-))\\s*(>)))',
name: 'meta.tag.tsx',
patterns: [
{
begin:
'(?x)\n (<)\\s*\n ([_$a-zA-Z][-$\\w.]*(?<!\\.|-))\n (?=\\s+(?!\\?)|/?>)',
beginCaptures: {
1: {name: 'punctuation.definition.tag.begin.tsx'},
2: {name: 'entity.name.tag.tsx'}
},
end: '(?=[/]?>)',
patterns: [
{include: '#comment'},
{include: '#jsx-tag-attributes'},
{include: '#jsx-tag-attributes-illegal'}
]
},
{
begin: '(>)',
beginCaptures: {1: {name: 'punctuation.definition.tag.end.tsx'}},
contentName: 'meta.jsx.children.tsx',
end: '(?=</)',
patterns: [{include: '#jsx-children'}]
}
]
},
'jsx-tag-attribute-assignment': {
match: '=(?=\\s*(?:\'|"|{|/\\*|//|\\n))',
name: 'keyword.operator.assignment.tsx'
},
'jsx-tag-attribute-name': {
captures: {1: {name: 'entity.other.attribute-name.tsx'}},
match: '(?x)\n \\s*\n ([_$a-zA-Z][-$\\w]*)\n (?=\\s|=|/?>|/\\*|//)'
},
'jsx-tag-attributes': {
patterns: [
{include: '#jsx-tag-attribute-name'},
{include: '#jsx-tag-attribute-assignment'},
{include: '#jsx-string-double-quoted'},
{include: '#jsx-string-single-quoted'},
{include: '#jsx-evaluated-code'}
]
},
'jsx-tag-attributes-illegal': {
match: '\\S+',
name: 'invalid.illegal.attribute.tsx'
},
'jsx-tag-in-expression': {
begin:
'(?x)\n (?<=[({\\[,?=>:*]|&&|\\|\\||\\?|\\Wreturn|^return|\\Wdefault|^)\\s*\n (?!(<)\\s*([_$a-zA-Z][-$\\w.]*(?<!\\.|-))\\s*(>)) #look ahead is not start of tag without attributes\n (?!<\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s+[^=>])|,)) # look ahead is not type parameter of arrow\n (?=(<)\\s*\n ([_$a-zA-Z][-$\\w.]*(?<!\\.|-))\n (?=\\s+(?!\\?)|/?>))',
end: '(/>)|(?:(</)\\s*([_$a-zA-Z][-$\\w.]*(?<!\\.|-))\\s*(>))',
endCaptures: {
0: {name: 'meta.tag.tsx'},
1: {name: 'punctuation.definition.tag.end.tsx'},
2: {name: 'punctuation.definition.tag.begin.tsx'},
3: {name: 'entity.name.tag.tsx'},
4: {name: 'punctuation.definition.tag.end.tsx'}
},
patterns: [{include: '#jsx-tag'}]
},
'jsx-tag-invalid': {
match: '<\\s*>',
name: 'invalid.illegal.tag.incomplete.tsx'
},
'jsx-tag-without-attributes': {
begin: '(<)\\s*([_$a-zA-Z][-$\\w.]*(?<!\\.|-))\\s*(>)',
beginCaptures: {
1: {name: 'punctuation.definition.tag.begin.tsx'},
2: {name: 'entity.name.tag.tsx'},
3: {name: 'punctuation.definition.tag.end.tsx'}
},
contentName: 'meta.jsx.children.tsx',
end: '(</)\\s*([_$a-zA-Z][-$\\w.]*(?<!\\.|-))\\s*(>)',
endCaptures: {
1: {name: 'punctuation.definition.tag.begin.tsx'},
2: {name: 'entity.name.tag.tsx'},
3: {name: 'punctuation.definition.tag.end.tsx'}
},
name: 'meta.tag.without-attributes.tsx',
patterns: [{include: '#jsx-children'}]
},
literal: {
name: 'literal.tsx',
patterns: [
{include: '#numeric-literal'},
{include: '#boolean-literal'},
{include: '#null-literal'},
{include: '#undefined-literal'},
{include: '#numericConstant-literal'},
{include: '#array-literal'},
{include: '#this-literal'},
{include: '#super-literal'}
]
},
'method-declaration': {
begin:
'(?<!\\.|\\$)(?:\\b(public|private|protected)\\s+)?(?:\\b(abstract)\\s+)?(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)?(?:(?:\\b(?:(new)|(constructor))\\b(?!\\$|:))|(?:(\\*)\\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\\\'[^\']*\\\')|(\\"[^"]*\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))?\\s*[\\(\\<]))',
beginCaptures: {
1: {name: 'storage.modifier.tsx'},
2: {name: 'storage.modifier.tsx'},
3: {name: 'storage.modifier.async.tsx'},
4: {name: 'storage.type.property.tsx'},
5: {name: 'keyword.operator.new.tsx'},
6: {name: 'storage.type.tsx'},
7: {name: 'keyword.generator.asterisk.tsx'}
},
end: '(?=\\}|;|,)|(?<=\\})',
name: 'meta.method.declaration.tsx',
patterns: [
{include: '#method-declaration-name'},
{include: '#comment'},
{include: '#type-parameters'},
{include: '#function-parameters'},
{include: '#return-type'},
{include: '#method-overload-declaration'},
{include: '#decl-block'}
]
},
'method-declaration-name': {
begin:
'(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\\'[^\']*\\\')|(\\"[^"]*\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??)\\s*[\\(\\<])',
end: '(?=\\(|\\<)',
patterns: [
{include: '#string'},
{include: '#array-literal'},
{
match: '[_$[:alpha:]][_$[:alnum:]]*',
name: 'meta.definition.method.tsx entity.name.function.tsx'
},
{match: '\\?', name: 'keyword.operator.optional.tsx'}
]
},
'method-overload-declaration': {
begin:
'(?<!\\.|\\$)(?:\\b(public|private|protected)\\s+)?(?:\\b(abstract)\\s+)?(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)?(?:(?:\\b(?:(new)|(constructor))\\b(?!\\$|:))|(?:(\\*)\\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\\\'[^\']*\\\')|(\\"[^"]*\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))?\\s*[\\(\\<]))',
beginCaptures: {
1: {name: 'storage.modifier.tsx'},
2: {name: 'storage.modifier.tsx'},
3: {name: 'storage.modifier.async.tsx'},
4: {name: 'storage.type.property.tsx'},
5: {name: 'keyword.operator.new.tsx'},
6: {name: 'storage.type.tsx'},
7: {name: 'keyword.generator.asterisk.tsx'}
},
end: '(?=\\(|\\<)',
patterns: [{include: '#method-declaration-name'}]
},
'namespace-declaration': {
begin: '(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(namespace|module)\\s+',
beginCaptures: {
1: {name: 'keyword.control.export.tsx'},
2: {name: 'storage.type.namespace.tsx'}
},
end: '(?=$|\\{)',
name: 'meta.namespace.declaration.tsx',
patterns: [
{include: '#comment'},
{include: '#string'},
{
match: '([_$[:alpha:]][_$[:alnum:]]*)',
name: 'entity.name.type.module.tsx'
},
{match: '\\.', name: 'punctuation.accessor.tsx'}
]
},
'new-expr': {
begin: '(?<!\\.|\\$)\\b(new)\\b(?!\\$)',
beginCaptures: {1: {name: 'keyword.operator.new.tsx'}},
end: '(?<=\\))|(?=[;),]|$|((?<!\\.|\\$)\\bnew\\b(?!\\$)))',
name: 'new.expr.tsx',
patterns: [