From c498684b601b8dbd9ca5954606065ee2f8a675dd Mon Sep 17 00:00:00 2001 From: Johannes Rappen Date: Fri, 18 Dec 2020 17:48:19 +0100 Subject: [PATCH 001/152] [CI] use Build 4094 test binary (#2655) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca3c44789f..d3023cb4f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/checkout@master - name: Download syntax_tests - run: wget -O st_syntax_tests.tar.xz https://download.sublimetext.com/st_syntax_tests_build_4090_x64.tar.xz + run: wget -O st_syntax_tests.tar.xz https://download.sublimetext.com/st_syntax_tests_build_4094_x64.tar.xz - name: Extract syntax_tests run: tar xf st_syntax_tests.tar.xz From d639fc1f01842cfd9b07dc399fd78271252f983e Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 13 Jan 2021 20:27:10 +0100 Subject: [PATCH 002/152] [R] Comment Documentation (#2609) --- R/R.sublime-syntax | 2 +- R/syntax_test_r.R | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/R.sublime-syntax b/R/R.sublime-syntax index 3e59c2b701..fdc76de066 100644 --- a/R/R.sublime-syntax +++ b/R/R.sublime-syntax @@ -346,7 +346,7 @@ contexts: - include: main roxygen-content: - - meta_scope: comment.line.roxygen.r + - meta_scope: comment.line.documentation.r - match: $\n? pop: true diff --git a/R/syntax_test_r.R b/R/syntax_test_r.R index 054ff29b7e..f7cb0e3fd0 100644 --- a/R/syntax_test_r.R +++ b/R/syntax_test_r.R @@ -477,19 +477,19 @@ print.foo() # ^^^^ support.function.r #' @param xyz abcde -#^^^^^^^^^^^^^^^^^^ comment.line.roxygen.r +#^^^^^^^^^^^^^^^^^^ comment.line.documentation.r # ^^^^^^ keyword.other.r # ^^^ variable.parameter.r #' @param xyz abcde -# ^^^^^^^^^^^^^^^^^^^ comment.line.roxygen.r +# ^^^^^^^^^^^^^^^^^^^ comment.line.documentation.r # ^^^^^^ keyword.other.r # ^^^ variable.parameter.r #' "@param xyz abcde" -# ^^^^^^^^^ comment.line.roxygen.r +# ^^^^^^^^^ comment.line.documentation.r # ^^^^^^ -keyword.other.r From 41117f3d1f854491af199ba189d41f3e01864b2f Mon Sep 17 00:00:00 2001 From: jwortmann Date: Wed, 13 Jan 2021 20:27:56 +0100 Subject: [PATCH 003/152] [C#] Use comment.line scope for single-line doc comments (#2610) --- C#/C#.sublime-syntax | 4 ++-- C#/tests/syntax_test_Comments.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/C#/C#.sublime-syntax b/C#/C#.sublime-syntax index 58036c34c9..f4de53a20b 100644 --- a/C#/C#.sublime-syntax +++ b/C#/C#.sublime-syntax @@ -56,7 +56,7 @@ contexts: comments: - match: '^\s*(///)' captures: - 1: comment.block.documentation.cs punctuation.definition.comment.documentation.cs + 1: comment.line.documentation.cs punctuation.definition.comment.documentation.cs push: documentation - match: '//' scope: punctuation.definition.comment.cs @@ -2182,7 +2182,7 @@ contexts: documentation: - meta_include_prototype: false - - meta_content_scope: comment.block.documentation.cs + - meta_content_scope: comment.line.documentation.cs - match: '(<)({{name}})' captures: 1: punctuation.definition.tag.begin.cs diff --git a/C#/tests/syntax_test_Comments.cs b/C#/tests/syntax_test_Comments.cs index 1dcfbb52e7..49cfc4a8ef 100755 --- a/C#/tests/syntax_test_Comments.cs +++ b/C#/tests/syntax_test_Comments.cs @@ -8,7 +8,7 @@ namespace HelloWorld { /// //* ^^^ punctuation.definition.comment.documentation.cs -//* ^^^^^^^^^^^^^^ comment.block.documentation +//* ^^^^^^^^^^^^^^ comment.line.documentation //* ^ punctuation.definition.tag.begin //* ^^^^^^^ entity.name.tag.begin //* ^ punctuation.definition.tag.end @@ -16,7 +16,7 @@ namespace HelloWorld //* ^^^^^^^^^ - text.documentation //* ^ text.documentation /// This class is testing comments -//* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.block.documentation +//* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.documentation //* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ text.documentation /// //* ^^ punctuation.definition.tag.begin From 688fe9f05622a4e56c09c5b95c6fec436595bf59 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 13 Jan 2021 20:29:38 +0100 Subject: [PATCH 004/152] [ShellScript] Add anonymous functions (#2611) Fixes #2608 This commit handles `() { ... }` as incomplete function definition in Bash, while it is valid anonymous function definition in ZSH. --- ShellScript/Bash.sublime-syntax | 30 +++++++++++++++++++-- ShellScript/test/syntax_test_bash.sh | 40 ++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 01c9a4d38e..95f6e4ac37 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -99,6 +99,7 @@ contexts: - include: line-continuations - include: operators - include: redirections + - include: def-anonymous - include: cmd-alias - include: cmd-arithmetic - include: cmd-compound @@ -191,6 +192,22 @@ contexts: ###[ FUNCTION DEFINITIONS ]#################################################### + def-anonymous: + - match: (\()\s*(\)) + scope: meta.function.parameters.shell + captures: + 1: punctuation.section.parameters.begin.shell + 2: punctuation.section.parameters.end.shell + push: + - def-functions-redirection + - def-anonymous-body + + def-anonymous-body: + - include: def-function-body-braces + - include: line-continuations + - include: comments + - include: else-pop + def-functions: # [Bash] 3.3 Shell Functions - match: (?={{cmd_literal}}\s*\(\s*\)) @@ -230,9 +247,18 @@ contexts: 1: punctuation.section.parameters.begin.shell 2: punctuation.section.parameters.end.shell pop: 1 + - include: line-continuations + - include: comments - include: else-pop def-functions-body: + - include: def-function-body-braces + - include: def-function-body-parens + - include: line-continuations + - include: comments + - include: else-pop + + def-function-body-braces: - match: \{ # Bash expects `{{cmd_break}}` but we don't care. scope: punctuation.section.compound.begin.shell set: @@ -241,6 +267,8 @@ contexts: scope: punctuation.section.compound.end.shell pop: 1 - include: statements + + def-function-body-parens: - match: \( scope: punctuation.section.compound.begin.shell set: @@ -249,8 +277,6 @@ contexts: scope: punctuation.section.compound.end.shell pop: 1 - include: statements - - include: comments - - include: else-pop def-functions-redirection: - meta_content_scope: meta.function.shell diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 0c91b2c12d..6cbf8b2063 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -865,6 +865,46 @@ coproc foobar { # 3.3 Shell Functions # #################################################################### + () +#^^ - meta.function +# ^ meta.function.parameters.shell +# ^ meta.function.parameters.shell +# ^ meta.function.shell + + () + {} +# ^ meta.function.shell - meta.compound +# ^^ meta.function.shell meta.compound.shell +# ^ - meta.function +# ^ punctuation.section.compound.begin.shell +# ^ punctuation.section.compound.end.shell + + () \ + {} +# ^ meta.function.shell - meta.compound +# ^^ meta.function.shell meta.compound.shell +# ^ - meta.function +# ^ punctuation.section.compound.begin.shell +# ^ punctuation.section.compound.end.shell + + () { [[ $# == 2 ]] && tput setaf $2 || tput setaf 3; echo -e "$1"; tput setaf 15; } +#^^ - meta.function +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function +# ^ meta.function.parameters.shell +# ^ meta.function.parameters.shell +# ^ meta.function.shell - meta.function.identifier - meta.compound +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.shell meta.compound.shell +# ^ punctuation.section.parameters.begin.shell +# ^ punctuation.section.parameters.end.shell +# ^ - punctuation +# ^ punctuation.section.compound.begin.shell +# ^^ support.function.double-brace.begin +# ^ punctuation.definition.variable +# ^ variable.language +# ^^ keyword.operator.comparison +# ^^ support.function.double-brace.end +# ^^ keyword.operator.logical + logC () { [[ $# == 2 ]] && tput setaf $2 || tput setaf 3; echo -e "$1"; tput setaf 15; } #^^ - meta.function # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function From 05642ac42ec13b345702f8ea82dad1b01d63b35c Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 13 Jan 2021 20:31:45 +0100 Subject: [PATCH 005/152] [D] Fix conditional statements (#2613) * [D] Fix ternary statements Fixes #2558 Problem Description D matches mapping keys globally in a general `value` context, which causes identifiers followed by colon such as `c :` to be matched as mapping key instead of variable and ternary operator. Solution This commit creates intermediate contexts `value-condition` and `value-no-mapping-key` to avoid matching keys within ternary statements. * [D] Fix switch case statements Fixes #2567 This one should have gone into a separate PR, but the root cause is exactly the same as with issue #2558. Thus the solution is nearly the same. More than that it makes use of parts of those fixes. Problem: The `value-list` content pushes into `value` which matches identifiers followed by colon as mapping key. --- D/D.sublime-syntax | 28 ++++++++++++++++++------- D/tests/syntax_test_d.d | 46 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 8 deletions(-) diff --git a/D/D.sublime-syntax b/D/D.sublime-syntax index d6b45ebe0d..ddfd230f66 100644 --- a/D/D.sublime-syntax +++ b/D/D.sublime-syntax @@ -1109,6 +1109,13 @@ contexts: - include: first-value-parens-after value: + - match: '\b({{name}})\s*(:)' + captures: + 1: variable.other.d + 2: punctuation.separator.mapping.key-value.d + set: value + - include: value-no-mapping-key + value-no-mapping-key: - include: attribute-in - match: '!' scope: keyword.operator.logical.d @@ -1236,11 +1243,6 @@ contexts: - match: \. scope: meta.path.d punctuation.accessor.dot.d set: [value-after, value-identifier] - - match: '\b({{name}})\s*(:)' - captures: - 1: variable.other.d - 2: punctuation.separator.mapping.key-value.d - set: value - match: '{{name_lookahead}}' set: [value-after, value-identifier] - include: not-whitespace-illegal-pop @@ -1432,7 +1434,7 @@ contexts: set: value-maybe-pointer-after - match: '\?' scope: keyword.operator.ternary.d - set: [value-condition-after, value] + set: [value-condition-after, value-condition] - match: '(?=\b(function|delegate)\b)' set: [value-after, basic-type2] - match: '(?=\S)' @@ -1464,6 +1466,10 @@ contexts: set: basic-type2 - match: '(?=\S)' set: value + value-condition: + - match: (?=:) + pop: 1 + - include: value-no-mapping-key value-condition-after: - match: ':' scope: keyword.operator.ternary.d @@ -1488,6 +1494,11 @@ contexts: pop: true - match: '(?=\S)' set: [value-list-after, value] + value-list-no-mapping-key: + - match: '(?=\)|}|]|;|:)' + pop: true + - match: '(?=\S)' + set: [value-list-after, value-no-mapping-key] value-list-after: - match: '(?=\)|}|]|;|:)' pop: true @@ -2080,9 +2091,10 @@ contexts: - match: '\(' scope: punctuation.section.parens.begin.d set: [switch-after, value] + - include: not-whitespace-illegal-pop - match: '\bcase\b' scope: keyword.control.flow.d - push: [case-after, value-list] + push: [case-after, value-list-no-mapping-key] - match: '\bdefault\b' scope: keyword.control.flow.d push: @@ -2104,7 +2116,7 @@ contexts: set: - match: '\bcase\b' scope: keyword.control.flow.d - set: [case-after, value] + set: [case-after, value-no-mapping-key] - include: not-whitespace-illegal-pop - match: '(?=\S)' pop: true diff --git a/D/tests/syntax_test_d.d b/D/tests/syntax_test_d.d index 46f00a93dc..ced0908e73 100644 --- a/D/tests/syntax_test_d.d +++ b/D/tests/syntax_test_d.d @@ -2118,6 +2118,28 @@ extern(1) // ^^ meta.number.integer.decimal.d // ^ punctuation.terminator.d + int a = b ? c : d; +//^^^ storage.type.d +// ^ variable.other.d +// ^ keyword.operator.assignment.d +// ^ meta.path.d variable.other.d +// ^ keyword.operator.ternary.d +// ^ meta.path.d variable.other.d +// ^ keyword.operator.ternary.d +// ^ meta.path.d variable.other.d +// ^ punctuation.terminator.d + + int a=b?c:d; +//^^^ storage.type.d +// ^ variable.other.d +// ^ keyword.operator.assignment.d +// ^ meta.path.d variable.other.d +// ^ keyword.operator.ternary.d +// ^ meta.path.d variable.other.d +// ^ keyword.operator.ternary.d +// ^ meta.path.d variable.other.d +// ^ punctuation.terminator.d + foreach (ref a; foo) {} //^^^^^^^ keyword.control.loop.d // ^ punctuation.section.parens.begin.d @@ -2202,6 +2224,30 @@ extern(1) // ^^^^ keyword.control.flow.d // ^ meta.number.integer.decimal.d // ^ punctuation.separator.case-statement.d + case NO_KEY: + //^^^^ keyword.control.flow.d + // ^^^^^^ meta.path.d variable.other.d + // ^ punctuation.separator.case-statement.d + if (foo) { + // ^^ keyword.control.conditional.d + } + break; + // ^^^^^ keyword.control.flow.d + // ^ punctuation.terminator.d + case no_key: .. case NO_KEY: + //^^^^ keyword.control.flow.d + // ^^^^^^ meta.path.d variable.other.d + // ^ punctuation.separator.case-statement.d + // ^^ keyword.operator.d + // ^^^^ keyword.control.flow.d + // ^^^^^^ meta.path.d variable.other.d + // ^ punctuation.separator.case-statement.d + if (foo) { + // ^^ keyword.control.conditional.d + } + break; + // ^^^^^ keyword.control.flow.d + // ^ punctuation.terminator.d default: //^^^^^^^ keyword.control.flow.d // ^ punctuation.separator.case-statement.d From 1c87c7d2a5728aff86f3d7305b37aed5c85dcbfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Ch=C5=82odnicki?= Date: Wed, 13 Jan 2021 20:32:30 +0100 Subject: [PATCH 006/152] [JavaScript] Enable auto-indentation rules for Typescript (#2614) Enable auto-indentation rules for Typescript, JSX and TSX --- JavaScript/Indentation Rules.tmPreferences | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JavaScript/Indentation Rules.tmPreferences b/JavaScript/Indentation Rules.tmPreferences index e338dc6594..6acdd2a7e9 100644 --- a/JavaScript/Indentation Rules.tmPreferences +++ b/JavaScript/Indentation Rules.tmPreferences @@ -2,7 +2,7 @@ scope - source.js + source.js, source.ts, source.jsx, source.tsx settings decreaseIndentPattern From c72086acae0efc696b2274f5dea95b1ec0f7a7b1 Mon Sep 17 00:00:00 2001 From: Thomas Smith Date: Wed, 13 Jan 2021 14:33:49 -0500 Subject: [PATCH 007/152] [JavaScript] Improve handling of identifiers. (#2615) * Improve handling of reserved words while typing. * Rename some special name contexts. * Rename identifier to identifier_name. * Use a simpler lookahead in a couple places. --- JavaScript/JavaScript.sublime-syntax | 115 ++++++++++++++------------- JavaScript/TypeScript.sublime-syntax | 28 +++---- JavaScript/tests/syntax_test_js.js | 14 ++++ JavaScript/tests/syntax_test_jsx.jsx | 5 +- 4 files changed, 91 insertions(+), 71 deletions(-) diff --git a/JavaScript/JavaScript.sublime-syntax b/JavaScript/JavaScript.sublime-syntax index d87e998445..7a4723e08f 100644 --- a/JavaScript/JavaScript.sublime-syntax +++ b/JavaScript/JavaScript.sublime-syntax @@ -22,7 +22,7 @@ variables: identifier_part: (?:[_$\p{L}\p{Nl}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]|{{identifier_escape}}) identifier_break: (?!{{identifier_part}}) - identifier: (?:{{identifier_start}}{{identifier_part}}*{{identifier_break}}) + identifier_name: (?:{{identifier_start}}{{identifier_part}}*{{identifier_break}}) constant_identifier: (?:[[:upper:]]{{identifier_part}}*{{identifier_break}}) dollar_only_identifier: (?:\${{identifier_break}}) dollar_identifier: '(?:(\$){{identifier_part}}*{{identifier_break}})' @@ -42,17 +42,17 @@ variables: null|true|false ){{identifier_break}} - non_reserved_identifier: (?:(?!{{reserved_word}}){{identifier}}) + non_reserved_identifier: (?:(?!{{reserved_word}}){{identifier_name}}) either_func_lookahead: (?:{{func_lookahead}}|{{arrow_func_lookahead}}) - binding_pattern_lookahead: (?:{{identifier}}|\[|\{) + binding_pattern_lookahead: (?:{{identifier_name}}|\[|\{) left_expression_end_lookahead: (?!\s*[.\[\(]) dot_accessor: (?:\??\.) property_name: >- (?x: - {{identifier}} + {{identifier_name}} | [0-9]+ | '(?:[^\\']|\\.)*' | "(?:[^\\"]|\\.)*" @@ -62,7 +62,7 @@ variables: class_element_name: |- (?x: {{property_name}} - | \#{{identifier}} + | \#{{identifier_name}} ) # Newline not permitted between `async` and `function`. @@ -76,7 +76,7 @@ variables: (?x: (?:async\s*)? (?: - {{identifier}} + {{identifier_name}} | \( ( [^()] | \( [^()]* \) )* \) ) \s* @@ -93,7 +93,7 @@ variables: ) )) - function_call_lookahead: (?={{identifier}}\s*(?:{{dot_accessor}})?\() + function_call_lookahead: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\() function_assignment_lookahead: |- (?x:(?= @@ -222,7 +222,7 @@ contexts: - match: default{{identifier_break}} scope: keyword.control.import-export.js pop: true - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: variable.other.readwrite.js pop: true - include: else-pop @@ -269,7 +269,7 @@ contexts: - match: '\}' scope: punctuation.section.block.end.js pop: true - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: variable.other.readwrite.js push: import-export-alias - match: '\*' @@ -329,7 +329,7 @@ contexts: - match: '\}' scope: punctuation.section.block.end.js pop: true - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: variable.other.readwrite.js push: import-export-alias - match: '\*' @@ -396,12 +396,12 @@ contexts: expect-label: - meta_include_prototype: false - - match: '(?={{nothing}}{{identifier}})' + - match: '(?={{nothing}}{{identifier_name}})' set: - match: '{{non_reserved_identifier}}' scope: variable.label.js pop: true - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: invalid.illegal.identifier.js variable.label.js pop: true - include: else-pop @@ -449,7 +449,7 @@ contexts: scope: punctuation.section.block.end.js pop: true - include: variable-binding-spread - - match: (?={{identifier}}|\[|'|") + - match: (?={{identifier_start}}|\[|'|") push: - initializer - variable-binding-object-alias @@ -464,7 +464,7 @@ contexts: - include: else-pop variable-binding-object-key: - - match: '{{identifier}}(?=\s*:)' + - match: '{{identifier_name}}(?=\s*:)' pop: true - include: literal-string - include: computed-property-name @@ -485,7 +485,7 @@ contexts: - include: else-pop variable-binding-top: - - match: (?={{identifier}}{{function_assignment_lookahead}}) + - match: (?={{identifier_name}}{{function_assignment_lookahead}}) set: - initializer - function-name-meta @@ -524,7 +524,7 @@ contexts: function-parameter-binding-name: - match: '{{non_reserved_identifier}}' scope: meta.binding.name.js variable.parameter.function.js - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: invalid.illegal.identifier.js meta.binding.name.js variable.parameter.function.js function-parameter-binding-array-destructuring: @@ -548,7 +548,7 @@ contexts: scope: punctuation.section.block.end.js pop: true - include: function-parameter-binding-spread - - match: (?={{identifier}}|\[|'|") + - match: (?={{identifier_start}}|\[|'|") push: - initializer - function-parameter-binding-object-alias @@ -562,7 +562,7 @@ contexts: - include: else-pop function-parameter-binding-object-key: - - match: '{{identifier}}(?=\s*:)' + - match: '{{identifier_name}}(?=\s*:)' pop: true - include: literal-string - include: computed-property-name @@ -853,7 +853,7 @@ contexts: - include: immediately-pop decorator-name: - - match: '{{identifier}}{{left_expression_end_lookahead}}' + - match: '{{identifier_name}}{{left_expression_end_lookahead}}' scope: variable.annotation.js pop: true @@ -936,14 +936,18 @@ contexts: - include: import-meta-expression - include: class - - include: constants + - include: special-name - - match: (?={{identifier}}{{function_assignment_lookahead}}) + - include: regular-function + + - match: (?={{reserved_word}}) + pop: true + + - match: (?={{identifier_name}}{{function_assignment_lookahead}}) set: - function-name-meta - literal-variable - - include: regular-function - include: object-literal # Newline not allowed between `async` and parameters. @@ -1059,7 +1063,7 @@ contexts: - include: string-content tagged-template: - - match: '{{identifier}}(?=\s*`)' + - match: '{{identifier_name}}(?=\s*`)' scope: variable.function.tagged-template.js pop: true @@ -1153,7 +1157,7 @@ contexts: captures: 1: punctuation.dollar.js pop: true - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: variable.type.js pop: true - include: else-pop @@ -1334,7 +1338,7 @@ contexts: - match: |- (?x)(?= - \#? {{identifier}} + \#? {{identifier_name}} \s* = \s* {{either_func_lookahead}} ) @@ -1443,7 +1447,7 @@ contexts: fail: class-field - include: else-pop - constants: + special-name: - match: true{{identifier_break}} scope: constant.language.boolean.true.js pop: true @@ -1453,6 +1457,12 @@ contexts: - 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 function-name-meta: - meta_include_prototype: false @@ -1539,7 +1549,7 @@ contexts: set: - clear_scopes: 1 - meta_scope: meta.function.parameters.js - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: variable.parameter.function.js pop: true - include: function-declaration-parameters @@ -1567,7 +1577,7 @@ contexts: - include: function-parameter-binding-list label: - - match: '({{identifier}})\s*(:)' + - match: '({{identifier_name}})\s*(:)' captures: 1: entity.name.label.js 2: punctuation.separator.js @@ -1600,7 +1610,7 @@ contexts: - match: (?=\*) push: method-declaration - - match: '{{identifier}}(?=\s*(?:[},]|$|//|/\*))' + - match: '{{identifier_name}}(?=\s*(?:[},]|$|//|/\*))' scope: variable.other.readwrite.js - match: (?=(?:get|set|async){{identifier_break}}) @@ -1645,7 +1655,7 @@ contexts: - include: literal-string - include: literal-number - - match: '{{identifier}}' + - match: '{{identifier_name}}' pop: true - include: else-pop @@ -1675,10 +1685,10 @@ contexts: captures: 1: punctuation.dollar.js pop: true - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: entity.name.function.js pop: true - - match: '(#){{identifier}}' + - match: '(#){{identifier_name}}' scope: entity.name.function.js captures: 1: punctuation.definition.js @@ -1721,7 +1731,7 @@ contexts: captures: 1: punctuation.dollar.js pop: true - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: variable.other.readwrite.js pop: true - match: "'" @@ -1750,7 +1760,7 @@ contexts: scope: invalid.illegal.newline.js pop: true - include: string-content - - match: (#)({{identifier}}) + - match: (#)({{identifier_name}}) captures: 1: punctuation.definition.variable.js 2: variable.other.readwrite.js @@ -1827,7 +1837,7 @@ contexts: - match: '{{dot_accessor}}' scope: punctuation.accessor.js push: - - match: '(?={{identifier}}\s*(?:{{dot_accessor}})?\()' + - match: '(?={{identifier_name}}\s*(?:{{dot_accessor}})?\()' set: - call-method-meta - function-call-arguments @@ -1907,13 +1917,13 @@ contexts: pop: true literal-call: - - match: (?={{identifier}}\s*(?:{{dot_accessor}})?\() + - match: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\() set: - call-function-meta - function-call-arguments - literal-variable - - match: (?={{identifier}}\s*(?:{{dot_accessor}}\s*#?{{identifier}}\s*)+(?:{{dot_accessor}})?\() + - match: (?={{identifier_name}}\s*(?:{{dot_accessor}}\s*#?{{identifier_name}}\s*)+(?:{{dot_accessor}})?\() set: - call-method-meta - function-call-arguments @@ -1940,17 +1950,17 @@ contexts: - match: '{{dollar_only_identifier}}' scope: variable.function.js variable.other.dollar.only.js punctuation.dollar.js pop: true - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: variable.function.js pop: true - include: else-pop call-method-name: - include: support-property - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: variable.function.js pop: true - - match: '(#){{identifier}}' + - match: '(#){{identifier_name}}' scope: variable.function.js captures: 1: punctuation.definition.js @@ -1958,7 +1968,7 @@ contexts: - include: else-pop literal-variable: - - include: language-identifiers + - include: special-identifier - include: support - match: '{{constant_identifier}}(?=\s*(?:{{dot_accessor}}|\[))' @@ -1982,33 +1992,26 @@ contexts: - match: '{{constant_identifier}}' scope: variable.other.constant.js pop: true - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: variable.other.readwrite.js pop: true - include: literal-private-variable literal-private-variable: - - match: (#)({{identifier}}) + - match: (#)({{identifier_name}}) captures: 1: punctuation.definition.variable.js 2: variable.other.readwrite.js pop: true - language-identifiers: + special-identifier: + # These are ordinary identifiers, not reserved words - match: arguments{{identifier_break}} scope: variable.language.arguments.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 - match: globalThis{{identifier_break}} scope: variable.language.global.js pop: true - - # These three are ordinary variables, not literals! - match: undefined{{identifier_break}} scope: constant.language.undefined.js pop: true @@ -2381,12 +2384,12 @@ contexts: object-property: - include: support-property - - match: (?=\#?{{identifier}}{{function_assignment_lookahead}}) + - match: (?=\#?{{identifier_name}}{{function_assignment_lookahead}}) set: - function-name-meta - object-property-base - - match: '(?=#?{{identifier}}\s*(?:{{dot_accessor}})?\()' + - match: '(?=#?{{identifier_name}}\s*(?:{{dot_accessor}})?\()' set: call-method-name - include: object-property-base @@ -2401,13 +2404,13 @@ contexts: captures: 1: punctuation.dollar.js pop: true - - match: '{{identifier}}' + - 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}}) + - match: (#)({{identifier_name}}) captures: 1: punctuation.definition.variable.js 2: meta.property.object.js diff --git a/JavaScript/TypeScript.sublime-syntax b/JavaScript/TypeScript.sublime-syntax index 5d43a4101e..3bee685cb2 100644 --- a/JavaScript/TypeScript.sublime-syntax +++ b/JavaScript/TypeScript.sublime-syntax @@ -12,7 +12,7 @@ variables: function_call_lookahead: >- (?x:(?= - {{identifier}} + {{identifier_name}} \s* (?: < @@ -93,7 +93,7 @@ contexts: - match: \!\. scope: punctuation.accessor.js push: - - match: '(?={{identifier}}\s*(?:\.\?)?\()' + - match: '(?={{identifier_name}}\s*(?:\.\?)?\()' set: - call-method-meta - function-call-arguments @@ -189,7 +189,7 @@ contexts: - include: immediately-pop ts-interface-name: - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: entity.name.interface.js pop: true - include: else-pop @@ -233,7 +233,7 @@ contexts: - match: \] scope: punctuation.section.brackets.end.js pop: true - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: variable.other.readwrite.js push: - match: in{{identifier_break}} @@ -251,7 +251,7 @@ contexts: - function-declaration-expect-parameters - ts-type-parameter-list - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: variable.other.readwrite.js push: - - match: (?=[<(]) @@ -277,7 +277,7 @@ contexts: - include: immediately-pop ts-enum-name: - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: entity.name.enum.js pop: true - include: else-pop @@ -293,7 +293,7 @@ contexts: - include: comma-separator - match: (?=['"]) push: literal-string - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: variable.other.readwrite.js push: initializer @@ -303,7 +303,7 @@ contexts: - include: immediately-pop ts-type-alias-name: - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: entity.name.type.js pop: true - include: else-pop @@ -331,7 +331,7 @@ contexts: - include: immediately-pop ts-namespace-name: - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: entity.name.namespace.js pop: true - include: else-pop @@ -369,7 +369,7 @@ contexts: - match: \> scope: punctuation.definition.generic.end.js pop: true - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: variable.parameter.generic.js push: - ts-type-parameter-default @@ -559,7 +559,7 @@ contexts: - match: \. scope: punctuation.separator.accessor.js push: - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: support.class.js set: ts-type-expression-end-no-line-terminator @@ -708,7 +708,7 @@ contexts: - include: comma-separator - match: ; scope: punctuation.separator.semicolon.js - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: variable.other.readwrite.js push: - ts-type-annotation @@ -755,7 +755,7 @@ contexts: pop: true ts-type-basic: - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: support.class.js pop: true @@ -790,7 +790,7 @@ contexts: - ts-type-expression-begin - include: else-pop - include: comma-separator - - match: '{{identifier}}' + - match: '{{identifier_name}}' scope: variable.other.readwrite.js push: - ts-type-annotation diff --git a/JavaScript/tests/syntax_test_js.js b/JavaScript/tests/syntax_test_js.js index d68ea64d78..9d453115d5 100644 --- a/JavaScript/tests/syntax_test_js.js +++ b/JavaScript/tests/syntax_test_js.js @@ -470,6 +470,9 @@ var obj = { // ^^^^^^^^^^^^ meta.function }, + class: null, // Keys are IdentifierNames, not merely Identifiers +// ^^^^^ meta.mapping.key + [true==false ? 'one' : 'two']: false, // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.key // ^ punctuation.section.brackets.begin @@ -1004,6 +1007,9 @@ class MyClass extends TheirClass { // ^ entity.name.function variable.other.readwrite // ^^^^^^^^^^^^^ meta.function + class = null; +// ^^^^^ variable.other.readwrite + static x = 42; // ^^^^^^ storage.modifier.js // ^ variable.other.readwrite @@ -1849,6 +1855,14 @@ const abc = new Set if (true) {}; // <- keyword.control.conditional + const x = + const y = 1; // Better highlighting while typing. +// ^^^^^ storage.type + + let x = + const y = 1; // Better highlighting while typing. +// ^^^^^ storage.type + var o = { a, b, diff --git a/JavaScript/tests/syntax_test_jsx.jsx b/JavaScript/tests/syntax_test_jsx.jsx index 01191ba6a7..b52de9c612 100644 --- a/JavaScript/tests/syntax_test_jsx.jsx +++ b/JavaScript/tests/syntax_test_jsx.jsx @@ -181,4 +181,7 @@ // ^ - punctuation } // ^ punctuation.definition.interpolation.end - \ No newline at end of file +; + + ; +// ^^^^^ entity.name.tag From e7c9cb293d25b895e75ba5b0b323aa00083e4d58 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 13 Jan 2021 20:35:24 +0100 Subject: [PATCH 008/152] [C#] Use keyword.declaration.function (#2616) This commit scopes all remaining function declaration keywords `keyword.declaration.function`. This commit scopes the `=>` as `keyword.declaration.function.anonymous`. It was applied to C#, D recently and will be used in Java an Python as a common alternative to the existing variants of defining anonymous functions. We currently have: - keyword.declaration.function.anonymous - keyword.declaration.function.arrow - keyword.declaration.function.inline - keyword.declaration.function.lambda --- C#/C#.sublime-syntax | 14 ++++---- C#/tests/syntax_test_C#7.cs | 2 +- C#/tests/syntax_test_C#8.cs | 2 +- C#/tests/syntax_test_C#9.cs | 6 ++-- C#/tests/syntax_test_GeneralStructure.cs | 44 ++++++++++++------------ C#/tests/syntax_test_Generics.cs | 2 +- C#/tests/syntax_test_Using.cs | 2 +- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/C#/C#.sublime-syntax b/C#/C#.sublime-syntax index f4de53a20b..8423593514 100644 --- a/C#/C#.sublime-syntax +++ b/C#/C#.sublime-syntax @@ -500,10 +500,10 @@ contexts: scope: punctuation.section.block.end.cs pop: true - match: \b(add)\b - scope: storage.type.function.accessor.add.cs + scope: keyword.declaration.function.accessor.add.cs push: method_body - match: \b(remove)\b - scope: storage.type.function.accessor.remove.cs + scope: keyword.declaration.function.accessor.remove.cs push: method_body - match: (?==) set: member_variables_declaration @@ -579,7 +579,7 @@ contexts: captures: 1: variable.other.member.cs 2: meta.method.cs - 3: storage.type.function.accessor.get.cs + 3: keyword.declaration.function.accessor.get.cs set: - meta_scope: meta.property.cs - meta_content_scope: meta.method.cs @@ -771,10 +771,10 @@ contexts: - match: (?:\b(readonly)\b\s+)?\b(get)\b captures: 1: storage.modifier.cs - 2: storage.type.function.accessor.get.cs + 2: keyword.declaration.function.accessor.get.cs push: method_body - match: \b(set|init)\b - scope: storage.type.function.accessor.set.cs + scope: keyword.declaration.function.accessor.set.cs push: method_body - match: '{{visibility}}' scope: storage.modifier.access.cs @@ -979,7 +979,7 @@ contexts: - match: ({{name}})\s+(=>)\s* captures: 1: variable.parameter.cs - 2: storage.type.function.lambda.cs + 2: keyword.declaration.function.anonymous.cs push: - meta_scope: meta.function.anonymous.cs - match: '(?=;)' @@ -999,7 +999,7 @@ contexts: - match: (\))\s*(=>) captures: 1: meta.group.cs punctuation.section.group.end.cs - 2: storage.type.function.lambda.cs + 2: keyword.declaration.function.anonymous.cs set: - meta_content_scope: meta.function.anonymous.cs - match: '(?=;)' diff --git a/C#/tests/syntax_test_C#7.cs b/C#/tests/syntax_test_C#7.cs index 2e06c2f396..24a5c24b88 100644 --- a/C#/tests/syntax_test_C#7.cs +++ b/C#/tests/syntax_test_C#7.cs @@ -564,7 +564,7 @@ private static (int Max, int Min) Range(IEnumerable numbers) /// ^^^^ variable.other /// ^ keyword.operator.assignment.variable /// ^ variable.parameter -/// ^^ storage.type.function.lambda +/// ^^ keyword.declaration.function.anonymous /// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group /// ^ punctuation.section.group.begin /// ^^^^^^^^ variable.other diff --git a/C#/tests/syntax_test_C#8.cs b/C#/tests/syntax_test_C#8.cs index e2e44ab011..fd3717f114 100644 --- a/C#/tests/syntax_test_C#8.cs +++ b/C#/tests/syntax_test_C#8.cs @@ -87,7 +87,7 @@ public struct Point3D /// ^^^^^^^^ storage.modifier /// ^^^^^^^ support.type /// ^^^^^^^ variable.other.member -/// ^^ storage.type.function.accessor.get +/// ^^ keyword.declaration.function.accessor.get /// ^^^ keyword.other /// ^^^^^^ variable.other /// ^ punctuation.terminator.statement diff --git a/C#/tests/syntax_test_C#9.cs b/C#/tests/syntax_test_C#9.cs index f33cb80777..21a7decfd3 100644 --- a/C#/tests/syntax_test_C#9.cs +++ b/C#/tests/syntax_test_C#9.cs @@ -10,15 +10,15 @@ public record Person { private readonly string lastName; public string FirstName { get; init; } -/// ^^^ storage.type.function.accessor.get +/// ^^^ keyword.declaration.function.accessor.get /// ^ punctuation.terminator -/// ^^^^ storage.type.function.accessor.set +/// ^^^^ keyword.declaration.function.accessor.set /// ^ punctuation.terminator public string LastName { get => lastName; init => lastName = (value ?? throw new ArgumentNullException(nameof(LastName))); -/// ^^^^ storage.type.function.accessor.set +/// ^^^^ keyword.declaration.function.accessor.set /// ^^ keyword.declaration.function.anonymous /// ^^^^^^^^ variable.other } diff --git a/C#/tests/syntax_test_GeneralStructure.cs b/C#/tests/syntax_test_GeneralStructure.cs index 06646fb2f5..9214adb1c8 100644 --- a/C#/tests/syntax_test_GeneralStructure.cs +++ b/C#/tests/syntax_test_GeneralStructure.cs @@ -46,14 +46,14 @@ public Int YourProperty { /// ^ meta.property punctuation.section.block.begin get {return x;} /// ^^^^^^^^^^^^^^^ meta.property meta.method -/// ^ storage.type.function.accessor.get +/// ^ keyword.declaration.function.accessor.get /// ^^^^^^^^^^^ meta.property meta.method.body meta.block /// ^ punctuation.section.block.begin /// ^ punctuation.terminator /// ^ punctuation.section.block.end set {x = value;} /// ^^^^^^^^^^^^^^^^ meta.property meta.method -/// ^ storage.type.function.accessor.set +/// ^ keyword.declaration.function.accessor.set /// ^^^^^^^^^^^^ meta.property meta.method.body meta.block /// ^ punctuation.section.block.begin /// ^ variable.other @@ -96,7 +96,7 @@ public Int YourProperty { /// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.property /// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.method /// ^ variable.other.member -/// ^^ storage.type.function.accessor.get +/// ^^ keyword.declaration.function.accessor.get /// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call /// ^^^^^^^ support.type /// ^^^^^^ meta.generic @@ -108,9 +108,9 @@ public Int YourProperty { /// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.property /// ^^^^^^^^^^^^^^ variable.other.member /// ^^^^^^^^^^^^^^^^^^^^ meta.property meta.block -/// ^^^ storage.type.function.accessor.get +/// ^^^ keyword.declaration.function.accessor.get /// ^^^^^^^ storage.modifier.access -/// ^^^ storage.type.function.accessor.set +/// ^^^ keyword.declaration.function.accessor.set /// ^ keyword.operator.assignment /// ^^^^^ constant.language @@ -715,8 +715,8 @@ IEnumerable Traverse() /// ^ punctuation.section.brackets.end /// ^^^ storage.type /// ^^^ variable.parameter -/// ^^^ storage.type.function.accessor -/// ^^^ storage.type.function.accessor +/// ^^^ keyword.declaration.function.accessor +/// ^^^ keyword.declaration.function.accessor ///////////////////////////// @@ -792,7 +792,7 @@ public virtual ActionResult Process([ModelBinder(typeof(MyModelBinder))] /// ^^^ storage.type /// ^^^^^^^ variable.other.member /// ^^^^ meta.method -/// ^^ storage.type.function +/// ^^ keyword.declaration.function /// ^ constant.numeric /// ^ punctuation.terminator @@ -829,24 +829,24 @@ void CodeContainingLambdas(){ /// ^^^ variable.other /// ^ keyword.operator.assignment /// ^^^^^^^^ meta.function.anonymous -/// ^^ storage.type.function.lambda +/// ^^ keyword.declaration.function.anonymous Func times2 = x => x + x; /// ^^^ support.type /// ^^^ variable.other /// ^ keyword.operator.assignment /// ^^^^^^^^^^ meta.function.anonymous -/// ^^ storage.type.function.lambda +/// ^^ keyword.declaration.function.anonymous var changes = refs.ToDictionary(kvp => kvp.key, arg => k + 5); /// ^^^^^^^^^^^^^^ meta.function.anonymous.cs /// ^^^ variable.parameter.cs -/// ^^ storage.type.function.lambda.cs +/// ^^ keyword.declaration.function.anonymous.cs /// ^^^ variable.other.cs /// ^ punctuation.separator.argument.cs /// ^^ - meta.function.anonymous /// ^^^^^^^^^^^^ meta.function.anonymous.cs /// ^^^ variable.parameter.cs -/// ^^ storage.type.function.lambda.cs +/// ^^ keyword.declaration.function.anonymous.cs /// ^ variable.other.cs /// ^ keyword.operator.cs /// ^ meta.number.integer.decimal.cs @@ -862,7 +862,7 @@ void CodeContainingLambdas(){ /// ^ punctuation.separator.parameter.function.cs /// ^^^^^ variable.parameter.cs /// ^ punctuation.section.group.end.cs -/// ^^ storage.type.function.lambda.cs +/// ^^ keyword.declaration.function.anonymous.cs /// ^^^^^ variable.other.cs } @@ -1010,7 +1010,7 @@ void TestMethod(int argument) { void TestMe () { a = b => b * 2; -/// ^^ storage.type.function.lambda +/// ^^ keyword.declaration.function.anonymous /// ^^^^^^^^ meta.function.anonymous /// ^ punctuation.terminator.statement - meta.function.anonymous @@ -1031,7 +1031,7 @@ void TestMe () { } a = b => { return b * 2; }; -/// ^^ meta.function.anonymous storage.type.function.lambda +/// ^^ meta.function.anonymous keyword.declaration.function.anonymous /// ^ meta.function.anonymous punctuation.section.block.begin /// ^ punctuation.section.block.end /// ^ punctuation.terminator.statement - meta.function.anonymous @@ -1055,7 +1055,7 @@ void TestMe () { /// ^ variable.parameter /// ^ punctuation.separator /// ^ variable.parameter -/// ^^ storage.type.function.lambda +/// ^^ keyword.declaration.function.anonymous /// ^ meta.function.anonymous punctuation.section.block.begin /// ^ punctuation.section.block.end /// ^ punctuation.terminator.statement - meta.function.anonymous @@ -1082,7 +1082,7 @@ void TestMe () { /// ^ variable.parameter /// ^ punctuation.separator.parameter.function /// ^ variable.parameter -/// ^^ storage.type.function.lambda +/// ^^ keyword.declaration.function.anonymous /// ^ punctuation.terminator.statement /// ^ - meta.function.anonymous @@ -1133,7 +1133,7 @@ void TestMe () { /// ^^^^^^ meta.cast support.type /// ^ punctuation.section.group.begin /// ^^ meta.function.anonymous meta.group -/// ^^ storage.type.function.lambda +/// ^^ keyword.declaration.function.anonymous /// ^ punctuation.section.group.end test = (Action)(() => {}); /// ^^^^^^^^ meta.cast @@ -1141,7 +1141,7 @@ void TestMe () { /// ^^^^^^^ meta.function.anonymous /// ^ meta.group punctuation.section.group.begin /// ^ meta.group punctuation.section.group.end -/// ^^ storage.type.function.lambda +/// ^^ keyword.declaration.function.anonymous /// ^ punctuation.section.block.begin /// ^ punctuation.section.block.end /// ^ meta.group punctuation.section.group.end @@ -1306,7 +1306,7 @@ protected event EventHandler IDrawingObject.OnDraw { /// ^ punctuation.section.block.begin add -/// ^^^ meta.method storage.type.function.accessor.add +/// ^^^ meta.method keyword.declaration.function.accessor.add { /// ^ punctuation.section.block.begin lock (objectLock) @@ -1319,7 +1319,7 @@ protected event EventHandler IDrawingObject.OnDraw /// ^ punctuation.section.block.end /// ^ - meta.method remove -/// ^^^^^^ meta.method storage.type.function.accessor.remove +/// ^^^^^^ meta.method keyword.declaration.function.accessor.remove { lock (objectLock) { @@ -1368,7 +1368,7 @@ public int Counter { readonly get => counter; /// ^^^^^^^^ storage.modifier -/// ^^^ storage.type.function.accessor.get +/// ^^^ keyword.declaration.function.accessor.get set => counter = value; } } diff --git a/C#/tests/syntax_test_Generics.cs b/C#/tests/syntax_test_Generics.cs index a28383465a..e38f53c023 100755 --- a/C#/tests/syntax_test_Generics.cs +++ b/C#/tests/syntax_test_Generics.cs @@ -154,7 +154,7 @@ string Frag { /// <- punctuation.section.block.begin get -/// ^^^ - storage.type.function +/// ^^^ - keyword.declaration.function { /// ^ punctuation.section.block.begin var list = new List(); diff --git a/C#/tests/syntax_test_Using.cs b/C#/tests/syntax_test_Using.cs index 09e1a46a1a..902857c4b0 100755 --- a/C#/tests/syntax_test_Using.cs +++ b/C#/tests/syntax_test_Using.cs @@ -141,7 +141,7 @@ public static Test Default { /// ^^^^^ meta.annotation /// ^ variable.annotation get { -/// ^ storage.type.function.accessor.get +/// ^ keyword.declaration.function.accessor.get return defaultInstance; } } From 46c2b71de83599f9f69cd16d2a2ba6ffadbfb44a Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 13 Jan 2021 20:38:34 +0100 Subject: [PATCH 009/152] [ASP] Add vbs file extension (#2619) ASP is visual basic. Thus we can also use that syntax for vbs files. --- ASP/ASP.sublime-syntax | 1 + 1 file changed, 1 insertion(+) diff --git a/ASP/ASP.sublime-syntax b/ASP/ASP.sublime-syntax index fcca419707..97941a63ed 100644 --- a/ASP/ASP.sublime-syntax +++ b/ASP/ASP.sublime-syntax @@ -4,6 +4,7 @@ name: ASP file_extensions: - asa # asp is handled by HTML-ASP.sublime-syntax + - vbs # Visual Basic Script scope: source.asp variables: apostrophe_comment_begin: "'" From 9a52d2ffe9e350acf35bcf094c0c07bee1551691 Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Wed, 13 Jan 2021 20:39:40 +0100 Subject: [PATCH 010/152] [Python] Don't cancel completions for function definitions (#2620) Other object-oriented languages in the default packages only disable completions for class/type names, because in object-oriented languages you can make use of function overloading, including the commonly defined dunder functions. Most notably, this allows auto-completion plugins like LSP to function properly. Aside from that, the regex was merely restructured. --- Python/Completion Rules.tmPreferences | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Python/Completion Rules.tmPreferences b/Python/Completion Rules.tmPreferences index f593545538..7b51660423 100644 --- a/Python/Completion Rules.tmPreferences +++ b/Python/Completion Rules.tmPreferences @@ -6,7 +6,12 @@ settings cancelCompletion - ^(.*\b(and|or)$)|(\s*(pass|return|and|or|(class|def)\s*[a-zA-Z_0-9]+)$) + (?x) + # Prevent completions when typing keywords + \b(and|or|pass|return)$ + | # Prevent completions for class names + ^\s* class \s+ [a-zA-Z_0-9]+ $ + From 8c209e51194bb5f0c9e79ec82e9b0df3414aafd3 Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Wed, 13 Jan 2021 20:40:57 +0100 Subject: [PATCH 011/152] [Python] Clean up built-ins (#2621) * Remove 'buffer' from the built-in types list. It is frequently used in Python 3 code where it is not a built-in type. * Replace remaining tab characters * Reorganize built-in matches - Split Python 2 and 3 specific built-ins. - `xrange` is not a type (no more than `map`, `filter`, or `property`) Does not include exception types. * Make some groups non-capturing * Trivial grouping fixes for built-ins --- Python/Python.sublime-syntax | 54 +++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/Python/Python.sublime-syntax b/Python/Python.sublime-syntax index 12b3d12318..356cefd166 100644 --- a/Python/Python.sublime-syntax +++ b/Python/Python.sublime-syntax @@ -897,7 +897,7 @@ contexts: lambda: - match: \b(lambda)(?=\s|:|$) - scope: + scope: meta.function.inline.python storage.type.function.inline.python keyword.declaration.function.inline.python @@ -1113,38 +1113,46 @@ contexts: builtin-exceptions: - match: |- (?x)\b( - ( - Arithmetic|Assertion|Attribute|BlockingIO|BrokenPipe|Buffer|ChildProcess| - Connection(Aborted|Refused|Reset)?|EOF|Environment|FileExists| - FileNotFound|FloatingPoint|Interrupted|IO|IsADirectoryError| - Import|Indentation|Index|Key|Lookup|Memory|Name|NotADirectory| - NotImplemented|OS|Overflow|Permission|ProcessLookup|Reference| - Runtime|Standard|Syntax|System|Tab|Timeout|Type|UnboundLocal| - Unicode(Encode|Decode|Translate)?|Value|VMS|Windows|ZeroDivision - )Error| - ((Pending)?Deprecation|Resource|Runtime|Syntax|User|Future|Import|Unicode|Bytes)?Warning| - (Base)?Exception| - SystemExit|StopIteration|NotImplemented|KeyboardInterrupt|GeneratorExit + (?: + Arithmetic|Assertion|Attribute|BlockingIO|BrokenPipe|Buffer|ChildProcess| + Connection(?:Aborted|Refused|Reset)?|EOF|Environment|FileExists| + FileNotFound|FloatingPoint|Interrupted|IO|IsADirectoryError| + Import|Indentation|Index|Key|Lookup|Memory|Name|NotADirectory| + NotImplemented|OS|Overflow|Permission|ProcessLookup|Reference| + Runtime|Standard|Syntax|System|Tab|Timeout|Type|UnboundLocal| + Unicode(?:Encode|Decode|Translate)?|Value|VMS|Windows|ZeroDivision + )Error| + (?:(?:Pending)?Deprecation|Resource|Runtime|Syntax|User|Future|Import|Unicode|Bytes)?Warning| + (?:Base)?Exception| + SystemExit|StopIteration|NotImplemented|KeyboardInterrupt|GeneratorExit )\b scope: support.type.exception.python builtin-functions: - match: |- - (?x)\b( - __import__|all|abs|any|apply|ascii|bin|breakpoint|callable|chr|classmethod|cmp|coerce| - compile|delattr|dir|divmod|enumerate|eval|exec|execfile|filter|format|getattr| - globals|hasattr|hash|help|hex|id|input|intern|isinstance|issubclass|iter| - len|locals|map|max|min|next|oct|open|ord|pow|print|property|range| - raw_input|reduce|reload|repr|reversed|round|setattr|sorted|staticmethod| - sum|super|type|unichr|vars|zip + (?x)\b(?: + __import__|all|abs|any|ascii|bin|callable|chr|classmethod| + compile|delattr|dir|divmod|enumerate|eval|filter|format|getattr| + globals|hasattr|hash|help|hex|id|input|isinstance|issubclass|iter| + len|locals|map|max|min|next|oct|open|ord|pow|property|range| + repr|reversed|round|setattr|sorted|staticmethod| + sum|super|type|vars|zip + # Python 2 functions + |apply|cmp|coerce|execfile|intern|raw_input|reduce|reload|unichr|xrange + # Python 3 functions + |breakpoint|exec|print )\b scope: support.function.builtin.python builtin-types: - match: |- - (?x)\b( - basestring|bool|buffer|bytearray|bytes|complex|dict|float|frozenset|int| - list|long|memoryview|object|range|set|slice|str|tuple|unicode|xrange + (?x)\b(?: + bool|bytearray|bytes|complex|dict|float|frozenset|int| + list|memoryview|object|set|slice|str|tuple + # Python 2 types + |basestring|long|unicode + # Python 2 types prone to conflicts + # |buffer|file )\b scope: support.type.python From 89d520d876ef76884300ea14413725480294e3a4 Mon Sep 17 00:00:00 2001 From: Thomas Smith Date: Wed, 13 Jan 2021 14:50:30 -0500 Subject: [PATCH 012/152] [JavaScript] Move class tests to separate file. (#2622) --- JavaScript/tests/syntax_test_js.js | 292 +---------------------- JavaScript/tests/syntax_test_js_class.js | 291 ++++++++++++++++++++++ 2 files changed, 292 insertions(+), 291 deletions(-) create mode 100644 JavaScript/tests/syntax_test_js_class.js diff --git a/JavaScript/tests/syntax_test_js.js b/JavaScript/tests/syntax_test_js.js index 9d453115d5..afb62de198 100644 --- a/JavaScript/tests/syntax_test_js.js +++ b/JavaScript/tests/syntax_test_js.js @@ -956,278 +956,7 @@ catch{}/**/ finally{}/**/ // ^ - meta.finally -class MyClass extends TheirClass { -// <- storage.type.class -// ^^^^^^^ entity.name.class -// ^^^^^^^ storage.modifier.extends -// ^^^^^^^^^^ entity.other.inherited-class -// ^ meta.block punctuation.section.block.begin - - x = 42; -// ^ variable.other.readwrite -// ^ keyword.operator.assignment -// ^^ constant.numeric - - 'y' = 42; -// ^^^ meta.string string.quoted.single -// ^ variable.other.readwrite -// ^ keyword.operator.assignment -// ^^ constant.numeric - - "z" = 42; -// ^^^ meta.string string.quoted.double -// ^ variable.other.readwrite -// ^ keyword.operator.assignment -// ^^ constant.numeric - - [w] = 42; -// ^ punctuation.section.brackets.begin -// ^ variable.other.readwrite -// ^ punctuation.section.brackets.end -// ^ keyword.operator.assignment -// ^^ constant.numeric - - #v = 42; -// ^ punctuation.definition.variable -// ^ variable.other.readwrite -// ^ keyword.operator.assignment -// ^^ constant.numeric - - f = a => b; -// ^ entity.name.function variable.other.readwrite -// ^^^^^^ meta.function -// ^ variable.parameter.function - - g = function() {}; -// ^ entity.name.function variable.other.readwrite -// ^^^^^^^^^^^^^ meta.function - - #h = function() {}; -// ^ punctuation.definition.variable -// ^ entity.name.function variable.other.readwrite -// ^^^^^^^^^^^^^ meta.function - - class = null; -// ^^^^^ variable.other.readwrite - - static x = 42; -// ^^^^^^ storage.modifier.js -// ^ variable.other.readwrite -// ^ keyword.operator.assignment -// ^^ constant.numeric - - static 'y' = 42; -// ^^^^^^ storage.modifier.js -// ^^^ meta.string string.quoted.single -// ^ variable.other.readwrite -// ^ keyword.operator.assignment -// ^^ constant.numeric - - static "z" = 42; -// ^^^^^^ storage.modifier.js -// ^^^ meta.string string.quoted.double -// ^ variable.other.readwrite -// ^ keyword.operator.assignment -// ^^ constant.numeric - - static [w] = 42; -// ^^^^^^ storage.modifier.js -// ^ punctuation.section.brackets.begin -// ^ variable.other.readwrite -// ^ punctuation.section.brackets.end -// ^ keyword.operator.assignment -// ^^ constant.numeric - - static #v = 42; -// ^ punctuation.definition.variable -// ^ variable.other.readwrite -// ^ keyword.operator.assignment -// ^^ constant.numeric - - static f = a => b; -// ^ entity.name.function variable.other.readwrite -// ^^^^^^ meta.function -// ^ variable.parameter.function - - static g = function() {}; -// ^ entity.name.function variable.other.readwrite -// ^^^^^^^^^^^^^ meta.function - - foo // You thought I was a field... - () { return '...but was a method all along!'; } -// ^^ meta.class meta.block meta.function - - someMethod() { - return #e * 2; -// ^ punctuation.definition.variable -// ^ variable.other.readwrite -// ^ keyword.operator.arithmetic - - for (const param of this.#data.get('value')) {} -// ^ punctuation.definition.variable -// ^^^^ meta.property.object - } - - #privateMethod() {} -// ^^^^^^^^^^^^^^^^^^^ meta.function -// ^^^^^^^^^^^^^^ entity.name.function.js -// ^ punctuation.definition.js - - constructor(el) -// ^^^^^^^^^^^^^^^ meta.function - // ^ entity.name.function.constructor - { -// ^ meta.class meta.block meta.function meta.block punctuation.section.block - $.foo = ""; - super(el); - } -// ^ meta.class meta.block meta.function meta.block punctuation.section.block - - get foo() -// ^^^^^^^^^ meta.function - // <- storage.type.accessor - // ^ entity.name.function - { - return this._foo; - } - - static foo(baz) { -// ^^^^^^ storage.modifier -// ^^^^^^^^^^ meta.function - // ^^^ entity.name.function - - } - - qux() -// ^^^^^ meta.function - { } -// ^ meta.class meta.block meta.block punctuation.section.block.begin - - get bar () { -// ^^^^^^^^^^^^ meta.function -// ^ meta.class meta.block meta.block punctuation.section.block.begin - // <- storage.type.accessor - // ^ entity.name.function - return false; - } - - baz() { return null } -// ^^^^^^^^^^^^^^^^^^^^^ meta.function - // <- entity.name.function - - get() { return "foobar"; } -// ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function -// ^^^ entity.name.function.js - storage.type.accessor - - set (value) { return value; } -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function -// ^^^^^ variable.parameter.function.js -// ^^^ entity.name.function.js - storage.type.accessor - - set abc(value1, value2) { return value1 + value2; } -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function -// ^^^ storage.type.accessor - entity.name.function.js -// ^^^ entity.name.function.js -// ^^^^^^ variable.parameter.function.js -// ^ punctuation.separator.parameter.function.js -// ^^^^^^ variable.parameter.function.js - - static$ -// ^^^^^^^ - storage - () {}; - - constructor$() {} -// ^^^^^^^^^^^^ entity.name.function - entity.name.function.constructor - - @foo bar() {} -// ^^^^ meta.annotation -// ^ punctuation.definition.annotation -// ^^^ variable.annotation -// ^^^ entity.name.function - - @foo.bar bar() {} -// ^^^^^^^^ meta.annotation -// ^ punctuation.definition.annotation -// ^^^ variable.other.readwrite - variable.annotation -// ^^^ variable.annotation -// ^^^ entity.name.function - - @(whatever) bar() {} -// ^^^^^^^^^^^ meta.annotation -// ^ punctuation.definition.annotation -// ^^^^^^^^^^ meta.group -// ^^^ entity.name.function - - ['foo']() {} -// ^^^^^^^^^^^^ meta.function - - static ['foo']() {} -// ^^^^^^^^^^^^ meta.function - - async foo() {} -// ^^^^^ keyword.declaration.async - - *foo() {} -// ^ keyword.generator.asterisk - - async *foo() {} -// ^^^^^ keyword.declaration.async -// ^ keyword.generator.asterisk - - static async foo() {} -// ^^^^^ keyword.declaration.async -} -// <- meta.block punctuation.section.block.end - -class Foo extends React.Component { -// ^^^^^ - entity.other.inherited-class -// ^^^^^^^^^ entity.other.inherited-class - constructor() - {} - - [foo.bar](arg) { -// ^^^ variable.other -// ^^^ meta.property -// ^^^ variable.parameter - return this.a; - } -} - -class Foo extends (Foo).Bar {} -// ^^^ entity.other.inherited-class - -class Foo extends Bar -// ^^^ entity.other.inherited-class - .baz {} -// ^^^^^^^ meta.class -// ^ punctuation.accessor -// ^^^ entity.other.inherited-class - -class Foo extends -// ^^^^^^^ storage.modifier.extends -Bar {} - -class Foo extends getSomeClass() {} -// ^^^^^^^^^^^^ meta.function-call variable.function - entity.other.inherited-class - - (class extends Bar {}); -// ^^^^^^^ storage.modifier.extends - entity.name.class - - (class extends class {} {}); -// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class -// ^^^^^^^ storage.modifier.extends -// ^^^^^^^^ meta.class meta.class -// ^^^^^ storage.type.class - -// Better highlighting while typing. -class -class -// <- storage.type.class - entity.name.class - -class{}/**/ -// ^ - meta.class - - () => {} + () => {}; // ^^^^^^^^ meta.function - meta.function meta.function // ^^ meta.function.parameters // ^ punctuation.section.group.begin @@ -1237,25 +966,6 @@ class{}/**/ // ^ punctuation.section.block // ^ punctuation.section.block - @foo class Foo {} -// ^^^^ meta.annotation -// ^ punctuation.definition.annotation -// ^^^ variable.annotation -// ^^^^^ storage.type.class - - @foo.bar class Foo {} -// ^^^^^^^^ meta.annotation -// ^ punctuation.definition.annotation -// ^^^ variable.other.readwrite - variable.annotation -// ^^^ variable.annotation -// ^^^^^ storage.type.class - - @(whatever) class Foo {} -// ^^^^^^^^^^^ meta.annotation -// ^ punctuation.definition.annotation -// ^^^^^^^^^^ meta.group -// ^^^^^ storage.type.class - () => {}; // ^^^^^ meta.function // ^ punctuation.section.group.begin diff --git a/JavaScript/tests/syntax_test_js_class.js b/JavaScript/tests/syntax_test_js_class.js new file mode 100644 index 0000000000..70e0be9255 --- /dev/null +++ b/JavaScript/tests/syntax_test_js_class.js @@ -0,0 +1,291 @@ +// SYNTAX TEST "Packages/JavaScript/JavaScript.sublime-syntax" + +class MyClass extends TheirClass { +// <- storage.type.class +// ^^^^^^^ entity.name.class +// ^^^^^^^ storage.modifier.extends +// ^^^^^^^^^^ entity.other.inherited-class +// ^ meta.block punctuation.section.block.begin + + x = 42; +// ^ variable.other.readwrite +// ^ keyword.operator.assignment +// ^^ constant.numeric + + 'y' = 42; +// ^^^ meta.string string.quoted.single +// ^ variable.other.readwrite +// ^ keyword.operator.assignment +// ^^ constant.numeric + + "z" = 42; +// ^^^ meta.string string.quoted.double +// ^ variable.other.readwrite +// ^ keyword.operator.assignment +// ^^ constant.numeric + + [w] = 42; +// ^ punctuation.section.brackets.begin +// ^ variable.other.readwrite +// ^ punctuation.section.brackets.end +// ^ keyword.operator.assignment +// ^^ constant.numeric + + #v = 42; +// ^ punctuation.definition.variable +// ^ variable.other.readwrite +// ^ keyword.operator.assignment +// ^^ constant.numeric + + f = a => b; +// ^ entity.name.function variable.other.readwrite +// ^^^^^^ meta.function +// ^ variable.parameter.function + + g = function() {}; +// ^ entity.name.function variable.other.readwrite +// ^^^^^^^^^^^^^ meta.function + + #h = function() {}; +// ^ punctuation.definition.variable +// ^ entity.name.function variable.other.readwrite +// ^^^^^^^^^^^^^ meta.function + + class = null; +// ^^^^^ variable.other.readwrite + + static x = 42; +// ^^^^^^ storage.modifier.js +// ^ variable.other.readwrite +// ^ keyword.operator.assignment +// ^^ constant.numeric + + static 'y' = 42; +// ^^^^^^ storage.modifier.js +// ^^^ meta.string string.quoted.single +// ^ variable.other.readwrite +// ^ keyword.operator.assignment +// ^^ constant.numeric + + static "z" = 42; +// ^^^^^^ storage.modifier.js +// ^^^ meta.string string.quoted.double +// ^ variable.other.readwrite +// ^ keyword.operator.assignment +// ^^ constant.numeric + + static [w] = 42; +// ^^^^^^ storage.modifier.js +// ^ punctuation.section.brackets.begin +// ^ variable.other.readwrite +// ^ punctuation.section.brackets.end +// ^ keyword.operator.assignment +// ^^ constant.numeric + + static #v = 42; +// ^ punctuation.definition.variable +// ^ variable.other.readwrite +// ^ keyword.operator.assignment +// ^^ constant.numeric + + static f = a => b; +// ^ entity.name.function variable.other.readwrite +// ^^^^^^ meta.function +// ^ variable.parameter.function + + static g = function() {}; +// ^ entity.name.function variable.other.readwrite +// ^^^^^^^^^^^^^ meta.function + + foo // You thought I was a field... + () { return '...but was a method all along!'; } +// ^^ meta.class meta.block meta.function + + someMethod() { + return #e * 2; +// ^ punctuation.definition.variable +// ^ variable.other.readwrite +// ^ keyword.operator.arithmetic + + for (const param of this.#data.get('value')) {} +// ^ punctuation.definition.variable +// ^^^^ meta.property.object + } + + #privateMethod() {} +// ^^^^^^^^^^^^^^^^^^^ meta.function +// ^^^^^^^^^^^^^^ entity.name.function.js +// ^ punctuation.definition.js + + constructor(el) +// ^^^^^^^^^^^^^^^ meta.function + // ^ entity.name.function.constructor + { +// ^ meta.class meta.block meta.function meta.block punctuation.section.block + $.foo = ""; + super(el); + } +// ^ meta.class meta.block meta.function meta.block punctuation.section.block + + get foo() +// ^^^^^^^^^ meta.function + // <- storage.type.accessor + // ^ entity.name.function + { + return this._foo; + } + + static foo(baz) { +// ^^^^^^ storage.modifier +// ^^^^^^^^^^ meta.function + // ^^^ entity.name.function + + } + + qux() +// ^^^^^ meta.function + { } +// ^ meta.class meta.block meta.block punctuation.section.block.begin + + get bar () { +// ^^^^^^^^^^^^ meta.function +// ^ meta.class meta.block meta.block punctuation.section.block.begin + // <- storage.type.accessor + // ^ entity.name.function + return false; + } + + baz() { return null } +// ^^^^^^^^^^^^^^^^^^^^^ meta.function + // <- entity.name.function + + get() { return "foobar"; } +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function +// ^^^ entity.name.function.js - storage.type.accessor + + set (value) { return value; } +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function +// ^^^^^ variable.parameter.function.js +// ^^^ entity.name.function.js - storage.type.accessor + + set abc(value1, value2) { return value1 + value2; } +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function +// ^^^ storage.type.accessor - entity.name.function.js +// ^^^ entity.name.function.js +// ^^^^^^ variable.parameter.function.js +// ^ punctuation.separator.parameter.function.js +// ^^^^^^ variable.parameter.function.js + + static$ +// ^^^^^^^ - storage + () {}; + + constructor$() {} +// ^^^^^^^^^^^^ entity.name.function - entity.name.function.constructor + + @foo bar() {} +// ^^^^ meta.annotation +// ^ punctuation.definition.annotation +// ^^^ variable.annotation +// ^^^ entity.name.function + + @foo.bar bar() {} +// ^^^^^^^^ meta.annotation +// ^ punctuation.definition.annotation +// ^^^ variable.other.readwrite - variable.annotation +// ^^^ variable.annotation +// ^^^ entity.name.function + + @(whatever) bar() {} +// ^^^^^^^^^^^ meta.annotation +// ^ punctuation.definition.annotation +// ^^^^^^^^^^ meta.group +// ^^^ entity.name.function + + ['foo']() {} +// ^^^^^^^^^^^^ meta.function + + static ['foo']() {} +// ^^^^^^^^^^^^ meta.function + + async foo() {} +// ^^^^^ keyword.declaration.async + + *foo() {} +// ^ keyword.generator.asterisk + + async *foo() {} +// ^^^^^ keyword.declaration.async +// ^ keyword.generator.asterisk + + static async foo() {} +// ^^^^^ keyword.declaration.async +} +// <- meta.block punctuation.section.block.end + +class Foo extends React.Component { +// ^^^^^ - entity.other.inherited-class +// ^^^^^^^^^ entity.other.inherited-class + constructor() + {} + + [foo.bar](arg) { +// ^^^ variable.other +// ^^^ meta.property +// ^^^ variable.parameter + return this.a; + } +} + +class Foo extends (Foo).Bar {} +// ^^^ entity.other.inherited-class + +class Foo extends Bar +// ^^^ entity.other.inherited-class + .baz {} +// ^^^^^^^ meta.class +// ^ punctuation.accessor +// ^^^ entity.other.inherited-class + +class Foo extends +// ^^^^^^^ storage.modifier.extends +Bar {} + +class Foo extends getSomeClass() {} +// ^^^^^^^^^^^^ meta.function-call variable.function - entity.other.inherited-class + + (class extends Bar {}); +// ^^^^^^^ storage.modifier.extends - entity.name.class + + (class extends class {} {}); +// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class +// ^^^^^^^ storage.modifier.extends +// ^^^^^^^^ meta.class meta.class +// ^^^^^ storage.type.class + +// Better highlighting while typing. +class +class +// <- storage.type.class - entity.name.class + +class{}/**/ +// ^ - meta.class + + @foo class Foo {} +// ^^^^ meta.annotation +// ^ punctuation.definition.annotation +// ^^^ variable.annotation +// ^^^^^ storage.type.class + + @foo.bar class Foo {} +// ^^^^^^^^ meta.annotation +// ^ punctuation.definition.annotation +// ^^^ variable.other.readwrite - variable.annotation +// ^^^ variable.annotation +// ^^^^^ storage.type.class + + @(whatever) class Foo {} +// ^^^^^^^^^^^ meta.annotation +// ^ punctuation.definition.annotation +// ^^^^^^^^^^ meta.group +// ^^^^^ storage.type.class From a03e986eb2c19b34b6d8df97d99610e62147e69e Mon Sep 17 00:00:00 2001 From: Thomas Smith Date: Wed, 13 Jan 2021 14:50:47 -0500 Subject: [PATCH 013/152] [JavaScript] Move import/export tests to separate file. (#2623) --- JavaScript/tests/syntax_test_js.js | 230 ----------------- .../tests/syntax_test_js_import_export.js | 231 ++++++++++++++++++ 2 files changed, 231 insertions(+), 230 deletions(-) create mode 100644 JavaScript/tests/syntax_test_js_import_export.js diff --git a/JavaScript/tests/syntax_test_js.js b/JavaScript/tests/syntax_test_js.js index afb62de198..90e73894ba 100644 --- a/JavaScript/tests/syntax_test_js.js +++ b/JavaScript/tests/syntax_test_js.js @@ -1,235 +1,5 @@ // SYNTAX TEST "Packages/JavaScript/JavaScript.sublime-syntax" -import TheirClass from "./mypath"; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.js -// ^ keyword.control.import-export -// ^ keyword.control.import-export - -import {identifier, otherIdentifier} from "somewhere"; -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import -// ^ keyword.control.import-export -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block -// ^ punctuation.section.block.begin -// ^ punctuation.section.block.end -// ^ meta.import meta.block variable.other.readwrite - -import thing, {identifier as otherIdentifier}, * as otherName from "otherplace"; -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import -// ^ keyword.control.import-export -// ^ variable.other.readwrite -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block -// ^ variable.other.readwrite -// ^ keyword.control.import-export -// ^ variable.other.readwrite -// ^ constant.other.js -// ^ keyword.control.import-export - -import 'module'; -// ^^^^^^^^^^^^^ meta.import - -// Better highlighting while typing. -import -import; -// <- keyword.control.import-export - -import;/**/ -// ^ - meta.import - -export { name1, name2 as name3 }; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export -//^ keyword.control.import-export -// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block -// ^ punctuation.separator.comma -// ^^ keyword.control.import-export - -export let name1, name2; -//^^^^^^^^^^^^^^^^^^^^^^ meta.export -//^ keyword.control.import-export -// ^^^ storage.type -// ^ punctuation.separator.comma - -export var name3; -//^^^^^^^^^^^^^^^ meta.export -//^ keyword.control.import-export -// ^^^ storage.type - -export const name1 = 5; -//^^^^^^^^^^^^^^^^^^^^^ meta.export -//^ keyword.control.import-export -// ^^^^^ storage.type -// ^ keyword.operator.assignment - -export let foo = 123 // No semicolon -export function bar() {} -// <- keyword.control.import-export - -export function foo() {}; -//^^^^^^^^^^^^^^^^^^^^^^ meta.export -//^^^^ keyword.control.import-export -// ^^^^^^^^^^^^^^^^^ meta.function -// ^ punctuation.terminator.statement.empty - -export function* foo() {}; -//^^^^^^^^^^^^^^^^^^^^^^^ meta.export -//^^^^ keyword.control.import-export -// ^^^^^^^^^^^^^^^^^^ meta.function -// ^ punctuation.terminator.statement.empty - -export async function foo() {}; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export -//^^^^ keyword.control.import-export -// ^^^^^^^^^^^^^^^^^^^^^^^ meta.function -// ^ punctuation.terminator.statement.empty - -export class Foo {}; -//^^^^^^^^^^^^^^^^^ meta.export -//^^^^ keyword.control.import-export -// ^^^^^^^^^^^^ meta.class -// ^ punctuation.terminator.statement.empty - -export default expression; -//^^^^^^^^^^^^^^^^^^^^^^^^ meta.export -//^ keyword.control.import-export -// ^ keyword.control.import-export - -export default function (a) { }; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export -//^^^^ keyword.control.import-export -// ^^^^^^^ keyword.control.import-export -// ^^^^^^^^^^^^^^^^ meta.function -// ^ punctuation.terminator.statement.empty - meta.export - -export default function* (a) { }; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export -//^^^^ keyword.control.import-export -// ^^^^^^^ keyword.control.import-export -// ^^^^^^^^^^^^^^^^^ meta.function -// ^ punctuation.terminator.statement.empty - meta.export - -export default function name1(b) { } -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export -//^ keyword.control.import-export -// ^ keyword.control.import-export -// ^^^^^^^^ keyword.declaration.function -// ^ entity.name.function - -export default class Foo {}; -//^^^^^^^^^^^^^^^^^ meta.export -//^^^^ keyword.control.import-export -// ^^^^^^^ keyword.control.import-export -// ^^^^^^^^^^^^ meta.class -// ^ punctuation.terminator.statement.empty - -export default +function (a) { }; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export -//^^^^ keyword.control.import-export -// ^^^^^^^ keyword.control.import-export -// ^^^^^^^^^^^^^^^^ meta.function - -export { name1 as default }; -//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export -//^ keyword.control.import-export -// ^^^^^^^^^^^^^^^^^^^^ meta.block -// ^ keyword.control.import-export -// ^ keyword.control.import-export - -export * from "./othermod"; -//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export -//^ keyword.control.import-export -// ^ constant.other -// ^ keyword.control.import-export - -export { name1, name2 } from "./othermod"; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export -//^ keyword.control.import-export -// ^^^^^^^^^^^^^^^^ meta.block -// ^ punctuation.section.block.begin -// ^ punctuation.section.block.end -// ^ keyword.control.import-export - -export { import1 as name1, import2 as name2, nameN } from "./othermod"; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export -//^ keyword.control.import-export -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block -// ^ keyword.control.import-export -// ^ keyword.control.import-export -// ^ keyword.control.import-export - -// Better highlighting while typing. -export -export; -// <- keyword.control.import-export - -export;/**/ -// ^ - meta.export - -import * as - alias from "module"; -// ^^^^^^^^^^^^^^^^^^^^^ meta.import.js - -import { member as - alias } from "module"; -// ^^^^^^^^^^^^^^^^^^^^^^^ meta.import.js - -import { * as - alias } from "module"; -// ^^^^^^^^^^^^^^^^^^^^^^^ meta.import.js - -export { member as - alias } from "module"; -// ^^^^^^^^^^^^^^^^^^^^^^^ meta.export.js - -export { member as - default } from "module"; -// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export.js - -let from; -// ^^^^ variable.other.readwrite.js - -import from from "./othermod"; -// ^^^^ variable.other.readwrite.js - -import { from } from "./othermod"; -// ^^^^ variable.other.readwrite.js - -export from from "./othermod"; -// ^^^^ variable.other.readwrite.js - -export { from } from "./othermod"; -// ^^^^ variable.other.readwrite.js - -export default$ -// ^^^^^^^^ - keyword -; - -let x = import.meta; -// ^^^^^^^^^^^ - meta.import -// ^^^^^^ keyword.import -// ^ punctuation.accessor -// ^^^^ variable.language.import - - import.meta; -// ^^^^^^^^^^^ - meta.import -// ^^^^^^ keyword.import -// ^ punctuation.accessor -// ^^^^ variable.language.import - - import -// ^^^^^^ - meta.import - .meta; -// ^^^^^ - meta.import -// ^ punctuation.accessor -// ^^^^ variable.language.import - - import('foo'); -// ^^^^^^ keyword.import -// ^^^^^^^ meta.group - - import -// ^^^^^^ - meta.import - ('foo'); -// ^^^^^^^ meta.group - // This object literal is technically broken since foo() does not have a // method body, but we include it here to ensure that highlighting is not // broken as the user is typing diff --git a/JavaScript/tests/syntax_test_js_import_export.js b/JavaScript/tests/syntax_test_js_import_export.js new file mode 100644 index 0000000000..5bc7faf3b4 --- /dev/null +++ b/JavaScript/tests/syntax_test_js_import_export.js @@ -0,0 +1,231 @@ +// SYNTAX TEST "Packages/JavaScript/JavaScript.sublime-syntax" + +import TheirClass from "./mypath"; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.js +// ^ keyword.control.import-export +// ^ keyword.control.import-export + +import {identifier, otherIdentifier} from "somewhere"; +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import +// ^ keyword.control.import-export +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block +// ^ punctuation.section.block.begin +// ^ punctuation.section.block.end +// ^ meta.import meta.block variable.other.readwrite + +import thing, {identifier as otherIdentifier}, * as otherName from "otherplace"; +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import +// ^ keyword.control.import-export +// ^ variable.other.readwrite +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block +// ^ variable.other.readwrite +// ^ keyword.control.import-export +// ^ variable.other.readwrite +// ^ constant.other.js +// ^ keyword.control.import-export + +import 'module'; +// ^^^^^^^^^^^^^ meta.import + +// Better highlighting while typing. +import +import; +// <- keyword.control.import-export + +import;/**/ +// ^ - meta.import + +export { name1, name2 as name3 }; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export +//^ keyword.control.import-export +// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block +// ^ punctuation.separator.comma +// ^^ keyword.control.import-export + +export let name1, name2; +//^^^^^^^^^^^^^^^^^^^^^^ meta.export +//^ keyword.control.import-export +// ^^^ storage.type +// ^ punctuation.separator.comma + +export var name3; +//^^^^^^^^^^^^^^^ meta.export +//^ keyword.control.import-export +// ^^^ storage.type + +export const name1 = 5; +//^^^^^^^^^^^^^^^^^^^^^ meta.export +//^ keyword.control.import-export +// ^^^^^ storage.type +// ^ keyword.operator.assignment + +export let foo = 123 // No semicolon +export function bar() {} +// <- keyword.control.import-export + +export function foo() {}; +//^^^^^^^^^^^^^^^^^^^^^^ meta.export +//^^^^ keyword.control.import-export +// ^^^^^^^^^^^^^^^^^ meta.function +// ^ punctuation.terminator.statement.empty + +export function* foo() {}; +//^^^^^^^^^^^^^^^^^^^^^^^ meta.export +//^^^^ keyword.control.import-export +// ^^^^^^^^^^^^^^^^^^ meta.function +// ^ punctuation.terminator.statement.empty + +export async function foo() {}; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export +//^^^^ keyword.control.import-export +// ^^^^^^^^^^^^^^^^^^^^^^^ meta.function +// ^ punctuation.terminator.statement.empty + +export class Foo {}; +//^^^^^^^^^^^^^^^^^ meta.export +//^^^^ keyword.control.import-export +// ^^^^^^^^^^^^ meta.class +// ^ punctuation.terminator.statement.empty + +export default expression; +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.export +//^ keyword.control.import-export +// ^ keyword.control.import-export + +export default function (a) { }; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export +//^^^^ keyword.control.import-export +// ^^^^^^^ keyword.control.import-export +// ^^^^^^^^^^^^^^^^ meta.function +// ^ punctuation.terminator.statement.empty - meta.export + +export default function* (a) { }; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export +//^^^^ keyword.control.import-export +// ^^^^^^^ keyword.control.import-export +// ^^^^^^^^^^^^^^^^^ meta.function +// ^ punctuation.terminator.statement.empty - meta.export + +export default function name1(b) { } +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export +//^ keyword.control.import-export +// ^ keyword.control.import-export +// ^^^^^^^^ keyword.declaration.function +// ^ entity.name.function + +export default class Foo {}; +//^^^^^^^^^^^^^^^^^ meta.export +//^^^^ keyword.control.import-export +// ^^^^^^^ keyword.control.import-export +// ^^^^^^^^^^^^ meta.class +// ^ punctuation.terminator.statement.empty + +export default +function (a) { }; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export +//^^^^ keyword.control.import-export +// ^^^^^^^ keyword.control.import-export +// ^^^^^^^^^^^^^^^^ meta.function + +export { name1 as default }; +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export +//^ keyword.control.import-export +// ^^^^^^^^^^^^^^^^^^^^ meta.block +// ^ keyword.control.import-export +// ^ keyword.control.import-export + +export * from "./othermod"; +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export +//^ keyword.control.import-export +// ^ constant.other +// ^ keyword.control.import-export + +export { name1, name2 } from "./othermod"; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export +//^ keyword.control.import-export +// ^^^^^^^^^^^^^^^^ meta.block +// ^ punctuation.section.block.begin +// ^ punctuation.section.block.end +// ^ keyword.control.import-export + +export { import1 as name1, import2 as name2, nameN } from "./othermod"; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export +//^ keyword.control.import-export +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block +// ^ keyword.control.import-export +// ^ keyword.control.import-export +// ^ keyword.control.import-export + +// Better highlighting while typing. +export +export; +// <- keyword.control.import-export + +export;/**/ +// ^ - meta.export + +import * as + alias from "module"; +// ^^^^^^^^^^^^^^^^^^^^^ meta.import.js + +import { member as + alias } from "module"; +// ^^^^^^^^^^^^^^^^^^^^^^^ meta.import.js + +import { * as + alias } from "module"; +// ^^^^^^^^^^^^^^^^^^^^^^^ meta.import.js + +export { member as + alias } from "module"; +// ^^^^^^^^^^^^^^^^^^^^^^^ meta.export.js + +export { member as + default } from "module"; +// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export.js + +let from; +// ^^^^ variable.other.readwrite.js + +import from from "./othermod"; +// ^^^^ variable.other.readwrite.js + +import { from } from "./othermod"; +// ^^^^ variable.other.readwrite.js + +export from from "./othermod"; +// ^^^^ variable.other.readwrite.js + +export { from } from "./othermod"; +// ^^^^ variable.other.readwrite.js + +export default$ +// ^^^^^^^^ - keyword +; + +let x = import.meta; +// ^^^^^^^^^^^ - meta.import +// ^^^^^^ keyword.import +// ^ punctuation.accessor +// ^^^^ variable.language.import + + import.meta; +// ^^^^^^^^^^^ - meta.import +// ^^^^^^ keyword.import +// ^ punctuation.accessor +// ^^^^ variable.language.import + + import +// ^^^^^^ - meta.import + .meta; +// ^^^^^ - meta.import +// ^ punctuation.accessor +// ^^^^ variable.language.import + + import('foo'); +// ^^^^^^ keyword.import +// ^^^^^^^ meta.group + + import +// ^^^^^^ - meta.import + ('foo'); +// ^^^^^^^ meta.group From bc8f6bf9d7fc7d10f3baf41b68dec47f97181d2f Mon Sep 17 00:00:00 2001 From: Thomas Smith Date: Wed, 13 Jan 2021 14:53:53 -0500 Subject: [PATCH 014/152] [JavaScript] Move control statement tests to separate file. (#2624) --- JavaScript/tests/syntax_test_js.js | 291 -------------------- JavaScript/tests/syntax_test_js_control.js | 293 +++++++++++++++++++++ 2 files changed, 293 insertions(+), 291 deletions(-) create mode 100644 JavaScript/tests/syntax_test_js_control.js diff --git a/JavaScript/tests/syntax_test_js.js b/JavaScript/tests/syntax_test_js.js index 90e73894ba..761e1c4d68 100644 --- a/JavaScript/tests/syntax_test_js.js +++ b/JavaScript/tests/syntax_test_js.js @@ -50,12 +50,6 @@ function() {} function foo(){}/**/ // ^ - meta.function -if (true) -// <- keyword.control.conditional.if -{ - bar() -} - // This is a comment function() { } // <- punctuation.definition.comment // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-slash @@ -443,289 +437,6 @@ var qux = 100; // ^ variable.other.readwrite // ^ constant.numeric -{}/**/ -//^ - meta.block - -if (Infinity > qux) { -// <- meta.conditional.js keyword.control.conditional.if -// ^^^^^^^^^^^^^^^ meta.conditional -// ^^^^^^^^ constant.language.infinity - a; -// ^ meta.conditional meta.block -} -// <- meta.conditional meta.block - -if (foo bar) - baz = "test" - -if(false){}/**/ -// ^ - meta.conditional - -do { -// <- meta.do-while keyword.control.loop.do-while -// ^ meta.block - qux += 1 -// ^^^^^^^^ meta.do-while meta.block -} while(qux < 20); -// <- meta.block -// ^^^^^^^^^^^^^^ meta.do-while - meta.block -// ^^^^ keyword.control.loop.while -// ^^^^^^^^ meta.group - -do // Incomplete statement - 42; -// ^^ constant.numeric - meta.do-while - -do {} while (false)/**/ -// <- meta.do-while keyword.control.loop.do-while -//^^^^^^^^^^^^^^^^^ meta.do-while.js -// ^^ - meta.do-while -// ^^^^^ keyword.control.loop.while.js - -for (var i = 0; i < 10; i++) { -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.for -// ^^^^^^^^^^^^^^^^^^^^^^ meta.group -// ^^^ storage.type.js -// ^ meta.block - i += 1; -// ^^^^^^^ meta.for meta.block -} -// <- meta.block - - for (; x in list;) {} -// ^^^^^^^^^^^^^^^^^^^^^ meta.for -// ^^^ keyword.control.loop.for -// ^^^^^^^^^^^^^^ meta.group -// ^ punctuation.separator.expression -// ^^ keyword.operator -// ^ punctuation.separator.expression - - for (a[x in list];;) {} -// ^^^^^^^^^^^^^^^^^^^^^^^ meta.for -// ^^^ keyword.control.loop.for -// ^^^^^^^^^^^^^^^^ meta.group -// ^^^^^^^^^^^ meta.brackets -// ^^ keyword.operator -// ^ punctuation.separator.expression -// ^ punctuation.separator.expression - - for (;function () {}/a/g;) {} -// ^ keyword.operator - - for (const x in list) {} -// ^^^^^^^^^^^^^^^^^^^^^^^^ meta.for -// ^^^ keyword.control.loop.for -// ^^^^^^^^^^^^^^^^^ meta.group -// ^^^^^ storage.type -// ^^ keyword.operator.word - - for (const x of list) {} -// ^^^^^^^^^^^^^^^^^^^^^^^^ meta.for -// ^^^ keyword.control.loop.for -// ^^^^^^^^^^^^^^^^^ meta.group -// ^^^^^ storage.type -// ^^ keyword.operator.word - - for (x in list) {} -// ^^^^^^^^^^^^^^^^^^ meta.for -// ^^^ keyword.control.loop.for -// ^^^^^^^^^^^ meta.group -// ^^ keyword.operator.word - - for (x of list) {} -// ^^^^^^^^^^^^^^^^^^ meta.for -// ^^^ keyword.control.loop.for -// ^^^^^^^^^^^ meta.group -// ^^ keyword.operator.word - - for await (const x of list) {} -// ^^^ keyword.control.loop.for -// ^^^^^ keyword.control.flow.await - -for - 42; -// ^^ constant.numeric - meta.for - -for(;;){}/**/ -// ^ - meta.for - -while (true) -// ^^^^^^^^^ meta.while -// ^^^^ meta.group -{ -// <- meta.block - x = yield; -// ^^^^^ keyword.control.flow.yield - - x = yield * 42; -// ^^^^^ keyword.control.flow.yield -// ^ keyword.generator.asterisk - - x = yield - function f() {} - []; -// ^^ meta.sequence - meta.brackets - - - x = yield* - function f() {} - []; -// ^^ meta.brackets - meta.sequence - - y = await 42; -// ^^^^^ keyword.control.flow.await - - y = yield await 42; -// ^^^^^ keyword.control.flow.yield -// ^^^^^ keyword.control.flow.await - - yield (parenthesized_expression); -// ^^^^^ keyword.control.flow.yield - - yield `template`; -// ^^^^^ keyword.control.flow.yield - - break; -// ^^^^^ keyword.control.flow.break - - break foo; -// ^^^^^ keyword.control.flow.break -// ^^^ variable.label - - break - foo; -// ^^^ variable.other.readwrite - variable.label - - break/**/foo; -// ^^^ variable.label - variable.other.readwrite - - break/* - */foo; -// ^^^ variable.other.readwrite - variable.label - - break function; -// ^^^^^^^^ invalid.illegal.identifier variable.label - - continue; -// ^^^^^^^^ keyword.control.flow.continue - - continue foo; -// ^^^^^^^^ keyword.control.flow.continue -// ^^^ variable.label - - continue - foo; -// ^^^ variable.other.readwrite - variable.label - - continue/**/foo; -// ^^^ variable.label - variable.other.readwrite - - continue/* - */ foo; -// ^^^ variable.other.readwrite - variable.label - - goto; -// ^^^^ variable.other.readwrite - keyword -} -// <- meta.block - -while // Incomplete statement - 42; -// ^^ constant.numeric - meta.while - -while(false){}/**/ -// ^ - meta.while - -with (undefined) { -// <- keyword.control.import.with -//^^^^^^^^^^ meta.with -// ^^^^^^^^^ constant.language.undefined - return; -// ^^^^^^ meta.with.js meta.block.js keyword.control.flow.return -} - -with // Incomplete statement - 42; -// ^^ constant.numeric - meta.while - -with(false){}/**/ -// ^ - meta.with - -switch ($foo) { -// <- meta.switch.js keyword.control.conditional.switch -// ^^^^^^^^^^^^ meta.switch -//^^^^ keyword.control.conditional.switch -// ^^^^ meta.group -// ^ meta.block punctuation.section.block.begin - case foo: - // ^ meta.switch meta.block keyword.control.conditional.case - // ^ - punctuation.separator.key-value - qux = 1; - break; - // ^ keyword.control.flow.break - case "baz": - // ^ keyword.control.conditional.case - // ^ - punctuation.separator.key-value string - qux = 2; - break; - // ^ keyword.control.flow.break - default: - // ^ meta.switch meta.block keyword.control.conditional.default - // ^ - punctuation.separator.key-value - qux = 3; - - case$ -// ^^^^^ - keyword - ; - - default$ -// ^^^^^^^^ - keyword - ; - - case 0: {} - case 1: -// ^^^^ keyword.control.conditional.case -} -// <- meta.block punctuation.section.block.end - -try { -// <- meta.try keyword.control.exception.try -// ^^ meta.try -// ^ meta.block - foobar = qux.bar(); -// ^^^^^^^^^^^^^^^^^^^ meta.try meta.block -} catch (e) { -// <- meta.block -//^^^^^^^^^^^^ meta.catch -//^^^^^ keyword.control.exception.catch -// ^ meta.group -// ^ meta.block - foobar = 0 -// ^^^^^^^^^^ meta.catch meta.block -} finally { -// <- meta.block -//^^^^^^^^^^ meta.finally -//^^^^^^^ keyword.control.exception.finally -// ^ meta.block - foobar += 1 -// ^^^^^^^^^^^ meta.finally meta.block -} -// <- meta.block - -switch // Incomplete statement - 42; -// ^^ constant.numeric - meta.switch - -switch(x){}/**/ -// ^^ - meta.switch - -try{}/**/ -// ^ - meta.try -catch{}/**/ -// ^ - meta.catch -finally{}/**/ -// ^ - meta.finally - () => {}; // ^^^^^^^^ meta.function - meta.function meta.function // ^^ meta.function.parameters @@ -1332,8 +1043,6 @@ return/* //^^^^^^ meta.block - meta.mapping const abc = new Set -if (true) {}; -// <- keyword.control.conditional const x = const y = 1; // Better highlighting while typing. diff --git a/JavaScript/tests/syntax_test_js_control.js b/JavaScript/tests/syntax_test_js_control.js new file mode 100644 index 0000000000..6627966354 --- /dev/null +++ b/JavaScript/tests/syntax_test_js_control.js @@ -0,0 +1,293 @@ +// SYNTAX TEST "Packages/JavaScript/JavaScript.sublime-syntax" + +if (true) +// <- keyword.control.conditional.if +{ + bar() +} + +if (Infinity > qux) { +// <- meta.conditional.js keyword.control.conditional.if +// ^^^^^^^^^^^^^^^ meta.conditional +// ^^^^^^^^ constant.language.infinity + a; +// ^ meta.conditional meta.block +} +// <- meta.conditional meta.block + +if (foo bar) + baz = "test" + +if(false){}/**/ +// ^ - meta.conditional + +do { +// <- meta.do-while keyword.control.loop.do-while +// ^ meta.block + qux += 1 +// ^^^^^^^^ meta.do-while meta.block +} while(qux < 20); +// <- meta.block +// ^^^^^^^^^^^^^^ meta.do-while - meta.block +// ^^^^ keyword.control.loop.while +// ^^^^^^^^ meta.group + +do // Incomplete statement + 42; +// ^^ constant.numeric - meta.do-while + +do {} while (false)/**/ +// <- meta.do-while keyword.control.loop.do-while +//^^^^^^^^^^^^^^^^^ meta.do-while.js +// ^^ - meta.do-while +// ^^^^^ keyword.control.loop.while.js + +for (var i = 0; i < 10; i++) { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.for +// ^^^^^^^^^^^^^^^^^^^^^^ meta.group +// ^^^ storage.type.js +// ^ meta.block + i += 1; +// ^^^^^^^ meta.for meta.block +} +// <- meta.block + + for (; x in list;) {} +// ^^^^^^^^^^^^^^^^^^^^^ meta.for +// ^^^ keyword.control.loop.for +// ^^^^^^^^^^^^^^ meta.group +// ^ punctuation.separator.expression +// ^^ keyword.operator +// ^ punctuation.separator.expression + + for (a[x in list];;) {} +// ^^^^^^^^^^^^^^^^^^^^^^^ meta.for +// ^^^ keyword.control.loop.for +// ^^^^^^^^^^^^^^^^ meta.group +// ^^^^^^^^^^^ meta.brackets +// ^^ keyword.operator +// ^ punctuation.separator.expression +// ^ punctuation.separator.expression + + for (;function () {}/a/g;) {} +// ^ keyword.operator + + for (const x in list) {} +// ^^^^^^^^^^^^^^^^^^^^^^^^ meta.for +// ^^^ keyword.control.loop.for +// ^^^^^^^^^^^^^^^^^ meta.group +// ^^^^^ storage.type +// ^^ keyword.operator.word + + for (const x of list) {} +// ^^^^^^^^^^^^^^^^^^^^^^^^ meta.for +// ^^^ keyword.control.loop.for +// ^^^^^^^^^^^^^^^^^ meta.group +// ^^^^^ storage.type +// ^^ keyword.operator.word + + for (x in list) {} +// ^^^^^^^^^^^^^^^^^^ meta.for +// ^^^ keyword.control.loop.for +// ^^^^^^^^^^^ meta.group +// ^^ keyword.operator.word + + for (x of list) {} +// ^^^^^^^^^^^^^^^^^^ meta.for +// ^^^ keyword.control.loop.for +// ^^^^^^^^^^^ meta.group +// ^^ keyword.operator.word + + for await (const x of list) {} +// ^^^ keyword.control.loop.for +// ^^^^^ keyword.control.flow.await + +for + 42; +// ^^ constant.numeric - meta.for + +for(;;){}/**/ +// ^ - meta.for + +{}/**/ +//^ - meta.block + +while (true) +// ^^^^^^^^^ meta.while +// ^^^^ meta.group +{ +// <- meta.block + x = yield; +// ^^^^^ keyword.control.flow.yield + + x = yield * 42; +// ^^^^^ keyword.control.flow.yield +// ^ keyword.generator.asterisk + + x = yield + function f() {} + []; +// ^^ meta.sequence - meta.brackets + + + x = yield* + function f() {} + []; +// ^^ meta.brackets - meta.sequence + + y = await 42; +// ^^^^^ keyword.control.flow.await + + y = yield await 42; +// ^^^^^ keyword.control.flow.yield +// ^^^^^ keyword.control.flow.await + + yield (parenthesized_expression); +// ^^^^^ keyword.control.flow.yield + + yield `template`; +// ^^^^^ keyword.control.flow.yield + + break; +// ^^^^^ keyword.control.flow.break + + break foo; +// ^^^^^ keyword.control.flow.break +// ^^^ variable.label + + break + foo; +// ^^^ variable.other.readwrite - variable.label + + break/**/foo; +// ^^^ variable.label - variable.other.readwrite + + break/* + */foo; +// ^^^ variable.other.readwrite - variable.label + + break function; +// ^^^^^^^^ invalid.illegal.identifier variable.label + + continue; +// ^^^^^^^^ keyword.control.flow.continue + + continue foo; +// ^^^^^^^^ keyword.control.flow.continue +// ^^^ variable.label + + continue + foo; +// ^^^ variable.other.readwrite - variable.label + + continue/**/foo; +// ^^^ variable.label - variable.other.readwrite + + continue/* + */ foo; +// ^^^ variable.other.readwrite - variable.label + + goto; +// ^^^^ variable.other.readwrite - keyword +} +// <- meta.block + +while // Incomplete statement + 42; +// ^^ constant.numeric - meta.while + +while(false){}/**/ +// ^ - meta.while + +with (undefined) { +// <- keyword.control.import.with +//^^^^^^^^^^ meta.with +// ^^^^^^^^^ constant.language.undefined + return; +// ^^^^^^ meta.with.js meta.block.js keyword.control.flow.return +} + +with // Incomplete statement + 42; +// ^^ constant.numeric - meta.while + +with(false){}/**/ +// ^ - meta.with + +switch ($foo) { +// <- meta.switch.js keyword.control.conditional.switch +// ^^^^^^^^^^^^ meta.switch +//^^^^ keyword.control.conditional.switch +// ^^^^ meta.group +// ^ meta.block punctuation.section.block.begin + case foo: + // ^ meta.switch meta.block keyword.control.conditional.case + // ^ - punctuation.separator.key-value + qux = 1; + break; + // ^ keyword.control.flow.break + case "baz": + // ^ keyword.control.conditional.case + // ^ - punctuation.separator.key-value string + qux = 2; + break; + // ^ keyword.control.flow.break + default: + // ^ meta.switch meta.block keyword.control.conditional.default + // ^ - punctuation.separator.key-value + qux = 3; + + case$ +// ^^^^^ - keyword + ; + + default$ +// ^^^^^^^^ - keyword + ; + + case 0: {} + case 1: +// ^^^^ keyword.control.conditional.case +} +// <- meta.block punctuation.section.block.end + +try { +// <- meta.try keyword.control.exception.try +// ^^ meta.try +// ^ meta.block + foobar = qux.bar(); +// ^^^^^^^^^^^^^^^^^^^ meta.try meta.block +} catch (e) { +// <- meta.block +//^^^^^^^^^^^^ meta.catch +//^^^^^ keyword.control.exception.catch +// ^ meta.group +// ^ meta.block + foobar = 0 +// ^^^^^^^^^^ meta.catch meta.block +} finally { +// <- meta.block +//^^^^^^^^^^ meta.finally +//^^^^^^^ keyword.control.exception.finally +// ^ meta.block + foobar += 1 +// ^^^^^^^^^^^ meta.finally meta.block +} +// <- meta.block + +switch // Incomplete statement + 42; +// ^^ constant.numeric - meta.switch + +switch(x){}/**/ +// ^^ - meta.switch + +try{}/**/ +// ^ - meta.try +catch{}/**/ +// ^ - meta.catch +finally{}/**/ +// ^ - meta.finally + +if (true) {}; +// <- keyword.control.conditional From 431638672cafb9606fdb7bf63fa7d426f40bcc03 Mon Sep 17 00:00:00 2001 From: Thomas Smith Date: Wed, 13 Jan 2021 15:01:08 -0500 Subject: [PATCH 015/152] [TypeScript] Improve function type parameter parsing (#2626) * Use variable.parameter for parameter names in function types. * Implement function type spread arguments. --- JavaScript/TypeScript.sublime-syntax | 4 +++- JavaScript/tests/syntax_test_typescript.ts | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/JavaScript/TypeScript.sublime-syntax b/JavaScript/TypeScript.sublime-syntax index 3bee685cb2..137826f861 100644 --- a/JavaScript/TypeScript.sublime-syntax +++ b/JavaScript/TypeScript.sublime-syntax @@ -790,8 +790,10 @@ contexts: - ts-type-expression-begin - include: else-pop - include: comma-separator + - match: '\.\.\.' + scope: keyword.operator.spread.js - match: '{{identifier_name}}' - scope: variable.other.readwrite.js + scope: variable.parameter.js push: - ts-type-annotation - ts-type-annotation-optional diff --git a/JavaScript/tests/syntax_test_typescript.ts b/JavaScript/tests/syntax_test_typescript.ts index 2cf32ee755..c7ea81b2a2 100644 --- a/JavaScript/tests/syntax_test_typescript.ts +++ b/JavaScript/tests/syntax_test_typescript.ts @@ -725,7 +725,7 @@ let x: ( foo ? : any ) => bar; // ^^^^^^^^^^^^^^^^^^^^^^ meta.type // ^^^^^^^^^^^^^^^ meta.group // ^ punctuation.section.group.begin -// ^^^ variable.other.readwrite - support.class +// ^^^ variable.parameter - support.class // ^ storage.modifier.optional // ^ punctuation.separator.type // ^^^ support.type.any @@ -733,6 +733,14 @@ let x: ( foo ? : any ) => bar; // ^^ keyword.declaration.function // ^^^ support.class +let x: ( ... foo : any ) => any; +// ^^^^^^^^^^^^^^^^^^^^^^^^ meta.type +// ^^^^^^^^^^^^^^^^^ meta.group +// ^^^ keyword.operator.spread +// ^^^ variable.parameter +// ^ punctuation.separator.type +// ^^^ support.type.any + let x: () => T U // ^ variable.other.constant - meta.type From ba5d5f471a85df4e0d42cb80b485a580981c6cae Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 13 Jan 2021 21:01:55 +0100 Subject: [PATCH 016/152] [ShellScript] Remove line continuation from comments (#2627) Fixes an issue discussed at https://discord.com/channels/280102180189634562/280157121897562114/777870917673156628 --- ShellScript/Bash.sublime-syntax | 2 -- ShellScript/test/syntax_test_bash.sh | 13 +++++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 95f6e4ac37..ed4be2b64e 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -172,7 +172,6 @@ contexts: # comment). - match: \n pop: 1 - - include: line-continuations shebang: - match: ^\#! @@ -188,7 +187,6 @@ contexts: scope: constant.language.shebang.shell - match: \n pop: 1 - - include: line-continuations ###[ FUNCTION DEFINITIONS ]#################################################### diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 6cbf8b2063..befb514dac 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -14,14 +14,13 @@ # ^ punctuation.definition.comment.shell # This is a \ -#^^^^^^^^^^^ comment.line.number-sign.shell - punctuation -# ^^ comment.line.number-sign.shell punctuation.separator.continuation.line.shell +#^^^^^^^^^^^^^ comment.line.number-sign.shell - punctuation command. -#^^^^^^^^^^ - comment.line +#^^^^^^^^^^ - comment # This is a \ comment. -#^^^^^^^^^^ comment.line.number-sign.shell - punctuation +#^^^^^^^^^^ - comment ### \\ \. \a \b \f \n \r # <- comment.line.number-sign.shell punctuation.definition.comment.shell @@ -34,6 +33,12 @@ echo hello #a-comment echo hello#not-a-comment # ^^^^^^^^^^^^^^ meta.function-call.arguments - comment.line - variable.function +curl -s \ + # This is comment \ + --request POST +# ^^^^^^^^^ meta.function-call.identifier.shell variable.function.shell +# ^^^^^ meta.function-call.arguments.shell + foo | `# get quarks ` \ # <- variable.function # ^ keyword.operator.assignment.pipe.shell From 8a0c84c6ee63831eb8b0449df0516f2bf544d57f Mon Sep 17 00:00:00 2001 From: Thomas Smith Date: Wed, 13 Jan 2021 15:04:05 -0500 Subject: [PATCH 017/152] [TypeScript] Implement negative number literal types. (#2633) --- JavaScript/TypeScript.sublime-syntax | 3 +++ JavaScript/tests/syntax_test_typescript.ts | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/JavaScript/TypeScript.sublime-syntax b/JavaScript/TypeScript.sublime-syntax index 137826f861..1f6273ed7a 100644 --- a/JavaScript/TypeScript.sublime-syntax +++ b/JavaScript/TypeScript.sublime-syntax @@ -677,6 +677,9 @@ contexts: - include: literal-string - include: literal-number + - match: '-' + scope: keyword.operator.arithmetic.js + - include: else-pop ts-type-tuple: diff --git a/JavaScript/tests/syntax_test_typescript.ts b/JavaScript/tests/syntax_test_typescript.ts index c7ea81b2a2..51a47ac9c0 100644 --- a/JavaScript/tests/syntax_test_typescript.ts +++ b/JavaScript/tests/syntax_test_typescript.ts @@ -544,7 +544,21 @@ let x: 'a string'; // ^ meta.type meta.string string.quoted.single let x: 42; -// ^^ meta.number.integer.decimal.js constant.numeric.value.js +// ^^ meta.type meta.number.integer.decimal constant.numeric.value + +let x: -42; +// ^^^ meta.type +// ^ keyword.operator.arithmetic +// ^^ meta.number.integer.decimal constant.numeric.value + +let x: 1.5; +// ^^^ meta.type meta.number.float.decimal constant.numeric.value + +let x: 1e10; +// ^^^^ meta.type meta.number.float.decimal constant.numeric.value + +let x: 0xabc; +// ^^^^^ meta.type meta.number.integer.hexadecimal let x: typeof Foo; // ^^^^^^^^^^ meta.type From 33f63a882ef0ac156beb68e75a9c4c5860c8f062 Mon Sep 17 00:00:00 2001 From: Thomas Smith Date: Wed, 13 Jan 2021 15:08:29 -0500 Subject: [PATCH 018/152] [TypeScript] Use correct scope for accessors in types. (#2636) --- JavaScript/TypeScript.sublime-syntax | 2 +- JavaScript/tests/syntax_test_tsx.tsx | 2 +- JavaScript/tests/syntax_test_typescript.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/JavaScript/TypeScript.sublime-syntax b/JavaScript/TypeScript.sublime-syntax index 1f6273ed7a..9dc4329448 100644 --- a/JavaScript/TypeScript.sublime-syntax +++ b/JavaScript/TypeScript.sublime-syntax @@ -557,7 +557,7 @@ contexts: scope: keyword.operator.word.js push: [ts-type-expression-end-no-line-terminator, ts-type-expression-begin] - match: \. - scope: punctuation.separator.accessor.js + scope: punctuation.accessor.js push: - match: '{{identifier_name}}' scope: support.class.js diff --git a/JavaScript/tests/syntax_test_tsx.tsx b/JavaScript/tests/syntax_test_tsx.tsx index 9c614f1823..ff52970626 100644 --- a/JavaScript/tests/syntax_test_tsx.tsx +++ b/JavaScript/tests/syntax_test_tsx.tsx @@ -22,7 +22,7 @@ let x : T.U; // ^^^^^^ meta.type // ^ support.class -// ^ punctuation.separator.accessor +// ^ punctuation.accessor // ^ support.class // ^^^ meta.generic // ^ support.class diff --git a/JavaScript/tests/syntax_test_typescript.ts b/JavaScript/tests/syntax_test_typescript.ts index 51a47ac9c0..28bbc36757 100644 --- a/JavaScript/tests/syntax_test_typescript.ts +++ b/JavaScript/tests/syntax_test_typescript.ts @@ -572,7 +572,7 @@ let x: keyof Foo; let x: Foo.bar; // ^^^^^^^ meta.type // ^^^ support.class -// ^ punctuation.separator.accessor +// ^ punctuation.accessor // ^^^ support.class let x: { @@ -793,7 +793,7 @@ let x: import ( "foo" ) . Bar ; // ^ punctuation.section.group.begin // ^^^^^ meta.string string.quoted.double // ^ punctuation.section.group.end -// ^ punctuation.separator.accessor +// ^ punctuation.accessor // ^^^ support.class foo < bar > (); From 2a2f224b2fd0bcdc0d9cb830f6f4919c88f55e65 Mon Sep 17 00:00:00 2001 From: Thomas Smith Date: Wed, 13 Jan 2021 15:09:07 -0500 Subject: [PATCH 019/152] [TypeScript] Slightly improve function assignment detection. (#2637) --- JavaScript/TypeScript.sublime-syntax | 11 +++++++++++ JavaScript/tests/syntax_test_typescript.ts | 3 +++ 2 files changed, 14 insertions(+) diff --git a/JavaScript/TypeScript.sublime-syntax b/JavaScript/TypeScript.sublime-syntax index 9dc4329448..9d610ba0ca 100644 --- a/JavaScript/TypeScript.sublime-syntax +++ b/JavaScript/TypeScript.sublime-syntax @@ -24,6 +24,17 @@ variables: \( )) + arrow_func_lookahead: |- + (?x: + (?:async\s*)? + (?: + {{identifier}} + | \( ( [^()] | \( [^()]* \) )* \) + ) + \s* + (?:=>|:) + ) + contexts: detect-parenthesized-arrow: - meta_prepend: true diff --git a/JavaScript/tests/syntax_test_typescript.ts b/JavaScript/tests/syntax_test_typescript.ts index 28bbc36757..8b6d1845b2 100644 --- a/JavaScript/tests/syntax_test_typescript.ts +++ b/JavaScript/tests/syntax_test_typescript.ts @@ -831,3 +831,6 @@ if (a < b || c < d) {} // ^ keyword.operator.logical // ^^ keyword.operator.logical // ^ keyword.operator.logical + +const f = (): any => {}; +// ^ entity.name.function meta.binding.name variable.other.readwrite From 872d0e7232977026d726bcb7be8eb51ef2c1bd99 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 13 Jan 2021 21:09:33 +0100 Subject: [PATCH 020/152] [ShellScript] Fix variable parameter expansion (#2639) Addresses one issue of #2635 Bash knows about the special parameter `$#` (number of parameters) see: https://www.gnu.org/software/bash/manual/bash.html#Special-Parameters It may be written as parameter expansion `${#}`. Before this commit the first `#` is always scoped `keyword.operator` as it is meant to be used with `${#foo}`, which returns the length of `foo`'s content. This commit adds a special pattern to match `${#}` as expansion of a `variable.language`. --- ShellScript/Bash.sublime-syntax | 7 +++++++ ShellScript/test/syntax_test_bash.sh | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index ed4be2b64e..1b4f643e37 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -1611,6 +1611,13 @@ contexts: 2: keyword.operator.match.shell expansions-parameter: + - match: (\$)(\{)(#)(\}) + captures: + 0: meta.interpolation.parameter.shell + 1: punctuation.definition.variable.shell + 2: punctuation.section.interpolation.begin.shell + 3: variable.language.shell + 4: punctuation.section.interpolation.end.shell - match: (\$)(\{) captures: 1: punctuation.definition.variable.shell diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index befb514dac..66109b150a 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -2873,6 +2873,13 @@ ${foo:=bar} # ^ keyword.operator.substitution.shell # ^ punctuation.section.interpolation.end.shell + +: ${#} # is the same as $# +# ^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell : ${#*} # ^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell From 04513823a0b7397c0df81937ad41740cbc1a39a5 Mon Sep 17 00:00:00 2001 From: wbond Date: Wed, 13 Jan 2021 15:14:57 -0500 Subject: [PATCH 021/152] [TypeScript] Fix variable reference --- JavaScript/TypeScript.sublime-syntax | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JavaScript/TypeScript.sublime-syntax b/JavaScript/TypeScript.sublime-syntax index 9d610ba0ca..9063d6b969 100644 --- a/JavaScript/TypeScript.sublime-syntax +++ b/JavaScript/TypeScript.sublime-syntax @@ -28,7 +28,7 @@ variables: (?x: (?:async\s*)? (?: - {{identifier}} + {{identifier_name}} | \( ( [^()] | \( [^()]* \) )* \) ) \s* From c9c0defc15b4154689d17c0c20261c429da4c49c Mon Sep 17 00:00:00 2001 From: Thomas Smith Date: Wed, 13 Jan 2021 15:16:34 -0500 Subject: [PATCH 022/152] [TypeScript] Fix scoping of != operators. (#2640) --- JavaScript/TypeScript.sublime-syntax | 2 +- JavaScript/tests/syntax_test_typescript.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/JavaScript/TypeScript.sublime-syntax b/JavaScript/TypeScript.sublime-syntax index 9063d6b969..d0ac4e9265 100644 --- a/JavaScript/TypeScript.sublime-syntax +++ b/JavaScript/TypeScript.sublime-syntax @@ -512,7 +512,7 @@ contexts: - ts-type-expression-begin ts-type-assertion: - - match: '!(?!\.)' + - match: '!(?![.=])' scope: keyword.operator.type.js - match: as{{identifier_break}} diff --git a/JavaScript/tests/syntax_test_typescript.ts b/JavaScript/tests/syntax_test_typescript.ts index 8b6d1845b2..8de68c6f10 100644 --- a/JavaScript/tests/syntax_test_typescript.ts +++ b/JavaScript/tests/syntax_test_typescript.ts @@ -834,3 +834,6 @@ if (a < b || c < d) {} const f = (): any => {}; // ^ entity.name.function meta.binding.name variable.other.readwrite + + a != b; +// ^^ keyword.operator.comparison From 8ebb448c66fc44259e65dfd67b62ac870ea43c67 Mon Sep 17 00:00:00 2001 From: jwortmann Date: Thu, 14 Jan 2021 22:02:56 +0100 Subject: [PATCH 023/152] [Go] Fix decimal point scope in floats (#2641) * [Go] Fix decimal point scope in floats The scope for the decimal point in floating point numbers should include constant.numeric.value instead of only punctuation.separator.decimal. * [Go] Remove special scope for exponent in numbers --- Go/Go.sublime-syntax | 34 +++--- Go/syntax_test_go.go | 250 ++++++++++++++----------------------------- 2 files changed, 91 insertions(+), 193 deletions(-) diff --git a/Go/Go.sublime-syntax b/Go/Go.sublime-syntax index 57505d4735..4bfee0ca43 100644 --- a/Go/Go.sublime-syntax +++ b/Go/Go.sublime-syntax @@ -399,24 +399,20 @@ contexts: match-imaginary: # Decimal imaginary numbers - - match: '({{dec_digits}})(?:(\.)({{dec_digits}})?)?({{dec_exponent}})?(i)' + - match: '({{dec_digits}}(?:(\.){{dec_digits}}?)?{{dec_exponent}}?)(i)' scope: meta.number.imaginary.decimal.go captures: 1: constant.numeric.value.go 2: punctuation.separator.decimal.go - 3: constant.numeric.value.go - 4: constant.numeric.value.exponent.go - 5: constant.numeric.suffix.go + 3: constant.numeric.suffix.go # Hexadecimal imaginary numbers - - match: (0[xX])({{hex_digits}})?(?:(\.)({{hex_digits}})?)?({{hex_exponent}})?(i) + - match: (0[xX])({{hex_digits}}?(?:(\.){{hex_digits}}?)?{{hex_exponent}}?)(i) scope: meta.number.imaginary.hexadecimal.go captures: 1: constant.numeric.base.go 2: constant.numeric.value.go 3: punctuation.separator.decimal.go - 4: constant.numeric.value.go - 5: constant.numeric.value.exponent.go - 6: constant.numeric.suffix.go + 4: constant.numeric.suffix.go # Octal imaginary numbers - match: (0[oO])({{oct_digits}})(i) scope: meta.number.imaginary.octal.go @@ -436,28 +432,24 @@ contexts: # Decimal float literal - match: |- (?x: - ({{dec_digits}})(?:(\.)({{dec_digits}})?({{dec_exponent}})?|({{dec_exponent}})) - | (\.)({{dec_digits}})({{dec_exponent}})? + # 1.1, 1., 1.1e1, 1.e1 + {{dec_digits}}(\.){{dec_digits}}?{{dec_exponent}}? + # 1e1 + | {{dec_digits}}{{dec_exponent}} + # .1, .1e1 + | (\.){{dec_digits}}{{dec_exponent}}? ) - scope: meta.number.float.decimal.go + scope: meta.number.float.decimal.go constant.numeric.value.go captures: - 1: constant.numeric.value.go + 1: punctuation.separator.decimal.go 2: punctuation.separator.decimal.go - 3: constant.numeric.value.go - 4: constant.numeric.value.exponent.go - 5: constant.numeric.value.exponent.go - 6: punctuation.separator.decimal.go - 7: constant.numeric.value.go - 8: constant.numeric.value.exponent.go # Hexadecimal float literal - - match: (0[xX])({{hex_digits}})?(?:(\.)({{hex_digits}})?)?({{hex_exponent}}) + - match: (0[xX])({{hex_digits}}?(?:(\.){{hex_digits}}?)?{{hex_exponent}}) scope: meta.number.float.hexadecimal.go captures: 1: constant.numeric.base.go 2: constant.numeric.value.go 3: punctuation.separator.decimal.go - 4: constant.numeric.value.go - 5: constant.numeric.value.exponent.go match-integers: - include: match-octal-integer diff --git a/Go/syntax_test_go.go b/Go/syntax_test_go.go index 30766e6362..474909523d 100644 --- a/Go/syntax_test_go.go +++ b/Go/syntax_test_go.go @@ -1846,184 +1846,116 @@ Note: built-ins are tested separately. Search for "# Built-in Types". // ## Floats 000.000; 123.456; .0; 1.; -// ^^^^^^^ meta.number.float.decimal.go -// ^^^ constant.numeric.value.go +// ^^^^^^^ meta.number.float.decimal.go constant.numeric.value.go // ^ punctuation.separator.decimal.go -// ^^^ constant.numeric.value.go -// ^^^^^^^ meta.number.float.decimal.go -// ^^^ constant.numeric.value.go +// ^^^^^^^ meta.number.float.decimal.go constant.numeric.value.go // ^ punctuation.separator.decimal.go -// ^^^ constant.numeric.value.go -// ^^ meta.number.float.decimal.go +// ^^ meta.number.float.decimal.go constant.numeric.value.go // ^ punctuation.separator.decimal.go -// ^ constant.numeric.value.go -// ^^ meta.number.float.decimal.go -// ^ constant.numeric.value.go +// ^^ meta.number.float.decimal.go constant.numeric.value.go // ^ punctuation.separator.decimal.go 0_1.0_1; 1_23.4_6; -// ^^^^^^^ meta.number.float.decimal.go -// ^^^ constant.numeric.value.go +// ^^^^^^^ meta.number.float.decimal.go constant.numeric.value.go // ^ punctuation.separator.decimal.go -// ^^^ constant.numeric.value.go -// ^^^^^^^^ meta.number.float.decimal.go -// ^^^^ constant.numeric.value.go +// ^^^^^^^^ meta.number.float.decimal.go constant.numeric.value.go // ^ punctuation.separator.decimal.go -// ^^^ constant.numeric.value.go -000.000; -123.456; -.0; -1. -1.. ; // ^ keyword.operator.arithmetic.go -// ^^^^^^^ meta.number.float.decimal.go -// ^^^ constant.numeric.value.go +// ^^^^^^^ meta.number.float.decimal.go constant.numeric.value.go // ^ punctuation.separator.decimal.go -// ^^^ constant.numeric.value.go // ^ keyword.operator.arithmetic.go -// ^^^^^^^ meta.number.float.decimal.go -// ^^^ constant.numeric.value.go +// ^^^^^^^ meta.number.float.decimal.go constant.numeric.value.go // ^ punctuation.separator.decimal.go -// ^^^ constant.numeric.value.go // ^ keyword.operator.arithmetic.go -// ^^ meta.number.float.decimal.go +// ^^ meta.number.float.decimal.go constant.numeric.value.go // ^ punctuation.separator.decimal.go -// ^ constant.numeric.value.go // ^ keyword.operator.arithmetic.go -// ^^ meta.number.float.decimal.go -// ^ constant.numeric.value.go +// ^^ meta.number.float.decimal.go constant.numeric.value.go // ^ punctuation.separator.decimal.go // ^ keyword.operator.arithmetic.go -// ^^ meta.number.float.decimal.go -// ^ constant.numeric.value.go +// ^^ meta.number.float.decimal.go constant.numeric.value.go // ^ punctuation.separator.decimal.go // ^ punctuation.accessor.dot.go - meta.number 0e+0; 0E+0; 0.0e+0; 0.0E+0; 123.456e+789; -// ^^^^ meta.number.float.decimal.go -// ^ constant.numeric.value.go -// ^^^ constant.numeric.value.exponent.go -// ^^^^ meta.number.float.decimal.go -// ^ constant.numeric.value.go -// ^^^ constant.numeric.value.exponent.go -// ^^^^^^ meta.number.float.decimal.go -// ^ constant.numeric.value.go +// ^^^^ meta.number.float.decimal.go constant.numeric.value.go +// ^^^^ meta.number.float.decimal.go constant.numeric.value.go +// ^^^^^^ meta.number.float.decimal.go constant.numeric.value.go // ^ punctuation.separator.decimal.go -// ^ constant.numeric.value.go -// ^^^ constant.numeric.value.exponent.go -// ^^^^^^ meta.number.float.decimal.go -// ^ constant.numeric.value.go +// ^^^^^^ meta.number.float.decimal.go constant.numeric.value.go // ^ punctuation.separator.decimal.go -// ^ constant.numeric.value.go -// ^^^ constant.numeric.value.exponent.go -// ^^^^^^^^^^^^ meta.number.float.decimal.go -// ^^^ constant.numeric.value.go +// ^^^^^^^^^^^^ meta.number.float.decimal.go constant.numeric.value.go // ^ punctuation.separator.decimal.go -// ^^^ constant.numeric.value.go -// ^^^^^ constant.numeric.value.exponent.go 1_2e+0; 1E+0_1; 0.1_2e2; 1_23.4_56e+78_9; -// ^^^ meta.number.float.decimal.go constant.numeric.value.go -// ^^^ meta.number.float.decimal.go constant.numeric.value.exponent.go -// ^ meta.number.float.decimal.go constant.numeric.value.go -// ^^^^^ meta.number.float.decimal.go constant.numeric.value.exponent.go -// ^ meta.number.float.decimal.go constant.numeric.value.go -// ^ meta.number.float.decimal.go punctuation.separator.decimal.go -// ^^^ meta.number.float.decimal.go constant.numeric.value.go -// ^^ meta.number.float.decimal.go constant.numeric.value.exponent.go -// ^^^^ meta.number.float.decimal.go constant.numeric.value.go -// ^ meta.number.float.decimal.go punctuation.separator.decimal.go -// ^^^^ meta.number.float.decimal.go constant.numeric.value.go -// ^^^^^^ meta.number.float.decimal.go constant.numeric.value.exponent.go +// ^^^^^^ meta.number.float.decimal.go constant.numeric.value.go +// ^^^^^^ meta.number.float.decimal.go constant.numeric.value.go +// ^^^^^^^ meta.number.float.decimal.go constant.numeric.value.go +// ^ punctuation.separator.decimal.go +// ^^^^^^^^^^^^^^^ meta.number.float.decimal.go constant.numeric.value.go +// ^ punctuation.separator.decimal.go 0e-0; 0E-0; 0.0e-0; 0.0E-0; 123.456e-789; -// ^ meta.number.float.decimal.go constant.numeric.value.go -// ^^^ meta.number.float.decimal.go constant.numeric.value.exponent.go -// ^ meta.number.float.decimal.go constant.numeric.value.go -// ^^^ meta.number.float.decimal.go constant.numeric.value.exponent.go -// ^ meta.number.float.decimal.go constant.numeric.value.go -// ^ meta.number.float.decimal.go punctuation.separator.decimal.go -// ^ meta.number.float.decimal.go constant.numeric.value.go -// ^^^ meta.number.float.decimal.go constant.numeric.value.exponent.go -// ^ meta.number.float.decimal.go constant.numeric.value.go -// ^ meta.number.float.decimal.go punctuation.separator.decimal.go -// ^ meta.number.float.decimal.go constant.numeric.value.go -// ^^^ meta.number.float.decimal.go constant.numeric.value.exponent.go -// ^^^ meta.number.float.decimal.go constant.numeric.value.go -// ^ meta.number.float.decimal.go punctuation.separator.decimal.go -// ^^^ meta.number.float.decimal.go constant.numeric.value.go -// ^^^^^ meta.number.float.decimal.go constant.numeric.value.exponent.go +// ^^^^ meta.number.float.decimal.go constant.numeric.value.go +// ^^^^ meta.number.float.decimal.go constant.numeric.value.go +// ^^^^^^ meta.number.float.decimal.go constant.numeric.value.go +// ^ punctuation.separator.decimal.go +// ^^^^^^ meta.number.float.decimal.go constant.numeric.value.go +// ^ punctuation.separator.decimal.go +// ^^^^^^^^^^^^ meta.number.float.decimal.go constant.numeric.value.go +// ^ punctuation.separator.decimal.go 0.e+0; .0e+0; 0.e-0; .0e-0; -// ^^^^^ meta.number.float.decimal.go -// ^ constant.numeric.value.go +// ^^^^^ meta.number.float.decimal.go constant.numeric.value.go // ^ punctuation.separator.decimal.go -// ^^^ constant.numeric.value.exponent.go -// ^^^^^ meta.number.float.decimal.go +// ^^^^^ meta.number.float.decimal.go constant.numeric.value.go // ^ punctuation.separator.decimal.go -// ^ constant.numeric.value.go -// ^^^ constant.numeric.value.exponent.go -// ^^^^^ meta.number.float.decimal.go -// ^ constant.numeric.value.go +// ^^^^^ meta.number.float.decimal.go constant.numeric.value.go // ^ punctuation.separator.decimal.go -// ^^^ constant.numeric.value.exponent.go -// ^^^^^ meta.number.float.decimal.go +// ^^^^^ meta.number.float.decimal.go constant.numeric.value.go // ^ punctuation.separator.decimal.go -// ^ constant.numeric.value.go -// ^^^ constant.numeric.value.exponent.go 0x1p-2; 0X1P+2; 0x1p2; // ^^ meta.number.float.hexadecimal.go constant.numeric.base.go -// ^ meta.number.float.hexadecimal.go constant.numeric.value.go -// ^^^ meta.number.float.hexadecimal.go constant.numeric.value.exponent.go +// ^^^^ meta.number.float.hexadecimal.go constant.numeric.value.go // ^^ meta.number.float.hexadecimal.go constant.numeric.base.go -// ^ meta.number.float.hexadecimal.go constant.numeric.value.go -// ^^^ meta.number.float.hexadecimal.go constant.numeric.value.exponent.go +// ^^^^ meta.number.float.hexadecimal.go constant.numeric.value.go // ^^ meta.number.float.hexadecimal.go constant.numeric.base.go -// ^ meta.number.float.hexadecimal.go constant.numeric.value.go -// ^^ meta.number.float.hexadecimal.go constant.numeric.value.exponent.go +// ^^^ meta.number.float.hexadecimal.go constant.numeric.value.go 0x_1p-2; 0X1_1P+2; 0x_1p2_1; // ^^ meta.number.float.hexadecimal.go constant.numeric.base.go -// ^^ meta.number.float.hexadecimal.go constant.numeric.value.go -// ^^^ meta.number.float.hexadecimal.go constant.numeric.value.exponent.go +// ^^^^^ meta.number.float.hexadecimal.go constant.numeric.value.go // ^^ meta.number.float.hexadecimal.go constant.numeric.base.go -// ^^^ meta.number.float.hexadecimal.go constant.numeric.value.go -// ^^^ meta.number.float.hexadecimal.go constant.numeric.value.exponent.go +// ^^^^^^ meta.number.float.hexadecimal.go constant.numeric.value.go // ^^ meta.number.float.hexadecimal.go constant.numeric.base.go -// ^^ meta.number.float.hexadecimal.go constant.numeric.value.go -// ^^^^ meta.number.float.hexadecimal.go constant.numeric.value.exponent.go +// ^^^^^^ meta.number.float.hexadecimal.go constant.numeric.value.go 0x1.0P-1021; 0X1.0p-1021; // ^^ meta.number.float.hexadecimal.go constant.numeric.base.go -// ^ meta.number.float.hexadecimal.go constant.numeric.value.go -// ^ meta.number.float.hexadecimal.go punctuation.separator.decimal.go -// ^ meta.number.float.hexadecimal.go constant.numeric.value.go -// ^^^^^^ meta.number.float.hexadecimal.go constant.numeric.value.exponent.go +// ^^^^^^^^^ meta.number.float.hexadecimal.go constant.numeric.value.go +// ^ punctuation.separator.decimal.go // ^^ meta.number.float.hexadecimal.go constant.numeric.base.go -// ^ meta.number.float.hexadecimal.go constant.numeric.value.go -// ^ meta.number.float.hexadecimal.go punctuation.separator.decimal.go -// ^ meta.number.float.hexadecimal.go constant.numeric.value.go -// ^^^^^^ meta.number.float.hexadecimal.go constant.numeric.value.exponent.go +// ^^^^^^^^^ meta.number.float.hexadecimal.go constant.numeric.value.go +// ^ punctuation.separator.decimal.go 0x_1_1.0_7P-1_021; // ^^ meta.number.float.hexadecimal.go constant.numeric.base.go -// ^^^^ meta.number.float.hexadecimal.go constant.numeric.value.go -// ^ meta.number.float.hexadecimal.go punctuation.separator.decimal.go -// ^^^ meta.number.float.hexadecimal.go constant.numeric.value.go -// ^^^^^^^ meta.number.float.hexadecimal.go constant.numeric.value.exponent.go +// ^^^^^^^^^^^^^^^ meta.number.float.hexadecimal.go constant.numeric.value.go +// ^ punctuation.separator.decimal.go 0x2.p10; 0x1.Fp+0; 0X.8p-0; // ^^ meta.number.float.hexadecimal.go constant.numeric.base.go -// ^ meta.number.float.hexadecimal.go constant.numeric.value.go -// ^ meta.number.float.hexadecimal.go punctuation.separator.decimal.go -// ^^^ meta.number.float.hexadecimal.go constant.numeric.value.exponent.go +// ^^^^^ meta.number.float.hexadecimal.go constant.numeric.value.go +// ^ punctuation.separator.decimal.go // ^^ meta.number.float.hexadecimal.go constant.numeric.base.go -// ^ meta.number.float.hexadecimal.go constant.numeric.value.go -// ^ meta.number.float.hexadecimal.go punctuation.separator.decimal.go -// ^ meta.number.float.hexadecimal.go constant.numeric.value.go -// ^^^ meta.number.float.hexadecimal.go constant.numeric.value.exponent.go +// ^^^^^^ meta.number.float.hexadecimal.go constant.numeric.value.go +// ^ punctuation.separator.decimal.go // ^^ meta.number.float.hexadecimal.go constant.numeric.base.go -// ^ meta.number.float.hexadecimal.go punctuation.separator.decimal.go -// ^ meta.number.float.hexadecimal.go constant.numeric.value.go -// ^^^ meta.number.float.hexadecimal.go constant.numeric.value.exponent.go +// ^^^^^ meta.number.float.hexadecimal.go constant.numeric.value.go +// ^ punctuation.separator.decimal.go // ## Imaginary @@ -2044,72 +1976,54 @@ Note: built-ins are tested separately. Search for "# Built-in Types". 123.456i; -123.456i; 1_23.45_6i; // ^^^^^^^^ meta.number.imaginary.decimal.go -// ^^^ constant.numeric.value.go +// ^^^^^^^ constant.numeric.value.go // ^ punctuation.separator.decimal.go -// ^^^ constant.numeric.value.go // ^ constant.numeric.suffix.go // ^ keyword.operator.arithmetic.go // ^^^^^^^^ meta.number.imaginary.decimal.go -// ^^^ constant.numeric.value.go +// ^^^^^^^ constant.numeric.value.go // ^ punctuation.separator.decimal.go -// ^^^ constant.numeric.value.go // ^ constant.numeric.suffix.go // ^^^^^^^^^^ meta.number.imaginary.decimal.go -// ^^^^ constant.numeric.value.go +// ^^^^^^^^^ constant.numeric.value.go // ^ punctuation.separator.decimal.go -// ^^^^ constant.numeric.value.go // ^ constant.numeric.suffix.go 1e+2i; 1e-2i; 1.2e+3i; 1.2e-3i; 1E+2i; 1E-2i; 1.2E+3i; 1.2E-3i; -// ^ meta.number.imaginary.decimal.go constant.numeric.value.go -// ^^^ meta.number.imaginary.decimal.go constant.numeric.value.exponent.go +// ^^^^ meta.number.imaginary.decimal.go constant.numeric.value.go // ^ meta.number.imaginary.decimal.go constant.numeric.suffix.go // ^ punctuation.terminator.go -// ^ meta.number.imaginary.decimal.go constant.numeric.value.go -// ^^^ meta.number.imaginary.decimal.go constant.numeric.value.exponent.go +// ^^^^ meta.number.imaginary.decimal.go constant.numeric.value.go // ^ meta.number.imaginary.decimal.go constant.numeric.suffix.go // ^ punctuation.terminator.go -// ^ meta.number.imaginary.decimal.go constant.numeric.value.go -// ^ meta.number.imaginary.decimal.go punctuation.separator.decimal.go -// ^ meta.number.imaginary.decimal.go constant.numeric.value.go -// ^^^ meta.number.imaginary.decimal.go constant.numeric.value.exponent.go +// ^^^^^^ meta.number.imaginary.decimal.go constant.numeric.value.go +// ^ punctuation.separator.decimal.go // ^ meta.number.imaginary.decimal.go constant.numeric.suffix.go // ^ punctuation.terminator.go -// ^ meta.number.imaginary.decimal.go constant.numeric.value.go -// ^ meta.number.imaginary.decimal.go punctuation.separator.decimal.go -// ^ meta.number.imaginary.decimal.go constant.numeric.value.go -// ^^^ meta.number.imaginary.decimal.go constant.numeric.value.exponent.go +// ^^^^^^ meta.number.imaginary.decimal.go constant.numeric.value.go +// ^ punctuation.separator.decimal.go // ^ meta.number.imaginary.decimal.go constant.numeric.suffix.go // ^ punctuation.terminator.go -// ^ meta.number.imaginary.decimal.go constant.numeric.value.go -// ^^^ meta.number.imaginary.decimal.go constant.numeric.value.exponent.go +// ^^^^ meta.number.imaginary.decimal.go constant.numeric.value.go // ^ meta.number.imaginary.decimal.go constant.numeric.suffix.go // ^ punctuation.terminator.go -// ^ meta.number.imaginary.decimal.go constant.numeric.value.go -// ^^^ meta.number.imaginary.decimal.go constant.numeric.value.exponent.go +// ^^^^ meta.number.imaginary.decimal.go constant.numeric.value.go // ^ meta.number.imaginary.decimal.go constant.numeric.suffix.go // ^ punctuation.terminator.go -// ^ meta.number.imaginary.decimal.go constant.numeric.value.go -// ^ meta.number.imaginary.decimal.go punctuation.separator.decimal.go -// ^ meta.number.imaginary.decimal.go constant.numeric.value.go -// ^^^ meta.number.imaginary.decimal.go constant.numeric.value.exponent.go +// ^^^^^^ meta.number.imaginary.decimal.go constant.numeric.value.go +// ^ punctuation.separator.decimal.go // ^ meta.number.imaginary.decimal.go constant.numeric.suffix.go // ^ punctuation.terminator.go -// ^ meta.number.imaginary.decimal.go constant.numeric.value.go -// ^ meta.number.imaginary.decimal.go punctuation.separator.decimal.go -// ^ meta.number.imaginary.decimal.go constant.numeric.value.go -// ^^^ meta.number.imaginary.decimal.go constant.numeric.value.exponent.go +// ^^^^^^ meta.number.imaginary.decimal.go constant.numeric.value.go +// ^ punctuation.separator.decimal.go // ^ meta.number.imaginary.decimal.go constant.numeric.suffix.go // ^ punctuation.terminator.go 1_1e+2_1i; 1.2_1E-3_5i; -// ^^^ meta.number.imaginary.decimal.go constant.numeric.value.go -// ^^^^^ meta.number.imaginary.decimal.go constant.numeric.value.exponent.go +// ^^^^^^^^ meta.number.imaginary.decimal.go constant.numeric.value.go // ^ meta.number.imaginary.decimal.go constant.numeric.suffix.go -// ^ meta.number.imaginary.decimal.go constant.numeric.value.go -// ^ meta.number.imaginary.decimal.go punctuation.separator.decimal.go -// ^^^ meta.number.imaginary.decimal.go constant.numeric.value.go -// ^^^^^ meta.number.imaginary.decimal.go constant.numeric.value.exponent.go +// ^^^^^^^^^^ meta.number.imaginary.decimal.go constant.numeric.value.go +// ^ punctuation.separator.decimal.go // ^ meta.number.imaginary.decimal.go constant.numeric.suffix.go 0o6i; 0O35i; 0o_6i; 0O3_5i; @@ -2153,32 +2067,24 @@ Note: built-ins are tested separately. Search for "# Built-in Types". 0x1p-2i; 0x1.0P-1021i; 0x1.Fp+0i; // ^^ meta.number.imaginary.hexadecimal.go constant.numeric.base.go -// ^ meta.number.imaginary.hexadecimal.go constant.numeric.value.go -// ^^^ meta.number.imaginary.hexadecimal.go constant.numeric.value.exponent.go +// ^^^^ meta.number.imaginary.hexadecimal.go constant.numeric.value.go // ^ meta.number.imaginary.hexadecimal.go constant.numeric.suffix.go // ^^ meta.number.imaginary.hexadecimal.go constant.numeric.base.go -// ^ meta.number.imaginary.hexadecimal.go constant.numeric.value.go -// ^ meta.number.imaginary.hexadecimal.go punctuation.separator.decimal.go -// ^ meta.number.imaginary.hexadecimal.go constant.numeric.value.go -// ^^^^^^ meta.number.imaginary.hexadecimal.go constant.numeric.value.exponent.go +// ^^^^^^^^^ meta.number.imaginary.hexadecimal.go constant.numeric.value.go +// ^ punctuation.separator.decimal.go // ^ meta.number.imaginary.hexadecimal.go constant.numeric.suffix.go // ^^ meta.number.imaginary.hexadecimal.go constant.numeric.base.go -// ^ meta.number.imaginary.hexadecimal.go constant.numeric.value.go -// ^ meta.number.imaginary.hexadecimal.go punctuation.separator.decimal.go -// ^ meta.number.imaginary.hexadecimal.go constant.numeric.value.go -// ^^^ meta.number.imaginary.hexadecimal.go constant.numeric.value.exponent.go +// ^^^^^^ meta.number.imaginary.hexadecimal.go constant.numeric.value.go +// ^ punctuation.separator.decimal.go // ^ meta.number.imaginary.hexadecimal.go constant.numeric.suffix.go 0x_1p-2i; 0x1_4.0_5P-102_1i; // ^^ meta.number.imaginary.hexadecimal.go constant.numeric.base.go -// ^^ meta.number.imaginary.hexadecimal.go constant.numeric.value.go -// ^^^ meta.number.imaginary.hexadecimal.go constant.numeric.value.exponent.go +// ^^^^^ meta.number.imaginary.hexadecimal.go constant.numeric.value.go // ^ meta.number.imaginary.hexadecimal.go constant.numeric.suffix.go // ^^ meta.number.imaginary.hexadecimal.go constant.numeric.base.go -// ^^^ meta.number.imaginary.hexadecimal.go constant.numeric.value.go -// ^ meta.number.imaginary.hexadecimal.go punctuation.separator.decimal.go -// ^^^ meta.number.imaginary.hexadecimal.go constant.numeric.value.go -// ^^^^^^^ meta.number.imaginary.hexadecimal.go constant.numeric.value.exponent.go +// ^^^^^^^^^^^^^^ meta.number.imaginary.hexadecimal.go constant.numeric.value.go +// ^ punctuation.separator.decimal.go // ^ meta.number.imaginary.hexadecimal.go constant.numeric.suffix.go // ## Runes From e606df31fb21c0319f17833bef7a09de1f1115e2 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 14 Jan 2021 22:03:34 +0100 Subject: [PATCH 024/152] [D] Fix decimal point scope in floats (#2642) As described in #2630. --- D/D.sublime-syntax | 50 +++++++++++++-------------------- D/tests/syntax_test_d.d | 62 +++++++++++++++++------------------------ 2 files changed, 46 insertions(+), 66 deletions(-) diff --git a/D/D.sublime-syntax b/D/D.sublime-syntax index ddfd230f66..e845491927 100644 --- a/D/D.sublime-syntax +++ b/D/D.sublime-syntax @@ -194,7 +194,7 @@ contexts: - include: integer-opt - include: not-whitespace-illegal-pop integer-opt: - - match: '(0[bB])(_?)({{bin_digits}})({{integer_suffix}})?' + - match: (0[bB])(_?)({{bin_digits}})({{integer_suffix}})? scope: meta.number.integer.binary.d captures: 1: constant.numeric.base.d @@ -202,7 +202,7 @@ contexts: 3: constant.numeric.value.d 4: constant.numeric.suffix.d pop: true - - match: '(0[xX])(_?)({{hex_digits}})({{integer_suffix}})?' + - match: (0[xX])(_?)({{hex_digits}})({{integer_suffix}})? scope: meta.number.integer.hexadecimal.d captures: 1: constant.numeric.base.d @@ -210,7 +210,7 @@ contexts: 3: constant.numeric.value.d 4: constant.numeric.suffix.d pop: true - - match: '({{dec_integer}})({{integer_suffix}})?' + - match: ({{dec_integer}})({{integer_suffix}})? scope: meta.number.integer.decimal.d captures: 1: constant.numeric.value.d @@ -222,77 +222,67 @@ contexts: - include: not-whitespace-illegal-pop floating-point-opt: # decimal imaginary numbers - - match: '({{dec_integer}})?(?:(\.)({{dec_digits}})?)?({{dec_exponent}})?({{imaginary_suffix}})' + - match: ({{dec_integer}}?(?:(\.){{dec_digits}}?)?{{dec_exponent}}?)({{imaginary_suffix}}) scope: meta.number.imaginary.decimal.d captures: 1: constant.numeric.value.d 2: punctuation.separator.decimal.d - 3: constant.numeric.value.d - 4: constant.numeric.value.exponent.d - 5: constant.numeric.suffix.d + 3: constant.numeric.suffix.d pop: true # decimal floats - match: |- (?x: ({{dec_integer}}) (?: - (?: + ( (\.) (?: # 1.1, 1.1e1, 1.1e-1, 1.1f, 1.1e1f, 1.1e-1f, 1.1L, 1.1e1L, 1.1e-1L - ({{dec_digits}}) ({{dec_exponent}})? + {{dec_digits}} {{dec_exponent}}? # 1.e1, 1.e-1, 1.e1f, 1.e-1f, 1.e1L, 1.e-1L - | ({{dec_exponent}}) + | {{dec_exponent}} # 1., 1.f, 1.L # but not `..` or method/attribute access | (?!\.|\s*[[:alpha:]_]) ) # 1e1 1e1f 1e1L - | ({{dec_exponent}}) + | {{dec_exponent}} ) ({{integer_float_suffix}})? # 1f | ({{float_suffix}}) ) # .1, .1e1, .1e-1, .1f, .1e1f, .1e-1f, .1L, .1e1L, .1e-1L - | (\.) ({{dec_digits}}) ({{dec_exponent}})? ({{integer_float_suffix}})? + | ( (\.) {{dec_digits}} {{dec_exponent}}? ) ({{integer_float_suffix}})? ) scope: meta.number.float.decimal.d captures: 1: constant.numeric.value.d - 2: punctuation.separator.decimal.d - 3: constant.numeric.value.d - 4: constant.numeric.value.exponent.d - 5: constant.numeric.value.exponent.d - 6: constant.numeric.value.exponent.d - 7: constant.numeric.suffix.d + 2: constant.numeric.value.d + 3: punctuation.separator.decimal.d + 4: constant.numeric.suffix.d + 5: constant.numeric.suffix.d + 6: constant.numeric.value.d + 7: punctuation.separator.decimal.d 8: constant.numeric.suffix.d - 9: punctuation.separator.decimal.d - 10: constant.numeric.value.d - 11: constant.numeric.value.exponent.d - 12: constant.numeric.suffix.d pop: true # hexadecimal imaginary numbers - - match: (0[xX])(_?)({{hex_digits}})?(?:(\.)({{hex_digits}})?)?({{hex_exponent}})?({{imaginary_suffix}}) + - match: (0[xX])(_?)({{hex_digits}}?(?:(\.){{hex_digits}}?)?{{hex_exponent}}?)({{imaginary_suffix}}) scope: meta.number.imaginary.hexadecimal.d captures: 1: constant.numeric.base.d 2: invalid.illegal.numeric.d 3: constant.numeric.value.d 4: punctuation.separator.decimal.d - 5: constant.numeric.value.d - 6: constant.numeric.value.exponent.d - 7: constant.numeric.suffix.d + 5: constant.numeric.suffix.d pop: true # hexadecimal floats - - match: (0[xX])(_?)({{hex_digits}})?(?:(\.)({{hex_digits}})?)?({{hex_exponent}})({{integer_float_suffix}})? + - match: (0[xX])(_?)({{hex_digits}}?(?:(\.){{hex_digits}}?)?{{hex_exponent}})({{integer_float_suffix}})? scope: meta.number.float.hexadecimal.d captures: 1: constant.numeric.base.d 2: invalid.illegal.numeric.d 3: constant.numeric.value.d 4: punctuation.separator.decimal.d - 5: constant.numeric.value.d - 6: constant.numeric.value.exponent.d - 7: constant.numeric.suffix.d + 5: constant.numeric.suffix.d pop: true # binary imaginary numbers diff --git a/D/tests/syntax_test_d.d b/D/tests/syntax_test_d.d index ced0908e73..819b83316d 100644 --- a/D/tests/syntax_test_d.d +++ b/D/tests/syntax_test_d.d @@ -233,19 +233,17 @@ imag = 123_45i + 0_.1_i + 12_.e1i; // ^ constant.numeric.suffix.d // ^ keyword.operator.arithmetic.d // ^^^^^^ meta.number.imaginary.decimal.d -// ^^ constant.numeric.value.d +// ^^^^^ constant.numeric.value.d // ^ punctuation.separator.decimal.d -// ^^ constant.numeric.value.d // ^ constant.numeric.suffix.d // ^^^^^^^ meta.number.imaginary.decimal.d -// ^^^ constant.numeric.value.d -// ^ punctuation.separator.decimal.d -// ^^ constant.numeric.value.exponent.d -// ^ constant.numeric.suffix.d +// ^^^ constant.numeric.value.d - punctuation +// ^ constant.numeric.value.d punctuation.separator.decimal.d +// ^^ constant.numeric.value.d - punctuation +// ^ constant.numeric.suffix.d - punctuation imag = 23134723__742e1i; // ^^^^^^^^^^^^^^^^ meta.number.imaginary.decimal.d -// ^^^^^^^^^^^^^ constant.numeric.value.d -// ^^ constant.numeric.value.exponent.d +// ^^^^^^^^^^^^^^^ constant.numeric.value.d // ^ constant.numeric.suffix.d imag = 0x_3472389742f_i; // ^^^^^^^^^^^^^^^^ meta.number.imaginary.hexadecimal.d @@ -257,8 +255,7 @@ imag = 0x_34723897p-34i; // ^^^^^^^^^^^^^^^^ meta.number.imaginary.hexadecimal.d // ^^ constant.numeric.base.d // ^ invalid.illegal.numeric.d -// ^^^^^^^^ constant.numeric.value.d -// ^^^^ constant.numeric.value.exponent.d +// ^^^^^^^^^^^^ constant.numeric.value.d // ^ constant.numeric.suffix.d imag = 0x347._23897p-34i; // ^^^^^ meta.number.integer.hexadecimal.d @@ -277,17 +274,16 @@ imag = 0b_0100_010_00_i; auto f = 0_.0_; // ^^^^^ meta.number.float.decimal.d -// ^^ constant.numeric.value.d +// ^^^^^ constant.numeric.value.d // ^ punctuation.separator.decimal.d -// ^^ constant.numeric.value.d f = 0_.; // ^^^ meta.number.float.decimal.d -// ^^ constant.numeric.value.d -// ^ punctuation.separator.decimal.d +// ^^ constant.numeric.value.d - punctuation +// ^ constant.numeric.value.d punctuation.separator.decimal.d f = .123_1243; // ^^^^^^^^^ meta.number.float.decimal.d -// ^ punctuation.separator.decimal.d -// ^^^^^^^^ constant.numeric.value.d +// ^ constant.numeric.value.d punctuation.separator.decimal.d +// ^^^^^^^^ constant.numeric.value.d - punctuation f = ._123_1243 + 1._123; // ^ punctuation.accessor.dot.d // ^^^^^^^^^ variable.other.d @@ -297,20 +293,18 @@ f = ._123_1243 + 1._123; // ^^^^ variable.other.d f = 3423.2e-45; // ^^^^^^^^^^ meta.number.float.decimal.d -// ^^^^ constant.numeric.value.d -// ^ punctuation.separator.decimal.d -// ^ constant.numeric.value.d -// ^^^^ constant.numeric.value.exponent.d +// ^^^^ constant.numeric.value.d - punctuation +// ^ constant.numeric.value.d punctuation.separator.decimal.d +// ^^^^^ constant.numeric.value.d - punctuation f = 2.e-45; // ^^^^^^ meta.number.float.decimal.d -// ^ constant.numeric.value.d -// ^ punctuation.separator.decimal.d -// ^^^^ constant.numeric.value.exponent.d +// ^ constant.numeric.value.d - punctuation +// ^ constant.numeric.value.d punctuation.separator.decimal.d +// ^^^^ constant.numeric.value.d - punctuation f = .4E+4L; // ^^^^^^ meta.number.float.decimal.d -// ^ punctuation.separator.decimal.d -// ^ constant.numeric.value.d -// ^^^ constant.numeric.value.exponent.d +// ^ constant.numeric.value.d punctuation.separator.decimal.d +// ^^^^ constant.numeric.value.d - punctuation // ^ constant.numeric.suffix.d f = 1f; // ^^ meta.number.float.decimal.d @@ -319,8 +313,7 @@ f = 1f; f = 0x123p2f; // ^^^^^^^^ meta.number.float.hexadecimal.d // ^^ constant.numeric.base.d -// ^^^ constant.numeric.value.d -// ^^ constant.numeric.value.exponent.d +// ^^^^^ constant.numeric.value.d // ^ constant.numeric.suffix.d f = 0b10101101f; // ^^^^^^^^^^^ meta.number.float.binary.d @@ -330,17 +323,14 @@ f = 0b10101101f; f = 0x.1aFp2; // ^^^^^^^^ meta.number.float.hexadecimal.d // ^^ constant.numeric.base.d -// ^ punctuation.separator.decimal.d -// ^ constant.numeric.value.d -// ^^ constant.numeric.value.d -// ^^ constant.numeric.value.exponent.d +// ^ constant.numeric.value.d punctuation.separator.decimal.d +// ^^^^^ constant.numeric.value.d - punctuation f = 0xF.AP-2f; // ^^^^^^^^^ meta.number.float.hexadecimal.d // ^^ constant.numeric.base.d -// ^ constant.numeric.value.d -// ^ punctuation.separator.decimal.d -// ^ constant.numeric.value.d -// ^^^ constant.numeric.value.exponent.d +// ^ constant.numeric.value.d - punctuation +// ^ constant.numeric.value.d punctuation.separator.decimal.d +// ^^^^ constant.numeric.value.d - punctuation // ^ constant.numeric.suffix.d @foo: From 994d8fb33a5930adf3cc58997e9a4f519c7698e6 Mon Sep 17 00:00:00 2001 From: Thomas Smith Date: Thu, 14 Jan 2021 16:04:17 -0500 Subject: [PATCH 025/152] [JavaScript] Use keyword.declaration for var, let, and const. (#2644) --- JavaScript/JavaScript.sublime-syntax | 2 +- JavaScript/tests/syntax_test_js.js | 12 ++++++------ JavaScript/tests/syntax_test_js_bindings.js | 4 ++-- JavaScript/tests/syntax_test_js_import_export.js | 6 +++--- PHP/tests/syntax_test_php.php | 4 ++-- Perl/syntax_test_perl.pl | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/JavaScript/JavaScript.sublime-syntax b/JavaScript/JavaScript.sublime-syntax index 7a4723e08f..0067101b49 100644 --- a/JavaScript/JavaScript.sublime-syntax +++ b/JavaScript/JavaScript.sublime-syntax @@ -509,7 +509,7 @@ contexts: variable-declaration: - match: (?:const|let|var){{identifier_break}} - scope: storage.type.js + scope: keyword.declaration.js set: - expect-semicolon - variable-binding-list-top diff --git a/JavaScript/tests/syntax_test_js.js b/JavaScript/tests/syntax_test_js.js index 761e1c4d68..73bb11d214 100644 --- a/JavaScript/tests/syntax_test_js.js +++ b/JavaScript/tests/syntax_test_js.js @@ -24,7 +24,7 @@ someFunction({ // ^ meta.function meta.block var bar = function() { -// ^^^ storage.type +// ^^^ keyword.declaration // ^^^ entity.name.function variable.other.readwrite // ^^^^^^^^^^^^ meta.function - meta.function meta.function // ^^^^^^^^ keyword.declaration.function @@ -165,7 +165,7 @@ not_a_comment; var str = '\':'; var str2 = NaN; -// <- storage.type +// <- keyword.declaration // ^ variable.other.readwrite // ^ keyword.operator.assignment // ^^^ constant.language.nan @@ -433,7 +433,7 @@ baz = ""; // ^^ meta.string string.quoted.double var qux = 100; -// <- storage.type +// <- keyword.declaration // ^ variable.other.readwrite // ^ constant.numeric @@ -928,7 +928,7 @@ new FooBar(function(){ { // <- meta.block punctuation.section.block.begin let foo = 1; -// ^^^ meta.block storage.type +// ^^^ meta.block keyword.declaration // ^^^ variable.other.readwrite } // <- meta.block punctuation.section.block.end @@ -1046,11 +1046,11 @@ const abc = new Set const x = const y = 1; // Better highlighting while typing. -// ^^^^^ storage.type +// ^^^^^ keyword.declaration let x = const y = 1; // Better highlighting while typing. -// ^^^^^ storage.type +// ^^^^^ keyword.declaration var o = { a, diff --git a/JavaScript/tests/syntax_test_js_bindings.js b/JavaScript/tests/syntax_test_js_bindings.js index 3d3d277602..f40b2676a7 100644 --- a/JavaScript/tests/syntax_test_js_bindings.js +++ b/JavaScript/tests/syntax_test_js_bindings.js @@ -57,7 +57,7 @@ const x; // ^ meta.binding.name variable.other.readwrite let -// <- storage.type +// <- keyword.declaration w // <- meta.binding.name variable.other.readwrite , @@ -82,7 +82,7 @@ let; const const x = 0; -// <- storage.type +// <- keyword.declaration // Function parameters diff --git a/JavaScript/tests/syntax_test_js_import_export.js b/JavaScript/tests/syntax_test_js_import_export.js index 5bc7faf3b4..2b7686594c 100644 --- a/JavaScript/tests/syntax_test_js_import_export.js +++ b/JavaScript/tests/syntax_test_js_import_export.js @@ -45,18 +45,18 @@ export { name1, name2 as name3 }; export let name1, name2; //^^^^^^^^^^^^^^^^^^^^^^ meta.export //^ keyword.control.import-export -// ^^^ storage.type +// ^^^ keyword.declaration // ^ punctuation.separator.comma export var name3; //^^^^^^^^^^^^^^^ meta.export //^ keyword.control.import-export -// ^^^ storage.type +// ^^^ keyword.declaration export const name1 = 5; //^^^^^^^^^^^^^^^^^^^^^ meta.export //^ keyword.control.import-export -// ^^^^^ storage.type +// ^^^^^ keyword.declaration // ^ keyword.operator.assignment export let foo = 123 // No semicolon diff --git a/PHP/tests/syntax_test_php.php b/PHP/tests/syntax_test_php.php index ca4dfda218..f2a2faecba 100644 --- a/PHP/tests/syntax_test_php.php +++ b/PHP/tests/syntax_test_php.php @@ -1755,7 +1755,7 @@ function generate2() // ^^^^^^^^^^ keyword.operator.heredoc var foo = 1; //^^^^^^^^^^ meta.embedded.js source.js -// <- storage.type +// <- keyword.declaration // ^^^ variable.other.readwrite // ^ constant.numeric $var @@ -2041,7 +2041,7 @@ public function __test()