{ "name": "Babel ES6 JavaScript", "scopeName": "source.js.jsx", "foldingStartMarker": "(/\\*|\\{|\\()", "foldingEndMarker": "(\\*/|\\}|\\))", "firstLineMatch": "^#!\\s*/.*\\b(node|js)$\\n?", "fileTypes": [ "js", "es6", "es", "babel", "jsx", "flow" ], "patterns": [ { "include": "#core" } ], "repository": { "core": { "patterns": [ { "include": "#ignore-long-lines" }, { "include": "#flowtype-keywords" }, { "include": "#literal-function-labels" }, { "include": "#literal-arrow-function-labels" }, { "include": "#literal-labels" }, { "include": "#literal-for" }, { "include": "#literal-switch" }, { "include": "#expression" }, { "include": "#literal-keywords" }, { "include": "#literal-punctuation" } ] }, "expression": { "patterns": [ { "include": "#ignore-long-lines" }, { "include": "#jsx" }, { "include": "#es7-decorators" }, { "include": "#support" }, { "include": "#literal-function-labels" }, { "include": "#literal-arrow-function-labels" }, { "include": "#literal-function" }, { "include": "#literal-arrow-function" }, { "include": "#literal-method-alternate" }, { "include": "#literal-prototype", "comment": "after literal-function, which includes some prototype strings" }, { "include": "#literal-regexp", "comment": "before operators to avoid abiguities" }, { "include": "#literal-number" }, { "include": "#literal-quasi" }, { "include": "#literal-string" }, { "include": "#literal-language-constant" }, { "include": "#literal-language-variable" }, { "include": "#literal-object", "comment": "before literal-module as it traps default {" }, { "include": "#literal-module" }, { "include": "#literal-class" }, { "include": "#literal-constructor" }, { "include": "#literal-method-call" }, { "include": "#literal-function-call" }, { "include": "#comments" }, { "include": "#brackets" }, { "include": "#literal-operators" }, { "include": "#literal-variable" }, { "include": "#literal-comma" }, { "include": "#miscellaneous" } ] }, "ignore-long-lines": { "comment": "so set at arbitary 1000 chars to avoid parsing minified files", "patterns": [ { "match": "^(?:).{1000,}" } ] }, "literal-function-labels": { "patterns": [ { "comment": "e.g. play: function(arg1, arg2) { }", "name": "meta.function.json.js", "begin": "(?<=^|{|,)\\s*+([_$a-zA-Z][$\\w]*)\\s*+(:)\\s*+(?:(async)\\s+)?\\s*+((?))\\s*+(:)\\s*+(async)?\\s*+((?(args) => { }", "name": "meta.function.json.arrow.js", "begin": "(?<=^|{|,)\\s*+(\\b[_$a-zA-Z][$\\w]*)\\s*+(:)\\s*+(\\basync\\b)?\\s*+(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*+(\\((?:(?>[^()]+)|\\g<-1>)*\\))\\s*+(?:\\s*:(\\s*+(&|\\|)?(\\s*+[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\g<-1>)*>)?|\\s*+(\\{(?:(?>[^{}]+)|\\g<-1>)*\\})|\\s*+(\\[(?:(?>[^\\[\\]]+)|\\g<-1>)*\\])|\\s*+(\\s*([\"']).*?\\k<-1>(?)", "end": "\\s*(=>)", "beginCaptures": { "1": { "name": "entity.name.function.js" }, "2": { "name": "punctuation.separator.key-value.js" }, "3": { "name": "storage.type.js" } }, "endCaptures": { "1": { "name": "storage.type.function.arrow.js" } }, "patterns": [ { "include": "#flowtype" } ] }, { "comment": "e.g. play: arg => { }", "name": "meta.function.json.arrow.js", "begin": "(?<=^|{|,)\\s*+(\\b[_$a-zA-Z][$\\w]*)\\s*+(:)\\s*+(\\basync\\b)?\\s*+(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*+([_$a-zA-Z][$\\w]*)\\s*+(?:\\s*:(\\s*+(&|\\|)?(\\s*+[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\g<-1>)*>)?|\\s*+(\\{(?:(?>[^{}]+)|\\g<-1>)*\\})|\\s*+(\\[(?:(?>[^\\[\\]]+)|\\g<-1>)*\\])|\\s*+(\\s*([\"']).*?\\k<-1>(?)", "end": "\\s*(=>)", "beginCaptures": { "1": { "name": "entity.name.function.js" }, "2": { "name": "punctuation.separator.key-value.js" }, "3": { "name": "storage.type.js" } }, "endCaptures": { "1": { "name": "storage.type.function.arrow.js" } }, "patterns": [ { "include": "#flowtype-polymorphs" }, { "include": "#flowtype-variable" } ] }, { "comment": "e.g. 'play': (args) => { }", "name": "meta.function.json.arrow.js", "begin": "(?<=^|{|,)\\s*+(('|\\\")([^\"']*)(\\k<-3>))\\s*(:)\\s*+(\\basync\\b)?\\s*+(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*+(\\((?:(?>[^()]+)|\\g<-1>)*\\))\\s*+(?:\\s*:(\\s*+(&|\\|)?(\\s*+[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\g<-1>)*>)?|\\s*+(\\{(?:(?>[^{}]+)|\\g<-1>)*\\})|\\s*+(\\[(?:(?>[^\\[\\]]+)|\\g<-1>)*\\])|\\s*+(\\s*([\"']).*?\\k<-1>(?)", "end": "\\s*(=>)", "applyEndPatternLast": 1, "endCaptures": { "1": { "name": "storage.type.function.arrow.js" } }, "beginCaptures": { "1": { "name": "string.quoted.js" }, "2": { "name": "punctuation.definition.string.begin.js" }, "3": { "name": "entity.name.function.js" }, "4": { "name": "punctuation.definition.string.end.js" }, "5": { "name": "punctuation.separator.key-value.js" }, "6": { "name": "storage.type.js" } }, "patterns": [ { "include": "#flowtype" } ] }, { "comment": "e.g. 'play': arg => { }", "name": "meta.function.json.arrow.js", "begin": "(?<=^|{|,)\\s*+(('|\\\")([^\"']*)(\\k<-3>))\\s*+(:)\\s*+(\\basync\\b)?\\s*+(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*+([_$a-zA-Z][$\\w]*)\\s*+(?:\\s*:(\\s*+(&|\\|)?(\\s*+[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\g<-1>)*>)?|\\s*+(\\{(?:(?>[^{}]+)|\\g<-1>)*\\})|\\s*+(\\[(?:(?>[^\\[\\]]+)|\\g<-1>)*\\])|\\s*+(\\s*([\"']).*?\\k<-1>(?)", "end": "\\s*(=>)", "beginCaptures": { "1": { "name": "string.quoted.js" }, "2": { "name": "punctuation.definition.string.begin.js" }, "3": { "name": "entity.name.function.js" }, "4": { "name": "punctuation.definition.string.end.js" }, "5": { "name": "punctuation.separator.key-value.js" }, "6": { "name": "storage.type.js" } }, "endCaptures": { "1": { "name": "storage.type.function.arrow.js" } }, "patterns": [ { "include": "#flowtype-polymorphs" }, { "include": "#flowtype-variable" } ] } ] }, "literal-labels": { "patterns": [ { "comment": "string as a property name", "match": "\\s*+(?|[^?:])*(:|\\?\\s*+:)))", "end": "\\s*\\)", "beginCaptures": { "2": { "name": "meta.brace.round.js" } }, "endCaptures": { "0": { "name": "meta.brace.round.js" } }, "patterns": [ { "include": "#flowtype-typecast" }, { "include": "#expression" } ] }, { "begin": "\\s*+\\(", "end": "\\s*\\)", "endCaptures": { "0": { "name": "meta.brace.round.js" } }, "beginCaptures": { "0": { "name": "meta.brace.round.js" } }, "patterns": [ { "include": "#expression" } ] } ] }, "square-brackets": { "patterns": [ { "begin": "\\s*+\\[", "end": "\\s*\\]", "endCaptures": { "0": { "name": "meta.brace.square.js" } }, "beginCaptures": { "0": { "name": "meta.brace.square.js" } }, "patterns": [ { "include": "#expression" } ] } ] }, "curly-brackets": { "patterns": [ { "begin": "\\s*+\\{", "end": "\\s*\\}", "endCaptures": { "0": { "name": "meta.brace.curly.js" } }, "beginCaptures": { "0": { "name": "meta.brace.curly.js" } }, "patterns": [ { "include": "$self" } ] } ] }, "jsdoc": { "patterns": [ { "comment": "common doc @ keywords", "match": "(?)", "captures": { "0": { "name": "punctuation.definition.comment.js" } } }, { "name": "comment.line.double-slash.js", "begin": "\\s*+(//)", "end": "\\s*$", "beginCaptures": { "1": { "name": "punctuation.definition.comment.js" } } }, { "name": "comment.line.shebang.js", "match": "^(#!).*$\\n?", "captures": { "1": { "name": "punctuation.definition.comment.js" } } } ] }, "special-comments-conditional-compilation": { "patterns": [ { "name": "comment.block.conditional.js", "begin": "\\s*+/\\*(?=@)", "end": "\\s*\\*/", "captures": { "0": { "name": "punctuation.definition.comment.js" } }, "endCaptures": { "1": { "name": "keyword.control.conditional.js" }, "2": { "name": "punctuation.definition.keyword.js" } }, "patterns": [ { "name": "punctuation.definition.comment.js", "match": "\\s*+/\\*" }, { "include": "$self" } ] }, { "name": "keyword.control.conditional.js", "match": "\\s*+(?!@)(@)(if|elif|else|end|ifdef|endif|cc_on|set)\\b", "captures": { "1": { "name": "punctuation.definition.keyword.js" } } }, { "name": "variable.other.conditional.js", "match": "\\s*+(?!@)(@)(_win32|_win16|_mac|_alpha|_x86|_mc680x0|_PowerPC|_jscript|_jscript_build|_jscript_version|_debug|_fast|[a-zA-Z]\\w+)", "captures": { "1": { "name": "punctuation.definition.variable.js" } } } ] }, "literal-punctuation": { "patterns": [ { "include": "#literal-semi-colon" }, { "include": "#literal-comma" } ] }, "literal-semi-colon": { "patterns": [ { "name": "punctuation.terminator.statement.js", "match": "\\s*+\\;" } ] }, "literal-comma": { "patterns": [ { "name": "meta.delimiter.comma.js", "match": "\\s*+," } ] }, "literal-keyword-storage": { "patterns": [ { "begin": "\\s*+(?(arg1, arg2) { }", "name": "meta.function.js", "begin": "\\s*+(?:\\b(async)\\b\\s+)?\\s*+(?:(?<=\\.\\.\\.)|(?)))" }, { "name": "keyword.operator.assignment.augmented.js", "match": "\\s*+(%=|&=|\\*=|\\+=|-=|/=|\\^=|\\|=|<<=|>>=|>>>=)" }, { "name": "keyword.operator.bitwise.js", "match": "\\s*+(~|<<|>>>|>>|&|\\^|\\|)" }, { "name": "keyword.operator.relational.js", "match": "\\s*+(<=|>=|<|>)" }, { "name": "keyword.operator.comparison.js", "match": "\\s*+(===|!==|==|!=)" }, { "name": "keyword.operator.arithmetic.js", "match": "\\s*+(--|\\+\\+|/(?!/|\\*)|%|\\*(?[^\\[\\]]+)|\\g<-1>)*\\])\\s*+\\(\\s*+\\))", "end": "(?=.)", "applyEndPatternLast": 1, "beginCaptures": { "2": { "name": "keyword.operator.js" } }, "patterns": [ { "include": "#square-brackets" }, { "include": "#round-brackets" } ] }, { "name": "meta.function-call.with-arguments.js", "begin": "\\s*+((\\bnew\\b)*)\\s*+([_$a-zA-Z][$\\w]*)\\s*+(?=\\()", "end": "(?=.)", "applyEndPatternLast": 1, "beginCaptures": { "2": { "name": "keyword.operator.js" }, "3": { "name": "entity.name.function.js" } }, "patterns": [ { "include": "#round-brackets" } ] }, { "name": "meta.function-call.without-arguments.js", "begin": "\\s*+((\\bnew\\b)*)\\s*+(?=(\\[(?:(?>[^\\[\\]]+)|\\g<-1>)*\\])\\s*+\\()", "end": "(?=.)", "applyEndPatternLast": 1, "beginCaptures": { "2": { "name": "keyword.operator.js" } }, "patterns": [ { "include": "#square-brackets" }, { "include": "#round-brackets" } ] } ] }, "literal-language-constant": { "patterns": [ { "name": "constant.language.boolean.true.js", "match": "\\s*+(?])", "end": "(^\\s*+(?=([$\\w]*\\s*+\\??\\s*+(:|=(?!^==|=>))|\\[|[$\\w]\\s*+\\(|\\bstatic\\b|\\s*++)))|\\s*(;)", "endCaptures": { "4": { "name": "punctuation.terminator.statement.js" } }, "patterns": [ { "include": "#expression" } ] }, { "match": "\\s*+\\b(? { }", "name": "meta.function.arrow.js", "begin": "\\s*+(\\basync\\b)?\\s*+(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*+(\\((?:(?>[^()]+)|\\g<-1>)*\\))\\s*+(?:\\s*:(\\s*+(&|\\|)?(\\s*+[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\g<-1>)*>)?|\\s*+(\\{(?:(?>[^{}]+)|\\g<-1>)*\\})|\\s*+(\\[(?:(?>[^\\[\\]]+)|\\g<-1>)*\\])|\\s*+(\\s*([\"']).*?\\k<-1>(?)", "end": "\\s*(=>)", "applyEndPatternLast": 1, "endCaptures": { "1": { "name": "storage.type.function.arrow.js" } }, "beginCaptures": { "1": { "name": "storage.type.js" } }, "patterns": [ { "include": "#flowtype" } ] }, { "comment": "e.g. arg => { }", "name": "meta.function.arrow.js", "match": "\\s*+(\\basync\\b)?\\s*+([_$a-zA-Z][$\\w]*)\\s*(=>)", "captures": { "1": { "name": "storage.type.js" }, "2": { "name": "variable.other.readwrite.js" }, "3": { "name": "storage.type.function.arrow.js" } } }, { "comment": "e.g. play = (args) => { }", "name": "meta.function.arrow.js", "begin": "\\s*+(\\b[_$a-zA-Z][$\\w]*)\\s*+(=)\\s*+(\\basync\\b)?\\s*+(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*+(\\((?:(?>[^()]+)|\\g<-1>)*\\))\\s*+(?:\\s*:(\\s*+(&|\\|)?(\\s*+[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\g<-1>)*>)?|\\s*+(\\{(?:(?>[^{}]+)|\\g<-1>)*\\})|\\s*+(\\[(?:(?>[^\\[\\]]+)|\\g<-1>)*\\])|\\s*+(\\s*([\"']).*?\\k<-1>(?)", "end": "\\s*(=>)", "applyEndPatternLast": 1, "beginCaptures": { "1": { "name": "entity.name.function.js" }, "2": { "name": "keyword.operator.assignment.js" }, "3": { "name": "storage.type.js" } }, "endCaptures": { "1": { "name": "storage.type.function.arrow.js" } }, "patterns": [ { "include": "#flowtype" } ] }, { "comment": "e.g. play = arg => { }", "name": "meta.function.arrow.js", "match": "\\s*+(\\b[_$a-zA-Z][$\\w]*)\\s*+(=)\\s*+\\s*+(\\basync\\b)?\\s*+([_$a-zA-Z][$\\w]*)\\s*(=>)", "captures": { "1": { "name": "entity.name.function.js" }, "2": { "name": "keyword.operator.assignment.js" }, "3": { "name": "storage.type.js" }, "4": { "name": "variable.other.readwrite.js" }, "5": { "name": "storage.type.function.arrow.js" } } }, { "comment": "Sound.prototype.play = (args) => { }", "name": "meta.prototype.function.arrow.js", "begin": "\\s*+(\\b[A-Z][$\\w]*)?(\\.)(prototype)(\\.)([_$a-zA-Z][$\\w]*)\\s*+(=)\\s*+(\\basync\\b)?\\s*+(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*+(\\((?:(?>[^()]+)|\\g<-1>)*\\))\\s*+(?:\\s*:(\\s*+(&|\\|)?(\\s*+[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\g<-1>)*>)?|\\s*+(\\{(?:(?>[^{}]+)|\\g<-1>)*\\})|\\s*+(\\[(?:(?>[^\\[\\]]+)|\\g<-1>)*\\])|\\s*+(\\s*([\"']).*?\\k<-1>(?)", "end": "\\s*(=>)", "applyEndPatternLast": 1, "beginCaptures": { "1": { "name": "entity.name.class.js" }, "2": { "name": "keyword.operator.accessor.js" }, "3": { "name": "variable.language.prototype.js" }, "4": { "name": "keyword.operator.accessor.js" }, "5": { "name": "entity.name.function.js" }, "6": { "name": "keyword.operator.assignment.js" }, "7": { "name": "storage.type.js" } }, "endCaptures": { "1": { "name": "storage.type.function.arrow.js" } }, "patterns": [ { "include": "#flowtype" } ] }, { "comment": "e.g. Sound.prototype.play = arg => { }", "name": "meta.prototype.function.arrow.js", "match": "\\s*+(\\b_?[A-Z][$\\w]*)?(\\.)(prototype)(\\.)([_$a-zA-Z][$\\w]*)\\s*+(=)\\s*+(\\basync\\b)?\\s*+([_$a-zA-Z][$\\w]*)\\s*(=>)", "captures": { "1": { "name": "entity.name.class.js" }, "2": { "name": "keyword.operator.accessor.js" }, "3": { "name": "variable.language.prototype.js" }, "4": { "name": "keyword.operator.accessor.js" }, "5": { "name": "entity.name.function.js" }, "6": { "name": "keyword.operator.assignment.js" }, "7": { "name": "storage.type.js" }, "8": { "name": "variable.other.readwrite.js" }, "9": { "name": "storage.type.function.arrow.js" } } }, { "comment": "e.g. Sound.play = (args) => { }", "name": "meta.function.static.arrow.js", "begin": "\\s*+(\\b_?[A-Z][$\\w]*)?(\\.)([_$a-zA-Z][$\\w]*)\\s*+(=)\\s*+(\\basync\\b)?\\s*+(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*+(\\((?:(?>[^()]+)|\\g<-1>)*\\))\\s*+(?:\\s*:(\\s*+(&|\\|)?(\\s*+[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\g<-1>)*>)?|\\s*+(\\{(?:(?>[^{}]+)|\\g<-1>)*\\})|\\s*+(\\[(?:(?>[^\\[\\]]+)|\\g<-1>)*\\])|\\s*+(\\s*([\"']).*?\\k<-1>(?)", "end": "\\s*(=>)", "applyEndPatternLast": 1, "beginCaptures": { "1": { "name": "entity.name.class.js" }, "2": { "name": "keyword.operator.accessor.js" }, "3": { "name": "entity.name.function.js" }, "4": { "name": "keyword.operator.assignment.js" }, "5": { "name": "storage.type.js" } }, "endCaptures": { "1": { "name": "storage.type.function.arrow.js" } }, "patterns": [ { "include": "#flowtype" } ] }, { "comment": "e.g. Sound.play = arg => { }", "name": "meta.function.static.arrow.js", "match": "\\s*+(\\b_?[A-Z][$\\w]*)?(\\.)([_$a-zA-Z][$\\w]*)\\s*+(=)\\s*+(\\basync\\b)?\\s*+([_$a-zA-Z][$\\w]*)\\s*(=>)", "captures": { "1": { "name": "entity.name.class.js" }, "2": { "name": "keyword.operator.accessor.js" }, "3": { "name": "entity.name.function.js" }, "4": { "name": "keyword.operator.assignment.js" }, "5": { "name": "storage.type.js" }, "6": { "name": "variable.other.readwrite.js" }, "7": { "name": "storage.type.function.arrow.js" } } } ] }, "literal-method-alternate": { "comment": "it assumes methods start on a new line/statement and have a open brace on the same line", "patterns": [ { "comment": "e.g. play(arg1, arg2): Type { }", "name": "meta.function.method.js", "begin": "(?:^|;)\\s*+(\\bstatic\\b)?\\s*+(\\basync\\b)?\\s*+(\\*?)\\s*+(?[^<>]+)|\\g<-1>)*>)?(\\((?:(?>[^()]+)|\\g<-1>)*\\))\\s*+(?:\\s*:(\\s*+(&|\\|)?(\\s*+[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\g<-1>)*>)?|\\s*+(\\{(?:(?>[^{}]+)|\\g<-1>)*\\})|\\s*+(\\[(?:(?>[^\\[\\]]+)|\\g<-1>)*\\])|\\s*+(\\s*([\"']).*?\\k<-1>(?(arg1, arg2): Type { }", "name": "meta.function.method.js", "begin": "(?[^<>]+)|\\g<-1>)*>)?(\\())", "end": "\\s*(?=.)", "applyEndPatternLast": 1, "beginCaptures": { "1": { "name": "storage.modifier.js" }, "2": { "name": "storage.type.js" }, "3": { "name": "keyword.generator.asterisk.js" }, "4": { "name": "entity.name.function.method.js" } }, "patterns": [ { "include": "#flowtype" } ] }, { "comment": "e.g. 'play'(arg1, arg2): Type { }", "name": "meta.function.method.js", "begin": "(?))\\s*+(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)?(\\())", "end": "\\s*(?=.)", "applyEndPatternLast": 1, "beginCaptures": { "1": { "name": "storage.modifier.js" }, "2": { "name": "storage.type.js" }, "3": { "name": "keyword.generator.asterisk.js" }, "4": { "name": "entity.name.function.method.js" } }, "patterns": [ { "include": "#flowtype" } ] }, { "comment": "e.g. [var](arg1, arg2): Type { } or 'var'(arg1, arg2)", "name": "meta.function.method.js", "begin": "(?[^\\[\\]]+)|\\g<-1>)*\\]))\\s*+(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*+(\\())", "end": "\\s*(?=.)", "applyEndPatternLast": 1, "beginCaptures": { "1": { "name": "storage.modifier.js" }, "2": { "name": "storage.type.js" }, "3": { "name": "keyword.generator.asterisk.js" }, "4": { "name": "entity.name.function.method.js" } }, "patterns": [ { "include": "#flowtype" }, { "include": "#square-brackets" } ] }, { "comment": "getter/setter", "name": "meta.accessor.js", "begin": "\\s*+\\b(?:(static)\\s+)?(get|set)\\s+([_$a-zA-Z][$\\w]*)\\s*+(?=\\()", "end": "\\s*(?={)", "applyEndPatternLast": 1, "beginCaptures": { "1": { "name": "storage.modifier.js" }, "2": { "name": "storage.type.accessor.js" }, "3": { "name": "entity.name.accessor.js" } }, "patterns": [ { "include": "#flowtype" } ] }, { "comment": "getter/setter set [var]() or get 'name'()", "name": "meta.accessor.js", "begin": "\\s*+\\b(?:(static)\\s+)?(get|set)\\s+(?=((\\[(?:(?>[^\\[\\]]+)|\\g<-1>)*\\])|\\s*+(((')((?:[^']|\\\\')*)('))|\\s*+((\")((?:[^\"]|\\\\\")*)(\"))))\\s*+(\\())", "end": "\\s*(?={)", "applyEndPatternLast": 1, "beginCaptures": { "1": { "name": "storage.modifier.js" }, "2": { "name": "storage.type.accessor.js" }, "3": { "name": "entity.name.accessor.js" } }, "patterns": [ { "include": "#flowtype-parse-array" }, { "include": "#literal-string" }, { "include": "#flowtype" } ] } ] }, "literal-regexp": { "patterns": [ { "name": "string.regexp.js", "begin": "(?<=\\.|\\(|,|{|}|\\[|;|,|<|>|<=|>=|==|!=|===|!==|\\+|-|\\*|%|\\+\\+|--|<<|>>|>>>|&|\\||\\^|!|~|&&|\\|\\||\\?|:|=|\\+=|-=|\\*=|%=|<<=|>>=|>>>=|&=|\\|=|\\^=|/|/=|\\Wnew|\\Wdelete|\\Wvoid|\\Wtypeof|\\Winstanceof|\\Win|\\Wdo|\\Wreturn|\\Wcase|\\Wthrow|^new|^delete|^void|^typeof|^instanceof|^in|^do|^return|^case|^throw|^)\\s*+(/)(?!/|\\*|$)", "end": "(/)([gimyu]*)", "beginCaptures": { "1": { "name": "punctuation.definition.string.begin.js" } }, "endCaptures": { "1": { "name": "punctuation.definition.string.end.js" }, "2": { "name": "keyword.other.js" } }, "patterns": [ { "include": "source.regexp.babel" } ] } ] }, "literal-string": { "patterns": [ { "contentName": "string.quoted.single.js", "begin": "\\s*+(('))", "end": "\\s*+(?:(('))|(\n))", "beginCaptures": { "1": { "name": "string.quoted.single.js" }, "2": { "name": "punctuation.definition.string.begin.js" } }, "endCaptures": { "1": { "name": "string.quoted.single.js" }, "2": { "name": "punctuation.definition.string.end.js" }, "3": { "name": "invalid.illegal.newline.js" } }, "patterns": [ { "include": "#string-content" } ] }, { "contentName": "string.quoted.double.js", "begin": "\\s*+((\"))", "end": "\\s*+(?:((\"))|(\n))", "beginCaptures": { "1": { "name": "string.quoted.double.js" }, "2": { "name": "punctuation.definition.string.begin.js" } }, "endCaptures": { "1": { "name": "string.quoted.double.js" }, "2": { "name": "punctuation.definition.string.end.js" }, "3": { "name": "invalid.illegal.newline.js" } }, "patterns": [ { "include": "#string-content" } ] } ] }, "literal-module": { "patterns": [ { "include": "#literal-module-import" }, { "include": "#literal-module-export" } ] }, "literal-module-import": { "begin": "\\s*+(?)))|(?=\\;|^\\s*\\b(if|switch|try|var|let|const|static|function|return|class|do|for|while|debugger|export|import|yield|type|declare|interface)\\b|\\)|}))", "beginCaptures": { "1": { "name": "keyword.control.module.js" } }, "endCaptures": { "1": { "name": "keyword.control.module.js" }, "3": { "name": "punctuation.definition.string.begin.js" }, "4": { "name": "string.quoted.module.js" }, "5": { "name": "punctuation.definition.string.begin.js" } }, "patterns": [ { "match": "\\s*\\b(default)\\b", "captures": { "1": { "name": "keyword.control.module.js" } } }, { "match": "\\s*\\b(typeof|type)\\b\\s++(?=\\{|[$_a-zA-Z])(?!\\b(instanceof|in|as)\\b|,)", "captures": { "1": { "name": "keyword.other.typedef.flowtype" } } }, { "name": "keyword.operator.module.all.js", "match": "\\*" }, { "include": "#literal-module-as" }, { "include": "#literal-module-brackets" }, { "include": "#literal-variable" }, { "include": "#comments" }, { "include": "#literal-comma" } ] }, "literal-module-export": { "patterns": [ { "comment": "e.g. export let variable =, export type a=", "match": "\\s*+(?)))|(?=\\;|^\\s*\\b(if|switch|try|var|let|const|static|function|return|class|do|for|while|debugger|export|import|yield|type|declare|interface)\\b|\\)|}))", "beginCaptures": { "1": { "name": "keyword.control.module.js" } }, "endCaptures": { "1": { "name": "keyword.control.module.js" }, "3": { "name": "punctuation.definition.string.begin.js" }, "4": { "name": "string.quoted.module.js" }, "5": { "name": "punctuation.definition.string.begin.js" } }, "patterns": [ { "name": "keyword.operator.module.all.js", "match": "\\*" }, { "include": "#literal-module-as" }, { "include": "#literal-module-brackets" }, { "include": "#literal-variable" }, { "include": "#comments" }, { "include": "#literal-comma" } ] }, { "comment": "trap expressions among - export function* () {}", "match": "\\s*+(?|\\Wreturn|^return|\\Wdefault|^)\\s*+(?=<[$_\\p{L}])", "end": "(?=.)", "applyEndPatternLast": 1, "patterns": [ { "include": "#jsx-tag-element-name" } ] } ] }, "jsx-tag-element-name": { "patterns": [ { "comment": "Tags that end > are trapped in #jsx-tag-termination", "name": "meta.tag.jsx", "begin": "\\s*+(<)((\\p{Ll}[\\p{Ll}0-9]*)|((?:[$_\\p{L}\\p{Nl}][$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}-]*?:)?+(?:[$_\\p{L}\\p{Nl}](?:[$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}\\.-](?\\s])(?![:])(?)|(/>)|((?<=", "beginCaptures": { "1": { "name": "punctuation.definition.tag.jsx" }, "2": { "name": "entity.name.tag.open.jsx" }, "4": { "name": "support.class.component.open.jsx" } }, "endCaptures": { "1": { "name": "entity.name.tag.close.jsx" }, "2": { "name": "support.class.component.close.jsx" }, "3": { "name": "punctuation.definition.tag.jsx" }, "4": { "name": "punctuation.definition.tag.jsx" }, "5": { "name": "invalid.illegal.termination.jsx" } }, "patterns": [ { "include": "#jsx-tag-termination" }, { "include": "#jsx-tag-attributes" } ] } ] }, "jsx-tag-termination": { "patterns": [ { "comment": "uses non consuming search for ", "begin": "(>)", "end": "(|/>)", "captures": { "0": { "name": "entity.other.attribute-name.jsx" } } } ] }, "jsx-assignment": { "patterns": [ { "comment": "look for attribute assignment", "name": "keyword.operator.assignment.jsx", "match": "=(?=\\s*(?:'|\"|{|/\\*|<|//|\\n))" } ] }, "jsx-string-double-quoted": { "name": "string.quoted.double.js", "begin": "\"", "end": "\"(?null = function() {return null}", "match": "(?[^()]+)|\\g<-1>)*\\))\\s*=>|\\(\\s*$))", "captures": { "1": { "name": "storage.type.function.js" }, "2": { "name": "keyword.operator.optional.parameter.flowtype" } } }, { "comment": "name of variable spread var with optional ? and optional flowtype :", "match": "\\s*+((?)", "captures": { "1": { "name": "keyword.operator.spread.js" }, "2": { "name": "variable.other.readwrite.js" }, "3": { "name": "keyword.operator.optional.parameter.flowtype" } } }, { "include": "#flowtype-vars-and-props" } ] }, "flowtype-vars-and-props": { "patterns": [ { "comment": "flowtype optional arg/parameter e.g. protocol? : string", "name": "punctuation.type.flowtype", "match": "\\s*+\\?" }, { "comment": "Type Unions |", "name": "kewyword.operator.union.flowtype", "match": "\\s*+\\|" }, { "comment": "intersection of types &", "name": "kewyword.operator.intersection.flowtype", "match": "\\s*+\\&" }, { "comment": "typed entity :", "begin": "\\s*+(:)", "end": "(?=.)", "applyEndPatternLast": 1, "beginCaptures": { "1": { "name": "punctuation.type.flowtype" } }, "patterns": [ { "include": "#flowtype-parse-types" } ] }, { "include": "#literal-comma" }, { "comment": "An Iterator prefix?", "match": "\\s*+@@" }, { "begin": "\\s*+(=>)", "end": "(?=.)", "applyEndPatternLast": 1, "beginCaptures": { "1": { "name": "storage.type.function.arrow.js" } }, "patterns": [ { "include": "#flowtype-parse-types" } ] }, { "comment": "assignment var = or = ", "begin": "\\s*+(?=([$_\\p{L}](?:[$.\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}])*+)?\\s*=)(?!=>|==)", "end": "\\s*(?=,|;|\\)|}|\\]|\\b(if|switch|try|var|let|const|static|function|return|class|do|for|while|debugger|export|import|yield)\\b|type\\s+[$\\w]+|declare\\s+[$\\w]+|interface\\s+[$\\w]+)", "patterns": [ { "include": "#expression" } ] }, { "include": "#flowtype-bracketed-parameters" }, { "include": "#flowtype-parse-array" }, { "include": "#expression" } ] }, "flowtype-parse-types": { "patterns": [ { "comment": "Maybe types", "name": "keyword.operator.maybe.flowtype", "match": "\\s*+\\?" }, { "name": "keyword.operator.flowtype", "match": "\\s*+\\btypeof\\b\\s*+" }, { "comment": "primitive flowtypes", "match": "(?!^)\\s*+\\b((?>any|boolean|mixed|number|string|void))\\b", "captures": { "1": { "name": "support.type.builtin.primitive.flowtype" } } }, { "comment": "Built-in Class Types", "match": "(?!^)\\s*+\\b((?>ArrayBuffer|ArrayBufferView|Boolean|Date|DataView|Error|EvalError|Float32Array|Float64Array|Function|Int8Array|Int16Array|Int32Array|JSON|Math|Number|Object|RangeError|ReferenceError|RegExp|String|Symbol|TypeError|Uint8Array|Uint16Array|Uint32Array|Uint8ClampedArray))\\b", "captures": { "1": { "name": "support.type.builtin.class.flowtype" } } }, { "include": "#flowtype-polymorphs" }, { "comment": "custom Class Types e.g. Abc avoid Abc(", "match": "(?!^)\\s*+([$_[\\p{Lu}\\p{Lt}\\p{Lm}\\p{Lo}]][$.\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}]*+)(?!\\s*+\\()", "captures": { "1": { "name": "support.type.class.flowtype" } } }, { "comment": "custom primitive/var Types e.g. abc avoid abc(", "match": "(?!^)\\s*+(?!\\b(if|switch|try|var|let|const|static|function|return|class|do|for|while|debugger|export|import|yield|type|declare|interface)\\b)([$_\\p{L}][$.\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}]*+)(?!\\s*+\\()", "captures": { "2": { "name": "support.type.primitive.flowtype" } } }, { "comment": "Type Unions |", "name": "kewyword.operator.union.flowtype", "match": "\\s*+\\|" }, { "comment": "intersection of types &", "name": "kewyword.operator.intersection.flowtype", "match": "\\s*+\\&" }, { "comment": "as per React declares in flowtype github", "name": "kewyword.operator.existential.flowtype", "match": "\\s*+\\*" }, { "comment": "types of type marker e.g. ", "name": "punctuation.type.flowtype", "match": "\\s*+(:)" }, { "comment": "call back with a form ) => type", "match": "(?<=\\))\\s*+(=>)", "captures": { "1": { "name": "storage.type.function.arrow.js" } } }, { "include": "#literal-string" }, { "include": "#literal-number" }, { "include": "#flowtype-bracketed-parameters" }, { "include": "#flowtype-parse-objects" }, { "include": "#flowtype-parse-array" }, { "include": "#comments" } ] }, "flowtype-bracketed-parameters": { "patterns": [ { "comment": "Get parameters within a function/method call", "begin": "(?", "begin": "\\s*+\\b((?>Array|Class|Map|Promise|Set|WeakMap|WeakSet))\\s*+(<)", "end": "\\s*(>)", "beginCaptures": { "1": { "name": "support.type.builtin.class.flowtype" }, "2": { "name": "punctuation.flowtype" } }, "endCaptures": { "1": { "name": "punctuation.flowtype" } }, "patterns": [ { "include": "#literal-comma" }, { "match": "\\s*+(\\+|-)", "captures": { "1": { "name": "support.type.variant.flowtype" } } }, { "include": "#flowtype-parse-types" } ] }, { "comment": "just the polymorph bit like this (arg,arg)", "begin": "\\s*+(<)(?!<)", "end": "\\s*(>)", "beginCaptures": { "1": { "name": "punctutation.flowtype" } }, "endCaptures": { "1": { "name": "punctutation.flowtype" } }, "patterns": [ { "include": "#literal-comma" }, { "match": "\\s*+(\\+|-)", "captures": { "1": { "name": "support.type.variant.flowtype" } } }, { "include": "#flowtype-parse-types" } ] } ] }, "flowtype-parse-objects": { "comment": "object literal flowtype preceded by either => : | & ? symbols", "begin": "(?<=:|\\||&|\\?|=>|<)\\s*+(\\{)", "end": "\\s*(\\})", "applyEndPatternLast": 1, "beginCaptures": { "1": { "name": "meta.brace.round.open.flowtype" } }, "endCaptures": { "1": { "name": "meta.brace.round.close.flowtype" } }, "patterns": [ { "include": "#flowtype-object-property" } ] }, "flowtype-object-property": { "patterns": [ { "comment": "name of property which can be a string", "match": "\\s*+(((\"|').*?(?<=[^\\\\])\\k<-1>)|([$_\\p{L}](?:[$.\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}])*+))\\s*+(\\??)\\s*+(?=:)", "captures": { "1": { "name": "variable.other.property.flowtype" }, "5": { "name": "keyword.operator.optional.parameter.flowtype" } } }, { "include": "#flowtype-vars-and-props" } ] }, "flowtype-parse-array": { "comment": "arrays such as [name: string, dob: Date]", "begin": "(?(): Map", "begin": "(?[^<>]+)|\\g<-1>)*>)?(\\())", "end": "\\s*(?=.)", "applyEndPatternLast": 1, "beginCaptures": { "1": { "name": "storage.modifier.js" }, "2": { "name": "storage.type.js" }, "3": { "name": "keyword.generator.asterisk.js" } }, "patterns": [ { "include": "#flowtype" } ] }, "flowtype-keywords": { "patterns": [ { "include": "#flowtype-declare" }, { "include": "#flowtype-type-aliases" }, { "include": "#flowtype-interface" } ] }, "flowtype-typecast": { "patterns": [ { "begin": "\\s*+:", "end": "(?=\\s*+\\))", "patterns": [ { "include": "#flowtype-parse-types" } ] } ] }, "miscellaneous": { "comment": "trap miscellaneous stuff", "patterns": [ { "comment": "match arrow func symbol when it appears by itself", "match": "\\s*(=>)", "captures": { "1": { "name": "storage.type.function.arrow.js" } } } ] } } }