├── .gitignore ├── package.json ├── README.md └── grammars └── rtemplate.json /.gitignore: -------------------------------------------------------------------------------- 1 | research 2 | test.rtpl -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "language-rtemplate", 3 | "version": "0.2.0", 4 | "description": "用于atom的rtemplate高亮package。", 5 | "repository": { 6 | "type": "git", 7 | "url": "git+https://github.com/oyyd/language-rtemplate" 8 | }, 9 | "license": "MIT", 10 | "engines": { 11 | "atom": ">1.0.0" 12 | }, 13 | "dependencies": {} 14 | } 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # language-rtemplate 2 | 3 | 用于atom的rtemplate高亮package。当前版本可能包含各种各样的问题和没有涉及到的地方,请发issue或pr来帮助我们解决。 4 | 5 | ## 注意 6 | 7 | 1. 当前rtemplate同时支持: `{}`、`""`的声明方式,而在language-rtemplate中只支持高亮`{}`中的内容。其原因是rtemplate的语法规则在[TextMate的grammar规则](https://manual.macromates.com/en/language_grammars)中,表达式中表示字符串开头的`"`和作为rtemplate界定符结尾的`"`会以完全相同的规则捕获文本内容,导致无法区分这二者(同样的情况对于`{}`而言,表达式开头的`{`和界定符结尾的`}`由于符号不同可以区分)。只有通过js(或其他语言)才能区分这种情况,而TextMate grammar的json形式不能。因此`""`中的内容将保持默认字符串的高亮。 8 | 9 | 2. 代码以[language-babel](https://github.com/gandm/language-babel)为基础构建,详情见`grammars/rtemplate.json`文件中的`repository`部分,稍有修改。 10 | 11 | ## 安装 12 | 13 | ``` 14 | apm install language-rtemplate 15 | ``` 16 | 17 | ## 反馈 18 | 19 | 请发到issue上。 20 | -------------------------------------------------------------------------------- /grammars/rtemplate.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rtemplate", 3 | "scopeName": "text.html.basic.rtemplate", 4 | "foldingStartMarker": "(/\\*|\\{|\\()", 5 | "foldingEndMarker": "(\\*/|\\}|\\))", 6 | "fileTypes": [ 7 | "rtpl" 8 | ], 9 | "patterns": [ 10 | { "include": "#rtemplate-tag-declare" }, 11 | { "include": "#jsx-evaluated-code"}, 12 | { "include": "#jsx-tag-element-name" } 13 | ], 14 | "repository": { 15 | "rtemplate-tag-declare": { 16 | "begin": "(", 22 | "endCaptures": { 23 | "0": {"name": "punctuation.definition.tag.end.rtemplate"} 24 | }, 25 | "name": "meta.tag.block.any.rtemplate", 26 | "patterns": [ 27 | { 28 | "include": "#rtemplate-declare-attribute" 29 | }, 30 | { 31 | "include": "#rtemplate-tag-attributes" 32 | } 33 | ] 34 | }, 35 | "rtemplate-tag-attributes": { 36 | "patterns": [ 37 | { "include": "#jsx-attribute-name" }, 38 | { "include": "#jsx-assignment" }, 39 | { "include": "#jsx-string-double-quoted" }, 40 | { "include": "#jsx-string-single-quoted" }, 41 | { "include": "#jsx-evaluated-code" }, 42 | { "include": "#jsx-tag-element-name" }, 43 | { "include": "#comments" } 44 | ] 45 | }, 46 | "rtemplate-declare-attribute": { 47 | "patterns": [ 48 | { "include": "#rtemplate-declare-attribute-square"}, 49 | { "include": "#rtemplate-declare-attribute-double-quote"} 50 | ] 51 | }, 52 | "rtemplate-declare-attribute-square": { 53 | "begin": "(declare)\\s*=\\s*({)", 54 | "beginCaptures": { 55 | "1": {"name": "entity.other.attribute-name.rtemplate"}, 56 | "2": {"name": "punctuation.section.embedded.begin.rtemplate"} 57 | }, 58 | "end": "}", 59 | "endCaptures": { 60 | "0": {"name": "punctuation.section.embedded.end.rtemplate"} 61 | }, 62 | "patterns": [ 63 | {"include": "#rtemplate-declare-assignment"} 64 | ] 65 | }, 66 | "rtemplate-declare-attribute-double-quote": { 67 | "begin": "(declare)\\s*=\\s*(\")", 68 | "beginCaptures": { 69 | "1": {"name": "entity.other.attribute-name.rtemplate"}, 70 | "2": {"name": "punctuation.section.embedded.begin.rtemplate"} 71 | }, 72 | "end": "\"", 73 | "endCaptures": { 74 | "0": {"name": "punctuation.section.embedded.end.rtemplate"} 75 | }, 76 | "patterns": [ 77 | {"include": "#rtemplate-declare-assignment"} 78 | ] 79 | }, 80 | "rtemplate-declare-assignment": { 81 | "patterns": [ 82 | {"include": "#rtemplate-declare-as"}, 83 | {"include": "#rtemplate-declare-comma"}, 84 | {"include": "#rtemplate-declare-url"}, 85 | {"include": "source.js.jsx"} 86 | ] 87 | }, 88 | "rtemplate-declare-as": { 89 | "match": "\\s*([\\w]+)\\s+(as)\\b", 90 | "captures": { 91 | "1": {"name": "string.unquoted.rtemplate"}, 92 | "2": {"name": "keyword.assignment.rtemplate"} 93 | } 94 | }, 95 | "rtemplate-declare-comma": { 96 | "match": ",", 97 | "name": "meta.delimiter.comma.rtemplate" 98 | }, 99 | "core": { 100 | "patterns": [ 101 | { "include": "#ignore-long-lines" }, 102 | { "include": "#flowtype-declare" }, 103 | { "include": "#flowtype-type-aliases" }, 104 | { "include": "#flowtype-interface" }, 105 | { "include": "#literal-function-labels" }, 106 | { "include": "#literal-arrow-function-labels" }, 107 | { "include": "#literal-labels" }, 108 | { "include": "#literal-keywords" }, 109 | { "include": "#literal-for" }, 110 | { "include": "#literal-switch" }, 111 | { "include": "#expression" }, 112 | { "include": "#literal-punctuation" } 113 | ] 114 | }, 115 | "expression": { 116 | "patterns": [ 117 | { "include": "#ignore-long-lines" }, 118 | { "include": "#jsx" }, 119 | { "include": "#es7-decorators" }, 120 | { "include": "#support" }, 121 | { "include": "#literal-function-labels" }, 122 | { "include": "#literal-arrow-function-labels" }, 123 | { "include": "#literal-function" }, 124 | { "include": "#literal-arrow-function" }, 125 | { "include": "#literal-prototype", "comment": "after literal-function, which includes some prototype strings" }, 126 | { "include": "#literal-regexp", "comment": "before operators to avoid abiguities" }, 127 | { "include": "#literal-number" }, 128 | { "include": "#literal-quasi" }, 129 | { "include": "#literal-string" }, 130 | { "include": "#literal-language-constant" }, 131 | { "include": "#literal-language-variable" }, 132 | { "include": "#literal-module" }, 133 | { "include": "#literal-class" }, 134 | { "include": "#literal-constructor" }, 135 | { "include": "#literal-method-call" }, 136 | { "include": "#literal-function-call" }, 137 | { "include": "#comments" }, 138 | { "include": "#brackets" }, 139 | { "include": "#literal-operators" }, 140 | { "include": "#literal-variable" }, 141 | { "include": "#literal-comma" }, 142 | { "include": "#miscellaneous"} 143 | ] 144 | }, 145 | "ignore-long-lines": { 146 | "comment": "long lines shouldn't be parsed for performance reasons as regex's are per line", 147 | "comment": "so set at arbitary 1000 chars to avoid parsing minified files", 148 | "patterns": [ 149 | { 150 | "match": "^(?:).{1000,}" 151 | } 152 | ] 153 | }, 154 | "literal-function-labels": { 155 | "patterns": [ 156 | { 157 | "comment": "e.g. play: function(arg1, arg2) { }", 158 | "name": "meta.function.json.js", 159 | "begin": "\\s*+([_$a-zA-Z][$\\w]*)\\s*+(:)\\s*+(?:(async)\\s+)?\\s*+(\\bfunction\\b)\\s*+(?:(\\*)\\s*)?\\s*(?=\\(|<)", 160 | "end": "(?=\\{)", 161 | "applyEndPatternLast": 1, 162 | "beginCaptures": { 163 | "1": { "name": "entity.name.function.js" }, 164 | "2": { "name": "punctuation.separator.key-value.js" }, 165 | "3": { "name": "storage.type.js" }, 166 | "4": { "name": "storage.type.function.js" }, 167 | "5": { "name": "keyword.generator.asterisk.js" } 168 | }, 169 | "patterns": [ 170 | { "include": "#flowtype" } 171 | ] 172 | }, 173 | { 174 | "comment": "e.g. 'play': function(arg1, arg2) { }", 175 | "name": "meta.function.json.js", 176 | "begin": "\\s*+(('|\\\")(\\b[_$a-zA-Z][$\\w]*)(\\k<2>))\\s*+(:)\\s*+(async)?\\s*+(\\bfunction\\b)\\s*(\\*\\s*)?\\s*(?=\\(|<)", 177 | "end": "(?=\\{)", 178 | "applyEndPatternLast": 1, 179 | "beginCaptures": { 180 | "1": { "name": "string.quoted.js" }, 181 | "2": { "name": "punctuation.definition.string.begin.js" }, 182 | "3": { "name": "entity.name.function.js" }, 183 | "4": { "name": "punctuation.definition.string.end.js" }, 184 | "5": { "name": "punctuation.separator.key-value.js" }, 185 | "6": { "name": "storage.type.js" }, 186 | "7": { "name": "storage.type.function.js" }, 187 | "8": { "name": "keyword.generator.asterisk.js" } 188 | }, 189 | "patterns": [ 190 | { "include": "#flowtype" } 191 | ] 192 | } 193 | ] 194 | }, 195 | "literal-arrow-function-labels": { 196 | "patterns": [ 197 | { 198 | "comment": "e.g. play: async (args) => { }", 199 | "name": "meta.function.json.arrow.js", 200 | "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>(?)", 201 | "end": "\\s*(=>)", 202 | "applyEndPatternLast": 1, 203 | "beginCaptures": { 204 | "1": { "name": "entity.name.function.js" }, 205 | "2": { "name": "punctuation.separator.key-value.js" }, 206 | "3": { "name": "storage.type.js" } 207 | }, 208 | "endCaptures": { 209 | "1": { "name": "storage.type.function.arrow.js" } 210 | }, 211 | "patterns": [ 212 | { "include": "#flowtype" } 213 | ] 214 | }, 215 | { 216 | "comment": "e.g. play: arg => { }", 217 | "name": "meta.function.json.arrow.js", 218 | "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>(?)", 219 | "end": "\\s*(=>)", 220 | "beginCaptures": { 221 | "1": { "name": "entity.name.function.js" }, 222 | "2": { "name": "punctuation.separator.key-value.js" }, 223 | "3": { "name": "storage.type.js" } 224 | }, 225 | "endCaptures": { 226 | "1": { "name": "storage.type.function.arrow.js" } 227 | }, 228 | "patterns": [ 229 | { "include": "#flowtype-polymorphs" }, 230 | { "include": "#flowtype-variable" } 231 | ] 232 | }, 233 | { 234 | "comment": "e.g. 'play': (args) => { }", 235 | "name": "meta.function.json.arrow.js", 236 | "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>(?)", 237 | "end": "\\s*(=>)", 238 | "applyEndPatternLast": 1, 239 | "endCaptures": { 240 | "1": { "name": "storage.type.function.arrow.js" } 241 | }, 242 | "beginCaptures": { 243 | "1": { "name": "string.quoted.js" }, 244 | "2": { "name": "punctuation.definition.string.begin.js" }, 245 | "3": { "name": "entity.name.function.js" }, 246 | "4": { "name": "punctuation.definition.string.end.js" }, 247 | "5": { "name": "punctuation.separator.key-value.js" }, 248 | "6": { "name": "storage.type.js" } 249 | }, 250 | "patterns": [ 251 | { "include": "#flowtype" } 252 | ] 253 | }, 254 | { 255 | "comment": "e.g. 'play': arg => { }", 256 | "name": "meta.function.json.arrow.js", 257 | "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>(?)", 258 | "end": "\\s*(=>)", 259 | "beginCaptures": { 260 | "1": { "name": "string.quoted.js" }, 261 | "2": { "name": "punctuation.definition.string.begin.js" }, 262 | "3": { "name": "entity.name.function.js" }, 263 | "4": { "name": "punctuation.definition.string.end.js" }, 264 | "5": { "name": "punctuation.separator.key-value.js" }, 265 | "6": { "name": "storage.type.js" } 266 | }, 267 | "endCaptures": { 268 | "1": { "name": "storage.type.function.arrow.js" } 269 | }, 270 | "patterns": [ 271 | { "include": "#flowtype-polymorphs" }, 272 | { "include": "#flowtype-variable" } 273 | ] 274 | } 275 | ] 276 | }, 277 | "literal-labels": { 278 | "patterns": [ 279 | { 280 | "comment": "string as a property name", 281 | "match": "\\s*+(?|[^?:])*(:|\\?\\s*+:)))", 431 | "end": "\\s*\\)", 432 | "beginCaptures": { 433 | "2": { "name": "meta.brace.round.js" } 434 | }, 435 | "endCaptures": { 436 | "0": { "name": "meta.brace.round.js" } 437 | }, 438 | "patterns": [ 439 | { "include": "#flowtype-typecast" }, 440 | { "include": "#expression" } 441 | ] 442 | }, 443 | { 444 | "name": "meta.group.braces.round", 445 | "begin": "\\s*+\\(", 446 | "end": "\\s*\\)", 447 | "endCaptures": { 448 | "0": { "name": "meta.brace.round.js" } 449 | }, 450 | "beginCaptures": { 451 | "0": { "name": "meta.brace.round.js" } 452 | }, 453 | "patterns": [ 454 | { "include": "#expression" } 455 | ] 456 | } 457 | ] 458 | }, 459 | "square-brackets": { 460 | "patterns": [ 461 | { 462 | "name": "meta.group.braces.square", 463 | "begin": "\\s*+\\[", 464 | "end": "\\s*\\]", 465 | "endCaptures": { 466 | "0": { "name": "meta.brace.square.js" } 467 | }, 468 | "beginCaptures": { 469 | "0": { "name": "meta.brace.square.js" } 470 | }, 471 | "patterns": [ 472 | { "include": "#expression" } 473 | ] 474 | } 475 | ] 476 | }, 477 | "curly-brackets": { 478 | "patterns": [ 479 | { 480 | "name": "meta.group.braces.curly", 481 | "begin": "\\s*+\\{", 482 | "end": "\\s*\\}", 483 | "endCaptures": { 484 | "0": { "name": "meta.brace.curly.js" } 485 | }, 486 | "beginCaptures": { 487 | "0": { "name": "meta.brace.curly.js" } 488 | }, 489 | "patterns": [ 490 | { "include": "$self" }, 491 | { "include": "source.js.jsx"} 492 | ] 493 | } 494 | ] 495 | }, 496 | "jsdoc": { 497 | "patterns": [ 498 | { 499 | "comment": "common doc @ keywords", 500 | "match": "(?)", 540 | "captures": { 541 | "0": { "name": "punctuation.definition.comment.js" } 542 | } 543 | }, 544 | { 545 | "name": "comment.line.double-slash.js", 546 | "begin": "\\s*+(//)", 547 | "end": "\\s*$", 548 | "beginCaptures": { 549 | "1": { "name": "punctuation.definition.comment.js" } 550 | } 551 | }, 552 | { 553 | "name": "comment.line.shebang.js", 554 | "match": "^(#!).*$\\n?", 555 | "captures": { 556 | "1": { "name": "punctuation.definition.comment.js" } 557 | } 558 | } 559 | ] 560 | }, 561 | "special-comments-conditional-compilation": { 562 | "patterns": [ 563 | { 564 | "name": "comment.block.conditional.js", 565 | "begin": "\\s*+/\\*(?=@)", 566 | "end": "\\s*\\*/", 567 | "captures": { 568 | "0": { "name": "punctuation.definition.comment.js" } 569 | }, 570 | "endCaptures": { 571 | "1": { "name": "keyword.control.conditional.js" }, 572 | "2": { "name": "punctuation.definition.keyword.js" } 573 | }, 574 | "patterns": [ 575 | { 576 | "name": "punctuation.definition.comment.js", 577 | "match": "\\s*+/\\*" 578 | }, 579 | { "include": "$self" } 580 | ] 581 | }, 582 | { 583 | "name": "keyword.control.conditional.js", 584 | "match": "\\s*+(?!@)(@)(if|elif|else|end|ifdef|endif|cc_on|set)\\b", 585 | "captures": { 586 | "1": { "name": "punctuation.definition.keyword.js" } 587 | } 588 | }, 589 | { 590 | "name": "variable.other.conditional.js", 591 | "match": "\\s*+(?!@)(@)(_win32|_win16|_mac|_alpha|_x86|_mc680x0|_PowerPC|_jscript|_jscript_build|_jscript_version|_debug|_fast|[a-zA-Z]\\w+)", 592 | "captures": { 593 | "1": { "name": "punctuation.definition.variable.js" } 594 | } 595 | } 596 | ] 597 | }, 598 | "literal-punctuation": { 599 | "patterns": [ 600 | { "include": "#literal-semi-colon"} , 601 | { "include": "#literal-comma" } 602 | ] 603 | }, 604 | "literal-semi-colon": { 605 | "patterns": [ 606 | { 607 | "name": "punctuation.terminator.statement.js", 608 | "match": "\\s*+\\;" 609 | } 610 | ] 611 | }, 612 | "literal-comma": { 613 | "patterns": [ 614 | { 615 | "name": "meta.delimiter.comma.js", 616 | "match": "\\s*+," 617 | } 618 | ] 619 | }, 620 | "literal-keyword-storage": { 621 | "patterns": [ 622 | { 623 | "comment": "flowtype vars with a : to indicate type", 624 | "comment": "these statements must end in a ;", 625 | "begin": "\\s*+(?[^{}]+)|\\g<-1>)*\\})\\s*+:)", 641 | "end": "\\s*\\;", 642 | "beginCaptures": { 643 | "1": { "name": "storage.type.js" } 644 | }, 645 | "endCaptures": { 646 | "0": { "name": "punctuation.terminator.statement.js" } 647 | }, 648 | "patterns": [ 649 | { "include": "#flowtype-destruct-lhs" } 650 | ] 651 | }, 652 | { 653 | "comment": "flowtype arrays [a,[b,c]] with a : to indicate type", 654 | "comment": "these statements must end in a ;", 655 | "begin": "\\s*+(?[^\\[\\]]+)|\\g<-1>)*\\])\\s*+:)", 656 | "end": "\\s*\\;", 657 | "beginCaptures": { 658 | "1": { "name": "storage.type.js" } 659 | }, 660 | "endCaptures": { 661 | "0": { "name": "punctuation.terminator.statement.js" } 662 | }, 663 | "patterns": [ 664 | { "include": "#flowtype-destruct-lhs" } 665 | ] 666 | }, 667 | { 668 | "comment": "var statements that done start with a flow indicator", 669 | "name": "storage.type.js", 670 | "match": "\\s*+(?(arg1, arg2) { }", 678 | "name": "meta.function.js", 679 | "begin": "\\s*+(?:\\b(async)\\b\\s+)?\\s*+(\\bfunction\\b)\\s*+(\\*?)\\s*+([_$a-zA-Z][$\\w]*)?\\s*+(?=\\(|<)", 680 | "end": "(?=\\s*+\\{)", 681 | "applyEndPatternLast": 1, 682 | "beginCaptures": { 683 | "1": { "name": "storage.type.js" }, 684 | "2": { "name": "storage.type.function.js" }, 685 | "3": { "name": "keyword.generator.asterisk.js" }, 686 | "4": { "name": "entity.name.function.js" } 687 | }, 688 | "patterns": [ 689 | { "include": "#flowtype" } 690 | ] 691 | }, 692 | { 693 | "comment": "e.g. play = function(arg1, arg2) { }", 694 | "name": "meta.function.js", 695 | "begin": "\\s*+(\\b[_$a-zA-Z][$\\w]*)\\s*+(=)\\s*+(?:(async)\\s+)?\\s*+(\\bfunction\\b)\\s*+(\\*?)\\s*+([_$a-zA-Z][$\\w]*)?\\s*+(?=\\(|<)", 696 | "end": "(?=\\s*+\\{)", 697 | "applyEndPatternLast": 1, 698 | "beginCaptures": { 699 | "1": { "name": "entity.name.function.js" }, 700 | "2": { "name": "keyword.operator.assignment.js" }, 701 | "3": { "name": "storage.type.js" }, 702 | "4": { "name": "storage.type.function.js" }, 703 | "5": { "name": "keyword.generator.asterisk.js" }, 704 | "6": { "name": "entity.name.function.js" } 705 | }, 706 | "patterns": [ 707 | { "include": "#flowtype" } 708 | ] 709 | }, 710 | { 711 | "comment": "e.g. Sound.prototype.play = function(arg1, arg2) { }", 712 | "name": "meta.prototype.function.js", 713 | "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*+(?=\\(|<)", 714 | "end": "(?=\\s*+\\{)", 715 | "applyEndPatternLast": 1, 716 | "beginCaptures": { 717 | "1": { "name": "entity.name.class.js" }, 718 | "2": { "name": "keyword.operator.accessor.js" }, 719 | "3": { "name": "variable.language.prototype.js" }, 720 | "4": { "name": "keyword.operator.accessor.js" }, 721 | "5": { "name": "entity.name.function.js" }, 722 | "6": { "name": "keyword.operator.assignment.js" }, 723 | "7": { "name": "storage.type.js" }, 724 | "8": { "name": "storage.type.function.js" }, 725 | "9": { "name": "keyword.generator.asterisk.js" }, 726 | "10": { "name": "entity.name.function.js" } 727 | }, 728 | "patterns": [ 729 | { "include": "#flowtype" } 730 | ] 731 | }, 732 | { 733 | "comment": "e.g. Sound.play = function(arg1, arg2) { }", 734 | "name": "meta.function.static.js", 735 | "begin": "\\s*+(\\b_?[A-Z][$\\w]*)?(\\.)([_$a-zA-Z][$\\w]*)\\s*+(=)\\s*+(?:(async)\\s+)?\\s*+(\\bfunction\\b)\\s*+(\\*?)\\s*+([_$a-zA-Z][$\\w]*)?\\s*+(?=\\(|<)", 736 | "end": "(?=\\s*+\\{)", 737 | "applyEndPatternLast": 1, 738 | "beginCaptures": { 739 | "1": { "name": "entity.name.class.js" }, 740 | "2": { "name": "keyword.operator.accessor.js" }, 741 | "3": { "name": "entity.name.function.js" }, 742 | "4": { "name": "keyword.operator.assignment.js" }, 743 | "5": { "name": "storage.type.js" }, 744 | "6": { "name": "storage.type.function.js" }, 745 | "7": { "name": "keyword.generator.asterisk.js" }, 746 | "8": { "name": "entity.name.function.js" } 747 | }, 748 | "patterns": [ 749 | { "include": "#flowtype" } 750 | ] 751 | } 752 | ] 753 | }, 754 | "literal-quasi": { 755 | "patterns": [ 756 | { 757 | "name": "string.quasi.js", 758 | "begin": "\\s*+([a-zA-Z$_][\\w$_]*)?(`)", 759 | "end": "\\s*(?)))" 800 | }, 801 | { 802 | "name": "keyword.operator.assignment.augmented.js", 803 | "match": "\\s*+(%=|&=|\\*=|\\+=|-=|/=|\\^=|\\|=|<<=|>>=|>>>=)" 804 | }, 805 | { 806 | "name": "keyword.operator.bitwise.js", 807 | "match": "\\s*+(~|<<|>>>|>>|&|\\^|\\|)" 808 | }, 809 | { 810 | "name": "keyword.operator.relational.js", 811 | "match": "\\s*+(<=|>=|<|>)" 812 | }, 813 | { 814 | "name": "keyword.operator.comparison.js", 815 | "match": "\\s*+(===|!==|==|!=)" 816 | }, 817 | { 818 | "name": "keyword.operator.arithmetic.js", 819 | "match": "\\s*+(--|\\+\\+|/(?!/|\\*)|%|\\*(?[^\\[\\]]+)|\\g<-1>)*\\])\\s*+\\(\\s*+\\))", 862 | "end": "(?=.)", 863 | "applyEndPatternLast": 1, 864 | "patterns": [ 865 | { "include": "#flowtype-parse-array"}, 866 | { "include": "#flowtype-bracketed-parameters" } 867 | ] 868 | }, 869 | { 870 | "name": "meta.function-call.with-arguments.js", 871 | "begin": "\\s*+([_$a-zA-Z][$\\w]*)\\s*+(?=\\()", 872 | "end": "(?=.)", 873 | "applyEndPatternLast": 1, 874 | "beginCaptures": { 875 | "1": { "name": "entity.name.function.js" } 876 | }, 877 | "patterns": [ 878 | { "include": "#flowtype-bracketed-parameters" } 879 | ] 880 | }, 881 | { 882 | "name": "meta.function-call.without-arguments.js", 883 | "begin": "\\s*+(?=(\\[(?:(?>[^\\[\\]]+)|\\g<-1>)*\\])\\s*+\\()", 884 | "end": "(?=.)", 885 | "applyEndPatternLast": 1, 886 | "patterns": [ 887 | { "include": "#flowtype-parse-array"}, 888 | { "include": "#flowtype-bracketed-parameters" } 889 | ] 890 | } 891 | ] 892 | }, 893 | "literal-language-constant": { 894 | "patterns": [ 895 | { 896 | "name": "constant.language.boolean.true.js", 897 | "match": "\\s*+(? { }", 1171 | "name": "meta.function.arrow.js", 1172 | "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*+=>)", 1173 | "end": "\\s*(=>)", 1174 | "applyEndPatternLast": 1, 1175 | "endCaptures": { 1176 | "1": { "name": "storage.type.function.arrow.js" } 1177 | }, 1178 | "beginCaptures": { 1179 | "1": { "name": "storage.type.js" } 1180 | }, 1181 | "patterns": [ 1182 | { "include": "#flowtype" } 1183 | ] 1184 | }, 1185 | { 1186 | "comment": "e.g. arg => { }", 1187 | "name": "meta.function.arrow.js", 1188 | "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*+=>)", 1189 | "end": "\\s*(=>)", 1190 | "beginCaptures": { 1191 | "1": { "name": "storage.type.js" } 1192 | }, 1193 | "endCaptures": { 1194 | "1": { "name": "storage.type.function.arrow.js" } 1195 | }, 1196 | "patterns": [ 1197 | { "include": "#flowtype-polymorphs" }, 1198 | { "include": "#flowtype-variable" } 1199 | ] 1200 | }, 1201 | { 1202 | "comment": "e.g. play = (args) => { }", 1203 | "name": "meta.function.arrow.js", 1204 | "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*+=>)", 1205 | "end": "\\s*(=>)", 1206 | "applyEndPatternLast": 1, 1207 | "beginCaptures": { 1208 | "1": { "name": "entity.name.function.js" }, 1209 | "2": { "name": "keyword.operator.assignment.js" }, 1210 | "3": { "name": "storage.type.js" } 1211 | }, 1212 | "endCaptures": { 1213 | "1": { "name": "storage.type.function.arrow.js" } 1214 | }, 1215 | "patterns": [ 1216 | { "include": "#flowtype" } 1217 | ] 1218 | }, 1219 | { 1220 | "comment": "e.g. play = arg => { }", 1221 | "name": "meta.function.arrow.js", 1222 | "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*+=>)", 1223 | "end": "\\s*(=>)", 1224 | "beginCaptures": { 1225 | "1": { "name": "entity.name.function.js" }, 1226 | "2": { "name": "keyword.operator.assignment.js" }, 1227 | "3": { "name": "storage.type.js" } 1228 | }, 1229 | "endCaptures": { 1230 | "1": { "name": "storage.type.function.arrow.js" } 1231 | }, 1232 | "patterns": [ 1233 | { "include": "#flowtype-polymorphs" }, 1234 | { "include": "#flowtype-variable" } 1235 | ] 1236 | }, 1237 | { 1238 | "comment": "Sound.prototype.play = (args) => { }", 1239 | "name": "meta.prototype.function.arrow.js", 1240 | "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*+=>)", 1241 | "end": "\\s*(=>)", 1242 | "applyEndPatternLast": 1, 1243 | "beginCaptures": { 1244 | "1": { "name": "entity.name.class.js" }, 1245 | "2": { "name": "keyword.operator.accessor.js" }, 1246 | "3": { "name": "variable.language.prototype.js" }, 1247 | "4": { "name": "keyword.operator.accessor.js" }, 1248 | "5": { "name": "entity.name.function.js" }, 1249 | "6": { "name": "keyword.operator.assignment.js" }, 1250 | "7": { "name": "storage.type.js" } 1251 | }, 1252 | "endCaptures": { 1253 | "1": { "name": "storage.type.function.arrow.js" } 1254 | }, 1255 | "patterns": [ 1256 | { "include": "#flowtype" } 1257 | ] 1258 | }, 1259 | { 1260 | "comment": "e.g. Sound.prototype.play = arg => { }", 1261 | "name": "meta.prototype.function.arrow.js", 1262 | "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*+=>)", 1263 | "end": "\\s*(=>)", 1264 | "beginCaptures": { 1265 | "1": { "name": "entity.name.class.js" }, 1266 | "2": { "name": "keyword.operator.accessor.js" }, 1267 | "3": { "name": "variable.language.prototype.js" }, 1268 | "4": { "name": "keyword.operator.accessor.js" }, 1269 | "5": { "name": "entity.name.function.js" }, 1270 | "6": { "name": "keyword.operator.assignment.js" }, 1271 | "7": { "name": "storage.type.js" } 1272 | }, 1273 | "endCaptures": { 1274 | "1": { "name": "storage.type.function.arrow.js" } 1275 | }, 1276 | "patterns": [ 1277 | { "include": "#flowtype-polymorphs" }, 1278 | { "include": "#flowtype-variable" } 1279 | ] 1280 | }, 1281 | { 1282 | "comment": "e.g. Sound.play = (args) => { }", 1283 | "name": "meta.function.static.arrow.js", 1284 | "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*+=>)", 1285 | "end": "\\s*(=>)", 1286 | "applyEndPatternLast": 1, 1287 | "beginCaptures": { 1288 | "1": { "name": "entity.name.class.js" }, 1289 | "2": { "name": "keyword.operator.accessor.js" }, 1290 | "3": { "name": "entity.name.function.js" }, 1291 | "4": { "name": "keyword.operator.assignment.js" }, 1292 | "5": { "name": "storage.type.js" } 1293 | 1294 | }, 1295 | "endCaptures": { 1296 | "1": { "name": "storage.type.function.arrow.js" } 1297 | }, 1298 | "patterns": [ 1299 | { "include": "#flowtype" } 1300 | ] 1301 | }, 1302 | { 1303 | "comment": "e.g. Sound.play = arg => { }", 1304 | "name": "meta.function.static.arrow.js", 1305 | "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*+=>)", 1306 | "end": "\\s*(=>)", 1307 | "beginCaptures": { 1308 | "1": { "name": "entity.name.class.js" }, 1309 | "2": { "name": "keyword.operator.accessor.js" }, 1310 | "3": { "name": "entity.name.function.js" }, 1311 | "4": { "name": "keyword.operator.assignment.js" }, 1312 | "5": { "name": "storage.type.js" } 1313 | }, 1314 | "endCaptures": { 1315 | "1": { "name": "storage.type.function.arrow.js" } 1316 | }, 1317 | "patterns": [ 1318 | { "include": "#flowtype-polymorphs" }, 1319 | { "include": "#flowtype-variable" } 1320 | ] 1321 | } 1322 | ] 1323 | }, 1324 | "literal-method": { 1325 | "patterns": [ 1326 | { 1327 | "comment": "e.g. play(arg1, arg2): Type { }", 1328 | "name": "meta.function.method.js", 1329 | "begin": "\\s*++(\\bstatic\\b)?\\s*++(\\basync\\b)?\\s*++(\\*?)\\s*++(?[^<>]+)|\\g<-1>)*>)?(\\())", 1330 | "end": "\\s*(?=.)", 1331 | "applyEndPatternLast": 1, 1332 | "beginCaptures": { 1333 | "1": { "name": "storage.modifier.js" }, 1334 | "2": { "name": "storage.type.js" }, 1335 | "3": { "name": "keyword.generator.asterisk.js" }, 1336 | "4": { "name": "entity.name.function.method.js" } 1337 | }, 1338 | "patterns": [ 1339 | { "include": "#flowtype" } 1340 | ] 1341 | }, 1342 | { 1343 | "comment": "e.g. [var](arg1, arg2): Type { } or 'var'(arg1, arg2)", 1344 | "name": "meta.function.method.js", 1345 | "begin": "\\s*++(\\bstatic\\b)?\\s*++(\\basync\\b)?\\s*++(\\*?)\\s*++(?=((\\[(?:(?>[^\\[\\]]+)|\\g<-1>)*\\])|\\s*+(((')((?:[^']|\\\\')*)('))|\\s*+((\")((?:[^\"]|\\\\\")*)(\"))))\\s*+(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*+(\\())", 1346 | "end": "\\s*(?=.)", 1347 | "applyEndPatternLast": 1, 1348 | "beginCaptures": { 1349 | "1": { "name": "storage.modifier.js" }, 1350 | "2": { "name": "storage.type.js" }, 1351 | "3": { "name": "keyword.generator.asterisk.js" }, 1352 | "4": { "name": "entity.name.function.method.js" }, 1353 | "6": { "name": "entity.name.function.method.js" } 1354 | }, 1355 | "patterns": [ 1356 | { "include": "#flowtype-parse-array" }, 1357 | { "include": "#literal-string"}, 1358 | { "include": "#flowtype" } 1359 | ] 1360 | }, 1361 | { 1362 | "comment": "getter/setter", 1363 | "name": "meta.accessor.js", 1364 | "begin": "\\s*+\\b(?:(static)\\s+)?(get|set)\\s+([_$a-zA-Z][$\\w]*)\\s*+(?=\\()", 1365 | "end": "\\s*(?={)", 1366 | "applyEndPatternLast": 1, 1367 | "beginCaptures": { 1368 | "1": { "name": "storage.modifier.static.js" }, 1369 | "2": { "name": "storage.type.accessor.js" }, 1370 | "3": { "name": "entity.name.accessor.js" } 1371 | }, 1372 | "patterns": [ 1373 | { "include": "#flowtype" } 1374 | ] 1375 | }, 1376 | { 1377 | "comment": "getter/setter set [var]() or get 'name'()", 1378 | "name": "meta.accessor.js", 1379 | "begin": "\\s*+\\b(?:(static)\\s+)?(get|set)\\s+(?=((\\[(?:(?>[^\\[\\]]+)|\\g<-1>)*\\])|\\s*+(((')((?:[^']|\\\\')*)('))|\\s*+((\")((?:[^\"]|\\\\\")*)(\"))))\\s*+(\\())", 1380 | "end": "\\s*(?={)", 1381 | "applyEndPatternLast": 1, 1382 | "beginCaptures": { 1383 | "1": { "name": "storage.modifier.static.js" }, 1384 | "2": { "name": "storage.type.accessor.js" }, 1385 | "3": { "name": "entity.name.accessor.js" } 1386 | }, 1387 | "patterns": [ 1388 | { "include": "#flowtype-parse-array" }, 1389 | { "include": "#literal-string"}, 1390 | { "include": "#flowtype" } 1391 | ] 1392 | } 1393 | ] 1394 | }, 1395 | "literal-regexp": { 1396 | "patterns": [ 1397 | { 1398 | "name": "string.regexp.js", 1399 | "begin": "(?<=\\.|\\(|,|{|}|\\[|;|,|<|>|<=|>=|==|!=|===|!==|\\+|-|\\*|%|\\+\\+|--|<<|>>|>>>|&|\\||\\^|!|~|&&|\\|\\||\\?|:|=|\\+=|-=|\\*=|%=|<<=|>>=|>>>=|&=|\\|=|\\^=|/|/=|\\Wnew|\\Wdelete|\\Wvoid|\\Wtypeof|\\Winstanceof|\\Win|\\Wdo|\\Wreturn|\\Wcase|\\Wthrow|^new|^delete|^void|^typeof|^instanceof|^in|^do|^return|^case|^throw|^)\\s*+(/)(?!/|\\*|$)", 1400 | "end": "(/)([gimyu]*)", 1401 | "beginCaptures": { 1402 | "1": { "name": "punctuation.definition.string.begin.js" } 1403 | }, 1404 | "endCaptures": { 1405 | "1": { "name": "punctuation.definition.string.end.js" }, 1406 | "2": { "name": "keyword.other.js" } 1407 | }, 1408 | "patterns": [ 1409 | { "include": "source.regexp.babel" } 1410 | ] 1411 | } 1412 | ] 1413 | }, 1414 | "literal-string": { 1415 | "patterns": [ 1416 | { 1417 | "contentName": "string.quoted.single.js", 1418 | "begin": "\\s*+(('))", 1419 | "end": "\\s*+(?:(('))|(\n))", 1420 | "beginCaptures": { 1421 | "1": { "name": "string.quoted.single.js" }, 1422 | "2": { "name": "punctuation.definition.string.begin.js" } 1423 | }, 1424 | "endCaptures": { 1425 | "1": { "name": "string.quoted.single.js" }, 1426 | "2": { "name": "punctuation.definition.string.end.js" }, 1427 | "3": { "name": "invalid.illegal.newline.js" } 1428 | }, 1429 | "patterns": [ 1430 | { "include": "#string-content" } 1431 | ] 1432 | }, 1433 | { 1434 | "contentName": "string.quoted.double.js", 1435 | "begin": "\\s*+((\"))", 1436 | "end": "\\s*+(?:((\"))|(\n))", 1437 | "beginCaptures": { 1438 | "1": { "name": "string.quoted.double.js" }, 1439 | "2": { "name": "punctuation.definition.string.begin.js" } 1440 | }, 1441 | "endCaptures": { 1442 | "1": { "name": "string.quoted.double.js" }, 1443 | "2": { "name": "punctuation.definition.string.end.js" }, 1444 | "3": { "name": "invalid.illegal.newline.js" } 1445 | }, 1446 | "patterns": [ 1447 | { "include": "#string-content" } 1448 | ] 1449 | } 1450 | ] 1451 | }, 1452 | "literal-module": { 1453 | "patterns": [ 1454 | { 1455 | "name": "keyword.control.module.js", 1456 | "match": "\\s*+(? and as per the draft. Will anyone use these?", 1550 | "comment": "Avoid < operator expressions as best we can using Zertosh's regex", 1551 | "patterns": [ 1552 | { 1553 | "begin": "(?<=\\(|\\{|\\[|,|&&|\\|\\||\\?|:|=|=>|\\Wreturn|^return|\\Wdefault|^)\\s*+(?=<[_$a-zA-Z])", 1554 | "end": "(?=.)", 1555 | "applyEndPatternLast": 1, 1556 | "patterns": [ 1557 | { "include": "#jsx-tag-element-name" } 1558 | ] 1559 | } 1560 | ] 1561 | }, 1562 | "jsx-tag-element-name": { 1563 | "patterns": [ 1564 | { 1565 | "comment": "Trap tag ", 1567 | "comment": "as well as terminating a form", 1568 | "comment": "Tags that end > are trapped in #jsx-tag-termination", 1569 | "name": "meta.tag.jsx", 1570 | "begin": "\\s*+(<)([$_\\p{L}](?:[$.:\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}-](?\\s])(?)|(/>)|((?<=", 1572 | "beginCaptures": { 1573 | "1": { "name": "punctuation.definition.tag.jsx" }, 1574 | "2": { "name": "entity.name.tag.open.jsx" } 1575 | }, 1576 | "endCaptures": { 1577 | "1": { "name": "entity.name.tag.close.jsx" }, 1578 | "2": { "name": "punctuation.definition.tag.jsx" }, 1579 | "3": { "name": "punctuation.definition.tag.jsx" }, 1580 | "4": { "name": "invalid.illegal.termination.jsx"} 1581 | }, 1582 | "patterns": [ 1583 | { "include": "#jsx-tag-termination" }, 1584 | { "include": "#jsx-tag-attributes" } 1585 | ] 1586 | } 1587 | ] 1588 | }, 1589 | "jsx-tag-termination": { 1590 | "patterns": [ 1591 | { 1592 | "comment": "this matches the end > of an opening tag when in the form ", 1593 | "comment": "uses non consuming search for ", 1594 | "begin": "(>)", 1595 | "end": "(|/>)", 1637 | "captures": { 1638 | "0": { "name": "entity.other.attribute-name.jsx" } 1639 | } 1640 | } 1641 | ] 1642 | }, 1643 | "jsx-assignment": { 1644 | "patterns": [ 1645 | { 1646 | "comment": "look for attribute assignment", 1647 | "name": "keyword.operator.assignment.jsx", 1648 | "match": "=(?=\\s*(?:'|\"|{|/\\*|<|//|\\n))" 1649 | } 1650 | ] 1651 | }, 1652 | "jsx-string-double-quoted": { 1653 | "name": "string.quoted.double.js", 1654 | "begin": "\"", 1655 | "end": "\"(?)", 1747 | "captures": { 1748 | "1": { "name": "keyword.operator.spread.js" }, 1749 | "2": { "name": "variable.other.readwrite.js" }, 1750 | "3": { "name": "keyword.operator.optional.parameter.flowtype" } 1751 | } 1752 | }, 1753 | { "include": "#flowtype-vars-and-props" } 1754 | ] 1755 | }, 1756 | "flowtype-destruct-lhs": { 1757 | "comment": "lhs destructs such as {a: z, [b,c] }", 1758 | "comment": "use this pattern to colour code the variable part correctly", 1759 | "patterns": [ 1760 | { 1761 | "begin": "\\s*+{", 1762 | "end": "\\s*}", 1763 | "patterns": [ 1764 | { "include": "#flowtype-destruct-lhs" } 1765 | ] 1766 | }, 1767 | { 1768 | "begin": "\\s*+\\[", 1769 | "end": "\\s*\\]", 1770 | "patterns": [ 1771 | { "include": "#flowtype-destruct-lhs" } 1772 | ] 1773 | }, 1774 | { 1775 | "comment": "string as destructor target", 1776 | "match": "\\s*+((['\\\"]).*?\\k<-1>(?)", 1834 | "captures": { 1835 | "1": { "name": "storage.type.function.arrow.js" } 1836 | } 1837 | }, 1838 | { "include": "#flowtype-bracketed-parameters" }, 1839 | { "include": "#flowtype-parse-array" }, 1840 | { "include": "#expression" } 1841 | ] 1842 | }, 1843 | "flowtype-parse-operators": { 1844 | "patterns": [ 1845 | { 1846 | "comment": "call back with a form ) => type", 1847 | "begin": "(?<=\\))\\s*+(=>)", 1848 | "end": "(?=.)", 1849 | "applyEndPatternLast": 1, 1850 | "beginCaptures": { 1851 | "1": { "name": "storage.type.function.arrow.js" } 1852 | }, 1853 | "patterns": [ 1854 | { "include": "#flowtype-parse-types" } 1855 | ] 1856 | }, 1857 | { 1858 | "comment": "some form of default assignment for func args", 1859 | "begin": "\\s*+=(?!>|=|==)", 1860 | "end": "\\s*(?=,|;|\\))", 1861 | "beginCaptures": { 1862 | "0": { "name": "keyword.operator.assignment.js" } 1863 | }, 1864 | "patterns": [ 1865 | { "include": "#expression" } 1866 | ] 1867 | } 1868 | ] 1869 | }, 1870 | "flowtype-parse-types": { 1871 | "patterns": [ 1872 | { 1873 | "comment": "Maybe types", 1874 | "name": "keyword.operator.maybe.flowtype", 1875 | "match": "\\s*+\\?" 1876 | }, 1877 | { 1878 | "name": "keyword.operator.flowtype", 1879 | "match": "\\s*+\\btypeof\\b\\s*+" 1880 | }, 1881 | { 1882 | "comment": "primitive flowtypes", 1883 | "match": "\\s*+\\b((?>any|boolean|mixed|number|string|void))\\b", 1884 | "captures": { 1885 | "1": { "name": "support.type.builtin.primitive.flowtype" } 1886 | } 1887 | }, 1888 | { 1889 | "comment": "Built-in Class Types", 1890 | "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", 1891 | "captures": { 1892 | "1": { "name": "support.type.builtin.class.flowtype" } 1893 | } 1894 | }, 1895 | { "include": "#flowtype-polymorphs" }, 1896 | { 1897 | "comment": "custom Class Types e.g. Abc avoid Abc(", 1898 | "match": "\\s*+([$_[\\p{Lu}\\p{Lt}\\p{Lm}\\p{Lo}]][$.\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}]*+)(?!\\s*+\\()", 1899 | "captures": { 1900 | "1": { "name": "support.type.class.flowtype" } 1901 | } 1902 | }, 1903 | { 1904 | "comment": "custom primitive/var Types e.g. abc avoid abc(", 1905 | "match": "\\s*+([$_\\p{L}][$.\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}]*+)(?!\\s*+\\()", 1906 | "captures": { 1907 | "1": { "name": "support.type.primitive.flowtype" } 1908 | } 1909 | }, 1910 | { 1911 | "comment": "Type Unions |", 1912 | "name": "kewyword.operator.union.flowtype", 1913 | "match": "\\s*+\\|" 1914 | }, 1915 | { 1916 | "comment": "intersection of types &", 1917 | "name": "kewyword.operator.intersection.flowtype", 1918 | "match": "\\s*+\\&" 1919 | }, 1920 | { 1921 | "comment": "as per React declares in flowtype github", 1922 | "name": "kewyword.operator.existential.flowtype", 1923 | "match": "\\s*+\\*" 1924 | }, 1925 | { "include": "#literal-string" }, 1926 | { "include": "#literal-number" }, 1927 | { "include": "#flowtype-bracketed-parameters" }, 1928 | { "include": "#flowtype-parse-objects" }, 1929 | { "include": "#flowtype-parse-operators" }, 1930 | { "include": "#flowtype-parse-array" }, 1931 | { "include": "#comments" } 1932 | ] 1933 | }, 1934 | "flowtype-bracketed-parameters": { 1935 | "patterns": [ 1936 | { 1937 | "comment": "Get parameters within a function/method call", 1938 | "begin": "\\s*+(\\()", 1939 | "end": "\\s*(\\))", 1940 | "beginCaptures": { 1941 | "1": { "name": "punctuation.definition.parameters.begin.js" } 1942 | }, 1943 | "endCaptures": { 1944 | "1": { "name": "punctuation.definition.parameters.end.js" } 1945 | }, 1946 | "patterns": [ 1947 | { "include": "#flowtype-variable" } 1948 | ] 1949 | } 1950 | ] 1951 | }, 1952 | "flowtype-polymorphs": { 1953 | "comment": "Support Bounded Polymorphism http://flowtype.org/blog/2015/03/12/Bounded-Polymorphism.html", 1954 | "patterns": [ 1955 | { 1956 | "comment": "Built-in Class Types with elements of type ", 1957 | "begin": "\\s*+\\b((?>Array|Class|Map|Promise|Set|WeakMap|WeakSet))\\s*+(<)", 1958 | "end": "\\s*(>)", 1959 | "beginCaptures": { 1960 | "1": { "name": "support.type.builtin.class.flowtype" }, 1961 | "2": { "name": "punctuation.flowtype" } 1962 | }, 1963 | "endCaptures" : { 1964 | "1": { "name": "punctuation.flowtype" } 1965 | }, 1966 | "patterns": [ 1967 | { "match": "\\s*+,", 1968 | "name": "punctuation.type.separator.flowtype" 1969 | }, 1970 | { "match": "\\s*+:", 1971 | "name": "punctuation.type.separator.flowtype" 1972 | }, 1973 | { "include": "#flowtype-parse-types" } 1974 | ] 1975 | }, 1976 | { 1977 | "comment": "just the polymorph bit like this (arg,arg)", 1978 | "begin": "\\s*+(<)(?!<)", 1979 | "end": "\\s*(>)", 1980 | "beginCaptures": { 1981 | "1": { "name": "punctutation.flowtype" } 1982 | }, 1983 | "endCaptures": { 1984 | "1": { "name": "punctutation.flowtype" } 1985 | }, 1986 | "patterns": [ 1987 | { "match": "\\s*+,", 1988 | "name": "punctuation.type.separator.flowtype" 1989 | }, 1990 | { "match": "\\s*+:", 1991 | "name": "punctuation.type.separator.flowtype" 1992 | }, 1993 | { "include": "#flowtype-parse-types" } 1994 | ] 1995 | } 1996 | ] 1997 | }, 1998 | "flowtype-parse-objects": { 1999 | "comment": "object literal flowtype preceded by either : | & ? symbols", 2000 | "begin": "(?<=:|\\||&|\\?)\\s*+(\\{)", 2001 | "end": "\\s*(\\})", 2002 | "applyEndPatternLast": 1, 2003 | "beginCaptures": { 2004 | "1": { "name": "meta.brace.round.open.flowtype" } 2005 | }, 2006 | "endCaptures": { 2007 | "1": { "name": "meta.brace.round.close.flowtype" } 2008 | }, 2009 | "patterns": [ 2010 | { "include": "#flowtype-object-property" } 2011 | ] 2012 | }, 2013 | "flowtype-object-property": { 2014 | "patterns": [ 2015 | { 2016 | "comment": "name of property which can be a string", 2017 | "match": "\\s*+(((\"|').*?(?<=[^\\\\])\\k<-1>)|([$_\\p{L}](?:[$.\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}])*+))\\s*+(\\??)\\s*+(?=:)", 2018 | "captures": { 2019 | "1": { "name": "variable.other.property.flowtype" }, 2020 | "5": { "name": "keyword.operator.optional.parameter.flowtype" } 2021 | } 2022 | }, 2023 | { "include": "#flowtype-vars-and-props" } 2024 | ] 2025 | }, 2026 | "flowtype-parse-array": { 2027 | "comment": "arrays such as [name: string, dob: Date]", 2028 | "begin": "\\s*+(\\[)", 2029 | "end": "\\s*(\\])", 2030 | "beginCaptures": { 2031 | "1": { "name": "meta.brace.square.open.flowtype" } 2032 | }, 2033 | "endCaptures": { 2034 | "1": { "name": "meta.brace.square.end.flowtype" } 2035 | }, 2036 | "patterns": [ 2037 | { "include": "#flowtype-variable" } 2038 | ] 2039 | }, 2040 | "flowtype-type-aliases": { 2041 | "patterns": [ 2042 | { 2043 | "comment": "import for types", 2044 | "match": "\\s*+(?)", 2262 | "captures": { 2263 | "1": { "name": "storage.type.function.arrow.js" } 2264 | } 2265 | } 2266 | ] 2267 | } 2268 | } 2269 | } 2270 | --------------------------------------------------------------------------------