From 5ca799fd0729cec5e7c30e70022f37bb3cb4b608 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Tue, 2 Aug 2016 17:20:41 +0200 Subject: [PATCH] [javascript] update grammar, grammar as JSON --- extensions/javascript/OSSREADME.json | 2 +- extensions/javascript/package.json | 4 +- .../javascript/syntaxes/JavaScript.tmLanguage | 2405 ----------------- .../syntaxes/JavaScript.tmLanguage.json | 1526 +++++++++++ extensions/javascript/syntaxes/Readme.md | 12 +- 5 files changed, 1537 insertions(+), 2412 deletions(-) delete mode 100644 extensions/javascript/syntaxes/JavaScript.tmLanguage create mode 100644 extensions/javascript/syntaxes/JavaScript.tmLanguage.json diff --git a/extensions/javascript/OSSREADME.json b/extensions/javascript/OSSREADME.json index 0a94b561277..89a7912b239 100644 --- a/extensions/javascript/OSSREADME.json +++ b/extensions/javascript/OSSREADME.json @@ -5,7 +5,7 @@ "version": "0.0.1", "license": "Apache2", "repositoryURL": "https://github.com/Microsoft/TypeScript-TmLanguage", - "description": "The file syntaxes/JavaScript.tmLanguage was derived from TypeScriptReact.tmLanguage in https://github.com/Microsoft/TypeScript-TmLanguage.", + "description": "The file syntaxes/JavaScript.tmLanguage.json was derived from TypeScriptReact.tmLanguage in https://github.com/Microsoft/TypeScript-TmLanguage.", "licenseDetail": [ // Reason: LICENSE file does not include Copyright statement "Copyright (c) Microsoft Corporation. All rights reserved.", diff --git a/extensions/javascript/package.json b/extensions/javascript/package.json index 7f49880b69c..b08729bbe12 100644 --- a/extensions/javascript/package.json +++ b/extensions/javascript/package.json @@ -54,12 +54,12 @@ { "language": "javascriptreact", "scopeName": "source.js", - "path": "./syntaxes/JavaScript.tmLanguage" + "path": "./syntaxes/JavaScript.tmLanguage.json" }, { "language": "javascript", "scopeName": "source.js", - "path": "./syntaxes/JavaScript.tmLanguage" + "path": "./syntaxes/JavaScript.tmLanguage.json" }, { "scopeName": "source.js.regexp", diff --git a/extensions/javascript/syntaxes/JavaScript.tmLanguage b/extensions/javascript/syntaxes/JavaScript.tmLanguage deleted file mode 100644 index 514e2251788..00000000000 --- a/extensions/javascript/syntaxes/JavaScript.tmLanguage +++ /dev/null @@ -1,2405 +0,0 @@ - - - - - fileTypes - - js - jsx - - name - JavaScript (with React support) - patterns - - - include - #expression - - - repository - - access-modifier - - match - \b(public|protected|private)\b - name - storage.modifier.js - - arithmetic-operator - - match - \*|/|\-\-|\-|\+\+|\+|% - name - keyword.operator.arithmetic.js - - array-literal - - begin - \[ - beginCaptures - - 0 - - name - meta.brace.square.js - - - end - \] - endCaptures - - 0 - - name - meta.brace.square.js - - - name - meta.array.literal.js - patterns - - - include - #expression - - - - assignment-operator - - match - <<=|>>>=|>>=|\*=|(?<!\()/=|%=|\+=|\-=|&=|\^= - name - keyword.operator.assignment.js - - await-modifier - - match - \bawait\b - name - storage.modifier.js - - block - - begin - \{ - beginCaptures - - 0 - - name - meta.brace.curly.js - - - end - \} - endCaptures - - 0 - - name - meta.brace.curly.js - - - name - meta.block.js - patterns - - - include - #object-member - - - include - #expression - - - - boolean-literal - - match - \b(false|true)\b - name - constant.language.boolean.js - - case-clause - - begin - (?<!\.)\b(case|default)\b - beginCaptures - - 1 - - name - keyword.control.js - - - end - : - name - case-clause.expr.js - patterns - - - include - #expression - - - - comment - - name - comment.js - patterns - - - include - #comment-block-doc - - - include - #comment-block - - - include - #comment-line - - - - comment-block - - begin - /\* - end - \*/ - name - comment.block.js - - comment-block-doc - - begin - /\*\*(?!/) - end - \*/ - name - comment.block.documentation.js - - comment-line - - match - (//).*$\n? - name - comment.line.js - - control-statement - - match - (?<!\.)\b(break|catch|continue|debugger|declare|do|else|finally|for|if|return|switch|throw|try|while|with|super|case|default|yield)\b - name - keyword.control.js - - decl-block - - begin - \{ - beginCaptures - - 0 - - name - meta.brace.curly.js - - - end - \} - endCaptures - - 0 - - name - meta.brace.curly.js - - - name - meta.decl.block.js - patterns - - - include - #expression - - - - declaration - - name - meta.declaration.js - patterns - - - include - #function-declaration - - - include - #object-declaration - - - include - #type-declaration - - - include - #enum-declaration - - - - enum-declaration - - captures - - 1 - - name - storage.modifier.js - - 2 - - name - storage.type.js - - 3 - - name - entity.name.class.js - - - match - (?:\b(const)\s+)?\b(enum)\s+([a-zA-Z_$][\w$]*) - name - meta.enum.declaration.js - - expression - - name - meta.expression.js - patterns - - - include - #jsx - - - include - #for-in-simple - - - include - #string - - - include - #regex - - - include - #template - - - include - #comment - - - include - #literal - - - include - #paren-expression - - - include - #var-expr - - - include - #declaration - - - include - #new-expr - - - include - #switch-statement - - - include - #block - - - include - #import-operator - - - include - #expression-operator - - - include - #imply-operator - - - include - #relational-operator - - - include - #arithmetic-operator - - - include - #logic-operator - - - include - #assignment-operator - - - include - #storage-keyword - - - include - #type-primitive - - - include - #function-call - - - include - #case-clause - - - include - #control-statement - - - - expression-operator - - match - \b(delete|in|instanceof|new|typeof|as|is|of)\b - name - keyword.others.js - - field-declaration - - begin - (?<!\()\s*((?:\b[a-zA-Z_$][\w$]*)|(?:\'[^']*\')|(?:\"[^"]*\"))\s*(\?\s*)?(?=(=|:)) - beginCaptures - - 1 - - name - variable.js - - 2 - - name - keyword.others.js - - - end - (?=\}|;|,|$)|(?<=\}) - name - meta.field.declaration.js - patterns - - - include - #expression - - - - for-in-simple - - captures - - 1 - - name - storage.type.js - - 3 - - name - keyword.others.js - - - match - (?<=\()\s*\b(var|let|const)\s+([a-zA-Z_$][\w$]*)\s+(in|of)\b - name - forin.expr.js - - function-call - - name - functioncall.expr.js - patterns - - - include - #await-modifier - - - include - #type-parameters - - - include - #paren-expression - - - - function-declaration - - begin - \b(?:(export)\s+)?(?:(async)\s+)?(function\b)(?:\s+([a-zA-Z_$][\w$]*))?\s* - beginCaptures - - 1 - - name - storage.type.js - - 2 - - name - storage.modifier.js - - 3 - - name - storage.type.function.js - - 4 - - name - entity.name.function.js - - - end - (?=;|\})|(?<=\}) - name - meta.function.js - patterns - - - include - #comment - - - include - #type-parameters - - - include - #function-type-parameters - - - include - #return-type - - - include - #function-overload-declaration - - - include - #decl-block - - - - function-overload-declaration - - captures - - 1 - - name - storage.type.js - - 2 - - name - storage.type.function.js - - 3 - - name - entity.name.function.js - - - match - \b(?:(export)\s+)?(function\b)(?:\s+([a-zA-Z_$][\w$]*))?\s* - name - meta.function.overload.js - - function-type-parameters - - begin - \( - beginCaptures - - 0 - - name - meta.brace.round.js - - - end - \) - endCaptures - - 0 - - name - meta.brace.round.js - - - name - meta.function.type.parameter.js - patterns - - - include - #comment - - - include - #parameter-name - - - include - #type-annotation - - - include - #variable-initializer - - - - imply-operator - - match - => - name - keyword.operator.js - - import-operator - - match - \b(import|from)\b - name - keyword.control.import.include.js - - indexer-declaration - - begin - \[ - beginCaptures - - 0 - - name - meta.brace.square.js - - - end - (\])\s*(\?\s*)?|$ - endCaptures - - 1 - - name - meta.brace.square.js - - 2 - - name - keyword.others.js - - - name - meta.indexer.declaration.js - patterns - - - include - #type-annotation - - - include - #indexer-parameter - - - include - #expression - - - - indexer-parameter - - captures - - 1 - - name - variable.parameter.js - - - match - ([a-zA-Z_$][\w$]*)(?=\:) - name - meta.indexer.parameter.js - - jsx - - name - meta.jsx.js - patterns - - - include - #jsx-tag-without-attributes - - - include - #jsx-tag-open - - - include - #jsx-tag-close - - - include - #jsx-tag-invalid - - - begin - (?<=(?:'|"|})>) - end - (?=</) - name - meta.jsx.children.js - patterns - - - include - #jsx-children - - - - - - jsx-children - - patterns - - - include - #jsx-tag-without-attributes - - - include - #jsx-tag-open - - - include - #jsx-tag-close - - - include - #jsx-tag-invalid - - - include - #jsx-evaluated-code - - - include - #jsx-entities - - - - jsx-entities - - patterns - - - captures - - 1 - - name - punctuation.definition.entity.js - - 3 - - name - punctuation.definition.entity.js - - - match - (&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;) - name - constant.character.entity.js - - - match - & - name - invalid.illegal.bad-ampersand.js - - - - jsx-evaluated-code - - begin - { - beginCaptures - - 0 - - name - punctuation.definition.brace.curly.start.js - - - end - } - endCaptures - - 0 - - name - punctuation.definition.brace.curly.end.js - - - name - meta.brace.curly.js - patterns - - - include - #expression - - - - jsx-string-double-quoted - - begin - " - beginCaptures - - 0 - - name - punctuation.definition.string.begin.js - - - end - " - endCaptures - - 0 - - name - punctuation.definition.string.end.js - - - name - string.quoted.double.js - patterns - - - include - #jsx-entities - - - - jsx-string-single-quoted - - begin - ' - beginCaptures - - 0 - - name - punctuation.definition.string.begin.js - - - end - ' - endCaptures - - 0 - - name - punctuation.definition.string.end.js - - - name - string.quoted.single.js - patterns - - - include - #jsx-entities - - - - jsx-tag-attribute-assignment - - match - =(?=\s*(?:'|"|{|/\*|//|\n)) - name - keyword.operator.assignment.js - - jsx-tag-attribute-name - - captures - - 1 - - name - entity.other.attribute-name.js - - - match - (?x) - \s* - ([_$a-zA-Z][-$\w]*) - (?=\s|=|/?>|/\*|//) - name - meta.tag.attribute-name.js - - jsx-tag-attributes - - patterns - - - include - #jsx-tag-attribute-name - - - include - #jsx-tag-attribute-assignment - - - include - #jsx-string-double-quoted - - - include - #jsx-string-single-quoted - - - include - #jsx-evaluated-code - - - - jsx-tag-attributes-illegal - - match - \S+ - name - invalid.illegal.attribute.js - - jsx-tag-close - - begin - (</)([_$a-zA-Z][-$\w.]*(?<!\.|-)) - beginCaptures - - 1 - - name - punctuation.definition.tag.begin.js - - 2 - - name - entity.name.tag.js - - - end - (>) - endCaptures - - 1 - - name - punctuation.definition.tag.end.js - - - name - tag.close.js - patterns - - - include - #comment - - - - jsx-tag-invalid - - match - <\s*> - name - invalid.illegal.tag.incomplete.js - - jsx-tag-open - - begin - (?x) - (<) - ([_$a-zA-Z][-$\w.]*(?<!\.|-)) - (?=\s+(?!\?)|/?>) - beginCaptures - - 1 - - name - punctuation.definition.tag.begin.js - - 2 - - name - entity.name.tag.js - - - end - (/?>) - endCaptures - - 1 - - name - punctuation.definition.tag.end.js - - - name - tag.open.js - patterns - - - include - #comment - - - include - #jsx-tag-attributes - - - include - #jsx-tag-attributes-illegal - - - - jsx-tag-without-attributes - - begin - (<)([_$a-zA-Z][-$\w.]*(?<!\.|-))(>) - beginCaptures - - 1 - - name - punctuation.definition.tag.begin.js - - 2 - - name - entity.name.tag.js - - 3 - - name - punctuation.definition.tag.end.js - - - end - (</)([_$a-zA-Z][-$\w.]*(?<!\.|-))(>) - endCaptures - - 1 - - name - punctuation.definition.tag.begin.js - - 2 - - name - entity.name.tag.js - - 3 - - name - punctuation.definition.tag.end.js - - - name - tag.without-attributes.js - patterns - - - include - #jsx-children - - - - known-type-parameters - - begin - (<) - beginCaptures - - 1 - - name - meta.brace.angle.js - - - end - (?=$)|(>) - endCaptures - - 2 - - name - meta.brace.angle.js - - - name - meta.known.type.parameters.ts - patterns - - - match - \b(extends)\b - name - keyword.other.ts - - - include - #comment - - - include - #type - - - - literal - - name - literal.js - patterns - - - include - #numeric-literal - - - include - #boolean-literal - - - include - #null-literal - - - include - #undefined-literal - - - include - #array-literal - - - include - #this-literal - - - - logic-operator - - match - \!|&&|&|~|\^|\|\||\| - name - keyword.operator.arithmetic.js - - method-declaration - - begin - \b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:\b(constructor)\b)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\<) - beginCaptures - - 1 - - name - storage.modifier.js - - 2 - - name - storage.modifier.js - - 3 - - name - storage.modifier.js - - 4 - - name - storage.type.property.js - - 5 - - name - keyword.operator.js - - 6 - - name - storage.type.js - - 7 - - name - entity.name.function.js - - 8 - - name - keyword.operator.js - - - end - (?=\}|;|,)|(?<=\}) - name - meta.method.declaration.js - patterns - - - include - #comment - - - include - #type-parameters - - - include - #function-type-parameters - - - include - #type-annotation - - - include - #method-overload-declaration - - - include - #decl-block - - - - method-overload-declaration - - captures - - 1 - - name - storage.modifier.js - - 2 - - name - storage.modifier.js - - 3 - - name - storage.modifier.js - - 4 - - name - storage.type.property.js - - 5 - - name - keyword.operator.js - - 6 - - name - storage.type.js - - 7 - - name - entity.name.function.js - - 8 - - name - keyword.operator.js - - - match - \b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:\b(constructor)\b)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\<) - name - meta.method.overload.declaration.js - - new-expr - - begin - \b(new)\b - beginCaptures - - 1 - - name - keyword.others.js - - - end - (?=[(;]|$) - name - new.expr.js - patterns - - - include - #type - - - include - #comment - - - - null-literal - - match - \b(null)\b - name - constant.language.null.js - - numeric-literal - - match - \b(?<=[^$])((0(x|X)[0-9a-fA-F]+)|(0(o|O)[0-7]+)|(0(b|B)(0|1)+)|(([0-9]+(\.[0-9]+)?))([eE]([+-]?)[0-9]+(\.[0-9]+)?)?)\b - name - constant.numeric.js - - object-body - - begin - \{ - beginCaptures - - 0 - - name - meta.brace.curly.js - - - end - \} - endCaptures - - 0 - - name - meta.brace.curly.js - - - name - meta.object.body.js - patterns - - - include - #string - - - include - #comment - - - include - #field-declaration - - - include - #method-declaration - - - include - #indexer-declaration - - - include - #type-annotation - - - include - #variable-initializer - - - include - #access-modifier - - - include - #static-modifier - - - include - #property-accessor - - - - object-declaration - - begin - \b(?:(export)\s+)?\b(?:(abstract)\s+)?\b(?<!\.)(class|interface)\b - beginCaptures - - 1 - - name - storage.type.js - - 2 - - name - storage.modifier.js - - 3 - - name - storage.type.js - - - end - (?<=\}) - endCaptures - - 1 - - name - brace.curly.js - - - name - meta.declaration.object.js - patterns - - - include - #comment - - - include - #object-heritage - - - include - #object-name - - - include - #know-type-parameters - - - include - #object-body - - - - object-heritage - - begin - (?:\b(extends|implements)\b) - beginCaptures - - 1 - - name - keyword.other.js - - - end - (?=\{) - endCaptures - - 1 - - name - brace.curly.js - - - name - meta.object.heritage.js - patterns - - - include - #comment - - - include - #object-heritage - - - include - #type-parameters - - - include - #object-heritage-type - - - - object-heritage-type - - captures - - 1 - - name - support.type.js - - - match - (?:\b([a-zA-Z_$][\w$]*)\b) - name - meta.object.heritage.parent.js - - object-member - - begin - [a-zA-Z_$][\w$]*\s*: - end - (?=,|\}) - name - meta.object.member.js - patterns - - - include - #expression - - - - object-name - - captures - - 0 - - name - entity.name.class.js - - - match - [a-zA-Z_$][\w$]* - name - meta.object.name.js - - parameter-name - - captures - - 1 - - name - storage.modifier.js - - 2 - - name - keyword.others.js - - 3 - - name - variable.parameter.js - - 4 - - name - keyword.others.js - - - match - (?:\s*\b(public|private|protected)\b\s+)?(\.\.\.)?\s*([a-zA-Z_$][\w$]*)\s*(\??) - name - parameter.name.js - - paren-expression - - begin - \( - beginCaptures - - 0 - - name - meta.brace.paren.js - - - end - \) - endCaptures - - 0 - - name - meta.brace.paren.js - - - patterns - - - include - #expression - - - - property-accessor - - match - \b(get|set)\b - name - storage.type.property.js - - qstring-double - - begin - " - end - "|(?:[^\\\n]$) - name - string.double.js - patterns - - - include - #string-character-escape - - - - qstring-single - - begin - ' - end - \'|(?:[^\\\n]$) - name - string.single.js - patterns - - - include - #string-character-escape - - - - regex - - begin - (?<=[=(:,\[]|^|return|&&|\|\||!)\s*(/)(?![/*+{}?]) - end - $|(/)[igm]* - name - string.regex.js - patterns - - - match - \\. - name - constant.character.escape.js - - - match - \[(\\\]|[^\]])*\] - name - constant.character.class.js - - - - relational-operator - - match - ===|!==|==|!=|<=|>=|<>|=|<|> - name - keyword.operator.comparison.js - - return-type - - begin - (?<=\))\s*: - end - (?=$)|(?=\{|;|//) - name - meta.return.type.js - patterns - - - include - #type - - - - static-modifier - - match - \b(static)\b - name - keyword.other.js - - storage-keyword - - match - \b(var|let|function|const|module|namespace|void|export)\b - name - storage.type.js - - string - - name - string.js - patterns - - - include - #qstring-single - - - include - #qstring-double - - - - string-character-escape - - match - \\(x\h{2}|[0-2][0-7]{,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.|$) - name - constant.character.escape - - switch-block - - begin - { - end - (?=\}) - name - switch-block.expr.js - patterns - - - include - #expression - - - - switch-expression - - begin - \b(switch)\b\s*\( - beginCaptures - - 1 - - name - keyword.control.js - - - end - \) - name - switch-expression.expr.js - patterns - - - include - #expression - - - - switch-statement - - begin - (?=\bswitch\b\s*\() - end - } - name - switch-statement.expr.js - patterns - - - include - #switch-expression - - - include - #switch-block - - - - template - - begin - ` - beginCaptures - - 0 - - name - string.template.js - - - end - ` - endCaptures - - 0 - - name - string.template.js - - - name - meta.template.js - patterns - - - include - #template-substitution-element - - - include - #template-string-contents - - - - template-string-contents - - begin - .*? - end - (?=(\$\{|`)) - name - string.template.js - patterns - - - include - #string-character-escape - - - - template-substitution-element - - begin - \$\{ - beginCaptures - - 0 - - name - keyword.others.js - - - end - \} - endCaptures - - 0 - - name - keyword.others.js - - - name - template.element.js - patterns - - - include - #expression - - - - ternary-expression - - begin - (?=\?) - end - (?=$|[;,]) - patterns - - - include - #ternary-operator - - - include - #ternary-expression-type - - - - ternary-expression-type - - name - meta.expression.js - patterns - - - include - #string - - - include - #regex - - - include - #template - - - include - #comment - - - include - #literal - - - include - #paren-expression - - - include - #ternary-expression - - - include - #import-operator - - - include - #expression-operator - - - include - #imply-operator - - - include - #relational-operator - - - include - #arithmetic-operator - - - include - #logic-operator - - - include - #assignment-operator - - - include - #type-primitive - - - include - #function-call - - - - ternary-operator - - begin - (\?) - end - (:) - patterns - - - include - #ternary-expression-type - - - - this-literal - - match - \b(this)\b - name - constant.language.this.js - - type - - name - meta.type.js - patterns - - - include - #type-primitive - - - include - #known-type-parameters - - - include - #type-tuple - - - include - #type-object - - - include - #type-operator - - - include - #type-paren-or-function-type-parameters - - - include - #type-function-return-type - - - include - #type-name - - - - type-annotation - - begin - : - end - (?=$|[,);\}\]]|//)|(?==[^>])|(?<=[\}>\]\)]|[a-zA-Z_$])\s*(?=\{) - name - meta.type.annotation.js - patterns - - - include - #expression-operator - - - include - #type - - - include - #string - - - include - #comment - - - - type-declaration - - begin - \b(type)\b\s+([a-zA-Z_$][\w$]*) - beginCaptures - - 1 - - name - keyword.other.js - - 2 - - name - entity.name.class.js - - - end - (?=$|[,);>]|var|type|function|class|interface) - name - meta.type.declaration.js - patterns - - - include - #known-type-parameters - - - include - #type - - - match - =\s* - name - keyword.operator.comparison.js - - - - type-function-return-type - - begin - => - beginCaptures - - 0 - - name - keyword.operator.js - - - end - (?=\s*[,\)\{=;>]|//|$) - name - meta.type.function.return.js - patterns - - - include - #type - - - - type-name - - captures - - 1 - - name - entity.name.type.js - - - match - [a-zA-Z_$][.\w$]* - name - meta.type.name.js - - type-object - - begin - \{ - beginCaptures - - 0 - - name - meta.brace.curly.js - - - end - \} - endCaptures - - 0 - - name - meta.brace.curly.js - - - name - meta.object.type.js - patterns - - - include - #comment - - - include - #field-declaration - - - include - #method-declaration - - - include - #indexer-declaration - - - include - #type-annotation - - - - type-operator - - match - [.|] - name - keyword.operator.type.js - - type-parameters - - begin - ([a-zA-Z_$][\w$]*)?\s*(<)(?=[^<]*(<[^<>]*>)*>\s*[(]) - beginCaptures - - 1 - - name - entity.name.type.js - - 2 - - name - meta.brace.angle.js - - - end - (?=$)|(>) - endCaptures - - 2 - - name - meta.brace.angle.js - - - name - meta.type.parameters.js - patterns - - - match - \b(extends)\b - name - keyword.other.js - - - include - #comment - - - include - #type - - - - type-paren-or-function-type-parameters - - begin - (?:\b(new)\b)?\s*\( - beginCaptures - - 1 - - name - keyword.control.js - - - end - \) - name - meta.type.paren.cover.js - patterns - - - include - #comment - - - include - #type - - - include - #function-type-parameters - - - - type-primitive - - captures - - 1 - - name - support.type.js - - - match - \b(string|number|boolean|symbol|any|void)\b - name - meta.type.primitive.js - - type-tuple - - begin - \[ - beginCaptures - - 0 - - name - meta.brace.square.js - - - end - \] - endCaptures - - 0 - - name - meta.brace.square.js - - - name - meta.type.tuple.js - patterns - - - include - #type - - - include - #comment - - - - undefined-literal - - match - \b(undefined)\b - name - constant.language.js - - var-expr - - begin - (?<!\()\s*\b(var|let|const(?!\s+enum))\b - beginCaptures - - 1 - - name - storage.type.js - - - end - (?=$|;) - name - meta.var.expr.js - patterns - - - include - #var-single-variable - - - include - #comment - - - - var-single-variable - - begin - \b([a-zA-Z_$][\w$]*)\s*(=?) - beginCaptures - - 1 - - name - variable.js - - - end - (?=$|[;,]) - name - meta.var-single-variable.expr.js - patterns - - - include - #ternary-expression - - - include - #type-annotation - - - include - #string - - - include - #comment - - - include - #expression - - - - variable-initializer - - begin - (=) - beginCaptures - - 1 - - name - keyword.operator.comparison.js - - - end - (?=$|[,);=]) - patterns - - - include - #expression - - - - - scopeName - source.js - uuid - 805375ec-d614-41f5-8993-5843fe63ea82 - - \ No newline at end of file diff --git a/extensions/javascript/syntaxes/JavaScript.tmLanguage.json b/extensions/javascript/syntaxes/JavaScript.tmLanguage.json new file mode 100644 index 00000000000..900f46e0178 --- /dev/null +++ b/extensions/javascript/syntaxes/JavaScript.tmLanguage.json @@ -0,0 +1,1526 @@ +{ + "fileTypes": [ + ".js", + ".jsx" + ], + "name": "JavaScript (with React support)", + "patterns": [ + { + "include": "#expression" + } + ], + "repository": { + "access-modifier": { + "match": "\\b(public|protected|private)\\b", + "name": "storage.modifier.js" + }, + "arithmetic-operator": { + "match": "\\*|/|\\-\\-|\\-|\\+\\+|\\+|%", + "name": "keyword.operator.arithmetic.js" + }, + "array-literal": { + "begin": "\\[", + "beginCaptures": { + "0": { + "name": "meta.brace.square.js" + } + }, + "end": "\\]", + "endCaptures": { + "0": { + "name": "meta.brace.square.js" + } + }, + "name": "meta.array.literal.js", + "patterns": [ + { + "include": "#expression" + } + ] + }, + "assignment-operator": { + "match": "<<=|>>>=|>>=|\\*=|(?", + "name": "keyword.operator.js" + }, + "import-operator": { + "match": "\\b(import|from)\\b", + "name": "keyword.control.import.include.js" + }, + "indexer-declaration": { + "begin": "\\[", + "beginCaptures": { + "0": { + "name": "meta.brace.square.js" + } + }, + "end": "(\\])\\s*(\\?\\s*)?|$", + "endCaptures": { + "1": { + "name": "meta.brace.square.js" + }, + "2": { + "name": "keyword.others.js" + } + }, + "name": "meta.indexer.declaration.js", + "patterns": [ + { + "include": "#type-annotation" + }, + { + "include": "#indexer-parameter" + }, + { + "include": "#expression" + } + ] + }, + "indexer-parameter": { + "captures": { + "1": { + "name": "variable.parameter.js" + } + }, + "match": "([a-zA-Z_$][\\w$]*)(?=\\:)", + "name": "meta.indexer.parameter.js" + }, + "jsx": { + "name": "meta.jsx.js", + "patterns": [ + { + "include": "#jsx-tag-without-attributes" + }, + { + "include": "#jsx-tag-open" + }, + { + "include": "#jsx-tag-close" + }, + { + "include": "#jsx-tag-invalid" + }, + { + "begin": "(?<=(?:'|\"|})>)", + "end": "(?=|/\\*|//)", + "name": "meta.tag.attribute-name.js" + }, + "jsx-tag-attributes": { + "patterns": [ + { + "include": "#jsx-tag-attribute-name" + }, + { + "include": "#jsx-tag-attribute-assignment" + }, + { + "include": "#jsx-string-double-quoted" + }, + { + "include": "#jsx-string-single-quoted" + }, + { + "include": "#jsx-evaluated-code" + } + ] + }, + "jsx-tag-attributes-illegal": { + "match": "\\S+", + "name": "invalid.illegal.attribute.js" + }, + "jsx-tag-close": { + "begin": "()", + "endCaptures": { + "1": { + "name": "punctuation.definition.tag.end.js" + } + }, + "name": "tag.close.js", + "patterns": [ + { + "include": "#comment" + } + ] + }, + "jsx-tag-invalid": { + "match": "<\\s*>", + "name": "invalid.illegal.tag.incomplete.js" + }, + "jsx-tag-open": { + "begin": "(?x)\n (<)\n ([_$a-zA-Z][-$\\w.]*(?)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.tag.begin.js" + }, + "2": { + "name": "entity.name.tag.js" + } + }, + "end": "(/?>)", + "endCaptures": { + "1": { + "name": "punctuation.definition.tag.end.js" + } + }, + "name": "tag.open.js", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#jsx-tag-attributes" + }, + { + "include": "#jsx-tag-attributes-illegal" + } + ] + }, + "jsx-tag-without-attributes": { + "begin": "(<)([_$a-zA-Z][-$\\w.]*(?)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.tag.begin.js" + }, + "2": { + "name": "entity.name.tag.js" + }, + "3": { + "name": "punctuation.definition.tag.end.js" + } + }, + "end": "()", + "endCaptures": { + "1": { + "name": "punctuation.definition.tag.begin.js" + }, + "2": { + "name": "entity.name.tag.js" + }, + "3": { + "name": "punctuation.definition.tag.end.js" + } + }, + "name": "tag.without-attributes.js", + "patterns": [ + { + "include": "#jsx-children" + } + ] + }, + "literal": { + "name": "literal.js", + "patterns": [ + { + "include": "#numeric-literal" + }, + { + "include": "#boolean-literal" + }, + { + "include": "#null-literal" + }, + { + "include": "#undefined-literal" + }, + { + "include": "#array-literal" + }, + { + "include": "#this-literal" + } + ] + }, + "logic-operator": { + "match": "\\!|&&|&|~|\\^|\\|\\||\\|", + "name": "keyword.operator.arithmetic.js" + }, + "method-declaration": { + "begin": "\\b(?:(abstract)\\s+)?\\b(?:(public|private|protected)\\s+)?\\b(?:(async)\\s+)?(?:(get|set)\\s+)?(?:(new)|(?:\\b(constructor)\\b)|(?:([a-zA-Z_$][\\.\\w$]*)\\s*(\\??)))?\\s*(?=\\(|\\<)", + "beginCaptures": { + "1": { + "name": "storage.modifier.js" + }, + "2": { + "name": "storage.modifier.js" + }, + "3": { + "name": "storage.modifier.js" + }, + "4": { + "name": "storage.type.property.js" + }, + "5": { + "name": "keyword.operator.js" + }, + "6": { + "name": "storage.type.js" + }, + "7": { + "name": "entity.name.function.js" + }, + "8": { + "name": "keyword.operator.js" + } + }, + "end": "(?=\\}|;|,)|(?<=\\})", + "name": "meta.method.declaration.js", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#type-parameters" + }, + { + "include": "#function-type-parameters" + }, + { + "include": "#type-annotation" + }, + { + "include": "#method-overload-declaration" + }, + { + "include": "#decl-block" + } + ] + }, + "method-overload-declaration": { + "captures": { + "1": { + "name": "storage.modifier.js" + }, + "2": { + "name": "storage.modifier.js" + }, + "3": { + "name": "storage.modifier.js" + }, + "4": { + "name": "storage.type.property.js" + }, + "5": { + "name": "keyword.operator.js" + }, + "6": { + "name": "storage.type.js" + }, + "7": { + "name": "entity.name.function.js" + }, + "8": { + "name": "keyword.operator.js" + } + }, + "match": "\\b(?:(abstract)\\s+)?\\b(?:(public|private|protected)\\s+)?\\b(?:(async)\\s+)?(?:(get|set)\\s+)?(?:(new)|(?:\\b(constructor)\\b)|(?:([a-zA-Z_$][\\.\\w$]*)\\s*(\\??)))?\\s*(?=\\(|\\<)", + "name": "meta.method.overload.declaration.js" + }, + "new-expr": { + "begin": "\\b(new)\\b", + "beginCaptures": { + "1": { + "name": "keyword.others.js" + } + }, + "end": "(?=[(;]|$)", + "name": "new.expr.js", + "patterns": [ + { + "include": "#type" + }, + { + "include": "#comment" + } + ] + }, + "null-literal": { + "match": "\\b(null)\\b", + "name": "constant.language.null.js" + }, + "numeric-literal": { + "match": "\\b(?<=[^$])((0(x|X)[0-9a-fA-F]+)|(0(o|O)[0-7]+)|(0(b|B)(0|1)+)|(([0-9]+(\\.[0-9]+)?))([eE]([+-]?)[0-9]+(\\.[0-9]+)?)?)\\b", + "name": "constant.numeric.js" + }, + "object-body": { + "begin": "\\{", + "beginCaptures": { + "0": { + "name": "meta.brace.curly.js" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "meta.brace.curly.js" + } + }, + "name": "meta.object.body.js", + "patterns": [ + { + "include": "#string" + }, + { + "include": "#comment" + }, + { + "include": "#field-declaration" + }, + { + "include": "#method-declaration" + }, + { + "include": "#indexer-declaration" + }, + { + "include": "#type-annotation" + }, + { + "include": "#variable-initializer" + }, + { + "include": "#access-modifier" + }, + { + "include": "#static-modifier" + }, + { + "include": "#property-accessor" + } + ] + }, + "object-declaration": { + "begin": "\\b(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(?=|<>|=|<|>", + "name": "keyword.operator.comparison.js" + }, + "return-type": { + "begin": "(?<=\\))\\s*:", + "end": "(?=$)|(?=\\{|;|//)", + "name": "meta.return.type.js", + "patterns": [ + { + "include": "#type" + } + ] + }, + "static-modifier": { + "match": "\\b(static)\\b", + "name": "keyword.other.js" + }, + "storage-keyword": { + "match": "\\b(var|let|function|const|module|namespace|void|export)\\b", + "name": "storage.type.js" + }, + "string": { + "name": "string.js", + "patterns": [ + { + "include": "#qstring-single" + }, + { + "include": "#qstring-double" + } + ] + }, + "string-character-escape": { + "match": "\\\\(x\\h{2}|[0-2][0-7]{,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.|$)", + "name": "constant.character.escape" + }, + "switch-block": { + "begin": "{", + "end": "(?=\\})", + "name": "switch-block.expr.js", + "patterns": [ + { + "include": "#expression" + } + ] + }, + "switch-expression": { + "begin": "\\b(switch)\\b\\s*\\(", + "beginCaptures": { + "1": { + "name": "keyword.control.js" + } + }, + "end": "\\)", + "name": "switch-expression.expr.js", + "patterns": [ + { + "include": "#expression" + } + ] + }, + "switch-statement": { + "begin": "(?=\\bswitch\\b\\s*\\()", + "end": "}", + "name": "switch-statement.expr.js", + "patterns": [ + { + "include": "#switch-expression" + }, + { + "include": "#switch-block" + } + ] + }, + "template": { + "begin": "`", + "beginCaptures": { + "0": { + "name": "string.template.js" + } + }, + "end": "`", + "endCaptures": { + "0": { + "name": "string.template.js" + } + }, + "name": "meta.template.js", + "patterns": [ + { + "include": "#template-substitution-element" + }, + { + "include": "#template-string-contents" + } + ] + }, + "template-string-contents": { + "begin": ".*?", + "end": "(?=(\\$\\{|`))", + "name": "string.template.js", + "patterns": [ + { + "include": "#string-character-escape" + } + ] + }, + "template-substitution-element": { + "begin": "\\$\\{", + "beginCaptures": { + "0": { + "name": "keyword.others.js" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "keyword.others.js" + } + }, + "name": "template.element.js", + "patterns": [ + { + "include": "#expression" + } + ] + }, + "ternary-expression": { + "begin": "(?=\\?)", + "end": "(?=$|[;,])", + "patterns": [ + { + "include": "#ternary-operator" + }, + { + "include": "#expression-type" + } + ] + }, + "ternary-operator": { + "begin": "(\\?)", + "end": "(:)", + "patterns": [ + { + "include": "#expression-type" + } + ] + }, + "this-literal": { + "match": "\\b(this)\\b", + "name": "constant.language.this.js" + }, + "type": { + "name": "meta.type.js", + "patterns": [ + { + "include": "#type-primitive" + }, + { + "include": "#type-parameters" + }, + { + "include": "#type-tuple" + }, + { + "include": "#type-object" + }, + { + "include": "#type-operator" + }, + { + "include": "#type-paren-or-function-type-parameters" + }, + { + "include": "#type-function-return-type" + }, + { + "include": "#type-name" + } + ] + }, + "type-annotation": { + "begin": ":", + "end": "(?=$|[,);\\}\\]]|//)|(?==[^>])|(?<=[\\}>\\]\\)]|[a-zA-Z_$])\\s*(?=\\{)", + "name": "meta.type.annotation.js", + "patterns": [ + { + "include": "#expression-operator" + }, + { + "include": "#type" + }, + { + "include": "#string" + }, + { + "include": "#comment" + } + ] + }, + "type-declaration": { + "begin": "\\b(type)\\b\\s+([a-zA-Z_$][\\w$]*)\\s*", + "beginCaptures": { + "1": { + "name": "keyword.other.js" + }, + "2": { + "name": "entity.name.class.js" + } + }, + "end": "(?=$|[,);>]|var|type|function|class|interface)", + "name": "meta.type.declaration.js", + "patterns": [ + { + "include": "#type-parameters" + }, + { + "include": "#type" + }, + { + "match": "=\\s*", + "name": "keyword.operator.comparison.js" + } + ] + }, + "type-function-return-type": { + "begin": "=>", + "beginCaptures": { + "0": { + "name": "keyword.operator.js" + } + }, + "end": "(?=\\s*[,\\)\\{=;>]|//|$)", + "name": "meta.type.function.return.js", + "patterns": [ + { + "include": "#type" + } + ] + }, + "type-name": { + "captures": { + "1": { + "name": "entity.name.type.js" + } + }, + "match": "[a-zA-Z_$][.\\w$]*", + "name": "meta.type.name.js" + }, + "type-object": { + "begin": "\\{", + "beginCaptures": { + "0": { + "name": "meta.brace.curly.js" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "meta.brace.curly.js" + } + }, + "name": "meta.object.type.js", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#field-declaration" + }, + { + "include": "#method-declaration" + }, + { + "include": "#indexer-declaration" + }, + { + "include": "#type-annotation" + } + ] + }, + "type-operator": { + "match": "[.|]", + "name": "keyword.operator.type.js" + }, + "type-parameters": { + "begin": "DO_NOT_MATCH", + "beginCaptures": { + "1": { + "name": "entity.name.type.js" + }, + "2": { + "name": "meta.brace.angle.js" + } + }, + "end": "(?=$)|(>)", + "endCaptures": { + "2": { + "name": "meta.brace.angle.js" + } + }, + "name": "meta.type.parameters.js", + "patterns": [ + { + "match": "\\b(extends)\\b", + "name": "keyword.other.js" + }, + { + "include": "#comment" + }, + { + "include": "#type" + } + ] + }, + "type-paren-or-function-type-parameters": { + "begin": "(?:\\b(new)\\b)?\\s*\\(", + "beginCaptures": { + "1": { + "name": "keyword.control.js" + } + }, + "end": "\\)", + "name": "meta.type.paren.cover.js", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#type" + }, + { + "include": "#function-type-parameters" + } + ] + }, + "type-primitive": { + "captures": { + "1": { + "name": "support.type.js" + } + }, + "match": "\\b(string|number|boolean|symbol|any|void)\\b", + "name": "meta.type.primitive.js" + }, + "type-tuple": { + "begin": "\\[", + "beginCaptures": { + "0": { + "name": "meta.brace.square.js" + } + }, + "end": "\\]", + "endCaptures": { + "0": { + "name": "meta.brace.square.js" + } + }, + "name": "meta.type.tuple.js", + "patterns": [ + { + "include": "#type" + }, + { + "include": "#comment" + } + ] + }, + "undefined-literal": { + "match": "\\b(undefined)\\b", + "name": "constant.language.js" + }, + "var-expr": { + "begin": "(? .js +To update to the latest version: +- `cd extensions/typescript` and run `npm run update-grammars` +- don't forget to run the integration tests at `./scripts/test-integration.sh` + +The script does the following changes: +- fileTypes .tsx -> .js & .jsx - scopeName scope.tsx -> scope.js -- update language name and file types +- update all rule names .tsx -> .js