{ "name": "Babel ES6 JavaScript", "scopeName": "source.js.jsx", "foldingStartMarker": "(/\\*|\\{|\\()", "foldingEndMarker": "(\\*/|\\}|\\))", "firstLineMatch": "^#!\\s*/.*\\b(node|js)$\\n?", "fileTypes": [ "js", "es6", "babel", "jsx", "flow" ], "patterns": [ { "include": "#core" } ], "repository": { "core": { "patterns": [ { "include": "#ignore-long-lines" }, { "include": "#flowtype-declare" }, { "include": "#flowtype-type-aliases" }, { "include": "#flowtype-interface" }, { "include": "#literal-function-labels" }, { "include": "#literal-arrow-function-labels" }, { "include": "#literal-labels" }, { "include": "#literal-keywords" }, { "include": "#literal-for" }, { "include": "#literal-switch" }, { "include": "#expression" }, { "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-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-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" } ] }, "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*(\\bfunction\\b)\\s*(?:(\\*)\\s*)?\\s*(?=\\(|<)", "end": "(?=\\{)", "applyEndPatternLast": 1, "beginCaptures": { "1": { "name": "entity.name.function.js" }, "2": { "name": "punctuation.separator.key-value.js" }, "3": { "name": "storage.type.js" }, "4": { "name": "storage.type.function.js" }, "5": { "name": "keyword.generator.asterisk.js" } }, "patterns": [ { "include": "#flowtype" } ] }, { "comment": "e.g. 'play': function(arg1, arg2) { }", "name": "meta.function.json.js", "begin": "\\s*(('|\\\")(\\b[_$a-zA-Z][$\\w]*)(\\k<2>))\\s*(:)\\s*(async)?\\s+(\\bfunction\\b)\\s*(\\*\\s*)?\\s*(?=\\(|<)", "end": "(?=\\{)", "applyEndPatternLast": 1, "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" }, "7": { "name": "storage.type.function.js" }, "8": { "name": "keyword.generator.asterisk.js" } }, "patterns": [ { "include": "#flowtype" } ] } ] }, "literal-arrow-function-labels": { "patterns": [ { "comment": "e.g. play: async (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*[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\g<-1>)*>)?|\\s*(\\{(?:(?>[^{}]+)|\\g<-1>)*\\})|\\s*(\\s*([\"']).*?\\k<-1>(?)", "end": "\\s*(=>)", "applyEndPatternLast": 1, "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*[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\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*(('|\\\")(\\b[_$a-zA-Z][$\\w]*)(\\k<2>))\\s*(:)\\s*(\\basync\\b)?\\s*(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*(\\((?:(?>[^()]+)|\\g<-1>)*\\))\\s*(?:\\s*(:|\\|)(\\s*[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\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*(('|\\\")(\\b[_$a-zA-Z][$\\w]*)(\\k<2>))\\s*(:)\\s*(\\basync\\b)?\\s*(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*([_$a-zA-Z][$\\w]*)\\s*(?:\\s*(:|\\|)(\\s*[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\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" } ] }, { "name": "meta.group.braces.round", "begin": "\\s*\\(", "end": "\\s*\\)", "endCaptures": { "0": { "name": "meta.brace.round.js" } }, "beginCaptures": { "0": { "name": "meta.brace.round.js" } }, "patterns": [ { "include": "#expression" } ] } ] }, "square-brackets": { "patterns": [ { "name": "meta.group.braces.square", "begin": "\\s*\\[", "end": "\\s*\\]", "endCaptures": { "0": { "name": "meta.brace.square.js" } }, "beginCaptures": { "0": { "name": "meta.brace.square.js" } }, "patterns": [ { "include": "#expression" } ] } ] }, "curly-brackets": { "patterns": [ { "name": "meta.group.braces.curly", "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": [ { "comment": "these statements must end in a ;", "begin": "\\s*(?[^{}]+)|\\g<-1>)*\\})\\s*:)", "end": "\\s*\\;", "beginCaptures": { "1": { "name": "storage.type.js" } }, "endCaptures": { "0": { "name": "punctuation.terminator.statement.js" } }, "patterns": [ { "include": "#flowtype-destruct-lhs" } ] }, { "comment": "these statements must end in a ;", "begin": "\\s*(?[^\\[\\]]+)|\\g<-1>)*\\])\\s*:)", "end": "\\s*\\;", "beginCaptures": { "1": { "name": "storage.type.js" } }, "endCaptures": { "0": { "name": "punctuation.terminator.statement.js" } }, "patterns": [ { "include": "#flowtype-destruct-lhs" } ] }, { "comment": "var statements that done start with a flow indicator", "name": "storage.type.js", "match": "\\s*(?(arg1, arg2) { }", "name": "meta.function.js", "begin": "\\s*(?:\\b(async)\\b\\s+)?\\s*(\\bfunction\\b)\\s*(\\*?)\\s*([_$a-zA-Z][$\\w]*)?\\s*(?=\\(|<)", "end": "(?=\\s*\\{)", "applyEndPatternLast": 1, "beginCaptures": { "1": { "name": "storage.type.js" }, "2": { "name": "storage.type.function.js" }, "3": { "name": "keyword.generator.asterisk.js" }, "4": { "name": "entity.name.function.js" } }, "patterns": [ { "include": "#flowtype" } ] }, { "comment": "e.g. play = function(arg1, arg2) { }", "name": "meta.function.js", "begin": "\\s*(\\b[_$a-zA-Z][$\\w]*)\\s*(=)\\s*(?:(async)\\s+)?\\s*(\\bfunction\\b)\\s*(\\*?)\\s*([_$a-zA-Z][$\\w]*)?\\s*(?=\\(|<)", "end": "(?=\\s*\\{)", "applyEndPatternLast": 1, "beginCaptures": { "1": { "name": "entity.name.function.js" }, "2": { "name": "keyword.operator.assignment.js" }, "3": { "name": "storage.type.js" }, "4": { "name": "storage.type.function.js" }, "5": { "name": "keyword.generator.asterisk.js" }, "6": { "name": "entity.name.function.js" } }, "patterns": [ { "include": "#flowtype" } ] }, { "comment": "e.g. Sound.prototype.play = function(arg1, arg2) { }", "name": "meta.prototype.function.js", "begin": "\\s*(\\b_?[A-Z][$\\w]*)?(\\.)(prototype)(\\.)([_$a-zA-Z][$\\w]*)\\s*(=)\\s*(?:(async)\\s+)?\\s*(\\bfunction\\b)\\s*(\\*?)\\s*([_$a-zA-Z][$\\w]*)?\\s*(?=\\(|<)", "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" }, "8": { "name": "storage.type.function.js" }, "9": { "name": "keyword.generator.asterisk.js" }, "10": { "name": "entity.name.function.js" } }, "patterns": [ { "include": "#flowtype" } ] }, { "comment": "e.g. Sound.play = function(arg1, arg2) { }", "name": "meta.function.static.js", "begin": "\\s*(\\b_?[A-Z][$\\w]*)?(\\.)([_$a-zA-Z][$\\w]*)\\s*(=)\\s*(?:(async)\\s+)?\\s*(\\bfunction\\b)\\s*(\\*?)\\s*([_$a-zA-Z][$\\w]*)?\\s*(?=\\(|<)", "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" }, "6": { "name": "storage.type.function.js" }, "7": { "name": "keyword.generator.asterisk.js" }, "8": { "name": "entity.name.function.js" } }, "patterns": [ { "include": "#flowtype" } ] } ] }, "literal-quasi": { "patterns": [ { "name": "string.quasi.js", "begin": "\\s*([a-zA-Z$_][\\w$_]*)?(`)", "end": "\\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, "patterns": [ { "include": "#flowtype-parse-array" }, { "include": "#flowtype-bracketed-parameters" } ] }, { "name": "meta.function-call.with-arguments.js", "begin": "\\s*([_$a-zA-Z][$\\w]*)\\s*(?=\\()", "end": "(?=.)", "applyEndPatternLast": 1, "beginCaptures": { "1": { "name": "entity.name.function.js" } }, "patterns": [ { "include": "#flowtype-bracketed-parameters" } ] }, { "name": "meta.function-call.without-arguments.js", "begin": "\\s*(?=(\\[(?:(?>[^\\[\\]]+)|\\g<-1>)*\\])\\s*\\()", "end": "(?=.)", "applyEndPatternLast": 1, "patterns": [ { "include": "#flowtype-parse-array" }, { "include": "#flowtype-bracketed-parameters" } ] } ] }, "literal-language-constant": { "patterns": [ { "name": "constant.language.boolean.true.js", "match": "\\s*(? { }", "name": "meta.function.arrow.js", "begin": "\\s*(\\basync\\b)?\\s*(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*(\\((?:(?>[^()]+)|\\g<-1>)*\\))\\s*(?:\\s*(:|\\|)(\\s*[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\g<-1>)*>)?|\\s*(\\{(?:(?>[^{}]+)|\\g<-1>)*\\})|\\s*(((')((?:[^']|\\\\')*)('))|\\s*((\")((?:[^\"]|\\\\\")*)(\")))|\\s*[x0-9A-Fa-f]+))*\\s*=>)", "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", "begin": "\\s*(\\basync\\b)?\\s*(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*([_$a-zA-Z][$\\w]*)\\s*(?:\\s*(:|\\|)(\\s*[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\g<-1>)*>)?|\\s*(\\{(?:(?>[^{}]+)|\\g<-1>)*\\})|\\s*(((')((?:[^']|\\\\')*)('))|\\s*((\")((?:[^\"]|\\\\\")*)(\")))|\\s*[x0-9A-Fa-f]+))*\\s*=>)", "end": "\\s*(=>)", "beginCaptures": { "1": { "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.arrow.js", "begin": "\\s*(\\b[_$a-zA-Z][$\\w]*)\\s*(=)\\s*(\\basync\\b)?\\s*(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*(\\((?:(?>[^()]+)|\\g<-1>)*\\))\\s*(?:\\s*(:|\\|)(\\s*[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\g<-1>)*>)?|\\s*(\\{(?:(?>[^{}]+)|\\g<-1>)*\\})|\\s*(((')((?:[^']|\\\\')*)('))|\\s*((\")((?:[^\"]|\\\\\")*)(\")))|\\s*[x0-9A-Fa-f]+))*\\s*=>)", "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", "begin": "\\s*(\\b[_$a-zA-Z][$\\w]*)\\s*(=)\\s*(\\basync\\b)?\\s*(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*([_$a-zA-Z][$\\w]*)\\s*(?:\\s*(:|\\|)(\\s*[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\g<-1>)*>)?|\\s*(\\{(?:(?>[^{}]+)|\\g<-1>)*\\})|\\s*(((')((?:[^']|\\\\')*)('))|\\s*((\")((?:[^\"]|\\\\\")*)(\")))|\\s*[x0-9A-Fa-f]+))*\\s*=>)", "end": "\\s*(=>)", "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-polymorphs" }, { "include": "#flowtype-variable" } ] }, { "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*[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\g<-1>)*>)?|\\s*(\\{(?:(?>[^{}]+)|\\g<-1>)*\\})|\\s*(((')((?:[^']|\\\\')*)('))|\\s*((\")((?:[^\"]|\\\\\")*)(\")))|\\s*[x0-9A-Fa-f]+))*\\s*=>)", "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", "begin": "\\s*(\\b_?[A-Z][$\\w]*)?(\\.)(prototype)(\\.)([_$a-zA-Z][$\\w]*)\\s*(=)\\s*(\\basync\\b)?\\s*(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*([_$a-zA-Z][$\\w]*)\\s*(?:\\s*(:|\\|)(\\s*[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\g<-1>)*>)?|\\s*(\\{(?:(?>[^{}]+)|\\g<-1>)*\\})|\\s*(((')((?:[^']|\\\\')*)('))|\\s*((\")((?:[^\"]|\\\\\")*)(\")))|\\s*[x0-9A-Fa-f]+))*\\s*=>)", "end": "\\s*(=>)", "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-polymorphs" }, { "include": "#flowtype-variable" } ] }, { "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*[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\g<-1>)*>)?|\\s*(\\{(?:(?>[^{}]+)|\\g<-1>)*\\})|\\s*(((')((?:[^']|\\\\')*)('))|\\s*((\")((?:[^\"]|\\\\\")*)(\")))|\\s*[x0-9A-Fa-f]+))*\\s*=>)", "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", "begin": "\\s*(\\b_?[A-Z][$\\w]*)?(\\.)([_$a-zA-Z][$\\w]*)\\s*(=)\\s*(\\basync\\b)?\\s*(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*([_$a-zA-Z][$\\w]*)\\s*(?:\\s*(:|\\|)(\\s*[$_a-zA-Z0-9]+(<(?:(?>[^<>]+)|\\g<-1>)*>)?|\\s*(\\{(?:(?>[^{}]+)|\\g<-1>)*\\})|\\s*(((')((?:[^']|\\\\')*)('))|\\s*((\")((?:[^\"]|\\\\\")*)(\")))|\\s*[x0-9A-Fa-f]+))*\\s*=>)", "end": "\\s*(=>)", "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-polymorphs" }, { "include": "#flowtype-variable" } ] } ] }, "literal-method": { "patterns": [ { "comment": "e.g. play(arg1, arg2): Type { }", "name": "meta.function.method.js", "begin": "\\s*(\\bstatic\\b)?\\s*(\\basync\\b)?\\s*(\\*?)\\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": "\\s*(\\bstatic\\b)?\\s*(\\basync\\b)?\\s*(\\*?)\\s*(?=((\\[(?:(?>[^\\[\\]]+)|\\g<-1>)*\\])|\\s*(((')((?:[^']|\\\\')*)('))|\\s*((\")((?:[^\"]|\\\\\")*)(\"))))\\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" }, "6": { "name": "entity.name.function.method.js" } }, "patterns": [ { "include": "#flowtype-parse-array" }, { "include": "#literal-string" }, { "include": "#flowtype" } ] }, { "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.static.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.static.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": "(/)([gimy]*)", "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": "(('))|(\\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": "((\"))|(\\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": [ { "name": "keyword.control.module.js", "match": "\\s*(?|\\Wreturn|^return|^)\\s*(?=<[_$a-zA-Z])", "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{L}](?:[$.:\\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" } }, "endCaptures": { "1": { "name": "entity.name.tag.close.jsx" }, "2": { "name": "punctuation.definition.tag.jsx" }, "3": { "name": "punctuation.definition.tag.jsx" }, "4": { "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": "\"(?)", "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-destruct-lhs": { "comment": "use this pattern to colour code the variable part correctly", "patterns": [ { "begin": "\\s*{", "end": "\\s*}", "patterns": [ { "include": "#flowtype-destruct-lhs" } ] }, { "begin": "\\s*\\[", "end": "\\s*\\]", "patterns": [ { "include": "#flowtype-destruct-lhs" } ] }, { "comment": "string as destructor target", "match": "\\s*((['\\\"]).*?\\k<-1>(?)", "captures": { "1": { "name": "storage.type.function.arrow.js" } } }, { "include": "#flowtype-bracketed-parameters" }, { "include": "#flowtype-parse-array" }, { "include": "#expression" } ] }, "flowtype-parse-operators": { "patterns": [ { "comment": "call back with a form ) => type", "begin": "(?<=\\))\\s*(=>)", "end": "(?=.)", "applyEndPatternLast": 1, "beginCaptures": { "1": { "name": "storage.type.function.arrow.js" } }, "patterns": [ { "include": "#flowtype-parse-types" } ] }, { "comment": "some form of default assignment for func args", "begin": "\\s*=(?!>|=|==)", "end": "\\s*(?=,|;|\\))", "beginCaptures": { "0": { "name": "keyword.operator.assignment.js" } }, "patterns": [ { "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*([$_\\p{L}][$.\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}]*+)(?!\\s*\\()", "captures": { "1": { "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*\\*" }, { "include": "#literal-string" }, { "include": "#literal-number" }, { "include": "#flowtype-bracketed-parameters" }, { "include": "#flowtype-parse-objects" }, { "include": "#flowtype-parse-operators" }, { "include": "#flowtype-parse-array" }, { "include": "#comments" } ] }, "flowtype-bracketed-parameters": { "patterns": [ { "comment": "Get parameters within a function/method call", "begin": "\\s*(\\()", "end": "\\s*(\\))", "beginCaptures": { "1": { "name": "punctuation.definition.parameters.begin.js" } }, "endCaptures": { "1": { "name": "punctuation.definition.parameters.end.js" } }, "patterns": [ { "include": "#flowtype-variable" } ] } ] }, "flowtype-polymorphs": { "comment": "Support Bounded Polymorphism http://flowtype.org/blog/2015/03/12/Bounded-Polymorphism.html", "patterns": [ { "comment": "Built-in Class Types with elements of type ", "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": [ { "match": "\\s*,", "name": "punctuation.type.separator.flowtype" }, { "match": "\\s*:", "name": "punctuation.type.separator.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": [ { "match": "\\s*,", "name": "punctuation.type.separator.flowtype" }, { "match": "\\s*:", "name": "punctuation.type.separator.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": "\\s*(\\[)", "end": "\\s*(\\])", "beginCaptures": { "1": { "name": "meta.brace.square.open.flowtype" } }, "endCaptures": { "1": { "name": "meta.brace.square.end.flowtype" } }, "patterns": [ { "include": "#flowtype-variable" } ] }, "flowtype-type-aliases": { "patterns": [ { "comment": "import for types", "match": "\\s*(?