From 2b3608cd8b555e3e16df5585e11543085658afbd Mon Sep 17 00:00:00 2001 From: Thomas Smith Date: Wed, 10 May 2023 11:13:19 -0400 Subject: [PATCH] Rebase from JS Custom 4.3.0 --- JavaScript (Babel).sublime-syntax | 5385 ++++++++++++----------- Styled Components.sublime-syntax | 29 +- tests/syntax_test_flow.js | 2 +- tests/syntax_test_js.js | 112 +- tests/syntax_test_js_bindings.js | 21 +- tests/syntax_test_js_class.js | 14 +- tests/syntax_test_js_control.js | 5 +- tests/syntax_test_js_import_export.js | 29 +- tests/syntax_test_js_indent_common.js | 979 ++++ tests/syntax_test_js_jsdoc.js | 2 +- tests/syntax_test_js_not_typescript.js | 2 +- tests/syntax_test_js_regexp.js | 28 +- tests/syntax_test_js_support_builtin.js | 2 +- tests/syntax_test_js_support_console.js | 2 +- tests/syntax_test_js_support_dom.js | 2 +- tests/syntax_test_js_support_node.js | 2 +- tests/syntax_test_jsx.jsx | 2 +- tests/syntax_test_string_object_keys.js | 2 +- 18 files changed, 3933 insertions(+), 2687 deletions(-) create mode 100644 tests/syntax_test_js_indent_common.js diff --git a/JavaScript (Babel).sublime-syntax b/JavaScript (Babel).sublime-syntax index 5ee56d1..dd26585 100644 --- a/JavaScript (Babel).sublime-syntax +++ b/JavaScript (Babel).sublime-syntax @@ -1,70 +1,121 @@ %YAML 1.2 --- -name: JavaScript (Babel) +first_line_match: |- + (?xi: + ^ \s* // .*? -\*- .*? \bjsx\b .*? -\*- # editorconfig + ) contexts: - parenthesized-expression: - - match: \( - scope: punctuation.section.group.begin.js + export-brace: + - meta_scope: meta.block.js + - include: comma-separator + - match: \} + scope: punctuation.section.block.end.js + pop: 1 + - match: '{{identifier_name}}' + scope: variable.other.readwrite.js + push: import-export-alias + - match: \* + scope: constant.other.js + push: import-export-alias + - include: else-pop + + variable-binding-pattern: + - match: '' set: - - meta_scope: meta.group.js - - match: \) - scope: punctuation.section.group.end.js + - - include: flow-type-annotation + - - include: variable-binding-name + - include: variable-binding-array-destructuring + - include: variable-binding-object-destructuring + - include: else-pop + + flow-type-module-meta: + - meta_scope: meta.module.js + - include: immediately-pop + + object-property-base: + - match: '{{dollar_only_identifier}}' + scope: meta.property.object.dollar.only.js punctuation.dollar.js + pop: 1 + - match: '{{dollar_identifier}}' + scope: meta.property.object.dollar.js + captures: + 1: punctuation.dollar.js + pop: 1 + - match: '{{identifier_name}}' + scope: meta.property.object.js + pop: 1 + - match: '{{identifier_part}}+{{identifier_break}}' + scope: invalid.illegal.illegal-identifier.js + pop: 1 + - match: (#)({{identifier_name}}) + captures: + 1: punctuation.definition.variable.js + 2: meta.property.object.js + pop: 1 + + regexp-complete: + - match: / + scope: punctuation.definition.string.begin.js + set: regexp + + flow-type-tuple: + - match: \[ + scope: punctuation.section.brackets.begin.js + set: + - meta_scope: meta.sequence.js + - match: \] + scope: punctuation.section.brackets.end.js pop: true - - match: (?=:) - push: flow-type-annotation - - match: (?=\S) - push: expression + - include: flow-type-list + + support-property-node-module: + - match: (?:children|exports|filename|id|loaded|parent|paths){{identifier_break}} + scope: support.constant.node.js + pop: 1 + - match: require{{identifier_break}} + scope: support.function.node.js + pop: 1 expression-end-no-comma: - match: (?=,) - pop: true + pop: 1 - include: expression-end - export-statement: - - match: export{{identifier_break}} - scope: keyword.control.import-export.js - set: - - export-meta - - export-extended - - immediately-pop-2: - - meta_include_prototype: false - - match: '' - pop: 2 + block-scope: + - include: block + - include: else-pop - line-comment-double-slash-body: - - meta_include_prototype: false - - meta_scope: comment.line.double-slash.js - - include: line-comment-end + import-item: + - include: flow-type-import-type - function-parameter-binding-object-key: - - match: '{{identifier_name}}(?=\s*:)' - pop: true - - include: literal-string - - include: computed-property-name - - include: function-parameter-binding-name + - match: \{ + scope: punctuation.section.block.begin.js + set: import-brace + - match: '{{non_reserved_identifier}}' + scope: variable.other.readwrite.js + pop: 1 + - match: \* + scope: constant.other.js + pop: 1 - include: else-pop - import-export-alias: - - match: as{{identifier_break}} - scope: keyword.control.import-export.js - set: - - match: default{{identifier_break}} - scope: keyword.control.import-export.js - pop: true - - match: '{{identifier_name}}' - scope: variable.other.readwrite.js - pop: true - - include: else-pop - - include: else-pop + await-expression: + - match: await{{identifier_break}} + scope: keyword.control.flow.await.js - support-property-node-process: - - match: (?:arch|argv|argv0|channel|config|connected|debugPort|env|execArgv|execPath|exitCode|mainModule|noDeprecation|pid|platform|ppid|release|stderr|stdin|stdout|throwDeprecation|title|traceDeprecation|version|versions){{identifier_break}} - scope: support.constant.node.js - pop: true - - match: (?:abort|chdir|cpuUsage|cwd|disconnect|dlopen|emitWarning|exit|getegid|geteuid|getgit|getgroups|getuid|hasUncaughtExceptionCaptureCallback|hrtime|initGroups|kill|memoryUsage|nextTick|send|setegid|seteuid|setgid|setgroups|setuid|hasUncaughtExceptionCaptureCallback|umask|uptime){{identifier_break}} - scope: support.function.node.js - pop: true + flow-type-import-type: + - match: type{{identifier_break}} + scope: keyword.declaration.js + + - match: typeof{{identifier_break}} + scope: keyword.operator.js + + arrow-function-expect-arrow-or-fail-async: + - match: => + scope: keyword.declaration.function.arrow.js + pop: 1 + - match: (?=\S) + fail: async-arrow-function support: - include: support-variable-ecma @@ -72,275 +123,520 @@ contexts: - include: support-variable-dom - include: support-variable-node - literal-variable-base: - - match: '{{dollar_only_identifier}}' - scope: variable.other.dollar.only.js punctuation.dollar.js - pop: true + styled-components: + - match: (?=(?:styled|css|createGlobalStyle|injectGlobal){{identifier_break}}) + set: + - styled-component-end + - styled-component-begin + - match: (?=keyframes{{identifier_break}}) + set: + - styled-component-keyframes-end + - styled-component-begin + function-parameter-binding-name: - match: '{{dollar_identifier}}' - scope: variable.other.dollar.js + scope: meta.binding.name.js variable.parameter.function.js captures: 1: punctuation.dollar.js - pop: true - - match: '{{constant_identifier}}' - scope: variable.other.constant.js - pop: true + - match: '{{non_reserved_identifier}}' + scope: meta.binding.name.js variable.parameter.function.js - match: '{{identifier_name}}' - scope: variable.other.readwrite.js - pop: true - - include: literal-private-variable - - block-comments: - # empty block comments - - match: /\*\*+/ - scope: comment.block.empty.js punctuation.definition.comment.js - # documentation block comments - - match: /\*\*+ - scope: punctuation.definition.comment.begin.js - push: - - jsdoc-comment-body - - jsdoc-block-tag - # normal block comments - - match: /\* - scope: punctuation.definition.comment.begin.js - push: block-comment-body - - catch-meta: - - meta_include_prototype: false - - meta_scope: meta.catch.js - - include: immediately-pop + scope: invalid.illegal.identifier.js meta.binding.name.js variable.parameter.function.js - flow-type-list: - - include: comma-separator - - match: (?=\S) - push: flow-type + flow-type-typeof: + - match: typeof{{identifier_break}} + scope: keyword.operator.js + set: + - left-expression-end + - expression-begin - ternary-operator: - - match: \?(?=[^.]|\.[0-9]) - scope: keyword.operator.ternary.js + new-target: + - match: \. + scope: punctuation.accessor.dot.js set: - - ternary-operator-expect-colon - - expression-no-comma + - match: target{{identifier_break}} + scope: variable.language.target.js + pop: 1 + - include: else-pop - expect-semicolon: - - match: \; - scope: punctuation.terminator.statement.js - pop: true - include: else-pop - flow-type-generic-parameters: - - match: < - scope: punctuation.definition.generic.begin.js + async-arrow-function: + - match: async{{identifier_break}} + scope: keyword.declaration.async.js set: - - meta_scope: meta.generic.declaration.js - - match: '>' - scope: punctuation.definition.generic.end.js - pop: true - - include: comma-separator - - match: \+ - scope: storage.modifier.variance.js - - match: '{{non_reserved_identifier}}' - scope: variable.parameter.type.js - push: - - - match: '=' - scope: keyword.operator.assignment.js - set: flow-type - - include: else-pop - - flow-type-annotation - - include: else-pop + - function-meta + - arrow-function-expect-body + - arrow-function-expect-arrow-or-fail-async + - arrow-function-expect-parameters - call-function-name: - - match: '{{dollar_only_identifier}}' - scope: variable.function.js variable.other.dollar.only.js punctuation.dollar.js - pop: true - - match: '{{identifier_name}}' - scope: variable.function.js - pop: true + expression-statement-end: + - match: '{{line_ending_ahead}}' + branch_point: expression-statement-continuation + branch: + - expression-statement-continuation + - expression-statement-pop + - include: expression-end + + arrow-function-declaration: + - meta_include_prototype: false + - match: '' + set: + - function-meta + - arrow-function-expect-body + - arrow-function-expect-arrow + - flow-arrow-function-return-type-annotation + - arrow-function-expect-parameters + - flow-type-generic-parameters + + line-comment-double-slash-body: + - meta_include_prototype: false + - meta_scope: comment.line.double-slash.js + - include: line-comment-end + + catch-binding: + - match: \( + scope: punctuation.section.group.begin.js + set: + - catch-binding-end + - variable-binding-pattern - include: else-pop - support-property-ecma-promise: - - match: (?:all|race|reject|resolve|allSettled|any){{identifier_break}} - scope: support.function.builtin.js - pop: true + object-literal-meta-key: + - meta_scope: meta.mapping.key.js + - include: else-pop - jsx-tag-attributes: - - meta_scope: meta.tag.attributes.js + class-name: + - match: '{{non_reserved_identifier}}' + scope: entity.name.class.js + set: flow-type-generic-parameters + - include: else-pop - - match: '>' - scope: punctuation.definition.tag.end.js - set: jsx-body + import-expression-end: + - match: (?=\() + set: function-call-arguments + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - match: meta{{identifier_break}} + scope: variable.language.import.js + pop: 1 + - include: object-property + - include: else-pop + expect-label: + - meta_include_prototype: false + - match: (?={{nothing}}{{identifier_name}}) + set: + - match: '{{non_reserved_identifier}}' + scope: variable.label.js + pop: 1 + - match: '{{identifier_name}}' + scope: invalid.illegal.identifier.js variable.label.js + pop: 1 + - include: else-pop + - include: immediately-pop - - match: / - scope: punctuation.definition.tag.end.js - set: jsx-expect-tag-end + special-name: + - match: true{{identifier_break}} + scope: constant.language.boolean.true.js + pop: 1 + - match: false{{identifier_break}} + scope: constant.language.boolean.false.js + pop: 1 + - match: null{{identifier_break}} + scope: constant.language.null.js + pop: 1 + - match: super{{identifier_break}} + scope: variable.language.super.js + pop: 1 + - match: this{{identifier_break}} + scope: variable.language.this.js + pop: 1 - - include: jsx-interpolation + class-body: + - match: \{ + scope: punctuation.section.block.begin.js + set: class-body-contents - - match: '{{jsx_identifier}}' - scope: entity.other.attribute-name.js + - include: else-pop + + constructor: + - match: new{{identifier_break}} + scope: keyword.operator.word.new.js + set: + - match: (?=\s*\.) + set: new-target + - match: (?=\s*\S) + set: + - constructor-meta + - constructor-body-expect-arguments + - constructor-body-expect-class-end + - constructor-body-expect-class-begin + + flow-type-meta: + - meta_scope: meta.flow-type.js + - include: immediately-pop + + immediately-pop: + - match: '' + pop: 1 + + variable-binding-array-destructuring: + - match: \[ + scope: punctuation.section.sequence.begin.js + set: + - meta_scope: meta.binding.destructuring.sequence.js + - match: \] + scope: punctuation.section.sequence.end.js + pop: 1 + - include: variable-binding-spread + - include: variable-binding-list + + class-element-modifier: + - match: '{{modifier}}' + scope: storage.modifier.js + set: + - match: (?={{class_element_name}}|\*) + pop: 1 + - match: (?=\S) + fail: class-element-modifier + comments: + - include: line-comments + - include: block-comments + + initializer: - match: '=' - scope: punctuation.separator.key-value.js - push: jsx-attribute-value + scope: keyword.operator.assignment.js + set: expression-no-comma + - include: else-pop - import-list: - - match: ',' - scope: punctuation.separator.comma.js - push: - - import-export-alias - - import-item + flow-type-module-body: + - match: \{ + scope: punctuation.section.block.begin.js + set: flow-type-module-contents - include: else-pop - field-name: + expression-statement-continuation: + - match: (?=\+\+|--) + fail: expression-statement-continuation + - match: |- + (?x) + (?= + != + | [-+*/%><=&|^\[(;,.:?] + | (?:in|instanceof){{identifier_break}} + ) + pop: 1 + - match: (?=\S) + fail: expression-statement-continuation + + support-property-ecma-typedarray: + - match: (?:BYTES_PER_ELEMENT){{identifier_break}} + scope: support.constant.builtin.js + pop: 1 + + variable-binding-object-alias: + - match: ':' + scope: punctuation.separator.key-value.js + set: variable-binding-pattern + - include: else-pop + + constructor-meta: + - meta_include_prototype: false + - meta_scope: meta.function-call.constructor.js + - include: immediately-pop + + variable-binding-name: + - match: (?={{non_reserved_identifier}}) + set: + - - meta_scope: meta.binding.name.js + - include: immediately-pop + - literal-variable + + else-pop-2: + - match: (?=\S) + pop: 2 + + jsx-tag-name: + - meta_include_prototype: false + - match: '' + set: + - jsx-tag-name-meta + - jsx-tag-name-end + - jsx-tag-name-component-possibly-native + + static-block: + - match: static{{identifier_break}} + scope: storage.modifier.js + set: + - match: \{ + scope: punctuation.section.block.begin.js + set: static-block-body + - match: (?=\S) + fail: static-block + + function-parameter-binding-spread: + - match: \.\.\. + scope: keyword.operator.spread.js + push: function-parameter + + expression-list: + - include: expression-break + - include: comma-separator + - match: (?=\S) + push: expression-no-comma + + jsx-html-escapes: + - match: (&)#?[[:alnum:]]+(;) + scope: constant.character.escape.js + captures: + 1: punctuation.definition.entity.js + 2: punctuation.definition.entity.js + + catch-binding-end: + - meta_scope: meta.group.js + - match: \) + scope: punctuation.section.group.end.js + pop: 1 + + variable-declaration: + - match: (?:const|let|var){{identifier_break}} + scope: keyword.declaration.js + set: + - expect-semicolon + - variable-binding-list-top + - variable-binding-top + + method-name: - match: '{{dollar_identifier}}' - scope: meta.mapping.key.dollar.js variable.other.readwrite.js + scope: meta.mapping.key.dollar.js entity.name.function.js captures: 1: punctuation.dollar.js - pop: true + pop: 1 - match: '{{identifier_name}}' - scope: variable.other.readwrite.js - pop: true + scope: entity.name.function.js + pop: 1 + - match: (#){{identifier_name}} + scope: entity.name.function.js + captures: + 1: punctuation.definition.js + pop: 1 - match: "'" scope: punctuation.definition.string.begin.js set: - meta_include_prototype: false - meta_scope: meta.string.js string.quoted.single.js - - meta_content_scope: variable.other.readwrite.js + - meta_content_scope: entity.name.function.js - match: \' scope: punctuation.definition.string.end.js - pop: true + pop: 1 - match: \n scope: invalid.illegal.newline.js - pop: true + pop: 1 - include: string-content - match: '"' scope: punctuation.definition.string.begin.js set: - meta_include_prototype: false - meta_scope: meta.string.js string.quoted.double.js - - meta_content_scope: variable.other.readwrite.js + - meta_content_scope: entity.name.function.js - match: \" scope: punctuation.definition.string.end.js - pop: true + pop: 1 - match: \n scope: invalid.illegal.newline.js - pop: true + pop: 1 - include: string-content - - match: (#)({{identifier_name}}) - captures: - 1: punctuation.definition.variable.js - 2: variable.other.readwrite.js - - match: (?=\[) - push: computed-property-name + - include: computed-property-name - include: else-pop - variable-binding-array-destructuring: - - match: \[ - scope: punctuation.section.brackets.begin.js + flow-type-object-indexer-label: + - match: ({{non_reserved_identifier}})\s*(:) + captures: + 1: meta.object-literal.key.js + 2: punctuation.separator.key-value.js + pop: true + - include: else-pop + + postfix-operators: + - match: -- + scope: keyword.operator.arithmetic.js + - match: \+\+ + scope: keyword.operator.arithmetic.js + + function-parameter-binding-object-destructuring: + - match: \{ + scope: punctuation.section.mapping.begin.js set: - - meta_scope: meta.binding.destructuring.sequence.js - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - include: variable-binding-spread - - include: variable-binding-list + - meta_scope: meta.binding.destructuring.mapping.js + - match: ',' + scope: punctuation.separator.parameter.function.js + - match: \} + scope: punctuation.section.mapping.end.js + pop: 1 + - include: function-parameter-binding-spread + - match: (?={{identifier_start}}|\[|'|") + push: + - initializer + - function-parameter-binding-object-alias + - object-literal-meta-key + - function-parameter-binding-object-key - import-statement: - - match: import{{identifier_break}} + flow-arrow-return-type: + - match: '' + push: + - flow-detect-arrow-after-return-type + - flow-arrow-function-return-type-annotation + + support-property-ecma-bigint: + - match: (?:asUintN|asIntN){{identifier_break}} + scope: support.function.builtin.js + pop: 1 + + export-statement: + - match: export{{identifier_break}} scope: keyword.control.import-export.js set: - - import-meta - - expect-semicolon - - import-string-or-items - - import-check-branch + - export-meta + - export-extended - class-element: - - match: '' + for-of-rest: + - match: (?:of|in){{identifier_break}} + scope: keyword.operator.word.js + set: expression + + class-field-check: + - match: (?=[(<]) + fail: class-field + - include: else-pop + + import-brace: + - include: flow-type-import-type + + - meta_scope: meta.block.js + - include: comma-separator + - match: \} + scope: punctuation.section.block.end.js + pop: 1 + - match: '{{identifier_name}}' + scope: variable.other.readwrite.js + push: import-export-alias + - match: \* + scope: constant.other.js + push: import-export-alias + - include: else-pop + + import-export-alias: + - match: as{{identifier_break}} + scope: keyword.control.import-export.js + set: + - match: default{{identifier_break}} + scope: keyword.control.import-export.js + pop: 1 + - match: '{{identifier_name}}' + scope: variable.other.readwrite.js + pop: 1 + - include: literal-string + - include: else-pop + - include: else-pop + + flow-type-special: + - match: any{{identifier_break}} + scope: support.type.any.js pop: true - branch_point: class-field - branch: - - class-field - - method-declaration - decorator-expression-begin: - - include: decorator-name - - include: expression-begin + - match: mixed{{identifier_break}} + scope: support.type.mixed.js + pop: true - try-meta: + left-expression-end: + - include: expression-break + + - match: (?=`) + push: literal-string-template + + - match: (?=(?:{{dot_accessor}})?\() + push: function-call-arguments + + - include: property-access + + - include: else-pop + + do-while-meta: - meta_include_prototype: false - - meta_scope: meta.try.js + - meta_scope: meta.do-while.js - include: immediately-pop - expression-end-no-in: - - match: (?=in{{identifier_break}}) - pop: true - - include: expression-end + function-declaration: + - match: '' + set: + - function-meta + - function-declaration-expect-body + - flow-type-annotation + - function-declaration-expect-parameters + - flow-type-generic-parameters + - function-declaration-expect-name + - function-declaration-expect-generator-star + - function-declaration-expect-function-keyword + - function-declaration-expect-async - flow-type-alias: - - match: (?=type{{identifier_break}}) + - match: extends{{identifier_break}} + scope: storage.modifier.extends.js set: - - - match: (?={{non_reserved_identifier}}) - set: - - - meta_scope: meta.declaration.type.js - - match: '' - pop: true - - flow-type-alias-initializer - - flow-type-generic-parameters - - - match: '{{non_reserved_identifier}}' - scope: entity.name.type.js - pop: true - - - include: else-pop + - inherited-class-expression-end + - inherited-class-expression-begin + - include: else-pop - - match: (?=\S) - set: [expression-statement, expression-end] - - - match: type{{identifier_break}}(?=\s*(?:$|{{non_reserved_identifier}})) - scope: keyword.declaration.js - set: - - meta_scope: meta.declaration.type.js - - include: else-pop - - include: expression-begin + function-parameter: + - match: '' + set: + - initializer + - function-parameter-binding-pattern - for-oldstyle-rest: - - match: (?=\)) + flow-arrow-function-return-type-annotation: + - match: ':' + scope: punctuation.separator.type.js + set: + - flow-type-meta + - flow-type-end-no-arrow + - flow-type-begin + - match: (?!\s*(?:$|:|//|/\*)) pop: true - - match: ; - scope: punctuation.separator.expression.js - - match: (?=\S) - push: expression - flow-arrow-function-declaration-with-type-parameters: [] - expression-list: - - include: expression-break - - include: comma-separator + expression-statement: - match: (?=\S) - push: expression-no-comma + set: + - expect-semicolon + - expression-statement-end + - expression-begin - prefix-operators: - - match: '~' - scope: keyword.operator.bitwise.js - - match: '!(?!=)' - scope: keyword.operator.logical.js - - match: -- - scope: keyword.operator.arithmetic.js - - match: \+\+ - scope: keyword.operator.arithmetic.js - - match: \.\.\. - scope: keyword.operator.spread.js - - match: \+|\- - scope: keyword.operator.arithmetic.js - - match: (?:delete|typeof|void){{identifier_break}} - scope: keyword.operator.js + flow-type-object: + - match: \{\| + scope: punctuation.section.block.begin.js + set: + - meta_scope: meta.type.object.exact.js + - match: \|\} + scope: punctuation.section.block.end.js + pop: true + - include: flow-type-object-contents - variable-declaration: - - match: (?:const|let|var){{identifier_break}} - scope: keyword.declaration.js + - match: \{ + scope: punctuation.section.block.begin.js set: - - expect-semicolon - - variable-binding-list-top - - variable-binding-top + - meta_scope: meta.type.object.js + - match: \} + scope: punctuation.section.block.end.js + pop: true + - include: flow-type-object-contents - prefixed-object-literal-method: + detect-arrow: + - match: (?==>) + fail: arrow-function + - include: else-pop + + prefixed-method: - match: (?:get|set){{identifier_break}} scope: storage.type.accessor.js set: @@ -348,7 +644,7 @@ contexts: - match: (?={{class_element_name}}) set: method-declaration - match: (?=\S) - fail: prefixed-object-literal-method + fail: prefixed-method - match: (?:async){{identifier_break}} scope: keyword.declaration.async.js set: @@ -356,631 +652,223 @@ contexts: - match: (?=\*|{{class_element_name}}) set: method-declaration - match: (?=\S) - fail: prefixed-object-literal-method + fail: prefixed-method - do-while-condition: - - match: while{{identifier_break}} - scope: keyword.control.loop.while.js - set: parenthesized-expression - - include: else-pop + builtin-console-properties: + - match: (?:warn|info|log|error|time|timeEnd|assert|count|dir|group|groupCollapsed|groupEnd|profile|profileEnd|table|trace|timeStamp){{identifier_break}} + scope: support.function.console.js + pop: 1 + - include: object-property - support-variable-ecma: - - match: Array{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-array - - include: object-property - - include: else-pop - - include: else-pop - - - match: ArrayBuffer{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-arraybuffer - - include: object-property - - include: else-pop - - include: else-pop - - - match: Atomics{{identifier_break}} - scope: support.constant.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-atomics - - include: object-property - - include: else-pop - - include: else-pop - - - match: BigInt{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-bigint - - include: object-property - - include: else-pop - - include: else-pop - - - match: Date{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-date - - include: object-property - - include: else-pop - - include: else-pop - - - match: JSON{{identifier_break}} - scope: support.constant.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-json - - include: object-property - - include: else-pop - - include: else-pop - - - match: Math{{identifier_break}} - scope: support.constant.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-math - - include: object-property - - include: else-pop - - include: else-pop - - - match: Number{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-number - - include: object-property - - include: else-pop - - include: else-pop - - - match: Object{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-object - - include: object-property - - include: else-pop - - include: else-pop - - - match: Promise{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-promise - - include: object-property - - include: else-pop - - include: else-pop - - - match: Proxy{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-proxy - - include: object-property - - include: else-pop - - include: else-pop - - - match: Reflect{{identifier_break}} - scope: support.constant.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-reflect - - include: object-property - - include: else-pop - - include: else-pop - - - match: String{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-string - - include: object-property - - include: else-pop - - include: else-pop - - - match: Symbol{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-symbol - - include: object-property - - include: else-pop - - include: else-pop - - - match: |- - (?x: - (?: - BigInt64| - BigUint64| - Float(?:32|64)| - Int(?:8|16|32)| - Uint(?:8|16|32|32Clamped) - ) - Array{{identifier_break}} - ) - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-typedarray - - include: object-property - - include: else-pop - - include: else-pop - - # Classes with no constructor properties - - match: (?:Boolean|DataView|Function|Map|RegExp|Set|WeakMap|WeakSet){{identifier_break}} - scope: support.class.builtin.js - pop: true - - match: (?:Eval|Range|Reference|Syntax|Type|URI)?Error{{identifier_break}} - scope: support.class.builtin.js - pop: true + support-property-ecma: + - match: constructor{{identifier_break}} + scope: variable.language.constructor.js + pop: 1 + - match: prototype{{identifier_break}} + scope: support.constant.prototype.js + pop: 1 - - match: (?:eval|isFinite|isNaN|parseFloat|parseInt|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent){{identifier_break}} + - match: (?:hasOwnProperty|isPrototypeOf|propertyIsEnumerable|toLocaleString|toString|valueOf){{identifier_break}} scope: support.function.js - pop: true - - finally-meta: - - meta_include_prototype: false - - meta_scope: meta.finally.js - - include: immediately-pop - - support-property-ecma-string: - - match: (?:fromCharCode|fromCodePoint|raw){{identifier_break}} - scope: support.function.builtin.js - pop: true - - class-extends: - - match: extends{{identifier_break}} - scope: storage.modifier.extends.js - set: - - inherited-class-expression-end - - inherited-class-expression-begin - - include: else-pop - - class-field: - - match: '' - set: - - initializer - - flow-type-annotation - - class-field-check - - field-name - - ternary-operator-expect-colon: - - match: ':' - scope: keyword.operator.ternary.js - set: expression-no-comma - - include: else-pop - - call-function-meta: - - meta_include_prototype: false - - meta_scope: meta.function-call.js - - include: else-pop - - line-comment-triple-slash-body: - - meta_include_prototype: false - - meta_scope: comment.line.triple-slash.js - - include: line-comment-end - - jsx-interpolation-plain: - - match: '{' - scope: punctuation.definition.interpolation.begin.js - set: - - - meta_scope: meta.interpolation.js - - meta_content_scope: source.js.embedded.jsx - - match: '}' - scope: punctuation.definition.interpolation.end.js - pop: true - - expression - - styled-components: - - match: (?=(?:styled|css|createGlobalStyle|injectGlobal){{identifier_break}}) - set: - - styled-component-end - - styled-component-begin - - match: (?=keyframes{{identifier_break}}) - set: - - styled-component-keyframes-end - - styled-component-begin - regexp-complete: - - match: / - scope: punctuation.definition.string.begin.js - set: regexp + pop: 1 - import-brace: - - include: flow-type-import-type + # Annex B + - match: __proto__{{identifier_break}} + scope: invalid.deprecated.js variable.language.prototype.js + pop: 1 + - match: (?:__defineGetter__|__defineSetter__|__lookupGetter__){{identifier_break}} + scope: invalid.deprecated.js support.function.js + pop: 1 - - meta_scope: meta.block.js - - include: comma-separator - - match: \} - scope: punctuation.section.block.end.js - pop: true + literal-variable-base: + - match: '{{dollar_only_identifier}}' + scope: variable.other.dollar.only.js punctuation.dollar.js + pop: 1 + - match: '{{dollar_identifier}}' + scope: variable.other.dollar.js + captures: + 1: punctuation.dollar.js + pop: 1 + - match: '{{constant_identifier}}' + scope: variable.other.constant.js + pop: 1 - match: '{{identifier_name}}' scope: variable.other.readwrite.js - push: import-export-alias - - match: \* - scope: constant.other.js - push: import-export-alias - - include: else-pop - - block-comment-end: - - match: \*+/ - scope: punctuation.definition.comment.end.js - pop: true - - flow-type-end-no-arrow: - - match: (?==>) - pop: true - - include: flow-type-end - - inherited-class-expression-begin: - - include: inherited-class-name - - include: expression-begin - - flow-function-type-arguments-or-less-than: - - match: (?=<(?![<=])) - branch_point: flow-function-type-arguments - branch: - - flow-function-type-arguments - - flow-less-than - - function-declaration: - - match: '' - set: - - function-meta - - function-declaration-expect-body - - flow-type-annotation - - function-declaration-expect-parameters - - flow-type-generic-parameters - - function-declaration-expect-name - - function-declaration-expect-generator-star - - function-declaration-expect-function-keyword - - function-declaration-expect-async - - - match: extends{{identifier_break}} - scope: storage.modifier.extends.js - set: - - inherited-class-expression-end - - inherited-class-expression-begin - - include: else-pop - - object-literal-property-check: - - match: (?=\() - fail: object-literal-property - - include: else-pop - - flow-type-module-name: - - include: literal-string - - match: '{{non_reserved_identifier}}' - scope: entity.name.module.js - pop: true - - include: else-pop - - restricted-production: - - meta_include_prototype: false - - match: '{{line_ending_ahead}}' - pop: true - - match: '' - set: expression-statement - - flow-type-operators: - - match: \|(?!\}) - scope: keyword.operator.type.union.js - push: flow-type-begin - - match: \& - scope: keyword.operator.type.intersection.js - push: flow-type-begin - - match: => - scope: keyword.declaration.function.arrow.js - push: flow-type-begin - - match: \? - scope: storage.modifier.maybe.js - push: flow-type-begin - - match: \. - scope: punctuation.separator.accessor.js - push: flow-type-begin - - - match: \[\] - scope: storage.modifier.array.js - - match: '%checks{{identifier_break}}' - scope: storage.modifier.checks.js - - variable-binding-spread: - - match: \.\.\. - scope: keyword.operator.spread.js - push: variable-binding-pattern + pop: 1 + - include: literal-private-variable - function-parameter-binding-list: + import-list: - match: ',' - scope: punctuation.separator.parameter.function.js - - include: function-parameter-binding-spread - - match: (?={{binding_pattern_lookahead}}) - push: function-parameter - - include: else-pop - - flow-type-special: - - match: any{{identifier_break}} - scope: support.type.any.js - pop: true - - - match: mixed{{identifier_break}} - scope: support.type.mixed.js - pop: true - - jsx-tag-name-end: - - match: '[:.]' - scope: punctuation.accessor.js - push: jsx-tag-name-component - - include: else-pop - - flow-type-object: - - match: \{\| - scope: punctuation.section.block.begin.js - set: - - meta_scope: meta.type.object.exact.js - - match: \|\} - scope: punctuation.section.block.end.js - pop: true - - include: flow-type-object-contents - - - match: \{ - scope: punctuation.section.block.begin.js - set: - - meta_scope: meta.type.object.js - - match: \} - scope: punctuation.section.block.end.js - pop: true - - include: flow-type-object-contents - - object-literal-contents: - - meta_scope: meta.mapping.js - - - match: \} - scope: punctuation.section.block.end.js - pop: true - - - match: \.\.\. - scope: keyword.operator.spread.js - push: expression-no-comma - - - match: >- - (?x)(?= - {{property_name}}\s*:\s* - {{either_func_lookahead}} - ) + scope: punctuation.separator.comma.js push: - - object-literal-meta-key - - method-name - - - match: (?=\*) - push: method-declaration - - - match: (?=(?:get|set|async){{identifier_break}}) - branch_point: prefixed-object-literal-method - branch: - - prefixed-object-literal-method - - object-literal-element - - - match: (?={{property_name}}) - push: object-literal-element - - - include: comma-separator - - - match: ':' - scope: punctuation.separator.key-value.js - push: expression-no-comma - - # If there's any garbage, parse it as an expression - # so that close braces won't break things. - - match: (?=\S) - push: expression-no-comma - - flow-type-primitive: - - match: boolean{{identifier_break}} - scope: support.type.primitive.boolean.js - pop: true - - - match: number{{identifier_break}} - scope: support.type.primitive.number.js - pop: true + - import-export-alias + - import-item + - include: else-pop - - match: string{{identifier_break}} - scope: support.type.primitive.string.js - pop: true + literal-number: + # floats + - match: |- + (?x: + # 1., 1.1, 1.1e1, 1.1e-1, 1.e1, 1.e-1 | 1e1, 1e-1 + {{dec_integer}} (?: (\.) {{dec_digit}}* (?:{{dec_exponent}})? | {{dec_exponent}} ) + # .1, .1e1, .1e-1 + | (\.) {{dec_digit}}+ (?:{{dec_exponent}})? + ){{identifier_break}} + scope: meta.number.float.decimal.js constant.numeric.value.js + captures: + 1: punctuation.separator.decimal.js + 2: punctuation.separator.decimal.js + pop: 1 - - match: null{{identifier_break}} - scope: support.type.primitive.null.js - pop: true + # integers + - match: (0)({{dec_digit}}+){{identifier_break}} + scope: meta.number.integer.octal.js + captures: + 1: constant.numeric.base.js invalid.deprecated.numeric.octal.js + 2: constant.numeric.value.js invalid.deprecated.numeric.octal.js + pop: 1 - - match: void{{identifier_break}} - scope: support.type.primitive.void.js - pop: true + - match: (0[Xx])({{hex_digit}}*)(n)?{{identifier_break}} + scope: meta.number.integer.hexadecimal.js + captures: + 1: constant.numeric.base.js + 2: constant.numeric.value.js + 3: constant.numeric.suffix.js + pop: 1 - literal-string: - - match: "'" - scope: punctuation.definition.string.begin.js - set: - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.single.js - - match: \' - scope: punctuation.definition.string.end.js - pop: true - - match: \n - scope: invalid.illegal.newline.js - pop: true - - include: string-content - - match: '"' - scope: punctuation.definition.string.begin.js - set: - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.double.js - - match: \" - scope: punctuation.definition.string.end.js - pop: true - - match: \n - scope: invalid.illegal.newline.js - pop: true - - include: string-content + - match: (0[Oo])({{oct_digit}}*)(n)?{{identifier_break}} + scope: meta.number.integer.octal.js + captures: + 1: constant.numeric.base.js + 2: constant.numeric.value.js + 3: constant.numeric.suffix.js + pop: 1 - object-literal-meta-key: - - meta_scope: meta.mapping.key.js - - include: else-pop + - match: (0[Bb])({{bin_digit}}*)(n)?{{identifier_break}} + scope: meta.number.integer.binary.js + captures: + 1: constant.numeric.base.js + 2: constant.numeric.value.js + 3: constant.numeric.suffix.js + pop: 1 - support-property-ecma: - - match: constructor{{identifier_break}} - scope: variable.language.constructor.js - pop: true - - match: prototype{{identifier_break}} - scope: support.constant.prototype.js - pop: true + - match: ({{dec_integer}})(n|(?!\.)){{identifier_break}} + scope: meta.number.integer.decimal.js + captures: + 1: constant.numeric.value.js + 2: constant.numeric.suffix.js + pop: 1 - - match: (?:hasOwnProperty|isPrototypeOf|propertyIsEnumerable|toLocaleString|toString|valueOf){{identifier_break}} - scope: support.function.js - pop: true + # illegal numbers + - match: 0[Xx]{{identifier_part}}+ + scope: invalid.illegal.numeric.hexadecimal.js + pop: 1 - # Annex B - - match: __proto__{{identifier_break}} - scope: invalid.deprecated.js variable.language.prototype.js - pop: true - - match: (?:__defineGetter__|__defineSetter__|__lookupGetter__){{identifier_break}} - scope: invalid.deprecated.js support.function.js - pop: true + - match: 0[Bb]{{identifier_part}}+ + scope: invalid.illegal.numeric.binary.js + pop: 1 - export-meta: - - meta_include_prototype: false - - meta_scope: meta.export.js - - include: immediately-pop + - match: 0{{identifier_part}}+ + scope: invalid.illegal.numeric.octal.js + pop: 1 - function-parameter-binding-pattern: - - match: '' - set: - - - include: flow-type-annotation-optional - - - include: function-parameter-binding-name - - include: function-parameter-binding-array-destructuring - - include: function-parameter-binding-object-destructuring - - include: else-pop + - match: '[1-9]{{identifier_part}}+(?:\.{{identifier_part}}*)?' + scope: invalid.illegal.numeric.decimal.js + pop: 1 - jsx-meta: - - meta_include_prototype: false - - meta_scope: meta.jsx.js - - include: immediately-pop + literal-string: + - include: literal-double-quoted-string + - include: literal-single-quoted-string - block-comment-body: - - meta_include_prototype: false - - meta_scope: comment.block.js - - include: block-comment-end + expression-end: + - include: flow-function-type-arguments-or-less-than - method-name: - - match: '{{dollar_identifier}}' - scope: meta.mapping.key.dollar.js entity.name.function.js - captures: - 1: punctuation.dollar.js - pop: true - - match: '{{identifier_name}}' - scope: entity.name.function.js - pop: true - - match: (#){{identifier_name}} - scope: entity.name.function.js - captures: - 1: punctuation.definition.js - pop: true - - match: "'" - scope: punctuation.definition.string.begin.js - set: - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.single.js - - meta_content_scope: entity.name.function.js - - match: \' - scope: punctuation.definition.string.end.js - pop: true - - match: \n - scope: invalid.illegal.newline.js - pop: true - - include: string-content - - match: '"' - scope: punctuation.definition.string.begin.js - set: - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.double.js - - meta_content_scope: entity.name.function.js - - match: \" - scope: punctuation.definition.string.end.js - pop: true - - match: \n - scope: invalid.illegal.newline.js - pop: true - - include: string-content + - include: postfix-operators + - include: binary-operators + - include: ternary-operator - - match: (?=\[) - push: computed-property-name + - include: left-expression-end - - include: else-pop + string-interpolation-content: + - clear_scopes: 1 + - meta_scope: meta.interpolation.js + - meta_content_scope: source.js.embedded + - match: \} + scope: punctuation.section.interpolation.end.js + pop: 1 + - match: (?=\S) + push: expression - support-property-ecma-array: - - match: (?:from|isArray|of){{identifier_break}} - scope: support.function.builtin.js - pop: true + script: + - match: \)|\}|\] + scope: invalid.illegal.stray-bracket-end.js + # Don't pop or embedding could break. - variable-binding-list-top: - - match: '{{line_ending_ahead}}' - set: - - match: '{{line_continuation_lookahead}}' - set: variable-binding-top - - include: else-pop - - match: ',' - scope: punctuation.separator.comma.js - push: variable-binding-top - - include: else-pop + - include: statements - function-parameter-binding-object-destructuring: + variable-binding-object-destructuring: - match: \{ - scope: punctuation.section.block.begin.js + scope: punctuation.section.mapping.begin.js set: - meta_scope: meta.binding.destructuring.mapping.js - - match: ',' - scope: punctuation.separator.parameter.function.js - match: \} - scope: punctuation.section.block.end.js - pop: true - - include: function-parameter-binding-spread + scope: punctuation.section.mapping.end.js + pop: 1 + - include: variable-binding-spread - match: (?={{identifier_start}}|\[|'|") push: - initializer - - function-parameter-binding-object-alias + - variable-binding-object-alias - object-literal-meta-key - - function-parameter-binding-object-key + - variable-binding-object-key + - include: comma-separator + + class-field: + - match: '' + set: + - initializer + - flow-type-annotation + - class-field-check + - field-name + + main: + - meta_include_prototype: false # don't match comments before shebang + - match: '' + push: [script, shebang] + + expect-parenthesized-expression: + - include: parenthesized-expression + - include: else-pop + + string-content: + - match: \\\n + scope: constant.character.escape.newline.js + - match: \\(?:x\h\h|u\h\h\h\h|.) + scope: constant.character.escape.js + + flow-type-alias: + - match: (?=type{{identifier_break}}) + set: + - - match: (?={{non_reserved_identifier}}) + set: + - - meta_scope: meta.declaration.type.js + - match: '' + pop: true + - flow-type-alias-initializer + - flow-type-generic-parameters + - - match: '{{non_reserved_identifier}}' + scope: entity.name.type.js + pop: true + - - include: else-pop + + - match: (?=\S) + set: [expression-statement, expression-end] + - - match: type{{identifier_break}}(?=\s*(?:$|{{non_reserved_identifier}})) + scope: keyword.declaration.js + set: + - meta_scope: meta.declaration.type.js + - include: else-pop + - include: expression-begin method-declaration: - meta_include_prototype: false @@ -994,422 +882,414 @@ contexts: - method-name - method-declaration-expect-asterisk - class-element-modifier: - - match: '{{modifier}}' - scope: storage.modifier.js + custom-templates-prototype: + - match: (?=`) + pop: true + - match: \$\{ + scope: punctuation.section.interpolation.begin.js + push: + - clear_scopes: 1 + - meta_scope: meta.interpolation.js + - meta_content_scope: source.js.embedded.expression + - match: \} + scope: punctuation.section.interpolation.end.js + pop: true + - match: (?=\S) + push: expression + - include: string-content + arrow-function-expect-arrow: + - match: => + scope: keyword.declaration.function.arrow.js + pop: 1 + - include: else-pop + + export-meta: + - meta_include_prototype: false + - meta_scope: meta.export.js + - include: immediately-pop + + arrow-function-expect-body: + - include: function-block + - match: (?=\S) set: - - match: (?={{class_element_name}}|\*) - pop: true - - match: (?=\S) - fail: class-element-modifier + - block-meta + - expression-no-comma - styled-component-begin: - - match: '{{non_reserved_identifier}}(?=\s*\()' - scope: variable.function.js - pop: true + literal-variable: + - include: special-identifier + - include: support - - match: '{{non_reserved_identifier}}(?=\s*[`<])' + - match: (?={{identifier_name}}{{function_assignment_lookahead}}) + set: + - function-name-meta + - literal-variable-base + + - match: '{{identifier_name}}(?={{nothing}}`)' scope: variable.function.tagged-template.js - pop: true + pop: 1 - - match: '{{non_reserved_identifier}}' - scope: variable.other.readwrite.js - pop: true + - match: '{{constant_identifier}}(?=\s*(?:{{dot_accessor}}|\[))' + scope: support.class.js + pop: 1 - - include: else-pop - call-method-meta: - - meta_include_prototype: false - - meta_scope: meta.function-call.method.js - - include: else-pop + - match: '{{function_call_lookahead}}' + set: call-function-name - statement: - - include: flow-type-declare - - include: flow-type-alias + - include: literal-variable-base - - match: \; - scope: punctuation.terminator.statement.empty.js + flow-type-existential: + - match: \* + scope: constant.language.type.existential.js pop: true - - include: declaration - - include: import-statement-or-import-meta - - include: export-statement - - include: conditional - - include: block - - include: label - - - match: break{{identifier_break}} - scope: keyword.control.flow.break.js - set: - - expect-semicolon - - expect-label - - - match: continue{{identifier_break}} - scope: keyword.control.flow.continue.js + jsx-interpolation-comment: + - match: ({)(/\*) + captures: + 1: punctuation.definition.interpolation.begin.js + 2: punctuation.definition.comment.begin.js set: - - expect-semicolon - - expect-label - - - match: debugger{{identifier_break}} - scope: keyword.control.flow.debugger.js - set: expect-semicolon - - - match: return{{identifier_break}} - scope: keyword.control.flow.return.js - set: restricted-production - - - match: throw{{identifier_break}} - scope: keyword.control.flow.throw.js - set: restricted-production + - meta_include_prototype: false + - meta_scope: meta.interpolation.js comment.block.js + - match: (\*/)(}) + captures: + 1: punctuation.definition.comment.end.js + 2: punctuation.definition.interpolation.end.js + pop: 1 + - match: (?=\*/) + fail: jsx-interpolation-comment - - include: decorator + styled-component-end: + - match: \. + scope: punctuation.accessor.dot.js + push: styled-component-begin - - include: expression-statement + - match: '`' + scope: string.quoted.other.js punctuation.definition.string.begin.js + push: + - - include: immediately-pop + - custom-templates-closing-quote + - custom-templates-clear-scopes + - - meta_include_prototype: false + - match: '' + set: scope:source.js.css + with_prototype: + - include: custom-templates-prototype + - include: expression-end - export-item: - - match: \{ - scope: punctuation.section.block.begin.js - set: export-brace - - match: '{{non_reserved_identifier}}' - scope: variable.other.readwrite.js + flow-type-literal: + - match: true{{identifier_break}} + scope: constant.language.boolean.true.js pop: true - - match: \* - scope: constant.other.js + - match: false{{identifier_break}} + scope: constant.language.boolean.false.js pop: true + - match: (?=\d) + set: + - - match: '{{identifier_part}}+' + scope: invalid.illegal.js + - include: immediately-pop + - literal-number + - match: (?=['"]) + set: literal-string + + flow-type-object-value: + - match: (\?)?(:) + captures: + 1: storage.modifier.optional.js + 2: punctuation.separator.key-value.js + set: flow-type - include: else-pop - binary-operators: - - match: instanceof{{identifier_break}} - scope: keyword.operator.js - push: expression-begin - - match: in{{identifier_break}} - scope: keyword.operator.js - push: expression-begin - - match: =(?![=>]) - scope: keyword.operator.assignment.js - push: expression-begin - - match: |- - (?x) - %= | # assignment right-to-left both - &= | # assignment right-to-left both - \*= | # assignment right-to-left both - \+= | # assignment right-to-left both - -= | # assignment right-to-left both - /= | # assignment right-to-left both - \^= | # assignment right-to-left both - \|= | # assignment right-to-left both - <<= | # assignment right-to-left both - >>= | # assignment right-to-left both - >>>= | # assignment right-to-left both - &&= | - \|\|= | - \?\?= - scope: keyword.operator.assignment.augmented.js - push: expression-begin - - match: '&&|\|\||\?\?' - scope: keyword.operator.logical.js - push: expression-begin - - match: |- - (?x) - << | # bitwise-shift left-to-right both - >>> | # bitwise-shift left-to-right both - >> | # bitwise-shift left-to-right both - & | # bitwise-and left-to-right both - \^ | # bitwise-xor left-to-right both - \| # bitwise-or left-to-right both - scope: keyword.operator.bitwise.js - push: expression-begin - - match: |- - (?x) - <= | # comparison left-to-right both - >= | # comparison left-to-right both - < | # comparison left-to-right both - > # comparison left-to-right both - scope: keyword.operator.comparison.js - push: expression-begin - - match: |- - (?x) - === | # equality left-to-right both - !== | # equality left-to-right both - == | # equality left-to-right both - != # equality left-to-right both - scope: keyword.operator.comparison.js - push: expression-begin + expression-break: + - match: (?=[;})\]]) + pop: 1 + + flow-type-utility: - match: |- - (?x) - / | # division left-to-right both - % | # modulus left-to-right both - \* | # multiplication left-to-right both - \+ | # addition left-to-right both - - # subtraction left-to-right both - scope: keyword.operator.arithmetic.js - push: expression-begin - - match: ',' - scope: keyword.operator.comma.js # Comma operator, not punctuation. - push: expression-begin + (?x) (?: + Class|Function| + \$(?: + Keys|Values|ReadOnly|Exact|Diff|Rest|PropertyType|ElementType| + ObjMap|TupleMap|Call|Supertype|Subtype + ) + ){{identifier_break}} + scope: support.type.utility.js + pop: true - expression-statement-end: - - match: '{{line_ending_ahead}}' - set: - - match: '{{line_continuation_lookahead}}' - set: expression-statement-end - - include: else-pop - - include: expression-end + jsx-interpolation: + - match: (?={/\*) + branch_point: jsx-interpolation-comment + branch: + - jsx-interpolation-comment + - jsx-interpolation-plain + - match: (?={) + push: jsx-interpolation-plain - string-content: - - match: \\\n - scope: constant.character.escape.newline.js - - match: \\(?:x\h\h|u\h\h\h\h|.) - scope: constant.character.escape.js + block-comment-body: + - meta_include_prototype: false + - meta_scope: comment.block.js + - include: block-comment-end - builtin-console-properties: - - match: (?:warn|info|log|error|time|timeEnd|assert|count|dir|group|groupCollapsed|groupEnd|profile|profileEnd|table|trace|timeStamp){{identifier_break}} - scope: support.function.console.js - pop: true - - include: object-property + literal-string-template-custom-lookahead: [] + restricted-production: + - meta_include_prototype: false + - match: '{{line_ending_ahead}}' + pop: 1 + - match: '' + set: expression-statement - flow-type-end: - - match: (?=\|\||&&) - fail: flow-function-type-arguments - - include: flow-type-operators - - include: flow-type-generic-arguments + function-declaration-expect-body: + - include: function-block - include: else-pop - function-parameter-binding-spread: - - match: \.\.\. - scope: keyword.operator.spread.js - push: function-parameter + statement: + - include: flow-type-declare + - include: flow-type-alias + + - match: \; + scope: punctuation.terminator.statement.empty.js + pop: 1 + + - include: declaration + - include: import-statement-or-import-meta + - include: export-statement + - include: conditional + - include: block + - include: label - function-parameter-binding-array-destructuring: - - match: \[ - scope: punctuation.section.brackets.begin.js + - match: break{{identifier_break}} + scope: keyword.control.flow.break.js set: - - meta_scope: meta.binding.destructuring.sequence.js - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - include: function-parameter-binding-list + - expect-semicolon + - expect-label - computed-property-name: - - match: \[ - scope: punctuation.section.brackets.begin.js + - match: continue{{identifier_break}} + scope: keyword.control.flow.continue.js set: - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - match: (?=\S) - push: expression - - jsx-attribute-value: - - include: jsx-tag - - include: jsx-interpolation + - expect-semicolon + - expect-label - - match: "'" - scope: punctuation.definition.string.begin.js - set: - - meta_include_prototype: false - - meta_scope: string.quoted.single.js - - match: \' - scope: punctuation.definition.string.end.js - pop: true - - include: jsx-html-escapes - - match: '"' - scope: punctuation.definition.string.begin.js - set: - - meta_include_prototype: false - - meta_scope: string.quoted.double.js - - match: \" - scope: punctuation.definition.string.end.js - pop: true - - include: jsx-html-escapes + - match: debugger{{identifier_break}} + scope: keyword.control.flow.debugger.js + set: expect-semicolon - - include: else-pop + - match: return{{identifier_break}} + scope: keyword.control.flow.return.js + set: restricted-production - flow-jsx-tag-check: - - match: (?=[:,]) - fail: arrow-function - - include: else-pop - call-path: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - push: object-property - - include: else-pop + - match: throw{{identifier_break}} + scope: keyword.control.flow.throw.js + set: restricted-production - expect-parenthesized-expression: - - include: parenthesized-expression - - include: else-pop + - include: decorator - flow-type-class: - - match: '{{non_reserved_identifier}}' - scope: variable.other.class.js - pop: true + - include: expression-statement - block-meta: + import-meta: - meta_include_prototype: false - - meta_scope: meta.block.js + - meta_scope: meta.import.js - include: immediately-pop - class-name: - - match: '{{non_reserved_identifier}}' - scope: entity.name.class.js - set: flow-type-generic-parameters - - include: else-pop + prefix-operators: + - match: '~' + scope: keyword.operator.bitwise.js + - match: '!(?!=)' + scope: keyword.operator.logical.js + - match: -- + scope: keyword.operator.arithmetic.js + - match: \+\+ + scope: keyword.operator.arithmetic.js + - match: \.\.\. + scope: keyword.operator.spread.js + - match: \+|\- + scope: keyword.operator.arithmetic.js + - match: (?:delete|typeof|void){{identifier_break}} + scope: keyword.operator.js + + function-meta: + - meta_include_prototype: false + - meta_scope: meta.function.js + - include: immediately-pop - literal-string-template-custom-comments: [] function-declaration-expect-function-keyword: - match: function{{identifier_break}} scope: keyword.declaration.function.js - pop: true + pop: 1 - include: else-pop - script: - - match: \)|\}|\] - scope: invalid.illegal.stray-bracket-end.js - # Don't pop or embedding could break. + flow-type: + - match: '' + set: + - flow-type-end + - flow-type-begin - - include: statements + for-condition-end: + - meta_scope: meta.group.js - decorator: - - match: '@' - scope: punctuation.definition.annotation.js + - match: \) + scope: punctuation.section.group.end.js + pop: 1 + + special-identifier: + # These are ordinary identifiers, not reserved words + - match: arguments{{identifier_break}} + scope: variable.language.arguments.js + pop: 1 + - match: globalThis{{identifier_break}} + scope: variable.language.global.js + pop: 1 + - match: undefined{{identifier_break}} + scope: constant.language.undefined.js + pop: 1 + - match: NaN{{identifier_break}} + scope: constant.language.nan.js + pop: 1 + - match: Infinity{{identifier_break}} + scope: constant.language.infinity.js + pop: 1 + + switch-block-contents: + - meta_scope: meta.block.js + + - match: \} + scope: punctuation.section.block.end.js + pop: 1 + + - match: case{{identifier_break}} + scope: keyword.control.conditional.case.js push: - - decorator-meta - - decorator-expression-end - - decorator-expression-begin + - expect-case-colon + - expression - literal-number: - # floats - - match: |- - (?x: - # 1., 1.1, 1.1e1, 1.1e-1, 1.e1, 1.e-1 | 1e1, 1e-1 - {{dec_integer}} (?: (\.) {{dec_digit}}* (?:{{dec_exponent}})? | {{dec_exponent}} ) - # .1, .1e1, .1e-1 - | (\.) {{dec_digit}}+ (?:{{dec_exponent}})? - ){{identifier_break}} - scope: meta.number.float.decimal.js constant.numeric.value.js - captures: - 1: punctuation.separator.decimal.js - 2: punctuation.separator.decimal.js - pop: true + - match: default{{identifier_break}} + scope: keyword.control.conditional.default.js + push: + - expect-case-colon - # integers - - match: (0)({{dec_digit}}+){{identifier_break}} - scope: meta.number.integer.octal.js - captures: - 1: constant.numeric.base.js invalid.deprecated.numeric.octal.js - 2: constant.numeric.value.js invalid.deprecated.numeric.octal.js - pop: true + - include: statements - - match: (0[Xx])({{hex_digit}}*)(n)?{{identifier_break}} - scope: meta.number.integer.hexadecimal.js - captures: - 1: constant.numeric.base.js - 2: constant.numeric.value.js - 3: constant.numeric.suffix.js - pop: true + inherited-class-expression-end: + - include: flow-type-generic-arguments - - match: (0[Oo])({{oct_digit}}*)(n)?{{identifier_break}} - scope: meta.number.integer.octal.js - captures: - 1: constant.numeric.base.js - 2: constant.numeric.value.js - 3: constant.numeric.suffix.js - pop: true + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + push: + - include: inherited-class-name + - include: object-property - - match: (0[Bb])({{bin_digit}}*)(n)?{{identifier_break}} - scope: meta.number.integer.binary.js - captures: - 1: constant.numeric.base.js - 2: constant.numeric.value.js - 3: constant.numeric.suffix.js - pop: true + - include: left-expression-end - - match: ({{dec_integer}})(n|(?!\.)){{identifier_break}} - scope: meta.number.integer.decimal.js - captures: - 1: constant.numeric.value.js - 2: constant.numeric.suffix.js - pop: true + import-statement: + - match: import{{identifier_break}} + scope: keyword.control.import-export.js + set: + - import-meta + - expect-semicolon + - import-assert + - import-string-or-items + - import-check-branch - # illegal numbers - - match: 0[Xx]{{identifier_part}}+ - scope: invalid.illegal.numeric.hexadecimal.js - pop: true + regular-function: + - match: (?={{func_lookahead}}) + set: function-declaration - - match: 0[Bb]{{identifier_part}}+ - scope: invalid.illegal.numeric.binary.js - pop: true + jsx-tag-attributes: + - meta_scope: meta.tag.attributes.js + + - match: '>' + scope: punctuation.definition.tag.end.js + set: jsx-body + + - match: / + scope: punctuation.definition.tag.end.js + set: jsx-expect-tag-end + + - include: jsx-interpolation - - match: 0{{identifier_part}}+ - scope: invalid.illegal.numeric.octal.js - pop: true + - match: '{{jsx_identifier}}' + scope: entity.other.attribute-name.js - - match: '[1-9]{{identifier_part}}+(?:\.{{identifier_part}}*)?' - scope: invalid.illegal.numeric.decimal.js - pop: true + - match: '=' + scope: punctuation.separator.key-value.js + push: jsx-attribute-value - import-export-from: - - match: from{{identifier_break}} - scope: keyword.control.import-export.js - set: literal-string + switch-block: + - match: \{ + scope: punctuation.section.block.begin.js + set: switch-block-contents - include: else-pop - branch-possible-arrow-function: - - match: (?=<) - set: jsx-tag + catch-meta: + - meta_include_prototype: false + - meta_scope: meta.catch.js + - include: immediately-pop - - match: (?=\() - set: - - detect-arrow - - flow-detect-arrow-function-return-type - - parenthesized-expression + while-meta: + - meta_include_prototype: false + - meta_scope: meta.while.js + - include: immediately-pop + try-meta: - meta_include_prototype: false - - match: (?=\() - set: - - detect-arrow - - parenthesized-expression - - match: (?={{identifier_start}}) - set: - - detect-arrow - - literal-variable + - meta_scope: meta.try.js + - include: immediately-pop - block: + function-block: - match: \{ scope: punctuation.section.block.begin.js set: - meta_scope: meta.block.js - match: \} scope: punctuation.section.block.end.js - pop: true + pop: 1 - include: statements - decorator-meta: + custom-templates-clear-scopes: - meta_include_prototype: false - - meta_scope: meta.annotation.js + - clear_scopes: 1 - include: immediately-pop - import-statement-or-import-meta: - - match: (?=import{{identifier_break}}) - branch_point: import-statement - branch: - - import-statement - - expression-statement + flow-detect-arrow-after-return-type: + - match: (?==>) + fail: arrow-function + - match: (?=\S) + fail: flow-arrow-function-return-type - function-parameter-binding-object-alias: - - match: ':' - scope: punctuation.separator.key-value.js - set: function-parameter-binding-pattern + constructor-body-expect-class-end: + - include: property-access - include: else-pop - flow-type-generic-arguments: - - match: < - scope: punctuation.definition.generic.begin.js + class: + - match: class{{identifier_break}} + scope: keyword.declaration.class.js set: - - meta_scope: meta.generic.js - - match: '>' - scope: punctuation.definition.generic.end.js - pop: true - - include: flow-type-list + - class-meta + - class-body + - class-extends + - class-name + + class-element: + - match: '' + pop: 1 + branch_point: class-field + branch: + - class-field + - method-declaration + + line-comment-other-body: + - meta_include_prototype: false + - meta_scope: comment.line.other.js + - include: line-comment-end + + block: + - match: \{ + scope: punctuation.section.block.begin.js + set: + - meta_scope: meta.block.js + - match: \} + scope: punctuation.section.block.end.js + pop: 1 + - include: statements function-declaration-parameters: - match: \( @@ -1419,256 +1299,370 @@ contexts: - meta_scope: meta.function.parameters.js - match: \) scope: punctuation.section.group.end.js - pop: true + pop: 1 - include: function-parameter-binding-list - literal-call: - - match: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\() - set: - - call-function-meta - - function-call-arguments - - literal-variable + switch-meta: + - meta_include_prototype: false + - meta_scope: meta.switch.js + - include: immediately-pop - - match: (?={{identifier_name}}\s*(?:{{dot_accessor}}\s*#?{{identifier_name}}\s*)+(?:{{dot_accessor}})?\() + array-literal: + - match: \[ + scope: punctuation.section.sequence.begin.js set: - - call-method-meta - - function-call-arguments - - call-path - - literal-variable + - meta_scope: meta.sequence.js + - match: \] + scope: punctuation.section.sequence.end.js + pop: 1 + - include: expression-list - prototype: - - include: comments + label: + - match: ({{identifier_name}})\s*(:) + captures: + 1: entity.name.label.js + 2: punctuation.separator.js - support-variable-console: - # https://console.spec.whatwg.org/ - - match: console{{identifier_break}} - scope: support.type.object.console.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: builtin-console-properties - - include: else-pop + expect-semicolon: + - match: \; + scope: punctuation.terminator.statement.js + pop: 1 + - include: else-pop - for-condition: - - match: \( - scope: punctuation.section.group.js + flow-function-type-arguments: + - match: \<(?!<) + scope: punctuation.definition.generic.begin.js region.redish set: - - for-condition-end - - for-condition-contents + - - match: (?=[\]()};,`]) + pop: true + - match: (?=\S) + fail: flow-function-type-arguments + - - meta_scope: meta.generic.js + - match: \> + scope: punctuation.definition.generic.end.js + pop: true + - match: ',' + scope: punctuation.separator.comma.js + push: flow-type + - match: (?=\S) + fail: flow-function-type-arguments + - flow-type + + support-property-ecma-symbol: + - match: (?:asyncIterator|hasInstance|isConcatSpreadable|iterator|match|replace|search|species|split|toPrimitive|toStringTag|unscopeables){{identifier_break}} + scope: support.constant.builtin.js + pop: 1 + - match: (?:for|keyFor){{identifier_break}} + scope: support.function.builtin.js + pop: 1 + + class-meta: + - meta_include_prototype: false + - meta_scope: meta.class.js + - include: immediately-pop + + static-block-body: + - meta_scope: meta.block.js + - match: \} + scope: punctuation.section.block.end.js + pop: 1 + - include: statements + + literal-private-variable: + - match: (#)({{identifier_name}}) + captures: + 1: punctuation.definition.variable.js + 2: variable.other.readwrite.js + pop: 1 + + block-meta: + - meta_include_prototype: false + - meta_scope: meta.block.js + - include: immediately-pop + + flow-type-module-name: + - include: literal-string + - match: '{{non_reserved_identifier}}' + scope: entity.name.module.js + pop: true - include: else-pop - function-block: - - match: \{ - scope: punctuation.section.block.begin.js - set: - - meta_scope: meta.block.js - - match: \} - scope: punctuation.section.block.end.js - pop: true - - include: statements + styled-component-begin: + - match: '{{non_reserved_identifier}}(?=\s*\()' + scope: variable.function.js + pop: true - variable-binding-object-key: - - match: '{{identifier_name}}(?=\s*:)' - scope: string.unquoted.js + - match: '{{non_reserved_identifier}}(?=\s*[`<])' + scope: variable.function.tagged-template.js pop: true - - match: '{{identifier_name}}(?=\s*:)' + + - match: '{{non_reserved_identifier}}' + scope: variable.other.readwrite.js pop: true - - include: literal-string - - include: computed-property-name - - include: variable-binding-name + - include: else-pop - support-property-node-module: - - match: (?:children|exports|filename|id|loaded|parent|paths){{identifier_break}} - scope: support.constant.node.js + object-literal-element: + - match: '{{identifier_name}}(?=\s*(?:[},]|$|//|/\*))' + scope: variable.other.readwrite.js + pop: 1 + - match: (?=\S) + pop: 1 + branch_point: object-literal-property + branch: + - object-literal-property + - method-declaration + + function-name-meta: + - meta_include_prototype: false + - meta_scope: entity.name.function.js + - include: immediately-pop + + object-literal: + - match: \{ + scope: punctuation.section.mapping.begin.js + set: object-literal-contents + + flow-type-primitive: + - match: boolean{{identifier_break}} + scope: support.type.primitive.boolean.js pop: true - - match: require{{identifier_break}} - scope: support.function.node.js + + - match: number{{identifier_break}} + scope: support.type.primitive.number.js pop: true - flow-type-literal: - - match: true{{identifier_break}} - scope: constant.language.boolean.true.js + - match: string{{identifier_break}} + scope: support.type.primitive.string.js pop: true - - match: false{{identifier_break}} - scope: constant.language.boolean.false.js + + - match: null{{identifier_break}} + scope: support.type.primitive.null.js pop: true - - match: (?=\d) - set: - - - match: '{{identifier_part}}+' - scope: invalid.illegal.js - - include: immediately-pop - - literal-number - - match: (?=['"]) - set: literal-string - flow-type-existential: - - match: \* - scope: constant.language.type.existential.js + - match: void{{identifier_break}} + scope: support.type.primitive.void.js pop: true - expression-no-comma: + jsx-tag-name-meta: + - clear_scopes: 1 - meta_include_prototype: false - - match: '' - set: [expression-end-no-comma, expression-begin] + - meta_scope: meta.tag.name.js + - include: immediately-pop - flow-less-than: - - match: < - scope: keyword.operator.comparison.js - set: expression-begin + jsx-meta-unmatched-tag: + - meta_include_prototype: false + - meta_scope: invalid.illegal.unmatched-tag.js + - include: immediately-pop - expression-break: - - match: (?=[;})\]]) - pop: true + flow-type-list: + - include: comma-separator + - match: (?=\S) + push: flow-type - flow-type-module-body: - - match: \{ - scope: punctuation.section.block.begin.js - set: flow-type-module-contents + call-method-name: + - include: support-property + - match: '{{identifier_name}}' + scope: variable.function.js + pop: 1 + - match: (#){{identifier_name}} + scope: variable.function.js + captures: + 1: punctuation.definition.js + pop: 1 - include: else-pop - shebang-body: - - meta_include_prototype: false - - meta_scope: comment.line.shebang.js - # Note: Keep sync with first_line_match! - - match: \b(node|js)\b - scope: constant.language.shebang.js - - match: \n + block-comment-end: + - match: \*+/ + scope: punctuation.definition.comment.end.js pop: 1 - class-body-contents: - - meta_scope: meta.block.js - - - match: \} - scope: punctuation.section.block.end.js - pop: true + constructor-body-expect-class-begin: + - match: (?={{non_reserved_identifier}}\s*\() + set: + - include: support + - match: '{{dollar_only_identifier}}' + scope: variable.type.dollar.only.js punctuation.dollar.js + pop: 1 + - match: '{{dollar_identifier}}' + scope: variable.type.dollar.js + captures: + 1: punctuation.dollar.js + pop: 1 + - match: '{{identifier_name}}' + scope: variable.type.js + pop: 1 + - include: else-pop - - match: \; - scope: punctuation.terminator.statement.js + - include: expression-begin - - include: decorator + support-variable-dom: + - match: XMLHttpRequest{{identifier_break}} + scope: support.class.dom.js + pop: 1 + - match: (?:document|window|navigator){{identifier_break}} + scope: support.type.object.dom.js + pop: 1 + - match: (?:clearTimeout|clearInterval|setTimeout|setInterval){{identifier_break}} + scope: support.function.dom.js + pop: 1 - - match: constructor{{identifier_break}} - scope: entity.name.function.constructor.js + variable-binding-list: + - include: comma-separator + - match: (?={{binding_pattern_lookahead}}) push: - - function-meta - - function-declaration-expect-body - - function-declaration-expect-parameters + - initializer + - variable-binding-pattern + - include: else-pop - - match: (?=static{{identifier_break}}) - branch_point: static-block - branch: - - static-block - - class-element-modifiers + object-literal-property: + - match: '' + set: + - object-literal-property-check + - object-literal-meta-key + - object-property-name - - match: (?={{modifier}}) - push: class-element-modifiers + flow-type-declare: + - match: declare{{identifier_break}}(?=\s*(?:type|class|function|var|let|const|opaque|export|module){{identifier_break}}) + scope: keyword.declaration.js + set: + - match: opaque{{identifier_break}} + scope: storage.modifier.js + pop: true + - match: module{{identifier_break}} + scope: keyword.declaration.js + set: + - flow-type-module-meta + - flow-type-module-body + - flow-type-module-name + - match: export{{identifier_break}} + scope: keyword.declaration.js + set: flow-type-declare-export + - include: else-pop - - match: |- - (?x)(?= - \#? {{identifier_name}} - \s* = \s* - {{either_func_lookahead}} - ) - push: - - initializer - - function-name-meta - - literal-variable-base + function-declaration-expect-name: + - match: '{{non_reserved_identifier}}' + scope: entity.name.function.js + pop: 1 + - include: else-pop - - match: (?=(?:get|set|async){{identifier_break}}) - branch_point: prefixed-method - branch: - - prefixed-method - - class-element + flow-type-end-no-arrow: + - match: (?==>) + pop: true + - include: flow-type-end - - match: (?=\*) - push: method-declaration + flow-type-annotation-optional: + - match: \?(?=:) + scope: storage.modifier.optional.js + - include: flow-type-annotation - - match: (?={{class_element_name}}) - push: class-element + flow-type-function: + - match: \( + scope: punctuation.section.grouping.begin.js + set: + - meta_scope: meta.group.js + - match: \) + scope: punctuation.section.grouping.end.js + pop: true + - include: flow-type-list - styled-component-end: - - match: \. - scope: punctuation.accessor.dot.js - push: styled-component-begin + support-property: + - include: support-property-ecma - - match: (?=`) + support-variable-console: + # https://console.spec.whatwg.org/ + - match: console{{identifier_break}} + scope: support.type.object.console.js set: - - match: '`' - scope: string.quoted.other.js punctuation.definition.string.begin.js - push: - - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.other.js - - match: '`' - scope: punctuation.definition.string.end.js - pop: true - - include: immediately-pop - - - meta_include_prototype: false - - clear_scopes: 1 - - include: immediately-pop - - - meta_include_prototype: false - - match: '' - set: scope:source.js.css - with_prototype: - - match: (?=`) - pop: true - - match: \$\{ - scope: punctuation.section.interpolation.begin.js - push: - - clear_scopes: 1 - - meta_scope: meta.interpolation.js - - meta_content_scope: source.js.embedded.expression - - match: \} - scope: punctuation.section.interpolation.end.js - pop: true - - match: (?=\S) - push: expression - - include: string-content + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: builtin-console-properties - include: else-pop - - include: expression-end - support-property-ecma-typedarray: - - match: (?:BYTES_PER_ELEMENT){{identifier_break}} - scope: support.constant.builtin.js - pop: true + decorator-expression-continuation: + - match: (?=[.`(]) + pop: 1 + - match: (?=\S) + fail: decorator-expression-continuation - function-declaration-expect-name: - - match: '{{non_reserved_identifier}}' - scope: entity.name.function.js - pop: true + jsx-tag-attributes-top: + - meta_scope: meta.tag.js + - match: / + scope: punctuation.definition.tag.begin.js + set: + - jsx-meta-unmatched-tag + - jsx-expect-tag-end + - jsx-tag-name + + - match: (?=\S) + set: + - jsx-tag-attributes + - flow-jsx-tag-check + - jsx-tag-name + - flow-jsx-tag-check-name + + support-property-ecma-atomics: + - match: (?:and|add|compareExchange|exchange|isLockFree|load|or|store|sub|wait|wake|xor){{identifier_break}} + scope: support.function.builtin.js + pop: 1 + + for-await: + - match: await{{identifier_break}} + scope: keyword.control.flow.await.js + pop: 1 - include: else-pop - statements: - - match: \)|\}|\] - scope: invalid.illegal.stray-bracket-end.js - pop: true + flow-type-operators: + - match: \|(?!\}) + scope: keyword.operator.type.union.js + push: flow-type-begin + - match: \& + scope: keyword.operator.type.intersection.js + push: flow-type-begin + - match: => + scope: keyword.declaration.function.arrow.js + push: flow-type-begin + - match: \? + scope: storage.modifier.maybe.js + push: flow-type-begin + - match: \. + scope: punctuation.separator.accessor.js + push: flow-type-begin + + - match: \[\] + scope: storage.modifier.array.js + - match: '%checks{{identifier_break}}' + scope: storage.modifier.checks.js - - match: (?=\S) - push: statement + branch-possible-arrow-function: + - match: (?=<) + set: jsx-tag - function-declaration-expect-async: - - match: async{{identifier_break}} - scope: keyword.declaration.async.js - pop: true - - include: else-pop + - match: (?=\() + set: + - detect-arrow + - flow-detect-arrow-function-return-type + - parenthesized-expression - conditional-meta: - meta_include_prototype: false - - meta_scope: meta.conditional.js - - include: immediately-pop - - flow-type-begin: - - include: flow-type-existential - - include: flow-type-literal - - include: flow-type-special - - include: flow-type-primitive - - include: flow-type-utility - - include: flow-type-typeof - - include: flow-type-class - - include: flow-type-function - - include: flow-type-tuple - - include: flow-type-object + - match: (?=\() + set: + - detect-arrow + - parenthesized-expression + - match: (?={{identifier_start}}) + set: + - detect-arrow + - literal-variable + variable-binding-object-key: + - match: '{{identifier_name}}(?=\s*:)' + scope: string.unquoted.js + pop: true + - match: '{{identifier_name}}(?=\s*:)' + pop: 1 + - include: literal-string + - include: computed-property-name + - include: variable-binding-name - include: else-pop flow-jsx-tag-check-name: @@ -1676,1359 +1670,1435 @@ contexts: fail: arrow-function - include: else-pop - switch-block-contents: - - meta_scope: meta.block.js - - - match: \} - scope: punctuation.section.block.end.js - pop: true + function-parameter-binding-list: + - match: ',' + scope: punctuation.separator.parameter.function.js + - include: function-parameter-binding-spread + - match: (?={{binding_pattern_lookahead}}) + push: function-parameter + - include: else-pop - - match: case{{identifier_break}} - scope: keyword.control.conditional.case.js + property-access: + - match: ({{dot_accessor}})?(\[) + captures: + 1: punctuation.accessor.js + 2: punctuation.section.brackets.begin.js push: - - expect-case-colon - - expression + - meta_scope: meta.brackets.js + - match: \] + scope: punctuation.section.brackets.end.js + pop: 1 + - match: (?=\S) + push: expression - - match: default{{identifier_break}} - scope: keyword.control.conditional.default.js + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js push: - - expect-case-colon + - match: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\() + set: + - call-method-meta + - function-call-arguments + - call-path + - object-property + - include: object-property - - include: statements + object-property: + - include: support-property - arrow-function-expect-arrow: - - match: => - scope: keyword.declaration.function.arrow.js - pop: true + - match: (?=\#?{{identifier_name}}{{function_assignment_lookahead}}) + set: + - function-name-meta + - object-property-base + + - match: (?=#?{{identifier_name}}\s*(?:{{dot_accessor}})?\() + set: call-method-name + + - match: '{{identifier_name}}(?={{nothing}}`)' + scope: variable.function.tagged-template.js + pop: 1 + + - include: object-property-base - include: else-pop - arrow-function-declaration: + jsdoc-comment-body: - meta_include_prototype: false - - match: '' - set: - - function-meta - - arrow-function-expect-body - - arrow-function-expect-arrow - - flow-arrow-function-return-type-annotation - - arrow-function-expect-parameters - - flow-type-generic-parameters + - meta_scope: comment.block.documentation.js + - include: block-comment-end + # JSDoc "block" tags (i.e. @param) are only accepted at the beginning of the documentation + # line so directly after the '/**' or after the '*' marker on the next lines. + - match: ^\s*(\*)(?!/) + captures: + 1: punctuation.definition.comment.js + push: jsdoc-block-tag - flow-type-declare-export: - - match: default{{identifier_break}} - scope: keyword.control.import-export.js - set: flow-type - - match: (?=\S) - pop: true + prototype: + - include: comments - constructor-body-expect-class-begin: - - match: (?={{non_reserved_identifier}}\s*\() - set: - - include: support - - match: '{{dollar_only_identifier}}' - scope: variable.type.dollar.only.js punctuation.dollar.js - pop: true - - match: '{{dollar_identifier}}' - scope: variable.type.dollar.js - captures: - 1: punctuation.dollar.js - pop: true - - match: '{{identifier_name}}' - scope: variable.type.js - pop: true - - include: else-pop + call-method-meta: + - meta_include_prototype: false + - meta_scope: meta.function-call.method.js + - include: immediately-pop + + jsx-meta: + - meta_include_prototype: false + - meta_scope: meta.jsx.js + - include: immediately-pop + decorator-expression-begin: + - include: decorator-name + - include: parenthesized-expression - include: expression-begin - literal-string-template-custom-lookahead: [] - line-comment-end: - - match: (//+)?\n - captures: - 1: punctuation.definition.comment.js + computed-property-name: + - match: \[ + scope: punctuation.section.brackets.begin.js + set: + - meta_scope: meta.brackets.js + - match: \] + scope: punctuation.section.brackets.end.js + pop: 1 + - match: (?=\S) + push: expression + + jsx-expect-tag-end: + - meta_content_scope: meta.tag.js + - match: '>' + scope: meta.tag.js punctuation.definition.tag.end.js pop: 1 + - include: else-pop - object-property-base: + support-property-ecma-date: + - match: (?:now|parse|UTC){{identifier_break}} + scope: support.function.builtin.js + pop: 1 + + block-comments: + # empty block comments + - match: /\*\*+/ + scope: comment.block.empty.js punctuation.definition.comment.js + # documentation block comments + - match: /\*\*+ + scope: punctuation.definition.comment.begin.js + push: + - jsdoc-comment-body + - jsdoc-block-tag + # normal block comments + - match: /\* + scope: punctuation.definition.comment.begin.js + push: block-comment-body + + decorator-expression-pop: + # Consume only comments (ignore patterns from inheriting syntaxes) + # and clear `meta.annotation` scope so it looks like the comment not being + # part of the annotation anymore. + # Pop `decorator-expression-end` at the same text point the previous branch + # fails at in order to prevent ST's syntax engine to lock up. + # see: https://github.com/sublimehq/sublime_text/issues/5853 + - clear_scopes: 1 + - meta_include_prototype: false + - include: comments + - include: else-pop-2 + + call-function-name: - match: '{{dollar_only_identifier}}' - scope: meta.property.object.dollar.only.js punctuation.dollar.js - pop: true - - match: '{{dollar_identifier}}' - scope: meta.property.object.dollar.js - captures: - 1: punctuation.dollar.js - pop: true + scope: variable.function.js variable.other.dollar.only.js punctuation.dollar.js + pop: 1 - match: '{{identifier_name}}' - scope: meta.property.object.js - pop: true - - match: '{{identifier_part}}+{{identifier_break}}' - scope: invalid.illegal.illegal-identifier.js - pop: true - - match: (#)({{identifier_name}}) - captures: - 1: punctuation.definition.variable.js - 2: meta.property.object.js - pop: true - - jsx-tag: - - match: < - scope: punctuation.definition.tag.begin.js - set: - - jsx-meta - - jsx-tag-attributes-top + scope: variable.function.js + pop: 1 + - include: else-pop - class-body: - - match: \{ - scope: punctuation.section.block.begin.js - set: class-body-contents + support-property-ecma-number: + - match: (?:EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY){{identifier_break}} + scope: support.constant.builtin.js + pop: 1 + - match: (?:isFinite|isInteger|isNaN|isSafeInteger|NaN|parseFloat|parseInt){{identifier_break}} + scope: support.function.builtin.js + pop: 1 - - include: else-pop + literal-single-quoted-string-content: + - meta_include_prototype: false + - meta_scope: meta.string.js string.quoted.single.js + - match: \' + scope: punctuation.definition.string.end.js + pop: 1 + - match: \n + scope: invalid.illegal.newline.js + pop: 1 + - include: string-content - styled-component-keyframes-end: - - match: (?=`) + regexp: + - meta_include_prototype: false + - meta_scope: meta.string.js string.regexp.js + - match: / + scope: punctuation.definition.string.end.js + set: + - meta_include_prototype: false + - meta_content_scope: meta.string.js string.regexp.js + - match: '[gimyus]' + scope: keyword.other.js + - match: '[A-Za-z0-9]' # Ignore unknown flags for future-compatibility + - include: immediately-pop + - match: (?=.|\n) push: - - match: '`' - scope: string.quoted.other.js punctuation.definition.string.begin.js - push: - - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.other.js - - match: '`' - scope: punctuation.definition.string.end.js - pop: true - - include: immediately-pop - - - meta_include_prototype: false - - clear_scopes: 1 - - include: immediately-pop - - - meta_include_prototype: false - - match: '' - set: scope:source.js.css#at-keyframe-block-content - with_prototype: - - match: (?=`) - pop: true - - match: \$\{ - scope: punctuation.section.interpolation.begin.js - push: - - clear_scopes: 1 - - meta_scope: meta.interpolation.js - - meta_content_scope: source.js.embedded.expression - - match: \} - scope: punctuation.section.interpolation.end.js - pop: true - - match: (?=\S) - push: expression - - include: string-content - - include: else-pop - - include: else-pop + - meta_include_prototype: false + - match: (?=/) + pop: 1 + - include: scope:source.regexp.js - line-comment-other-body: + call-function-meta: - meta_include_prototype: false - - meta_scope: comment.line.other.js - - include: line-comment-end + - meta_scope: meta.function-call.js + - include: immediately-pop - detect-arrow: - - match: (?==>) - fail: arrow-function - - include: else-pop + yield-expression: + - match: yield{{identifier_break}} + scope: keyword.control.flow.yield.js + set: + - match: $ + pop: 1 + - match: \* + scope: keyword.generator.asterisk.js + set: expression-begin + - match: (?=\S) + set: expression-begin - support-property-ecma-bigint: - - match: (?:asUintN|asIntN){{identifier_break}} - scope: support.function.builtin.js - pop: true + declaration: + - include: variable-declaration + - include: class + - include: regular-function - postfix-operators: - - match: -- - scope: keyword.operator.arithmetic.js - - match: \+\+ - scope: keyword.operator.arithmetic.js + export-list: + - match: ',' + scope: punctuation.separator.comma.js + push: + - import-export-alias + - export-item + - include: else-pop - import-meta: - - meta_include_prototype: false - - meta_scope: meta.import.js - - include: immediately-pop + literal-single-quoted-string: + - match: \' + scope: punctuation.definition.string.begin.js + set: literal-single-quoted-string-content - support-property-ecma-json: - - match: (?:parse|stringify){{identifier_break}} + literal-string-template-custom-comments: [] + support-property-ecma-arraybuffer: + - match: isView{{identifier_break}} scope: support.function.builtin.js - pop: true + pop: 1 - arrow-function-expect-arrow-or-fail-async: - - match: => - scope: keyword.declaration.function.arrow.js - pop: true - - match: (?=\S) - fail: async-arrow-function + support-property-ecma-string: + - match: (?:fromCharCode|fromCodePoint|raw){{identifier_break}} + scope: support.function.builtin.js + pop: 1 - inherited-class-expression-end: - - include: flow-type-generic-arguments + class-element-modifiers: + - match: '' + pop: 1 + branch_point: class-element-modifier + branch: + - class-element-modifier + - class-element - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - push: - - include: inherited-class-name - - include: object-property + line-comment-end: + - match: (//+)?\n + captures: + 1: punctuation.definition.comment.js + pop: 1 - - include: left-expression-end + else-pop: + - match: (?=\S) + pop: 1 - jsx-tag-name-component: - - match: '{{jsx_identifier}}' - scope: entity.name.tag.js - pop: true + import-check-branch: + - match: (?=[.(]) # Recovery for import expressions + fail: import-statement - include: else-pop - support-variable-node: - - match: global{{identifier_break}} - scope: support.type.object.node.js - pop: true - - - match: Buffer{{identifier_break}} - scope: support.class.node.js - pop: true - - - match: process{{identifier_break}} - scope: support.constant.node.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-node-process - - include: object-property - - include: else-pop - - include: else-pop + literal-string-template-content: + - meta_include_prototype: false + - meta_scope: meta.string.js string.quoted.other.js + - match: \` + scope: punctuation.definition.string.end.js + pop: 1 + - include: string-interpolations + - include: string-content - # Module-level variables - - match: (?:__dirname|__filename|exports){{identifier_break}} - scope: support.constant.node.js - pop: true - - match: module{{identifier_break}} - scope: support.constant.node.js + jsx-interpolation-plain: + - match: '{' + scope: punctuation.definition.interpolation.begin.js set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-node-module - - include: object-property - - include: else-pop - - include: else-pop - - match: require{{identifier_break}} - scope: support.function.node.js - pop: true + - - meta_scope: meta.interpolation.js + - meta_content_scope: source.js.embedded.jsx + - match: '}' + scope: punctuation.definition.interpolation.end.js + pop: 1 + - expression - inherited-class-name: - - match: '{{non_reserved_identifier}}{{left_expression_end_lookahead}}' - scope: entity.other.inherited-class.js - pop: true + flow-type-export-type: + - match: type{{identifier_break}}(?=\s*\{) + scope: keyword.declaration.js + set: export-item + - include: flow-type-alias - property-access: - - match: ({{dot_accessor}})?(\[) - captures: - 1: punctuation.accessor.js - 2: punctuation.section.brackets.begin.js - push: - - meta_scope: meta.brackets.js - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - match: (?=\S) - push: expression + class-extends: + - match: extends{{identifier_break}} + scope: storage.modifier.extends.js + set: + - inherited-class-expression-end + - inherited-class-expression-begin + - include: else-pop - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - push: - - match: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\() - set: - - call-method-meta - - function-call-arguments - - call-path - - object-property - - include: object-property + flow-less-than: + - match: < + scope: keyword.operator.comparison.js + set: expression-begin - line-comments: - - match: /{4,} - scope: punctuation.definition.comment.js - push: line-comment-other-body - - match: /{3} - scope: punctuation.definition.comment.js - push: line-comment-triple-slash-body - - match: /{2} - scope: punctuation.definition.comment.js - push: line-comment-double-slash-body + flow-type-alias-initializer: + - match: '=' + scope: keyword.operator.assignment.js + set: + - flow-type-meta + - flow-type + - include: else-pop + import-meta-expression: + - match: import{{identifier_break}} + scope: keyword.import.js + set: import-expression-end - custom-templates-default: - - include: literal-string-template + comma-separator: + - match: ',' + scope: punctuation.separator.comma.js - call-method-name: - - include: support-property - - match: '{{identifier_name}}' - scope: variable.function.js - pop: true - - match: (#){{identifier_name}} - scope: variable.function.js - captures: - 1: punctuation.definition.js - pop: true + literal-string-template-custom-tags: [] + import-export-from: + - match: from{{identifier_break}} + scope: keyword.control.import-export.js + set: literal-string - include: else-pop - function-meta: - - meta_include_prototype: false - - meta_scope: meta.function.js - - include: immediately-pop + function-parameter-binding-object-alias: + - match: ':' + scope: punctuation.separator.key-value.js + set: function-parameter-binding-pattern + - include: else-pop - constructor-meta: - - meta_include_prototype: false - - meta_scope: meta.function-call.constructor.js - - include: immediately-pop + jsx-tag: + - match: < + scope: punctuation.definition.tag.begin.js + set: + - jsx-meta + - jsx-tag-attributes-top - for-meta: - - meta_include_prototype: false - - meta_scope: meta.for.js - - include: immediately-pop + flow-function-type-arguments-or-less-than: + - match: (?=<(?![<=])) + branch_point: flow-function-type-arguments + branch: + - flow-function-type-arguments + - flow-less-than - for-condition-end: - - meta_scope: meta.group.js + flow-type-object-contents: + - include: comma-separator + - match: ; + scope: punctuation.separator.semicolon.js + - match: '{{method_lookahead}}' + push: method-declaration + - match: \+ + scope: storage.modifier.variance.js + - match: '{{non_reserved_identifier}}' + scope: meta.object-literal.key.js + push: flow-type-object-value + - match: \[ + scope: punctuation.section.brackets.begin.js + push: + - flow-type-object-value + - flow-type-object-indexer-type + - flow-type-object-indexer-label - - match: \) - scope: punctuation.section.group.js - pop: true + literal-double-quoted-string-content: + - meta_include_prototype: false + - meta_scope: meta.string.js string.quoted.double.js + - match: \" + scope: punctuation.definition.string.end.js + pop: 1 + - match: \n + scope: invalid.illegal.newline.js + pop: 1 + - include: string-content - export-extended: - - include: flow-type-export-type + conditional: + - match: switch{{identifier_break}} + scope: keyword.control.conditional.switch.js + set: + - switch-meta + - switch-block + - expect-parenthesized-expression - - include: declaration + - match: do{{identifier_break}} + scope: keyword.control.loop.do-while.js + set: + - do-while-meta + - do-while-condition + - statement - - match: default{{identifier_break}} - scope: keyword.control.import-export.js + - match: for{{identifier_break}} + scope: keyword.control.loop.for.js set: - - include: declaration - - match: (?=\S) - set: expression-statement + - for-meta + - block-scope + - for-condition + - for-await - - match: (?=\S) + - match: while{{identifier_break}} + scope: keyword.control.loop.while.js set: - - expect-semicolon - - import-export-from - - export-list - - import-export-alias - - export-item + - while-meta + - block-scope + - expect-parenthesized-expression - flow-type-meta: - - meta_scope: meta.flow-type.js - - include: immediately-pop + - match: with{{identifier_break}} + scope: keyword.control.import.with.js + set: + - with-meta + - block-scope + - expect-parenthesized-expression - left-expression-end: - - include: expression-break + - match: if{{identifier_break}} + scope: keyword.control.conditional.if.js + set: + - conditional-meta + - statement + - expect-parenthesized-expression - - match: (?=`) - push: literal-string-template + - match: else\s+if{{identifier_break}} + scope: keyword.control.conditional.elseif.js + set: + - conditional-meta + - statement + - expect-parenthesized-expression - - match: (?=(?:{{dot_accessor}})?\() - push: function-call-arguments + - match: else{{identifier_break}} + scope: keyword.control.conditional.else.js + set: + - conditional-meta + - statement - - include: property-access + - match: try{{identifier_break}} + scope: keyword.control.exception.try.js + set: + - try-meta + - block-scope - - include: else-pop + - match: finally{{identifier_break}} + scope: keyword.control.exception.finally.js + set: + - finally-meta + - block-scope - support-property-ecma-atomics: - - match: (?:and|add|compareExchange|exchange|isLockFree|load|or|store|sub|wait|wake|xor){{identifier_break}} - scope: support.function.builtin.js - pop: true + - match: catch{{identifier_break}} + scope: keyword.control.exception.catch.js + set: + - catch-meta + - block-scope + - catch-binding - flow-arrow-return-type: - - match: '' - push: - - flow-detect-arrow-after-return-type - - flow-arrow-function-return-type-annotation + statements: + - match: \)|\}|\] + scope: invalid.illegal.stray-bracket-end.js + pop: 1 - object-literal-element: - - match: '{{identifier_name}}(?=\s*(?:[},]|$|//|/\*))' - scope: variable.other.readwrite.js - pop: true - match: (?=\S) - pop: true - branch_point: object-literal-property - branch: - - object-literal-property - - method-declaration + push: statement - import-item: - - include: flow-type-import-type + prefixed-object-literal-method: + - match: (?:get|set){{identifier_break}} + scope: storage.type.accessor.js + set: + - meta_scope: meta.function.js + - match: (?={{class_element_name}}) + set: method-declaration + - match: (?=\S) + fail: prefixed-object-literal-method + - match: (?:async){{identifier_break}} + scope: keyword.declaration.async.js + set: + - meta_scope: meta.function.js + - match: (?=\*|{{class_element_name}}) + set: method-declaration + - match: (?=\S) + fail: prefixed-object-literal-method - - match: \{ - scope: punctuation.section.block.begin.js - set: import-brace - - match: '{{non_reserved_identifier}}' - scope: variable.other.readwrite.js - pop: true - - match: \* - scope: constant.other.js - pop: true - - include: else-pop + jsx-tag-name-component-possibly-native: + - match: '[[:lower:]]{{jsx_identifier_part}}*{{jsx_identifier_break}}(?!{{nothing}}[.:])' + scope: entity.name.tag.native.js + pop: 1 + - include: jsx-tag-name-component - jsx-meta-unmatched-tag: + decorator-meta: - meta_include_prototype: false - - meta_scope: invalid.illegal.unmatched-tag.js + - meta_scope: meta.annotation.js - include: immediately-pop - flow-type-import-type: - - match: type{{identifier_break}} - scope: keyword.declaration.js - - - match: typeof{{identifier_break}} - scope: keyword.operator.js - - flow-type-object-indexer-label: - - match: ({{non_reserved_identifier}})\s*(:) - captures: - 1: meta.object-literal.key.js - 2: punctuation.separator.key-value.js - pop: true + function-declaration-expect-async: + - match: async{{identifier_break}} + scope: keyword.declaration.async.js + pop: 1 - include: else-pop - variable-binding-list: - - include: comma-separator - - match: (?={{binding_pattern_lookahead}}) - push: - - initializer - - variable-binding-pattern - - include: else-pop + shebang-body: + - meta_include_prototype: false + - meta_scope: comment.line.shebang.js + # Note: Keep sync with first_line_match! + - match: '{{shebang_lang}}' + scope: constant.language.shebang.js + - match: \n + pop: 1 - flow-type-declare: - - match: declare{{identifier_break}}(?=\s*(?:type|class|function|var|let|const|opaque|export|module){{identifier_break}}) - scope: keyword.declaration.js + jsx-body: + - meta_include_prototype: false + + - match: < + scope: punctuation.definition.tag.begin.js set: - - match: opaque{{identifier_break}} - scope: storage.modifier.js - pop: true - - match: module{{identifier_break}} - scope: keyword.declaration.js + - meta_scope: meta.tag.js + + - match: / + scope: punctuation.definition.tag.begin.js set: - - flow-type-module-meta - - flow-type-module-body - - flow-type-module-name - - match: export{{identifier_break}} - scope: keyword.declaration.js - set: flow-type-declare-export - - include: else-pop + - jsx-expect-tag-end + - jsx-tag-name + + - match: (?=\S) + set: + - jsx-body + - jsx-tag-attributes + - jsx-tag-name - support-property-ecma-object: - - match: (?:assign|create|defineProperties|defineProperty|entries|freeze|fromEntries|getOwnPropertyDescriptors?|getOwnPropertyNames|getOwnPropertySymbols|getPrototypeOf|is|isExtensible|isFrozen|isSealed|keys|preventExtensions|seal|setPrototypeOf|values){{identifier_break}} - scope: support.function.builtin.js - pop: true + - include: jsx-html-escapes + - include: jsx-interpolation + import-statement-or-import-meta: + - match: (?=import{{identifier_break}}) + branch_point: import-statement + branch: + - import-statement + - expression-statement - jsx-expect-tag-end: - - meta_content_scope: meta.tag.js - - match: '>' - scope: meta.tag.js punctuation.definition.tag.end.js - pop: true + function-parameter-binding-object-key: + - match: '{{identifier_name}}(?=\s*:)' + pop: 1 + - include: literal-string + - include: computed-property-name + - include: function-parameter-binding-name - include: else-pop - immediately-pop: - - match: '' - pop: true - - support-property-ecma-number: - - match: (?:EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY){{identifier_break}} - scope: support.constant.builtin.js - pop: true - - match: (?:isFinite|isInteger|isNaN|isSafeInteger|NaN|parseFloat|parseInt){{identifier_break}} - scope: support.function.builtin.js - pop: true + for-condition-contents: + # This could be either type of for loop. + - match: (?:const|let|var){{identifier_break}} + scope: keyword.declaration.js + set: + - - include: for-of-rest + - match: (?=\S) + set: + - for-oldstyle-rest + - variable-binding-list + - initializer + - variable-binding-pattern - expression-statement: - match: (?=\S) set: - - expect-semicolon - - expression-statement-end + - - include: for-of-rest + - match: (?=\S) + set: for-oldstyle-rest + - expression-end-no-in - expression-begin - flow-arrow-function-return-type-annotation: - - match: ':' - scope: punctuation.separator.type.js - set: - - flow-type-meta - - flow-type-end-no-arrow - - flow-type-begin - - match: (?!\s*(?:$|:|//|/\*)) - pop: true + support-property-ecma-array: + - match: (?:from|isArray|of){{identifier_break}} + scope: support.function.builtin.js + pop: 1 - prefixed-method: - - match: (?:get|set){{identifier_break}} - scope: storage.type.accessor.js + literal-double-quoted-string: + - match: \" + scope: punctuation.definition.string.begin.js + set: literal-double-quoted-string-content + + function-parameter-binding-pattern: + - match: '' set: - - meta_scope: meta.function.js - - match: (?={{class_element_name}}) - set: method-declaration - - match: (?=\S) - fail: prefixed-method - - match: (?:async){{identifier_break}} - scope: keyword.declaration.async.js + - - include: flow-type-annotation-optional + - - include: function-parameter-binding-name + - include: function-parameter-binding-array-destructuring + - include: function-parameter-binding-object-destructuring + - include: else-pop + + function-parameter-binding-array-destructuring: + - match: \[ + scope: punctuation.section.sequence.begin.js set: - - meta_scope: meta.function.js - - match: (?=\*|{{class_element_name}}) - set: method-declaration - - match: (?=\S) - fail: prefixed-method + - meta_scope: meta.binding.destructuring.sequence.js + - match: \] + scope: punctuation.section.sequence.end.js + pop: 1 + - include: function-parameter-binding-list - export-list: + variable-binding-list-top: - match: ',' scope: punctuation.separator.comma.js - push: - - import-export-alias - - export-item + push: variable-binding-top - include: else-pop - shebang: + import-assert: + - match: assert{{identifier_break}} + scope: keyword.control.import-export.js + set: + - include: object-literal + - include: else-pop + - include: else-pop + + object-literal-property-check: + - match: (?=\() + fail: object-literal-property + - include: else-pop + + ternary-operator-expect-colon: + - match: ':' + scope: keyword.operator.ternary.js + set: expression-no-comma + - include: else-pop + + with-meta: - meta_include_prototype: false - - match: ^\#! - scope: punctuation.definition.comment.js - set: shebang-body - - match: ^|(?=\S) # Note: Ensure to highlight shebang if the syntax is embedded. - pop: 1 + - meta_scope: meta.with.js + - include: immediately-pop - static-block: - - match: static{{identifier_break}} - scope: storage.modifier.js - set: - - match: \{ - scope: punctuation.section.block.begin.js - set: static-block-body - - match: (?=\S) - fail: static-block + object-literal-contents: + - meta_scope: meta.mapping.js - expression-end: - - include: flow-function-type-arguments-or-less-than + - match: \} + scope: punctuation.section.mapping.end.js + pop: 1 - - include: postfix-operators - - include: binary-operators - - include: ternary-operator + - match: \.\.\. + scope: keyword.operator.spread.js + push: expression-no-comma - - include: left-expression-end + - match: >- + (?x)(?= + {{property_name}}\s*:\s* + {{either_func_lookahead}} + ) + push: + - object-literal-meta-key + - method-name - yield-expression: - - match: yield{{identifier_break}} - scope: keyword.control.flow.yield.js - set: - - match: $ - pop: true - - match: \* - scope: keyword.generator.asterisk.js - set: expression-begin - - match: (?=\S) - set: expression-begin + - match: (?=\*) + push: method-declaration - flow-detect-arrow-function-return-type: - - match: (?=:) - pop: true - branch_point: flow-arrow-function-return-type + - match: (?=(?:get|set|async){{identifier_break}}) + branch_point: prefixed-object-literal-method branch: - - flow-arrow-return-type - - immediately-pop - - include: else-pop + - prefixed-object-literal-method + - object-literal-element - jsdoc-block-tag: - - match: '{{jsdoc_block_tag}}' - scope: entity.other.attribute-name.documentation.js - pop: 1 - - match: (?=\S)|$ - pop: 1 + - match: (?={{property_name}}) + push: object-literal-element - export-brace: - - meta_scope: meta.block.js - include: comma-separator - - match: \} - scope: punctuation.section.block.end.js - pop: true - - match: '{{identifier_name}}' - scope: variable.other.readwrite.js - push: import-export-alias - - match: \* - scope: constant.other.js - push: import-export-alias - - include: else-pop - decorator-expression-end: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - push: - - include: decorator-name - - include: object-property + - match: ':' + scope: punctuation.separator.key-value.js + push: expression-no-comma - - include: left-expression-end + # If there's any garbage, parse it as an expression + # so that close braces won't break things. + - match: (?=\S) + push: expression-no-comma - literal-private-variable: - - match: (#)({{identifier_name}}) - captures: - 1: punctuation.definition.variable.js - 2: variable.other.readwrite.js - pop: true + expression-no-comma: + - meta_include_prototype: false + - match: '' + set: [expression-end-no-comma, expression-begin] - flow-type-annotation-optional: - - match: \?(?=:) - scope: storage.modifier.optional.js - - include: flow-type-annotation + method-declaration-expect-asterisk: + - match: \* + scope: keyword.generator.asterisk.js + - include: else-pop - class-meta: + support-property-ecma-reflect: + - match: (?:apply|construct|defineProperty|deleteProperty|get|getOwnPropertyDescriptor|getPrototypeOf|has|isExtensible|ownKeys|preventExtensions|set|setPrototypeOf){{identifier_break}} + scope: support.function.builtin.js + pop: 1 + + for-oldstyle-rest: + - match: (?=\)) + pop: 1 + - match: ; + scope: punctuation.separator.expression.js + - match: (?=\S) + push: expression + + finally-meta: - meta_include_prototype: false - - meta_scope: meta.class.js + - meta_scope: meta.finally.js - include: immediately-pop - literal-string-template-custom-tags: [] - jsx-interpolation: - - match: (?={/\*) - branch_point: jsx-interpolation-comment - branch: - - jsx-interpolation-comment - - jsx-interpolation-plain - - match: (?={) - push: jsx-interpolation-plain + class-body-contents: + - meta_scope: meta.block.js + + - match: \} + scope: punctuation.section.block.end.js + pop: 1 - declaration: - - include: variable-declaration - - include: class - - include: regular-function + - match: \; + scope: punctuation.terminator.statement.js - decorator-name: - - match: '{{identifier_name}}{{left_expression_end_lookahead}}' - scope: variable.annotation.js - pop: true + - include: decorator - jsx-tag-name: - - meta_include_prototype: false - - match: '' - set: - - jsx-tag-name-meta - - jsx-tag-name-end - - jsx-tag-name-component-possibly-native + - match: constructor{{identifier_break}} + scope: entity.name.function.constructor.js + push: + - function-meta + - function-declaration-expect-body + - function-declaration-expect-parameters - conditional: - - match: switch{{identifier_break}} - scope: keyword.control.conditional.switch.js - set: - - switch-meta - - switch-block - - expect-parenthesized-expression + - match: (?=static{{identifier_break}}) + branch_point: static-block + branch: + - static-block + - class-element-modifiers - - match: do{{identifier_break}} - scope: keyword.control.loop.do-while.js - set: - - do-while-meta - - do-while-condition - - statement + - match: (?={{modifier}}) + push: class-element-modifiers - - match: for{{identifier_break}} - scope: keyword.control.loop.for.js - set: - - for-meta - - block-scope - - for-condition - - for-await + - match: |- + (?x)(?= + \#? {{identifier_name}} + \s* = \s* + {{either_func_lookahead}} + ) + push: + - initializer + - function-name-meta + - literal-variable-base - - match: while{{identifier_break}} - scope: keyword.control.loop.while.js - set: - - while-meta - - block-scope - - expect-parenthesized-expression + - match: (?=(?:get|set|async){{identifier_break}}) + branch_point: prefixed-method + branch: + - prefixed-method + - class-element - - match: with{{identifier_break}} - scope: keyword.control.import.with.js - set: - - with-meta - - block-scope - - expect-parenthesized-expression + - match: (?=\*) + push: method-declaration - - match: if{{identifier_break}} - scope: keyword.control.conditional.if.js - set: - - conditional-meta - - statement - - expect-parenthesized-expression + - match: (?={{class_element_name}}) + push: class-element - - match: else\s+if{{identifier_break}} - scope: keyword.control.conditional.elseif.js - set: - - conditional-meta - - statement - - expect-parenthesized-expression + support-property-ecma-json: + - match: (?:parse|stringify){{identifier_break}} + scope: support.function.builtin.js + pop: 1 - - match: else{{identifier_break}} - scope: keyword.control.conditional.else.js - set: - - conditional-meta - - statement + line-comments: + - match: /{4,} + scope: punctuation.definition.comment.js + push: line-comment-other-body + - match: /{3} + scope: punctuation.definition.comment.js + push: line-comment-triple-slash-body + - match: /{2} + scope: punctuation.definition.comment.js + push: line-comment-double-slash-body - - match: try{{identifier_break}} - scope: keyword.control.exception.try.js - set: - - try-meta - - block-scope + support-property-ecma-promise: + - match: (?:all|race|reject|resolve|allSettled|any){{identifier_break}} + scope: support.function.builtin.js + pop: 1 - - match: finally{{identifier_break}} - scope: keyword.control.exception.finally.js - set: - - finally-meta - - block-scope + export-extended: + - include: flow-type-export-type - - match: catch{{identifier_break}} - scope: keyword.control.exception.catch.js - set: - - catch-meta - - block-scope - - expect-parenthesized-expression + - include: declaration - jsx-tag-attributes-top: - - meta_scope: meta.tag.js - - match: / - scope: punctuation.definition.tag.begin.js + - match: default{{identifier_break}} + scope: keyword.control.import-export.js set: - - jsx-meta-unmatched-tag - - jsx-expect-tag-end - - jsx-tag-name + - include: declaration + - match: (?=\S) + set: expression-statement - match: (?=\S) set: - - jsx-tag-attributes - - flow-jsx-tag-check - - jsx-tag-name - - flow-jsx-tag-check-name - - new-target: - - match: \. - scope: punctuation.accessor.dot.js - set: - - match: target{{identifier_break}} - scope: variable.language.target.js - pop: true - - include: else-pop - - - include: else-pop + - expect-semicolon + - import-export-from + - export-list + - import-export-alias + - export-item - static-block-body: - - meta_scope: meta.block.js + flow-type-module-contents: - match: \} scope: punctuation.section.block.end.js pop: true - - include: statements + - include: main - flow-type-annotation: - - match: ':' - scope: punctuation.separator.type.js + arrow-function-expect-parameters: + - match: (?={{identifier_start}}) set: - - flow-type-meta - - flow-type - - match: (?!\s*(?:$|:|//|/\*)) - pop: true + - clear_scopes: 1 + - meta_scope: meta.function.parameters.js + - match: '{{identifier_name}}' + scope: variable.parameter.function.js + pop: 1 + - include: function-declaration-parameters + - include: else-pop - jsx-tag-name-component-possibly-native: - - match: '[[:lower:]]{{jsx_identifier_part}}*{{jsx_identifier_break}}(?!{{nothing}}[.:])' - scope: entity.name.tag.native.js - pop: true - - include: jsx-tag-name-component + jsdoc-block-tag: + - match: '{{jsdoc_block_tag}}' + scope: entity.other.attribute-name.documentation.js + pop: 1 + - match: (?=\S)|$ + pop: 1 - with-meta: + expression-statement-pop: + # Consume only comments (ignore patterns from inheriting syntaxes) and + # pop `expression-statement-end` at the same text point the previous branch + # fails at in order to prevent ST's syntax engine to lock up. + # see: https://github.com/sublimehq/sublime_text/issues/5853 - meta_include_prototype: false - - meta_scope: meta.with.js - - include: immediately-pop + - include: comments + - include: else-pop-2 - method-declaration-expect-asterisk: - - match: \* - scope: keyword.generator.asterisk.js - - include: else-pop + jsx-attribute-value: + - include: jsx-tag + - include: jsx-interpolation - flow-function-type-arguments: - - match: \<(?!<) - scope: punctuation.definition.generic.begin.js + - match: "'" + scope: punctuation.definition.string.begin.js set: - - - match: (?=[\]()};,`]) - pop: true - - match: (?=\S) - fail: flow-function-type-arguments - - - meta_scope: meta.generic.js - - match: \> - scope: punctuation.definition.generic.end.js - pop: true - - match: ',' - scope: punctuation.separator.comma.js - push: flow-type - - match: (?=\S) - fail: flow-function-type-arguments - - flow-type + - meta_include_prototype: false + - meta_scope: string.quoted.single.js + - match: \' + scope: punctuation.definition.string.end.js + pop: 1 + - include: jsx-html-escapes + - match: '"' + scope: punctuation.definition.string.begin.js + set: + - meta_include_prototype: false + - meta_scope: string.quoted.double.js + - match: \" + scope: punctuation.definition.string.end.js + pop: 1 + - include: jsx-html-escapes + + - include: else-pop - variable-binding-object-destructuring: - - match: \{ - scope: punctuation.section.block.begin.js - set: - - meta_scope: meta.binding.destructuring.mapping.js - - match: \} - scope: punctuation.section.block.end.js - pop: true - - include: variable-binding-spread - - match: (?={{identifier_start}}|\[|'|") - push: - - initializer - - variable-binding-object-alias - - object-literal-meta-key - - variable-binding-object-key - - include: comma-separator + flow-detect-arrow-function-return-type: + - match: (?=:) + pop: true + branch_point: flow-arrow-function-return-type + branch: + - flow-arrow-return-type + - immediately-pop + - include: else-pop support-property-ecma-math: - match: (?:E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2){{identifier_break}} scope: support.constant.builtin.js - pop: true + pop: 1 - match: (?:abs|acos|acosh|asin|asin|atan|atanh|atan2|cbrt|ceil|clz32|cos|cosh|exp|expm1|floor|fround|hypot|imul|log|log1p|log10|log2|max|min|pow|random|round|sign|sin|sinh|sqrt|tan|tanh|trunc){{identifier_break}} scope: support.function.builtin.js - pop: true - - literal-variable: - - include: special-identifier - - include: support + pop: 1 - - match: (?={{identifier_name}}{{function_assignment_lookahead}}) + flow-type-generic-parameters: + - match: < + scope: punctuation.definition.generic.begin.js set: - - function-name-meta - - literal-variable-base - - - match: '{{identifier_name}}(?={{nothing}}`)' - scope: variable.function.tagged-template.js - pop: true - - - match: '{{constant_identifier}}(?=\s*(?:{{dot_accessor}}|\[))' - scope: support.class.js - pop: true - - - match: '{{function_call_lookahead}}' - set: call-function-name - - - include: literal-variable-base + - meta_scope: meta.generic.declaration.js + - match: '>' + scope: punctuation.definition.generic.end.js + pop: true + - include: comma-separator + - match: \+ + scope: storage.modifier.variance.js + - match: '{{non_reserved_identifier}}' + scope: variable.parameter.type.js + push: + - - match: '=' + scope: keyword.operator.assignment.js + set: flow-type + - include: else-pop + - flow-type-annotation + - include: else-pop - import-expression-end: - - match: (?=\() - set: function-call-arguments + decorator-expression-end: - match: '{{dot_accessor}}' scope: punctuation.accessor.js - set: - - match: meta{{identifier_break}} - scope: variable.language.import.js - pop: true + push: + - include: decorator-name - include: object-property - - include: else-pop - special-name: - - match: true{{identifier_break}} - scope: constant.language.boolean.true.js - pop: true - - match: false{{identifier_break}} - scope: constant.language.boolean.false.js - pop: true - - match: null{{identifier_break}} - scope: constant.language.null.js - pop: true - - match: super{{identifier_break}} - scope: variable.language.super.js - pop: true - - match: this{{identifier_break}} - scope: variable.language.this.js - pop: true - - flow-detect-arrow-after-return-type: - - match: (?==>) - fail: arrow-function - - match: (?=\S) - fail: flow-arrow-function-return-type - jsx-html-escapes: - - match: (&)#?[[:alnum:]]+(;) - scope: constant.character.escape.js - captures: - 1: punctuation.definition.entity.js - 2: punctuation.definition.entity.js + - match: (?=`) + push: literal-string-template - expect-label: - - meta_include_prototype: false - - match: (?={{nothing}}{{identifier_name}}) - set: - - match: '{{non_reserved_identifier}}' - scope: variable.label.js - pop: true - - match: '{{identifier_name}}' - scope: invalid.illegal.identifier.js variable.label.js - pop: true - - include: else-pop - - include: immediately-pop + - match: (?=(?:{{dot_accessor}})?\() + push: function-call-arguments - jsx-tag-name-meta: - - clear_scopes: 1 - - meta_include_prototype: false - - meta_scope: meta.tag.name.js - - include: immediately-pop + - match: '{{line_ending_ahead}}' + branch_point: decorator-expression-continuation + branch: + - decorator-expression-continuation + - decorator-expression-pop - class-field-check: - - match: (?=[(<]) - fail: class-field - include: else-pop - function-declaration-expect-parameters: - - include: function-declaration-parameters + for-condition: + - match: \( + scope: punctuation.section.group.begin.js + set: + - for-condition-end + - for-condition-contents - include: else-pop - support-property-ecma-symbol: - - match: (?:asyncIterator|hasInstance|isConcatSpreadable|iterator|match|replace|search|species|split|toPrimitive|toStringTag|unscopeables){{identifier_break}} - scope: support.constant.builtin.js - pop: true - - match: (?:for|keyFor){{identifier_break}} - scope: support.function.builtin.js - pop: true - - support-variable-dom: - - match: XMLHttpRequest{{identifier_break}} - scope: support.class.dom.js - pop: true - - match: (?:document|window|navigator){{identifier_break}} - scope: support.type.object.dom.js - pop: true - - match: (?:clearTimeout|clearInterval|setTimeout|setInterval){{identifier_break}} - scope: support.function.dom.js - pop: true - - label: - - match: ({{identifier_name}})\s*(:) - captures: - 1: entity.name.label.js - 2: punctuation.separator.js + expression: + - meta_include_prototype: false + - match: '' + set: [expression-end, expression-begin] - comments: - - include: line-comments - - include: block-comments + shebang: + - meta_include_prototype: false + - match: ^\#! + scope: punctuation.definition.comment.js + set: shebang-body + - match: ^|(?=\S) # Note: Ensure to highlight shebang if the syntax is embedded. + pop: 1 - variable-binding-name: - - match: (?={{non_reserved_identifier}}) + ternary-operator: + - match: \?(?=[^.]|\.[0-9]) + scope: keyword.operator.ternary.js set: - - - meta_scope: meta.binding.name.js - - include: immediately-pop - - literal-variable + - ternary-operator-expect-colon + - expression-no-comma - jsx-tag-hack: [] - await-expression: - - match: await{{identifier_break}} - scope: keyword.control.flow.await.js + flow-type-class: + - match: '{{non_reserved_identifier}}' + scope: variable.other.class.js + pop: true - import-string-or-items: - - include: literal-string - - match: (?=\S) + flow-type-annotation: + - match: ':' + scope: punctuation.separator.type.js set: - - import-export-from - - import-list - - import-export-alias - - import-item + - flow-type-meta + - flow-type + - match: (?!\s*(?:$|:|//|/\*)) + pop: true - jsx-body: - - meta_include_prototype: false + custom-templates-default: + - match: '`' + scope: string.quoted.other.js punctuation.definition.string.begin.js + push: + - - include: immediately-pop + - custom-templates-closing-quote + - custom-templates-clear-scopes + - - meta_include_prototype: false + - include: literal-string-template-custom-lookahead + - match: (?=\s*\S) + set: + - meta_scope: string.quoted.other.js + - meta_include_prototype: false + - include: custom-templates-prototype - - match: < - scope: punctuation.definition.tag.begin.js + support-variable-ecma: + - match: Array{{identifier_break}} + scope: support.class.builtin.js set: - - meta_scope: meta.tag.js - - - match: / - scope: punctuation.definition.tag.begin.js - set: - - jsx-expect-tag-end - - jsx-tag-name - - - match: (?=\S) + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js set: - - jsx-body - - jsx-tag-attributes - - jsx-tag-name - - - include: jsx-html-escapes - - include: jsx-interpolation - flow-type-utility: - - match: |- - (?x) (?: - Class|Function| - \$(?: - Keys|Values|ReadOnly|Exact|Diff|Rest|PropertyType|ElementType| - ObjMap|TupleMap|Call|Supertype|Subtype - ) - ){{identifier_break}} - scope: support.type.utility.js - pop: true - - variable-binding-object-alias: - - match: ':' - scope: punctuation.separator.key-value.js - set: variable-binding-pattern - - include: else-pop + - include: support-property-ecma-array + - include: object-property + - include: else-pop + - include: else-pop - regexp: - - meta_include_prototype: false - - meta_scope: meta.string.js string.regexp.js - - match: / - scope: punctuation.definition.string.end.js + - match: ArrayBuffer{{identifier_break}} + scope: support.class.builtin.js set: - - meta_include_prototype: false - - meta_content_scope: meta.string.js string.regexp.js - - match: '[gimyus]' - scope: keyword.other.js - - match: '[A-Za-z0-9]' # Ignore unknown flags for future-compatibility - - include: immediately-pop - - match: (?=.|\n) - push: - - meta_include_prototype: false - - match: (?=/) - pop: true - - include: scope:source.regexp.js + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-arraybuffer + - include: object-property + - include: else-pop + - include: else-pop - variable-binding-top: - - match: (?={{binding_pattern_lookahead}}) + - match: Atomics{{identifier_break}} + scope: support.constant.builtin.js set: - - initializer - - variable-binding-pattern - - include: else-pop + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-atomics + - include: object-property + - include: else-pop + - include: else-pop - flow-type: - - match: '' + - match: BigInt{{identifier_break}} + scope: support.class.builtin.js set: - - flow-type-end - - flow-type-begin + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-bigint + - include: object-property + - include: else-pop + - include: else-pop - import-check-branch: - - match: (?=[.(]) # Recovery for import expressions - fail: import-statement - - include: else-pop + - match: Date{{identifier_break}} + scope: support.class.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-date + - include: object-property + - include: else-pop + - include: else-pop - function-parameter: - - match: '' + - match: JSON{{identifier_break}} + scope: support.constant.builtin.js set: - - initializer - - function-parameter-binding-pattern + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-json + - include: object-property + - include: else-pop + - include: else-pop - main: - - meta_include_prototype: false # don't match comments before shebang - - match: '' - push: [script, shebang] + - match: Math{{identifier_break}} + scope: support.constant.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-math + - include: object-property + - include: else-pop + - include: else-pop - flow-type-object-indexer-type: - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - include: flow-type-list + - match: Number{{identifier_break}} + scope: support.class.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-number + - include: object-property + - include: else-pop + - include: else-pop - support-property-ecma-reflect: - - match: (?:apply|construct|defineProperty|deleteProperty|get|getOwnPropertyDescriptor|getPrototypeOf|has|isExtensible|ownKeys|preventExtensions|set|setPrototypeOf){{identifier_break}} - scope: support.function.builtin.js - pop: true + - match: Object{{identifier_break}} + scope: support.class.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-object + - include: object-property + - include: else-pop + - include: else-pop - while-meta: - - meta_include_prototype: false - - meta_scope: meta.while.js - - include: immediately-pop + - match: Promise{{identifier_break}} + scope: support.class.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-promise + - include: object-property + - include: else-pop + - include: else-pop - function-declaration-expect-body: - - include: function-block - - include: else-pop + - match: Proxy{{identifier_break}} + scope: support.class.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-proxy + - include: object-property + - include: else-pop + - include: else-pop - flow-type-object-contents: - - include: comma-separator - - match: ; - scope: punctuation.separator.semicolon.js - - match: '{{method_lookahead}}' - push: method-declaration - - match: \+ - scope: storage.modifier.variance.js - - match: '{{non_reserved_identifier}}' - scope: meta.object-literal.key.js - push: flow-type-object-value - - match: \[ - scope: punctuation.section.brackets.begin.js - push: - - flow-type-object-value - - flow-type-object-indexer-type - - flow-type-object-indexer-label + - match: Reflect{{identifier_break}} + scope: support.constant.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-reflect + - include: object-property + - include: else-pop + - include: else-pop - support-property-ecma-proxy: - - match: revocable{{identifier_break}} - scope: support.function.builtin.js - pop: true + - match: String{{identifier_break}} + scope: support.class.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-string + - include: object-property + - include: else-pop + - include: else-pop - expect-case-colon: - - match: ':' - scope: punctuation.separator.js - pop: true - - include: else-pop + - match: Symbol{{identifier_break}} + scope: support.class.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-symbol + - include: object-property + - include: else-pop + - include: else-pop - class: - - match: class{{identifier_break}} - scope: keyword.declaration.class.js + - match: |- + (?x: + (?: + BigInt64| + BigUint64| + Float(?:32|64)| + Int(?:8|16|32)| + Uint(?:8|16|32|32Clamped) + ) + Array{{identifier_break}} + ) + scope: support.class.builtin.js set: - - class-meta - - class-body - - class-extends - - class-name + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-typedarray + - include: object-property + - include: else-pop + - include: else-pop - jsdoc-comment-body: - - meta_include_prototype: false - - meta_scope: comment.block.documentation.js - - include: block-comment-end - # JSDoc "block" tags (i.e. @param) are only accepted at the beginning of the documentation - # line so directly after the '/**' or after the '*' marker on the next lines. - - match: ^\s*(\*)(?!/) - captures: - 1: punctuation.definition.comment.js - push: jsdoc-block-tag + # Classes with no constructor properties + - match: (?:Boolean|DataView|Function|Map|RegExp|Set|WeakMap|WeakSet){{identifier_break}} + scope: support.class.builtin.js + pop: 1 + - match: (?:Eval|Range|Reference|Syntax|Type|URI)?Error{{identifier_break}} + scope: support.class.builtin.js + pop: 1 + + - match: (?:eval|isFinite|isNaN|parseFloat|parseInt|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent){{identifier_break}} + scope: support.function.js + pop: 1 - else-pop: - - match: (?=\S) + object-property-name: + - match: '{{identifier_name}}' + scope: string.unquoted.js pop: true - jsx-interpolation-comment: - - match: ({)(/\*) - captures: - 1: punctuation.definition.interpolation.begin.js - 2: punctuation.definition.comment.begin.js - set: - - meta_include_prototype: false - - meta_scope: meta.interpolation.js comment.block.js - - match: (\*/)(}) - captures: - 1: punctuation.definition.comment.end.js - 2: punctuation.definition.interpolation.end.js - pop: true - - match: (?=\*/) - fail: jsx-interpolation-comment + - include: computed-property-name + - include: literal-string + - include: literal-number - arrow-function-expect-body: - - include: function-block - - match: (?=\S) + - match: '{{identifier_name}}' + pop: 1 + + - include: else-pop + + flow-arrow-function-declaration-with-type-parameters: [] + flow-type-generic-arguments: + - match: < + scope: punctuation.definition.generic.begin.js region.greenish set: - - block-meta - - expression-no-comma + - - meta_scope: meta.generic.js + - match: '>' + scope: punctuation.definition.generic.end.js + pop: true + - match: ',' + scope: punctuation.separator.comma.js + push: flow-type + - match: (?=\S) + fail: flow-arrow-function-return-type + - flow-type - switch-block: + expression-end-no-in: + - match: (?=in{{identifier_break}}) + pop: 1 + - include: expression-end + + decorator-name: + - match: '{{identifier_name}}(?!\s*[.\(`])' + scope: variable.annotation.js + pop: 1 + + literal-string-template: + - match: \` + scope: punctuation.definition.string.begin.js + set: literal-string-template-content + + export-item: - match: \{ scope: punctuation.section.block.begin.js - set: switch-block-contents + set: export-brace + - match: '{{non_reserved_identifier}}' + scope: variable.other.readwrite.js + pop: 1 + - match: \* + scope: constant.other.js + pop: 1 - include: else-pop - initializer: - - match: '=' - scope: keyword.operator.assignment.js - set: expression-no-comma + jsx-tag-hack: [] + flow-jsx-tag-check: + - match: (?=[:,]) + fail: arrow-function - include: else-pop + inherited-class-name: + - match: '{{non_reserved_identifier}}{{left_expression_end_lookahead}}' + scope: entity.other.inherited-class.js + pop: 1 - flow-type-typeof: - - match: typeof{{identifier_break}} - scope: keyword.operator.js - set: - - left-expression-end - - expression-begin - - support-property-ecma-arraybuffer: - - match: isView{{identifier_break}} - scope: support.function.builtin.js - pop: true - - for-of-rest: - - match: (?:of|in){{identifier_break}} - scope: keyword.operator.word.js - set: expression + flow-type-end: + - match: (?=\|\||&&) + fail: flow-function-type-arguments + - include: flow-type-operators + - include: flow-type-generic-arguments + - include: else-pop - do-while-meta: + conditional-meta: - meta_include_prototype: false - - meta_scope: meta.do-while.js + - meta_scope: meta.conditional.js - include: immediately-pop - constructor-body-expect-arguments: - - include: function-call-arguments - - include: else-pop + literal-call: + - match: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\() + set: + - call-function-meta + - function-call-arguments + - literal-variable - function-call-arguments: - - match: ({{dot_accessor}})?(\() - captures: - 1: punctuation.accessor.js - 2: punctuation.section.group.begin.js + - match: (?={{identifier_name}}\s*(?:{{dot_accessor}}\s*#?{{identifier_name}}\s*)+(?:{{dot_accessor}})?\() set: - - meta_scope: meta.group.js - - match: \) - scope: punctuation.section.group.end.js - pop: true - - include: expression-list + - call-method-meta + - function-call-arguments + - call-path + - literal-variable - class-element-modifiers: - - match: '' - pop: true - branch_point: class-element-modifier - branch: - - class-element-modifier - - class-element + flow-type-begin: + - include: flow-type-existential + - include: flow-type-literal + - include: flow-type-special + - include: flow-type-primitive + - include: flow-type-utility + - include: flow-type-typeof + - include: flow-type-class + - include: flow-type-function + - include: flow-type-tuple + - include: flow-type-object - support-property-ecma-date: - - match: (?:now|parse|UTC){{identifier_break}} - scope: support.function.builtin.js - pop: true + - include: else-pop - object-property: - - include: support-property + inherited-class-expression-begin: + - include: inherited-class-name + - include: expression-begin - - match: (?=\#?{{identifier_name}}{{function_assignment_lookahead}}) - set: - - function-name-meta - - object-property-base + do-while-condition: + - match: while{{identifier_break}} + scope: keyword.control.loop.while.js + set: parenthesized-expression + - include: else-pop - - match: (?=#?{{identifier_name}}\s*(?:{{dot_accessor}})?\() - set: call-method-name + line-comment-triple-slash-body: + - meta_include_prototype: false + - meta_scope: comment.line.triple-slash.js + - include: line-comment-end - - match: '{{identifier_name}}(?={{nothing}}`)' - scope: variable.function.tagged-template.js + flow-type-object-indexer-type: + - match: \] + scope: punctuation.section.brackets.end.js pop: true + - include: flow-type-list - - include: object-property-base + string-interpolations: + - match: \$\{ + scope: punctuation.section.interpolation.begin.js + push: string-interpolation-content + + call-path: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + push: object-property - include: else-pop - flow-type-object-value: - - match: (\?)?(:) - captures: - 1: storage.modifier.optional.js - 2: punctuation.separator.key-value.js - set: flow-type + jsx-tag-name-end: + - match: '[:.]' + scope: punctuation.accessor.js + push: jsx-tag-name-component - include: else-pop - arrow-function-expect-parameters: - - match: (?={{identifier_start}}) - set: - - clear_scopes: 1 - - meta_scope: meta.function.parameters.js - - match: '{{identifier_name}}' - scope: variable.parameter.function.js - pop: true - - include: function-declaration-parameters + function-declaration-expect-generator-star: + - match: \* + scope: keyword.declaration.generator.js + pop: 1 - include: else-pop - async-arrow-function: - - match: async{{identifier_break}} - scope: keyword.declaration.async.js - set: - - function-meta - - arrow-function-expect-body - - arrow-function-expect-arrow-or-fail-async - - arrow-function-expect-parameters + support-property-ecma-object: + - match: (?:assign|create|defineProperties|defineProperty|entries|freeze|fromEntries|getOwnPropertyDescriptors?|getOwnPropertyNames|getOwnPropertySymbols|getPrototypeOf|is|isExtensible|isFrozen|isSealed|keys|preventExtensions|seal|setPrototypeOf|values){{identifier_break}} + scope: support.function.builtin.js + pop: 1 - for-await: - - match: await{{identifier_break}} - scope: keyword.control.flow.await.js - pop: true + constructor-body-expect-arguments: + - include: function-call-arguments - include: else-pop - variable-binding-pattern: - - match: '' - set: - - - include: flow-type-annotation - - - include: variable-binding-name - - include: variable-binding-array-destructuring - - include: variable-binding-object-destructuring - - include: else-pop + decorator: + - match: '@' + scope: punctuation.definition.annotation.js + push: + - decorator-meta + - decorator-expression-end + - decorator-expression-begin + + flow-type-declare-export: + - match: default{{identifier_break}} + scope: keyword.control.import-export.js + set: flow-type + - match: (?=\S) + pop: true + + custom-templates-closing-quote: + - meta_include_prototype: false + - meta_scope: meta.string.js string.quoted.other.js + - match: '`' + scope: punctuation.definition.string.end.js + pop: true + - include: immediately-pop + + styled-component-keyframes-end: + - match: '`' + scope: string.quoted.other.js punctuation.definition.string.begin.js + push: + - - include: immediately-pop + - custom-templates-closing-quote + - custom-templates-clear-scopes + - - meta_include_prototype: false + - match: '' + set: scope:source.js.css#styled-components-keyframe-body + with_prototype: + - include: custom-templates-prototype + - include: else-pop - constructor: - - match: new{{identifier_break}} - scope: keyword.operator.word.new.js - set: - - match: (?=\s*\.) - set: new-target - - match: (?=\s*\S) - set: - - constructor-meta - - constructor-body-expect-arguments - - constructor-body-expect-class-end - - constructor-body-expect-class-begin + variable-binding-spread: + - match: \.\.\. + scope: keyword.operator.spread.js + push: variable-binding-pattern - object-literal: - - match: \{ - scope: punctuation.section.block.begin.js - set: object-literal-contents + function-declaration-expect-parameters: + - include: function-declaration-parameters + - include: else-pop - function-parameter-binding-name: - - match: '{{non_reserved_identifier}}' - scope: meta.binding.name.js variable.parameter.function.js - - match: '{{identifier_name}}' - scope: invalid.illegal.identifier.js meta.binding.name.js variable.parameter.function.js + jsx-tag-name-component: + - match: '{{jsx_identifier}}' + scope: entity.name.tag.js + pop: 1 + - include: else-pop - object-literal-property: - - match: '' + variable-binding-top: + - match: (?={{binding_pattern_lookahead}}) set: - - object-literal-property-check - - object-literal-meta-key - - object-property-name - - constructor-body-expect-class-end: - - include: property-access + - initializer + - variable-binding-pattern - include: else-pop - flow-type-module-contents: - - match: \} - scope: punctuation.section.block.end.js - pop: true - - include: main + support-variable-node: + - match: global{{identifier_break}} + scope: support.type.object.node.js + pop: 1 - array-literal: - - match: \[ - scope: punctuation.section.brackets.begin.js + - match: Buffer{{identifier_break}} + scope: support.class.node.js + pop: 1 + + - match: process{{identifier_break}} + scope: support.constant.node.js set: - - meta_scope: meta.sequence.js - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - include: expression-list + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-node-process + - include: object-property + - include: else-pop + - include: else-pop - for-condition-contents: - # This could be either type of for loop. - - match: (?:const|let|var){{identifier_break}} - scope: keyword.declaration.js + # Module-level variables + - match: (?:__dirname|__filename|exports){{identifier_break}} + scope: support.constant.node.js + pop: 1 + - match: module{{identifier_break}} + scope: support.constant.node.js set: - - - include: for-of-rest - - match: (?=\S) - set: - - for-oldstyle-rest - - variable-binding-list - - initializer - - variable-binding-pattern + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-node-module + - include: object-property + - include: else-pop + - include: else-pop + - match: require{{identifier_break}} + scope: support.function.node.js + pop: 1 - - match: (?=\S) + function-call-arguments: + - match: ({{dot_accessor}})?(\() + captures: + 1: punctuation.accessor.js + 2: punctuation.section.group.begin.js set: - - - include: for-of-rest - - match: (?=\S) - set: for-oldstyle-rest - - expression-end-no-in - - expression-begin + - meta_scope: meta.group.js + - match: \) + scope: punctuation.section.group.end.js + pop: 1 + - include: expression-list - flow-type-tuple: - - match: \[ - scope: punctuation.section.brackets.begin.js + parenthesized-expression: + - match: \( + scope: punctuation.section.group.begin.js set: - - meta_scope: meta.sequence.js - - match: \] - scope: punctuation.section.brackets.end.js + - meta_scope: meta.group.js + - match: \) + scope: punctuation.section.group.end.js pop: true - - include: flow-type-list - - function-declaration-expect-generator-star: - - match: \* - scope: keyword.declaration.generator.js - pop: true - - include: else-pop - - support-property: - - include: support-property-ecma + - match: (?=:) + push: flow-type-annotation + - match: (?=\S) + push: expression - flow-type-module-meta: - - meta_scope: meta.module.js - - include: immediately-pop + support-property-node-process: + - match: (?:arch|argv|argv0|channel|config|connected|debugPort|env|execArgv|execPath|exitCode|mainModule|noDeprecation|pid|platform|ppid|release|stderr|stdin|stdout|throwDeprecation|title|traceDeprecation|version|versions){{identifier_break}} + scope: support.constant.node.js + pop: 1 + - match: (?:abort|chdir|cpuUsage|cwd|disconnect|dlopen|emitWarning|exit|getegid|geteuid|getgit|getgroups|getuid|hasUncaughtExceptionCaptureCallback|hrtime|initGroups|kill|memoryUsage|nextTick|send|setegid|seteuid|setgid|setgroups|setuid|hasUncaughtExceptionCaptureCallback|umask|uptime){{identifier_break}} + scope: support.function.node.js + pop: 1 expression-begin: - include: jsx-tag-hack - include: flow-arrow-function-declaration-with-type-parameters + - include: literal-string-template-custom-tags + - include: styled-components + - match: (?=`) set: - include: literal-string-template-custom-comments - - include: literal-string-template-custom-lookahead - include: custom-templates-default + - include: else-pop - include: expression-break @@ -3049,7 +3119,7 @@ contexts: - include: regular-function - match: (?={{reserved_word}}) - pop: true + pop: 1 - match: (?={{identifier_name}}{{function_assignment_lookahead}}) set: @@ -3060,7 +3130,7 @@ contexts: # Newline not allowed between `async` and parameters. - match: (?=async{{identifier_break}}{{nothing}}{{possible_arrow_function_begin}}) - pop: true + pop: 1 branch_point: async-arrow-function branch: - async-arrow-function @@ -3069,7 +3139,7 @@ contexts: - include: literal-call - match: (?={{possible_arrow_function_begin}}) - pop: true + pop: 1 branch_point: arrow-function branch: - branch-possible-arrow-function @@ -3081,125 +3151,190 @@ contexts: - include: else-pop - flow-type-alias-initializer: - - match: '=' - scope: keyword.operator.assignment.js + field-name: + - match: '{{dollar_identifier}}' + scope: meta.mapping.key.dollar.js variable.other.readwrite.js + captures: + 1: punctuation.dollar.js + pop: 1 + - match: '{{identifier_name}}' + scope: variable.other.readwrite.js + pop: 1 + - match: (#)({{identifier_name}}) + captures: + 1: punctuation.definition.variable.js + 2: variable.other.readwrite.js + pop: 1 + - match: "'" + scope: punctuation.definition.string.begin.js set: - - flow-type-meta - - flow-type - - include: else-pop - flow-type-function: - - match: \( - scope: punctuation.section.grouping.begin.js + - meta_include_prototype: false + - meta_scope: meta.string.js string.quoted.single.js + - meta_content_scope: variable.other.readwrite.js + - match: \' + scope: punctuation.definition.string.end.js + pop: 1 + - match: \n + scope: invalid.illegal.newline.js + pop: 1 + - include: string-content + - match: '"' + scope: punctuation.definition.string.begin.js set: - - meta_scope: meta.group.js - - match: \) - scope: punctuation.section.grouping.end.js - pop: true - - include: flow-type-list - - expression: - - meta_include_prototype: false - - match: '' - set: [expression-end, expression-begin] - - special-identifier: - # These are ordinary identifiers, not reserved words - - match: arguments{{identifier_break}} - scope: variable.language.arguments.js - pop: true - - match: globalThis{{identifier_break}} - scope: variable.language.global.js - pop: true - - match: undefined{{identifier_break}} - scope: constant.language.undefined.js - pop: true - - match: NaN{{identifier_break}} - scope: constant.language.nan.js - pop: true - - match: Infinity{{identifier_break}} - scope: constant.language.infinity.js - pop: true - - block-scope: - - include: block - - include: else-pop - - switch-meta: - - meta_include_prototype: false - - meta_scope: meta.switch.js - - include: immediately-pop - - function-name-meta: - - meta_include_prototype: false - - meta_scope: entity.name.function.js - - include: immediately-pop - - regular-function: - - match: (?={{func_lookahead}}) - set: function-declaration - - import-meta-expression: - - match: import{{identifier_break}} - scope: keyword.import.js - set: import-expression-end - - comma-separator: - - match: ',' - scope: punctuation.separator.comma.js + - meta_include_prototype: false + - meta_scope: meta.string.js string.quoted.double.js + - meta_content_scope: variable.other.readwrite.js + - match: \" + scope: punctuation.definition.string.end.js + pop: 1 + - match: \n + scope: invalid.illegal.newline.js + pop: 1 + - include: string-content - object-property-name: - - match: '{{identifier_name}}' - scope: string.unquoted.js - pop: true + - include: computed-property-name - - match: (?=\[) - set: computed-property-name + - include: else-pop - - include: literal-string - - include: literal-number + support-property-ecma-proxy: + - match: revocable{{identifier_break}} + scope: support.function.builtin.js + pop: 1 - - match: '{{identifier_name}}' - pop: true + binary-operators: + - match: instanceof{{identifier_break}} + scope: keyword.operator.js + push: expression-begin + - match: in{{identifier_break}} + scope: keyword.operator.js + push: expression-begin + - match: =(?![=>]) + scope: keyword.operator.assignment.js + push: expression-begin + - match: |- + (?x) + %= | # assignment right-to-left both + &= | # assignment right-to-left both + \*= | # assignment right-to-left both + \+= | # assignment right-to-left both + -= | # assignment right-to-left both + /= | # assignment right-to-left both + \^= | # assignment right-to-left both + \|= | # assignment right-to-left both + <<= | # assignment right-to-left both + >>= | # assignment right-to-left both + >>>= | # assignment right-to-left both + &&= | + \|\|= | + \?\?= + scope: keyword.operator.assignment.augmented.js + push: expression-begin + - match: '&&|\|\|' + scope: keyword.operator.logical.js + push: expression-begin + - match: \?\? + scope: keyword.operator.null-coalescing.js + push: expression-begin + - match: |- + (?x) + << | # bitwise-shift left-to-right both + >>> | # bitwise-shift left-to-right both + >> | # bitwise-shift left-to-right both + & | # bitwise-and left-to-right both + \^ | # bitwise-xor left-to-right both + \| # bitwise-or left-to-right both + scope: keyword.operator.bitwise.js + push: expression-begin + - match: |- + (?x) + <= | # comparison left-to-right both + >= | # comparison left-to-right both + < | # comparison left-to-right both + > # comparison left-to-right both + scope: keyword.operator.comparison.js + push: expression-begin + - match: |- + (?x) + === | # equality left-to-right both + !== | # equality left-to-right both + == | # equality left-to-right both + != # equality left-to-right both + scope: keyword.operator.comparison.js + push: expression-begin + - match: |- + (?x) + / | # division left-to-right both + % | # modulus left-to-right both + \* | # multiplication left-to-right both + \+ | # addition left-to-right both + - # subtraction left-to-right both + scope: keyword.operator.arithmetic.js + push: expression-begin + - match: ',' + scope: keyword.operator.comma.js # Comma operator, not punctuation. + push: expression-begin + expect-case-colon: + - match: ':' + scope: punctuation.separator.js + pop: 1 - include: else-pop - literal-string-template: - - include: literal-string-template-custom-comments - - include: literal-string-template-custom-tags - - include: styled-components + for-meta: + - meta_include_prototype: false + - meta_scope: meta.for.js + - include: immediately-pop - - match: '`' - scope: punctuation.definition.string.begin.js + import-string-or-items: + - include: literal-string + - match: (?=\S) set: - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.other.js - - match: '`' - scope: punctuation.definition.string.end.js - pop: true - - match: \$\{ - scope: punctuation.section.interpolation.begin.js - push: - - clear_scopes: 1 - - meta_scope: meta.interpolation.js - - meta_content_scope: source.js.embedded - - match: \} - scope: punctuation.section.interpolation.end.js - pop: true - - match: (?=\S) - push: expression - - include: string-content - - flow-type-export-type: - - match: type{{identifier_break}}(?=\s*\{) - scope: keyword.declaration.js - set: export-item - - include: flow-type-alias + - import-export-from + - import-list + - import-export-alias + - import-item +name: JavaScript (Babel) +file_extensions: + - js + - jsx + - es6 + - babel version: 2 variables: + identifier_break: (?!{{identifier_part}}) + either_func_lookahead: (?:{{func_lookahead}}|{{arrow_func_lookahead}}) + identifier_start: (?:[_$\p{L}\p{Nl}]|{{identifier_escape}}) + property_name: >- + (?x: + {{identifier_name}} + | [0-9]+ + | '(?:[^\\']|\\.)*' + | "(?:[^\\"]|\\.)*" + | \[ .* \] + ) + jsx_identifier: '{{identifier_start}}{{jsx_identifier_part}}*{{jsx_identifier_break}}' + identifier_escape: (?:\\u(?:\h{4}|\{\h+\})) + binding_pattern_lookahead: (?:{{identifier_name}}|\[|\{) + line_ending_ahead: (?={{nothing}}(?:/\*{{block_comment_contents}}|//.*)?$) + reserved_word: |- + (?x: + break|case|catch|class|const|continue|debugger|default|delete|do|else| + export|extends|finally|for|function|if|import|in|instanceof|new|return| + super|switch|this|throw|try|typeof|var|void|while|with|yield| + enum| + null|true|false + ){{identifier_break}} + constant_identifier: (?:[[:upper:]]{{identifier_part}}*{{identifier_break}}) + oct_digit: '[0-7_]' + dollar_only_identifier: (?:\${{identifier_break}}) + dec_integer: (?:0|[1-9]{{dec_digit}}*) jsx_identifier_break: (?!{{jsx_identifier_part}}) - dot_accessor: (?:\??\.) + function_assignment_lookahead: |- + (?x:(?= + \s* = \s* + {{either_func_lookahead}} + )) function_call_lookahead: >- (?x:(?= {{identifier_name}} @@ -3213,42 +3348,37 @@ variables: (?:{{dot_accessor}})? \( )) - line_continuation_lookahead: >- - (?x:(?= - (?! \+\+ | -- ) - (?= - != | - [-+*/%><=&|^\[(;,.:?] | - (?:in|instanceof){{identifier_break}} - ) - )) - jsx_identifier: '{{identifier_start}}{{jsx_identifier_part}}*{{jsx_identifier_break}}' - block_comment: (?:/\*{{block_comment_contents}}\*/) - method_lookahead: |- - (?x)(?= - (?: get|set|async ){{identifier_break}}(?!\s*:) - | \* - | {{property_name}} \s* (?:\(|<) - ) - possible_arrow_function_begin: (?:\(|{{identifier_start}}|<) - dec_integer: (?:0|[1-9]{{dec_digit}}*) hex_digit: '[\h_]' - dec_exponent: '[Ee](?:[-+]|(?![-+])){{dec_digit}}*' - dollar_identifier: (?:(\$){{identifier_part}}*{{identifier_break}}) - either_func_lookahead: (?:{{func_lookahead}}|{{arrow_func_lookahead}}) - non_reserved_identifier: (?:(?!{{reserved_word}}){{identifier_name}}) - constant_identifier: (?:[[:upper:]]{{identifier_part}}*{{identifier_break}}) - dollar_only_identifier: (?:\${{identifier_break}}) - left_expression_end_lookahead: (?!\s*[.\[\(]) func_lookahead: |- (?x: (?:async{{identifier_break}}{{nothing}})? function{{identifier_break}} ) - binding_pattern_lookahead: (?:{{identifier_name}}|\[|\{) - identifier_name: (?:{{identifier_start}}{{identifier_part}}*{{identifier_break}}) - oct_digit: '[0-7_]' + shebang_lang: \b(?:node|js)\b + non_reserved_identifier: (?:(?!{{reserved_word}}){{identifier_name}}) bin_digit: '[01_]' + dollar_identifier: (?:(\$){{identifier_part}}*{{identifier_break}}) + identifier_name: (?:{{identifier_start}}{{identifier_part}}*{{identifier_break}}) + identifier_part: (?:[_$\p{L}\p{Nl}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]|{{identifier_escape}}) + dot_accessor: (?:\??\.) + dec_digit: '[0-9_]' + nothing: (?:(?:\s|{{block_comment}})*) + jsx_identifier_part: (?:{{identifier_part}}|-) + possible_arrow_function_begin: (?:\(|{{identifier_start}}|<) + left_expression_end_lookahead: (?!\s*[.\[\(]) + block_comment_contents: (?:(?:[^*]|\*(?!/))*) + block_comment: (?:/\*{{block_comment_contents}}\*/) + jsdoc_block_tag: \@[^\n\t\f\v *@]+ + class_element_name: |- + (?x: + \+? + (?: + \*? + {{property_name}} + | \#{{non_reserved_identifier}} + ) + ) + dec_exponent: '[Ee](?:[-+]|(?![-+])){{dec_digit}}*' arrow_func_lookahead: |- (?x)(?: \s*(async\s*)? @@ -3262,54 +3392,11 @@ variables: )? \s*=> ) - nothing: (?x:(?:\s|{{block_comment}})*) - jsx_identifier_part: (?:{{identifier_part}}|-) - line_ending_ahead: (?={{nothing}}(?:/\*{{block_comment_contents}})?$) - function_assignment_lookahead: |- - (?x:(?= - \s* = \s* - {{either_func_lookahead}} - )) - property_name: >- - (?x: - {{identifier_name}} - | [0-9]+ - | '(?:[^\\']|\\.)*' - | "(?:[^\\"]|\\.)*" - | \[ .* \] - ) - dec_digit: '[0-9_]' - modifier: (?:static{{identifier_break}}) - identifier_escape: (?:\\u(?:\h{4}|\{\h+\})) - reserved_word: |- - (?x: - break|case|catch|class|const|continue|debugger|default|delete|do|else| - export|extends|finally|for|function|if|import|in|instanceof|new|return| - super|switch|this|throw|try|typeof|var|void|while|with|yield| - enum| - null|true|false - ){{identifier_break}} - jsdoc_block_tag: \@[^\n\t\f\v *@]+ - identifier_break: (?!{{identifier_part}}) - class_element_name: |- - (?x: - \+? - (?: - \*? - {{property_name}} - | \#{{non_reserved_identifier}} - ) + method_lookahead: |- + (?x)(?= + (?: get|set|async ){{identifier_break}}(?!\s*:) + | \* + | {{property_name}} \s* (?:\(|<) ) - identifier_start: (?:[_$\p{L}\p{Nl}]|{{identifier_escape}}) - identifier_part: (?:[_$\p{L}\p{Nl}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]|{{identifier_escape}}) - block_comment_contents: (?:(?:[^*]|\*(?!/))*) -file_extensions: - - js - - jsx - - es6 - - babel + modifier: (?:(?:static|accessor){{identifier_break}}) scope: source.js -first_line_match: |- - (?xi: - ^ \s* // .*? -\*- .*? \bjsx\b .*? -\*- # editorconfig - ) diff --git a/Styled Components.sublime-syntax b/Styled Components.sublime-syntax index 31d2efc..5597281 100644 --- a/Styled Components.sublime-syntax +++ b/Styled Components.sublime-syntax @@ -9,12 +9,13 @@ first_line_match: contexts: main: - meta_prepend: true - - match: (?={{html_tags}}|{{svg_tags}}) - push: selector-content + - match: (?=(?:{{html_tags}}|{{svg_tags}})(?!:)) + push: styled-components-selector-body - include: property-identifiers - include: property-values rule-list-body: + - meta_prepend: true - include: main comments: @@ -29,9 +30,31 @@ contexts: selectors: - meta_prepend: true - match: (?=&) - push: selector-content + push: styled-components-selector-body + + selector-body: + - meta_prepend: true + - match: \& + scope: variable.language.css.styled-components selector-content: - meta_prepend: true - match: \& scope: variable.language.css.styled-components + + # Make sure that we handle both the old and new CSS context names + styled-components-selector-body: + - meta_scope: meta.selector.css + - include: selector-body + - include: selector-content + + at-keyframe-block-body: + - meta_prepend: true + + at-keyframe-block-content: + - meta_prepend: true + + styled-components-keyframe-body: + - meta_scope: meta.at-rule.keyframe.css + - include: at-keyframe-block-body + - include: at-keyframe-block-content diff --git a/tests/syntax_test_flow.js b/tests/syntax_test_flow.js index a3fcb1a..89b058a 100644 --- a/tests/syntax_test_flow.js +++ b/tests/syntax_test_flow.js @@ -1,4 +1,4 @@ -// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax" +// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax" /* Built-in types */ const x:boolean; diff --git a/tests/syntax_test_js.js b/tests/syntax_test_js.js index 5c88a76..0d0af42 100644 --- a/tests/syntax_test_js.js +++ b/tests/syntax_test_js.js @@ -1,4 +1,4 @@ -// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax" +// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax" // comment // <- comment.line.double-slash.js punctuation.definition.comment.js @@ -296,7 +296,7 @@ a = test ? a + b : c; // ^ meta.block meta.block variable.other.readwrite var obj = { -// ^ meta.mapping punctuation.section.block.begin - meta.block +// ^ meta.mapping punctuation.section.mapping.begin - meta.block key: bar, // <- meta.mapping.key $key2: "string value", @@ -476,7 +476,7 @@ var obj = { // ^ keyword.operator // ^ constant.language }; -// <- meta.mapping punctuation.section.block.end +// <- meta.mapping punctuation.section.mapping.end ({ // <- meta.mapping @@ -488,10 +488,10 @@ var obj = { }); [ a, b, c ]; -// <- meta.sequence punctuation.section.brackets.begin +// <- meta.sequence punctuation.section.sequence.begin // ^ meta.sequence punctuation.separator.comma // ^^^^^^^^ meta.sequence -// ^ meta.sequence punctuation.section.brackets.end +// ^ meta.sequence punctuation.section.sequence.end function x() {} [ a, b, c ]; @@ -723,9 +723,83 @@ class MyClass extends TheirClass { // ^^^^^^^^^^ meta.group // ^^^ entity.name.function - ['foo']() {} + @foo`bar` bar() {} +// ^^^^^^^^^^ meta.annotation +// ^ punctuation.definition.annotation +// ^^^ variable.function.tagged-template +// ^^^^^ meta.string string.quoted.other +// ^ punctuation.definition.string.begin +// ^ punctuation.definition.string.end +// ^^^ meta.function entity.name.function + + @foo['bar']() {} +// ^^^^ meta.annotation +// ^ punctuation.definition.annotation +// ^^^ variable.annotation +// ^^^^^^^^^^^^ meta.function - meta.annotation + + @foo +// ^^^^ meta.annotation +// ^ - meta.annotation + bar() {} +// ^^^^^^^^ meta.function + + @foo +// ^^^^ meta.annotation +// ^ - meta.annotation + ['bar']() {} // ^^^^^^^^^^^^ meta.function + @foo() +// ^^^^^^ meta.annotation +// ^ - meta.annotation + bar() {} + + @(foo) +// ^^^^^^ meta.annotation +// ^ - meta.annotation + bar() {} + + @foo // comment +// ^^^^ meta.annotation - comment +// ^ - comment - meta.annotation.js +// ^^^^^^^^^^^ comment.line - meta.annotation + bar() {} +//^^ - meta.annotation +// ^^^^^^^^ meta.function - meta.annotation + + @foo /* comment +// ^^^^ meta.annotation - comment +// ^ - comment - meta.annotation.js +// ^^^^^^^^^^^ comment.block.js - meta.annotation + */bar() {} +//^^^^ comment.block.js - meta.annotation +// ^^^^^^^^ meta.function - meta.annotation + + @foo /* block */ /* comment +// ^^^^ meta.annotation - comment +// ^ - comment - meta.annotation.js +// ^^^^^^^^^^^^^^^^^^^^^^^ - meta.annotation +// ^^^^^^^^^^^ comment.block.js +// ^^^^^^^^^^^ comment.block.js + bar() {} +// ^^^^^^^^^ comment.block.js + */bar() {} +//^^^^ comment.block.js - meta.annotation +// ^^^^^^^^ meta.function - meta.annotation + + @foo /* block */ /* comment +// ^^^^^ meta.annotation.js - comment +// ^^^^^^^^^^^ meta.annotation.js comment.block.js +// ^ meta.annotation.js - comment +// ^^^^^^^^^^^ meta.annotation.js comment.block.js + bar() {} +// ^^^^^^^^^meta.annotation.js comment.block.js + */ . bar baz() {} +//^^^^ meta.annotation.js comment.block.js +// ^^^^^^ meta.annotation.js - comment +// ^^^^^^^^ meta.function - meta.annotation + static ['foo']() {} // ^^^^^^^^^^^^ meta.function @@ -854,7 +928,7 @@ const test = ({a, b, c=()=>({active:false}) }) => {}; // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring -// ^ punctuation.section.block.begin +// ^ punctuation.section.mapping.begin // ^ variable.parameter // ^ variable.parameter // ^ variable.parameter @@ -864,7 +938,7 @@ const test = ({a, b, c=()=>({active:false}) }) => {}; // ^ punctuation.section.group.end // ^^^^^^^^^^^^^^^^ meta.group // ^ constant.language -// ^ punctuation.section.block.end +// ^ punctuation.section.mapping.end ([a, b]) => { return x; } @@ -883,7 +957,7 @@ const test = ({a, b, c=()=>({active:false}) }) => {}; ({ a = {}, // ^ keyword.operator.assignment -// ^^ punctuation.section.block +// ^^ punctuation.section.mapping // ^ punctuation.separator.parameter - keyword.operator.comma b, // ^ punctuation.separator.parameter - keyword.operator.comma @@ -955,6 +1029,7 @@ sources.DOM // <- variable.other.readwrite .status() // ^ meta.function-call.method variable.function + // ^ - meta.function-call foo.#bar(); // ^^^^^^^^^^ meta.function-call.method.js @@ -987,7 +1062,7 @@ var foo = ~{a:function(){}.a()} // ^^^ variable.other.readwrite // ^ keyword.operator.assignment // ^ keyword.operator.bitwise -// ^ punctuation.section.block.begin +// ^ punctuation.section.mapping.begin // ^^^^^^^^^^^^^^^^^^^^ meta.mapping // ^^^^^^^^^^^^ meta.function // ^ entity.name.function @@ -1002,14 +1077,14 @@ var foo = ~{a:function(){}.a()} // ^ variable.function - entity.name.function // ^ punctuation.section.group.begin // ^ punctuation.section.group.end -// ^ punctuation.section.block.end +// ^ punctuation.section.mapping.end // ^ - meta baz(foo(x => x('bar'))); // ^ meta.function-call meta.function-call punctuation.section.group.end // ^ meta.function-call punctuation.section.group.end -func(a, b); +func(a, b) ; //^^^^^^^^ meta.function-call // ^ variable.function // ^^^^^^ meta.group @@ -1018,6 +1093,7 @@ func(a, b); // ^ punctuation.separator.comma // ^ variable.other.readwrite // ^ punctuation.section.group.end +// ^ - meta.function-call var instance = new Constructor(param1, param2) // ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.constructor @@ -1105,7 +1181,7 @@ void { // ^ meta.brackets 'test3': "asdf" } -// <- meta.mapping punctuation.section.block.end +// <- meta.mapping punctuation.section.mapping.end // This tests parsing semi-broken object literals, which should help while a // user is in the middle of typing code @@ -1299,7 +1375,7 @@ new FooBar(function(){ var test = {a: 1} -// <- meta.mapping punctuation.section.block.begin +// <- meta.mapping punctuation.section.mapping.begin var arrowFuncBraceNextLine = () => /* comments! */ // ^ entity.name.function @@ -1351,7 +1427,7 @@ $var.fn.name = () => {} // ^ variable.other.dollar - punctuation.dollar someFunction(() => [() => 'X']); -// ^ punctuation.section.brackets.end +// ^ punctuation.section.sequence.end string = 'invalid // ^ invalid.illegal.newline @@ -1431,10 +1507,10 @@ var query = { // ^ keyword.operator.ternary // ^^^^ constant.language.null // ^ keyword.operator.ternary -// ^ punctuation.section.block.begin +// ^ punctuation.section.mapping.begin // ^^ meta.mapping.key.js // ^ punctuation.separator.key-value.js -// ^ punctuation.section.block.end +// ^ punctuation.section.mapping.end }; var str = `Hello, ${name}!`; @@ -1597,7 +1673,7 @@ debugger // <- meta.sequence a ?? b; -// ^^ keyword.operator.logical +// ^^ keyword.operator.null-coalescing a &&= b; // ^^^ keyword.operator.assignment.augmented diff --git a/tests/syntax_test_js_bindings.js b/tests/syntax_test_js_bindings.js index 7db4f38..3e07bce 100644 --- a/tests/syntax_test_js_bindings.js +++ b/tests/syntax_test_js_bindings.js @@ -1,4 +1,4 @@ -// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax" +// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax" // Variable declarations @@ -102,6 +102,18 @@ function f ([ x, [a, b], z]) {} // ^ meta.binding.name variable.parameter.function // ^ meta.binding.name variable.parameter.function +function f ([ $x, [$a, $b], $z]) {} +// ^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence +// ^ meta.binding.name variable.parameter.function punctuation.dollar +// ^ meta.binding.name variable.parameter.function - punctuation.dollar +// ^^^^^^^^ meta.binding.destructuring.sequence meta.binding.destructuring.sequence +// ^ meta.binding.name variable.parameter.function punctuation.dollar +// ^ meta.binding.name variable.parameter.function - punctuation.dollar +// ^ meta.binding.name variable.parameter.function punctuation.dollar +// ^ meta.binding.name variable.parameter.function - punctuation.dollar +// ^ meta.binding.name variable.parameter.function punctuation.dollar +// ^ meta.binding.name variable.parameter.function - punctuation.dollar + function f ([ x = 42, y = [a, b, c] ]) {} // ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence // ^ keyword.operator.assignment @@ -137,6 +149,13 @@ function f (a, ...rest) {} // ^^^ keyword.operator.spread // ^^^^ variable.parameter.function +function f ($a, ...$rest) {} +// ^ meta.binding.name variable.parameter.function punctuation.dollar +// ^ meta.binding.name variable.parameter.function - punctuation.dollar +// ^^^ keyword.operator.spread +// ^ meta.binding.name variable.parameter.function punctuation.dollar +// ^^^^ meta.binding.name variable.parameter.function - punctuation.dollar + function f (new) {} // ^^^^^^^^^^^^^^^^ meta.function // ^^^ invalid.illegal.identifier meta.binding.name variable.parameter.function diff --git a/tests/syntax_test_js_class.js b/tests/syntax_test_js_class.js index 7f741a8..f8e1c40 100644 --- a/tests/syntax_test_js_class.js +++ b/tests/syntax_test_js_class.js @@ -1,4 +1,4 @@ -// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax" +// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax" class MyClass extends TheirClass { // <- keyword.declaration.class @@ -31,12 +31,20 @@ class MyClass extends TheirClass { // ^ keyword.operator.assignment // ^^ constant.numeric + [w] + get other() {} +// ^^^ storage.type.accessor.js + #v = 42; // ^ punctuation.definition.variable // ^ variable.other.readwrite // ^ keyword.operator.assignment // ^^ constant.numeric + #u + get other() {} +// ^^^ storage.type.accessor.js + f = a => b; // ^ entity.name.function variable.other.readwrite // ^^^^^^ meta.function @@ -117,6 +125,10 @@ class MyClass extends TheirClass { // ^^^^^^^^^^^ meta.function // ^^^^^^ entity.name.function + accessor foo; +// ^^^^^^^^ storage.modifier +// ^^^ variable.other.readwrite + foo // You thought I was a field... () { return '...but was a method all along!'; } // ^^ meta.class meta.block meta.function diff --git a/tests/syntax_test_js_control.js b/tests/syntax_test_js_control.js index 3c0010a..461ee7e 100644 --- a/tests/syntax_test_js_control.js +++ b/tests/syntax_test_js_control.js @@ -1,4 +1,4 @@ -// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax" +// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax" if ( true ) { } ; // ^^^^^^^^^^^^^^^ meta.conditional @@ -336,7 +336,8 @@ try { // <- meta.block //^^^^^^^^^^^^ meta.catch //^^^^^ keyword.control.exception.catch -// ^ meta.group +// ^^^ meta.group +// ^ meta.binding.name variable.other.readwrite // ^ meta.block foobar = 0 // ^^^^^^^^^^ meta.catch meta.block diff --git a/tests/syntax_test_js_import_export.js b/tests/syntax_test_js_import_export.js index 04b8b8f..65fdfa7 100644 --- a/tests/syntax_test_js_import_export.js +++ b/tests/syntax_test_js_import_export.js @@ -1,4 +1,4 @@ -// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax" +// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax" import TheirClass from "./mypath"; //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.js @@ -27,6 +27,25 @@ import thing, {identifier as otherIdentifier}, * as otherName from "otherplace"; import 'module'; // ^^^^^^^^^^^^^ meta.import +import foo from 'bar' assert { type: "json" }; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.js +//^^^^ keyword.control.import-export.js +// ^^^ variable.other.readwrite.js +// ^^^^ keyword.control.import-export.js +// ^^^^^ meta.string.js string.quoted.single.js +// ^ punctuation.definition.string.begin.js +// ^ punctuation.definition.string.end.js +// ^^^^^^ keyword.control.import-export.js +// ^^^^^^^^^^^^^^^^ meta.mapping.js +// ^ punctuation.section.mapping.begin.js +// ^^^^ meta.mapping.key.js +// ^ punctuation.separator.key-value.js +// ^^^^^^ meta.string.js string.quoted.double.js +// ^ punctuation.definition.string.begin.js +// ^ punctuation.definition.string.end.js +// ^ punctuation.section.mapping.end.js +// ^ punctuation.terminator.statement.js + // Better highlighting while typing. import import; @@ -35,12 +54,16 @@ import; import;/**/ // ^ - meta.import -export { name1, name2 as name3 }; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export +export { name1, name2 as name3, name4 as '+', name5 as "+" }; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export //^ keyword.control.import-export // ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block // ^ punctuation.separator.comma // ^^ keyword.control.import-export +// ^^ keyword.control.import-export +// ^^^ meta.string string.quoted.single +// ^^ keyword.control.import-export +// ^^^ meta.string string.quoted.double export let name1, name2; //^^^^^^^^^^^^^^^^^^^^^^ meta.export diff --git a/tests/syntax_test_js_indent_common.js b/tests/syntax_test_js_indent_common.js new file mode 100644 index 0000000..bb11c1c --- /dev/null +++ b/tests/syntax_test_js_indent_common.js @@ -0,0 +1,979 @@ +// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax" + +/** + * This is my first JavaScript program. + * This will print 'Hello World' as the output + **/ + +function testIfElseIndentationNoBraces(v) +{ + /** + * comment + */ + if (v.isNull() == true) return fun(v); + + if (v.isNull() == true) + return false; + + if (v.isNull() == true) + return false; + else + { + if (v.endsWith("(")) + return false; + else if (v.endsWith(")")) + return true; + else if (v.endsWith("\"")) + return true; + else if (v.endsWith("\\")) + return true; + else if (v.endsWith('(')) + return false; + else if (v.endsWith(')')) + return true; + else if (v.endsWith('\'')) + return true; + else if (v.endsWith('\\')) + return true; + else + return false; + + if (v.endsWith("baz")) + return false; + return true; + } +} + +function testIfElseIndentationNoBracesWithLineComments(v) +{ + /** + * comment + */ + + // line comment + if (v.isNull() == true) return fun(v); + + // line comment + if (v.isNull() == true) + // line comment + return false; + + // line comment + if (v.isNull() == true) + // line comment + return false; + // line comment + else + // line comment + { + // line comment + if (v.endsWith("(")) + // line comment + return false; + // line comment + else if (v.endsWith(")")) + // line comment + return true; + // line comment + else if (v.endsWith("\"")) + // line comment + return true; + // line comment + else if (v.endsWith("\\")) + // line comment + return true; + // line comment + else if (v.endsWith('(')) + // line comment + return false; + // line comment + else if (v.endsWith(')')) + // line comment + return true; + // line comment + else if (v.endsWith('\'')) + // line comment + return true; + // line comment + else if (v.endsWith('\\')) + // line comment + return true; + // line comment + else + // line comment + return false; + + // line comment + if (v.endsWith("baz")) + // line comment + return false; + // line comment + return true; + } +} + +function testIfElseIndentationNoBracesMultiLine(v) +{ + // line comment + if (v.isNull() == true + || v.endsWith(")")) + // line comment + return false; + else if (v.isNull() == true + || v.endsWith("(")) + return false; + // line comment + return true; +} + +function testIfElseIndentationNoBracesButComments(v) +{ + if (v.isNull() == true) return fun(v); /**/ // ; "comment" () + + if (v.isNull() == true) /**/ // ; "comment" () + return false; /**/ // ; "comment" () + + if (v.isNull() == true) /**/ // ; "comment" () + return false; /**/ // ; "comment" () + else /**/ // ; "comment" () + { /**/ // ; "comment" () + if (v.endsWith("(")) /**/ // ; "comment" () + return false; /**/ // ; "comment" () + else if (v.endsWith(")")) /**/ // ; "comment" () + return true; /**/ // ; "comment" () + else if (v.endsWith("\"")) /**/ // ; "comment" () + return true; /**/ // ; "comment" () + else if (v.endsWith("\\")) /**/ // ; "comment" () + return true; /**/ // ; "comment" () + else if (v.endsWith('(')) /**/ // ; "comment" () + return false; /**/ // ; "comment" () + else if (v.endsWith(')')) /**/ // ; "comment" () + return true; /**/ // ; "comment" () + else if (v.endsWith('\'')) /**/ // ; "comment" () + return true; /**/ // ; "comment" () + else if (v.endsWith('\\')) /**/ // ; "comment" () + return true; /**/ // ; "comment" () + else /**/ // ; "comment" () + return false; /**/ // ; "comment" () + } /**/ // ; "comment" () +} + +function testIfElseIndentationNoBracesButBlockCommentsPart1(v) +{ + /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ isNull( /*(*/ ) /*(*/ == /*(*/ true /*(*/ ) /*(*/ return /*(*/ fun /*(*/ ( /*(*/ ) /*(*/ ; // ; "comment" () + + /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ isNull( /*(*/ ) /*(*/ == /*(*/ true /*(*/ ) /*(*/ // ; "comment" () + return false; /*(*/ // ; "comment" () + + /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ isNull( /*(*/ ) /*(*/ == /*(*/ true /*(*/ ) /*(*/ // ; "comment" () + return false; /*(*/ // ; "comment" () + else /*(*/ // ; "comment" () + { /*(*/ // ; "comment" () + /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ endsWith /*(*/ ( /*(*/ "(") /*(*/ ) /*(*/ // ; "comment" () + return false; /*(*/ // ; "comment" () + else /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ endsWith /*(*/ ( /*(*/ ")") /*(*/ ) /*(*/ // ; "comment" () + return true; /*(*/ // ; "comment" () + else /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ endsWith /*(*/ ( /*(*/ "\"") /*(*/ ) /*(*/ // ; "comment" () + return true; /*(*/ // ; "comment" () + else /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ endsWith /*(*/ ( /*(*/ "\\") /*(*/ ) /*(*/ // ; "comment" () + return true; /*(*/ // ; "comment" () + else /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ endsWith /*(*/ ( /*(*/ '(') /*(*/ ) /*(*/ // ; "comment" () + return false; /*(*/ // ; "comment" () + else /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ endsWith /*(*/ ( /*(*/ ')') /*(*/ ) /*(*/ // ; "comment" () + return true; /*(*/ // ; "comment" () + else /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ endsWith /*(*/ ( /*(*/ '\'') /*(*/ ) /*(*/ // ; "comment" () + return true; /*(*/ // ; "comment" () + else /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ endsWith /*(*/ ( /*(*/ '\\') /*(*/ ) /*(*/ // ; "comment" () + return true; /*(*/ // ; "comment" () + else /*(*/ // ; "comment" () + return false; /*(*/ // ; "comment" () + } /*(*/ // ; "comment" () +} + +function testIfElseIndentationNoBracesButBlockCommentsPart2(v) +{ + /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ isNull( /*)*/ ) /*)*/ == /*)*/ true /*)*/ ) /*)*/ return /*)*/ fun /*)*/ ( /*)*/ ) /*)*/ ; // ; "comment" () + + /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ isNull( /*)*/ ) /*)*/ == /*)*/ true /*)*/ ) /*)*/ // ; "comment" () + return false; /*)*/ // ; "comment" () + + /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ isNull( /*)*/ ) /*)*/ == /*)*/ true /*)*/ ) /*)*/ // ; "comment" () + return false; /*)*/ // ; "comment" () + else /*)*/ // ; "comment" () + { /*)*/ // ; "comment" () + /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ endsWith /*)*/ ( /*)*/ "(") /*)*/ ) /*)*/ // ; "comment" () + return false; /*)*/ // ; "comment" () + else /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ endsWith /*)*/ ( /*)*/ ")") /*)*/ ) /*)*/ // ; "comment" () + return true; /*)*/ // ; "comment" () + else /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ endsWith /*)*/ ( /*)*/ "\"") /*)*/ ) /*)*/ // ; "comment" () + return true; /*)*/ // ; "comment" () + else /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ endsWith /*)*/ ( /*)*/ "\\") /*)*/ ) /*)*/ // ; "comment" () + return true; /*)*/ // ; "comment" () + else /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ endsWith /*)*/ ( /*)*/ '(') /*)*/ ) /*)*/ // ; "comment" () + return false; /*)*/ // ; "comment" () + else /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ endsWith /*)*/ ( /*)*/ ')') /*)*/ ) /*)*/ // ; "comment" () + return true; /*)*/ // ; "comment" () + else /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ endsWith /*)*/ ( /*)*/ '\'') /*)*/ ) /*)*/ // ; "comment" () + return true; /*)*/ // ; "comment" () + else /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ endsWith /*)*/ ( /*)*/ '\\') /*)*/ ) /*)*/ // ; "comment" () + return true; /*)*/ // ; "comment" () + else /*)*/ // ; "comment" () + return false; /*)*/ // ; "comment" () + } /*)*/ // ; "comment" () +} + +function testIfElseIndentationWithBraces(v) { + + if (v.isNull() == true) { return fun(v); } + + if (v.isNull() == true) { + return false; + } + + if (v.isNull() == true) { + return false; + } else { + if (v.endsWith("(")) { + return false; + } else if (v.endsWith(")")) { + return true; + } else if (v.endsWith("\"")) { + return true; + } else if (v.endsWith("\\")) { + return true; + } else if (v.endsWith('(')) { + return false; + } else if (v.endsWith(')')) { + return true; + } else if (v.endsWith('\'')) { + return true; + } else if (v.endsWith('\\')) { + return true; + } else { + return false; + } + } + + if (v.isNull() == true) + { + return + } + if (v.isNull() == true) + { + return false + } + if (v.isNull() == true) + { + return false; + } + + if (v.isNull() == true) + { + return false; + } + else + { + if (v.endsWith("(")) + { + return false; + } + else if (v.endsWith(")")) + { + return true; + } + else if (v.endsWith("\"")) + { + return true; + } + else if (v.endsWith("\\")) + { + return true; + } + else if (v.endsWith('(')) + { + return false; + } + else if (v.endsWith(')')) + { + return true; + } + else if (v.endsWith('\'')) + { + return true; + } + else if (v.endsWith('\\')) + { + return true; + } + else + { + return false; + } + } +} + +function testIfElseIndentationWithBracesAndLineComments(v) { + + // comment + if (v.isNull() == true) { return fun(v); } + + // comment + if (v.isNull() == true) { + // comment + return false; + } + + // comment + if (v.isNull() == true) { + // comment + return false; + } else { + // comment + if (v.endsWith("(")) { + // comment + return false; + // comment + } else if (v.endsWith(")")) { + // comment + return true; + // comment + } else if (v.endsWith("\"")) { + // comment + return true; + // comment + } else if (v.endsWith("\\")) { + // comment + return true; + // comment + } else if (v.endsWith('(')) { + // comment + return false; + // comment + } else if (v.endsWith(')')) { + // comment + return true; + // comment + } else if (v.endsWith('\'')) { + // comment + return true; + // comment + } else if (v.endsWith('\\')) { + // comment + return true; + // comment + } else { + // comment + return false; + } + } + + // comment + if (v.isNull() == true) + { + // comment + return + } + // comment + if (v.isNull() == true) + { + // comment + return false + } + // comment + if (v.isNull() == true) + { + // comment + return false; + } + + // comment + if (v.isNull() == true) + { + // comment + return false; + } + // comment + else + { + // comment + if (v.endsWith("(")) + { + // comment + return false; + } + // comment + else if (v.endsWith(")")) + { + // comment + return true; + } + // comment + else if (v.endsWith("\"")) + { + // comment + return true; + } + // comment + else if (v.endsWith("\\")) + { + // comment + return true; + } + // comment + else if (v.endsWith('(')) + { + // comment + return false; + } + // comment + else if (v.endsWith(')')) + { + // comment + return true; + } + // comment + else if (v.endsWith('\'')) + { + // comment + return true; + } + // comment + else if (v.endsWith('\\')) + { + // comment + return true; + } + // comment + else + { + // comment + return false; + } + } +} + +function testIfElseIndentationWithBracesAndComment(v) { + + if (v.isNull() == true) { return } /**/ // ; "comment" () + + if (v.isNull() == true) { return fun(v) } /**/ // ; "comment" () + + if (v.isNull() == true) { return fun(v); } /**/ // ; "comment" () + + if (v.isNull() == true) { /**/ // ; "comment" () + return false; /**/ // ; "comment" () + } /**/ // ; "comment" () + + if (v.isNull() == true) { /**/ // ; "comment" () + return false; /**/ // ; "comment" () + } else { /**/ // ; "comment" () + if (v.endsWith("(")) { /**/ // ; "comment" () + return false; /**/ // ; "comment" () + } else if (v.endsWith(")")) { /**/ // ; "comment" () + return true; /**/ // ; "comment" () + } else if (v.endsWith("\"")) { /**/ // ; "comment" () + return true; /**/ // ; "comment" () + } else if (v.endsWith("\\")) { /**/ // ; "comment" () + return true; /**/ // ; "comment" () + } else if (v.endsWith('(')) { /**/ // ; "comment" () + return false; /**/ // ; "comment" () + } else if (v.endsWith(')')) { /**/ // ; "comment" () + return true; /**/ // ; "comment" () + } else if (v.endsWith('\'')) { /**/ // ; "comment" () + return true; /**/ // ; "comment" () + } else if (v.endsWith('\\')) { /**/ // ; "comment" () + return true; /**/ // ; "comment" () + } else { /**/ // ; "comment" () + return false; /**/ // ; "comment" () + } /**/ // ; "comment" () + } /**/ // ; "comment" () + + if (v.isNull() == true) /**/ // ; "comment" () + { /**/ // ; "comment" () + return /**/ // ; "comment" () + } /**/ // ; "comment" () + if (v.isNull() == true) /**/ // ; "comment" () + { /**/ // ; "comment" () + return false /**/ // ; "comment" () + } /**/ // ; "comment" () + if (v.isNull() == true) /**/ // ; "comment" () + { /**/ // ; "comment" () + return false; /**/ // ; "comment" () + } /**/ // ; "comment" () + + if (v.isNull() == true) /**/ // ; "comment" () + { /**/ // ; "comment" () + return false; /**/ // ; "comment" () + } /**/ // ; "comment" () + else /**/ // ; "comment" () + { /**/ // ; "comment" () + if (v.endsWith("(")) /**/ // ; "comment" () + { /**/ // ; "comment" () + return false; /**/ // ; "comment" () + } /**/ // ; "comment" () + else if (v.endsWith(")")) /**/ // ; "comment" () + { /**/ // ; "comment" () + return true; /**/ // ; "comment" () + } /**/ // ; "comment" () + else if (v.endsWith("\"")) /**/ // ; "comment" () + { /**/ // ; "comment" () + return true; /**/ // ; "comment" () + } /**/ // ; "comment" () + else if (v.endsWith("\\")) /**/ // ; "comment" () + { /**/ // ; "comment" () + return true; /**/ // ; "comment" () + } /**/ // ; "comment" () + else if (v.endsWith('(')) /**/ // ; "comment" () + { /**/ // ; "comment" () + return false; /**/ // ; "comment" () + } /**/ // ; "comment" () + else if (v.endsWith(')')) /**/ // ; "comment" () + { /**/ // ; "comment" () + return true; /**/ // ; "comment" () + } /**/ // ; "comment" () + else if (v.endsWith('\'')) /**/ // ; "comment" () + { /**/ // ; "comment" () + return true; /**/ // ; "comment" () + } /**/ // ; "comment" () + else if (v.endsWith('\\')) /**/ // ; "comment" () + { /**/ // ; "comment" () + return true; /**/ // ; "comment" () + } /**/ // ; "comment" () + else /**/ // ; "comment" () + { /**/ // ; "comment" () + return false; /**/ // ; "comment" () + } /**/ // ; "comment" () + } /**/ // ; "comment" () +} + +function testSwitchCaseIndentation(v) { + switch (s) { + case + case: + case break + case: break + case "(": break + case ")": break; + case ":": break; + case ";": break; + case + break; + case: + break; + case ":" + break; + case ':': + break; + case NestedIfStatement: + if (s.endsWith() = '(') + return; + break; + case NestedSwitchCase: + switch (v) { + case 0: break; + case 2: + break; + } + break; + case NestedSwitchCaseBlock: + { + switch (v) { + case 0: break; + case 2: + break; + } + break; + } + case NestedSwitchCaseBlock2: + { + switch (v) { + case 0: break; + case 2: + break; + } + } + break; + default: + break; + } +} + +function testSwitchCaseIndentationWithLineComments(v) { + switch (s) { // comments + case // comments + case: // comments + case break // comments + case: break // comments + case "(": break // comments + case ")": break; // comments + case ":": break; // comments + case ";": break; // comments + case // comments + break; // comments + case: // comments + break; // comments + case ":" // comments + break; // comments + case ':': // comments + break; // comments + case NestedIfStatement: // comments + if (s.endsWith() = '(') // comments + return; // comments + break; // comments + case NestedSwitchCase: // comments + switch (v) { // comments + case 0: break; // comments + case 2: // comments + break; // comments + } // comments + break; // comments + case NestedSwitchCaseBlock: // comments + { // comments + switch (v) { // comments + case 0: break; // comments + case 2: // comments + break; // comments + } // comments + break; // comments + } // comments + case NestedSwitchCaseBlock2: // comments + { // comments + switch (v) { // comments + case 0: break; // comments + case 2: // comments + break; // comments + } // comments + } // comments + break; // comments + default: // comments + break; // comments + } // comments +} // comments + +function testForIndentation(v) { + + for (let i = 0; i < 10; i++) + System.out.println("Row " + i); + + for (let i = 0; i < 10; i++) { + System.out.println("Row " + i); + } + + for (let i = 0; i < 10; i++) + { + System.out.println("Row " + i); + } + + for (let i = 0; i < 10; i++) { + for (let j = 0; j < 10; j++) + System.out.println("Row " + i + " Col " + j); + } + + for (let i = 0; i < 10; i++) { + for (let j = 0; j < 10; j++) { + System.out.println("Row " + i + " Col " + j); + } + } + + for ( + let i = 0; + i < 10; + i++) + { + let j = 0; + let k = 0; + } +} + +function testWhileIndentationNoBraces(v) { + while () v++; + while (()) v++; + while ((())) v++; + while ((())()) v++; + while () + v++; + while (v == '(') + v++; + while (v == ')') + v++; + while (v == '\'') + v++; + while (v == '\\') + v++; + while (v == "(") + v++; + while (v == ")") + v++; + while (v == "\"") + v++; + while (v == "\\\"") + v++; + while (v == foo( bar("") + "" )) + v++; +} + +function testWhileIndentationNoBracesButComments(v) { + while () v++; // ; "comment" () + while (()) v++; // ; "comment" () + while ((())) v++; // ; "comment" () + while ((())()) v++; // ; "comment" () + while () // ; "comment" () + v++; // ; "comment" () + while (v == '(') // ; "comment" () + v++; // ; "comment" () + while (v == ')') // ; "comment" () + v++; // ; "comment" () + while (v == '\'') // ; "comment" () + v++; // ; "comment" () + while (v == '\\') // ; "comment" () + v++; // ; "comment" () + while (v == "(") // ; "comment" () + v++; // ; "comment" () + while (v == ")") // ; "comment" () + v++; // ; "comment" () + while (v == "\"") // ; "comment" () + v++; // ; "comment" () + while (v == "\\\"") // ; "comment" () + v++; // ; "comment" () + while (v == foo( bar("") + "" )) // ; "comment" () + v++; // ; "comment" () + while () { } // a hack to make tests succeed +} + +function testWhileIndentationNoBracesButBlockCommentsPart1(v) { + while /*(*/ () v++; /*(*/ // ; "comment" () + while /*(*/ (()) v++; /*(*/ // ; "comment" () + while /*(*/ ((())) v++; /*(*/ // ; "comment" () + while /*(*/ ((()/*(*/)/*(*/()) v++; /*(*/ // ; "comment" () + while /*(*/ () /*(*/ // ; "comment" () + v++; /*(*/ // ; "comment" () + while /*(*/ ( /*(*/ v /*(*/ == /*(*/ '(' /*(*/ ) /*(*/ // ; "comment" () + v++; /*(*/ // ; "comment" () + while /*(*/ ( /*(*/ v /*(*/ == /*(*/ ')' /*(*/ ) /*(*/ // ; "comment" () + v++; /*(*/ // ; "comment" () + while /*(*/ ( /*(*/ v /*(*/ == /*(*/ '\'' /*(*/ ) /*(*/ // ; "comment" () + v++; /*(*/ // ; "comment" () + while /*(*/ ( /*(*/ v /*(*/ == /*(*/ '\\' /*(*/ ) /*(*/ // ; "comment" () + v++; /*(*/ // ; "comment" () + while /*(*/ ( /*(*/ v /*(*/ == /*(*/ "(" /*(*/ ) /*(*/ // ; "comment" () + v++; /*(*/ // ; "comment" () + while /*(*/ ( /*(*/ v /*(*/ == /*(*/ ")" /*(*/ ) /*(*/ // ; "comment" () + v++; /*(*/ // ; "comment" () + while /*(*/ ( /*(*/ v /*(*/ == /*(*/ "\"" /*(*/ ) /*(*/ // ; "comment" () + v++; /*(*/ // ; "comment" () + while /*(*/ ( /*(*/ v /*(*/ == /*(*/ "\\\"" /*(*/ ) /*(*/ // ; "comment" () + v++; /*(*/ // ; "comment" () + while /*(*/ ( /*(*/ v /*(*/ == /*(*/ foo( /*(*/ bar( /*(*/ "/*(*/" /*(*/ ) /*(*/ + /*(*/ "" /*(*/ ) /*(*/ ) /*(*/ // ; "comment" () + v++; /*(*/ // ; "comment" () + while /*(*/ () { } // a hack to make tests succeed +} + +function testWhileIndentationNoBracesButBlockCommentsPart2(v) { + while /*)*/ () v++; /*)*/ // ; "comment" () + while /*)*/ (()) v++; /*)*/ // ; "comment" () + while /*)*/ ((())) v++; /*)*/ // ; "comment" () + while /*)*/ ((()/*)*/)/*)*/()) v++; /*)*/ // ; "comment" () + while /*)*/ () /*)*/ // ; "comment" () + v++; /*)*/ // ; "comment" () + while /*)*/ ( /*)*/ v /*)*/ == /*)*/ '(' /*)*/ ) /*)*/ // ; "comment" () + v++; /*)*/ // ; "comment" () + while /*)*/ ( /*)*/ v /*)*/ == /*)*/ ')' /*)*/ ) /*)*/ // ; "comment" () + v++; /*)*/ // ; "comment" () + while /*)*/ ( /*)*/ v /*)*/ == /*)*/ '\'' /*)*/ ) /*)*/ // ; "comment" () + v++; /*)*/ // ; "comment" () + while /*)*/ ( /*)*/ v /*)*/ == /*)*/ '\\' /*)*/ ) /*)*/ // ; "comment" () + v++; /*)*/ // ; "comment" () + while /*)*/ ( /*)*/ v /*)*/ == /*)*/ "(" /*)*/ ) /*)*/ // ; "comment" () + v++; /*)*/ // ; "comment" () + while /*)*/ ( /*)*/ v /*)*/ == /*)*/ ")" /*)*/ ) /*)*/ // ; "comment" () + v++; /*)*/ // ; "comment" () + while /*)*/ ( /*)*/ v /*)*/ == /*)*/ "\"" /*)*/ ) /*)*/ // ; "comment" () + v++; /*)*/ // ; "comment" () + while /*)*/ ( /*)*/ v /*)*/ == /*)*/ "\\\"" /*)*/ ) /*)*/ // ; "comment" () + v++; /*)*/ // ; "comment" () + while /*)*/ ( /*)*/ v /*)*/ == /*)*/ foo( /*)*/ bar( /*)*/ "/*)*/" /*)*/ ) /*)*/ + /*)*/ "" /*)*/ ) /*)*/ ) /*)*/ // ; "comment" () + v++; /*)*/ // ; "comment" () + while /*)*/ () { } // a hack to make tests succeed +} + +function testWhileIndentationWithBraces(v) { + + while () { v++; } + while (()) { v++; } + while ((())) { v++; } + while ((())()) { v++; } + while () { + v++; + } + while (v == '(') { + v++; + } + while (v == ')') { + v++; + } + while (v == '\'') { + v++; + } + while (v == '\\') { + v++; + } + while (v == "(") { + v++; + } + while (v == ")") { + v++; + } + while (v == "\"") { + v++; + } + while (v == "\\\"") { + v++; + } + while (v == foo( bar("") + "" )) { + v++; + } + while () + { + v++; + } + while (v == '(') + { + v++; + } + while (v == ')') + { + v++; + } + while (v == '\'') + { + v++; + } + while (v == '\\') + { + v++; + } + while (v == "(") + { + v++; + } + while (v == ")") + { + v++; + } + while (v == "\"") + { + v++; + } + while (v == "\\\"") + { + v++; + } + while (v == foo( bar("") + "" )) + { + v++; + } + while ( + v == foo( bar("") + "" ) + ) + { + v++; + v++; + } +} + +function testWhileIndentationWithBracesAndComments(v) { + + while () { v++ } // ; "comments" () + while () { v++; } // ; "comments" () + while (()) { v++ } // ; "comments" () + while ((())) { v++ } // ; "comments" () + while ((())()) { v++ } // ; "comments" () + while () { // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while (v == '(') { // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while (v == ')') { // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while (v == '\'') { // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while (v == '\\') { // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while (v == "(") { // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while (v == ")") { // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while (v == "\"") { // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while (v == "\\\"") { // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while (v == foo( bar("") + "" )) { // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while () // ; "comments" () + { // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while (v == '(') // ; "comments" () + { // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while (v == ')') // ; "comments" () + { // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while (v == '\'') // ; "comments" () + { // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while (v == '\\') // ; "comments" () + { // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while (v == "(") // ; "comments" () + { // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while (v == ")") // ; "comments" () + { // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while (v == "\"") // ; "comments" () + { // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while (v == "\\\"") // ; "comments" () + { // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while (v == foo( bar("") + "" )) // ; "comments" () + { // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while ( // ; "comments" () + v == foo( bar("") + "" ) // ; "comments" () + ) // ; "comments" () + { // ; "comments" () + v++ // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while ( // ; "comments" () + v == foo( bar("") + "" ) ) { // ; "comments" () + v++ // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () + while ( // ; "comments" () + v == foo( bar("") + "" ) // ; "comments" () + ) { // ; "comments" () + v++ // ; "comments" () + v++ // ; "comments" () + } // ; "comments" () +} diff --git a/tests/syntax_test_js_jsdoc.js b/tests/syntax_test_js_jsdoc.js index 629e3b6..22566e4 100644 --- a/tests/syntax_test_js_jsdoc.js +++ b/tests/syntax_test_js_jsdoc.js @@ -1,4 +1,4 @@ -// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax" +// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax" /**@a*/ // ^^^ punctuation.definition.comment.begin diff --git a/tests/syntax_test_js_not_typescript.js b/tests/syntax_test_js_not_typescript.js index 084a0da..ec79425 100644 --- a/tests/syntax_test_js_not_typescript.js +++ b/tests/syntax_test_js_not_typescript.js @@ -1,4 +1,4 @@ -// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax" +// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax" /// // <- comment.line.triple-slash.js punctuation.definition.comment.js diff --git a/tests/syntax_test_js_regexp.js b/tests/syntax_test_js_regexp.js index 48bb935..6f39ceb 100644 --- a/tests/syntax_test_js_regexp.js +++ b/tests/syntax_test_js_regexp.js @@ -1,4 +1,4 @@ -// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax" +// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax" /* LITERAL */ @@ -239,3 +239,29 @@ /[^-z]/; // ^^^ - constant.other.character-class.range // ^ - punctuation.definition.range + + /[\\/]foo[\\/]/; +// ^^^^^^^^^^^^^^^ meta.string.js string.regexp.js +// ^ punctuation.definition.string.begin.js +// ^^^^^ constant.other.character-class.set.regexp +// ^ punctuation.definition.character-class.begin.regexp +// ^^ constant.character.escape.backslash.regexp +// ^ punctuation.definition.character-class.end.regexp +// ^^^^^ constant.other.character-class.set.regexp +// ^ punctuation.definition.character-class.begin.regexp +// ^^ constant.character.escape.backslash.regexp +// ^ punctuation.definition.character-class.end.regexp +// ^ punctuation.definition.string.end.js + + /[\\\/]foo[\\\/]/; +// ^^^^^^^^^^^^^^^^^ meta.string.js string.regexp.js +// ^ punctuation.definition.string.begin.js +// ^^^^^^ constant.other.character-class.set.regexp +// ^ punctuation.definition.character-class.begin.regexp +// ^^^^ constant.character.escape.backslash.regexp +// ^ punctuation.definition.character-class.end.regexp +// ^^^^^^ constant.other.character-class.set.regexp +// ^ punctuation.definition.character-class.begin.regexp +// ^^^^ constant.character.escape.backslash.regexp +// ^ punctuation.definition.character-class.end.regexp +// ^ punctuation.definition.string.end.js diff --git a/tests/syntax_test_js_support_builtin.js b/tests/syntax_test_js_support_builtin.js index 769a794..33c213c 100644 --- a/tests/syntax_test_js_support_builtin.js +++ b/tests/syntax_test_js_support_builtin.js @@ -1,4 +1,4 @@ -// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax" +// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax" isNaN; // ^^^^^ support.function - meta.function-call diff --git a/tests/syntax_test_js_support_console.js b/tests/syntax_test_js_support_console.js index 69e8014..9e8eec5 100644 --- a/tests/syntax_test_js_support_console.js +++ b/tests/syntax_test_js_support_console.js @@ -1,4 +1,4 @@ -// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax" +// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax" console; // ^^^^^^^ support.type.object.console diff --git a/tests/syntax_test_js_support_dom.js b/tests/syntax_test_js_support_dom.js index 7ef824d..beab41e 100644 --- a/tests/syntax_test_js_support_dom.js +++ b/tests/syntax_test_js_support_dom.js @@ -1,4 +1,4 @@ -// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax" +// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax" XMLHttpRequest; // ^^^^^^^^^^^^^^ support.class.dom diff --git a/tests/syntax_test_js_support_node.js b/tests/syntax_test_js_support_node.js index 3222ca3..c6824d1 100644 --- a/tests/syntax_test_js_support_node.js +++ b/tests/syntax_test_js_support_node.js @@ -1,4 +1,4 @@ -// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax" +// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax" global; // ^^^^^^ support.type.object.node diff --git a/tests/syntax_test_jsx.jsx b/tests/syntax_test_jsx.jsx index 8b76dcf..a4774d6 100644 --- a/tests/syntax_test_jsx.jsx +++ b/tests/syntax_test_jsx.jsx @@ -1,4 +1,4 @@ -// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax" +// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax" // comment // <- comment.line.double-slash.js punctuation.definition.comment.js diff --git a/tests/syntax_test_string_object_keys.js b/tests/syntax_test_string_object_keys.js index d3aadf6..477df98 100644 --- a/tests/syntax_test_string_object_keys.js +++ b/tests/syntax_test_string_object_keys.js @@ -1,4 +1,4 @@ -// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax" +// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax" ({ foo: 42, // ^^^ meta.group meta.mapping meta.mapping.key string.unquoted