diff --git a/TypeScript.YAML-tmLanguage b/TypeScript.YAML-tmLanguage index e2b1d615..67112682 100644 --- a/TypeScript.YAML-tmLanguage +++ b/TypeScript.YAML-tmLanguage @@ -34,6 +34,8 @@ variables: propertyName: ({{anyNumber}}|({{identifier}})|{{nonIdentifierPropertyName}}) constantVar: ({{constantIdentifier}})(?![_$[:alnum:]]) endOfStatement: ';|^\s*abstract\b|^\s*async\b|^\s*class\b|^\s*const\b|^\s*declare\b|^\s*enum\b|^\s*export\b|^\s*function\b|^\s*import\b|^\s*interface\b|^\s*let\b|^\s*module\b|^\s*namespace\b|^\s*return\b|^\s*type\b|^\s*var\b' + varExprStart: '{{startOfDeclaration}}\b(var|let){{endOfIdentifier}}' + constExprStart: '{{startOfDeclaration}}\b(const(?!\s+enum\b)){{endOfIdentifier}}' nonPropertyLookBehind: '[^\._$[:alnum:]]' lookBehindReturn: '^return|{{nonPropertyLookBehind}}return' lookBehindThrow: '^throw|{{nonPropertyLookBehind}}throw' @@ -245,13 +247,15 @@ repository: patterns: # let/var - name: meta.var.expr.ts - begin: '{{startOfDeclaration}}\b(var|let){{endOfIdentifier}}' - beginCaptures: - '1': { name: keyword.control.export.ts } - '2': { name: storage.modifier.ts } - '3': { name: storage.type.ts } - end: ((?=;|}|(\s+(of|in)\s+)|^\s*$|{{endOfStatement}})|((?<=\S)(?name meta.var.expr.ts begin - (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(var|let)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)) - beginCaptures - - 1 - - name - keyword.control.export.ts - - 2 - - name - storage.modifier.ts - - 3 - - name - storage.type.ts - - + (?=(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(var|let)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))) end - ((?=;|}|(\s+(of|in)\s+)|^\s*$|;|^\s*abstract\b|^\s*async\b|^\s*class\b|^\s*const\b|^\s*declare\b|^\s*enum\b|^\s*export\b|^\s*function\b|^\s*import\b|^\s*interface\b|^\s*let\b|^\s*module\b|^\s*namespace\b|^\s*return\b|^\s*type\b|^\s*var\b)|((?<=\S)(?<!^let|[^\._$[:alnum:]]let|^var|[^\._$[:alnum:]]var)(?=\s*$))) + (?!(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(var|let)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))((?=;|}|(\s+(of|in)\s+)|^\s*$|;|^\s*abstract\b|^\s*async\b|^\s*class\b|^\s*const\b|^\s*declare\b|^\s*enum\b|^\s*export\b|^\s*function\b|^\s*import\b|^\s*interface\b|^\s*let\b|^\s*module\b|^\s*namespace\b|^\s*return\b|^\s*type\b|^\s*var\b)|((?<!^let|[^\._$[:alnum:]]let|^var|[^\._$[:alnum:]]var)(?=\s*$))) patterns + + begin + (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(var|let)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s* + beginCaptures + + 1 + + name + keyword.control.export.ts + + 2 + + name + storage.modifier.ts + + 3 + + name + storage.type.ts + + + end + (?=\S) + include #destructuring-variable @@ -497,7 +503,7 @@ name meta.var.expr.ts begin - (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(const(?!\s+enum\b))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)) + (?=(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(const(?!\s+enum\b))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))) beginCaptures 1 @@ -517,9 +523,33 @@ end - ((?=;|}|(\s+(of|in)\s+)|^\s*$|;|^\s*abstract\b|^\s*async\b|^\s*class\b|^\s*const\b|^\s*declare\b|^\s*enum\b|^\s*export\b|^\s*function\b|^\s*import\b|^\s*interface\b|^\s*let\b|^\s*module\b|^\s*namespace\b|^\s*return\b|^\s*type\b|^\s*var\b)|((?<=\S)(?<!^const|[^\._$[:alnum:]]const)(?=\s*$))) + (?!(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(const(?!\s+enum\b))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))((?=;|}|(\s+(of|in)\s+)|^\s*$|;|^\s*abstract\b|^\s*async\b|^\s*class\b|^\s*const\b|^\s*declare\b|^\s*enum\b|^\s*export\b|^\s*function\b|^\s*import\b|^\s*interface\b|^\s*let\b|^\s*module\b|^\s*namespace\b|^\s*return\b|^\s*type\b|^\s*var\b)|((?<!^const|[^\._$[:alnum:]]const)(?=\s*$))) patterns + + begin + (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(const(?!\s+enum\b))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s* + beginCaptures + + 1 + + name + keyword.control.export.ts + + 2 + + name + storage.modifier.ts + + 3 + + name + storage.type.ts + + + end + (?=\S) + include #destructuring-const diff --git a/TypeScriptReact.tmLanguage b/TypeScriptReact.tmLanguage index 99e6ec4e..4edcf2ab 100644 --- a/TypeScriptReact.tmLanguage +++ b/TypeScriptReact.tmLanguage @@ -415,29 +415,35 @@ name meta.var.expr.tsx begin - (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(var|let)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)) - beginCaptures - - 1 - - name - keyword.control.export.tsx - - 2 - - name - storage.modifier.tsx - - 3 - - name - storage.type.tsx - - + (?=(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(var|let)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))) end - ((?=;|}|(\s+(of|in)\s+)|^\s*$|;|^\s*abstract\b|^\s*async\b|^\s*class\b|^\s*const\b|^\s*declare\b|^\s*enum\b|^\s*export\b|^\s*function\b|^\s*import\b|^\s*interface\b|^\s*let\b|^\s*module\b|^\s*namespace\b|^\s*return\b|^\s*type\b|^\s*var\b)|((?<=\S)(?<!^let|[^\._$[:alnum:]]let|^var|[^\._$[:alnum:]]var)(?=\s*$))) + (?!(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(var|let)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))((?=;|}|(\s+(of|in)\s+)|^\s*$|;|^\s*abstract\b|^\s*async\b|^\s*class\b|^\s*const\b|^\s*declare\b|^\s*enum\b|^\s*export\b|^\s*function\b|^\s*import\b|^\s*interface\b|^\s*let\b|^\s*module\b|^\s*namespace\b|^\s*return\b|^\s*type\b|^\s*var\b)|((?<!^let|[^\._$[:alnum:]]let|^var|[^\._$[:alnum:]]var)(?=\s*$))) patterns + + begin + (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(var|let)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s* + beginCaptures + + 1 + + name + keyword.control.export.tsx + + 2 + + name + storage.modifier.tsx + + 3 + + name + storage.type.tsx + + + end + (?=\S) + include #destructuring-variable @@ -501,7 +507,7 @@ name meta.var.expr.tsx begin - (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(const(?!\s+enum\b))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)) + (?=(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(const(?!\s+enum\b))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))) beginCaptures 1 @@ -521,9 +527,33 @@ end - ((?=;|}|(\s+(of|in)\s+)|^\s*$|;|^\s*abstract\b|^\s*async\b|^\s*class\b|^\s*const\b|^\s*declare\b|^\s*enum\b|^\s*export\b|^\s*function\b|^\s*import\b|^\s*interface\b|^\s*let\b|^\s*module\b|^\s*namespace\b|^\s*return\b|^\s*type\b|^\s*var\b)|((?<=\S)(?<!^const|[^\._$[:alnum:]]const)(?=\s*$))) + (?!(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(const(?!\s+enum\b))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))((?=;|}|(\s+(of|in)\s+)|^\s*$|;|^\s*abstract\b|^\s*async\b|^\s*class\b|^\s*const\b|^\s*declare\b|^\s*enum\b|^\s*export\b|^\s*function\b|^\s*import\b|^\s*interface\b|^\s*let\b|^\s*module\b|^\s*namespace\b|^\s*return\b|^\s*type\b|^\s*var\b)|((?<!^const|[^\._$[:alnum:]]const)(?=\s*$))) patterns + + begin + (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(const(?!\s+enum\b))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s* + beginCaptures + + 1 + + name + keyword.control.export.tsx + + 2 + + name + storage.modifier.tsx + + 3 + + name + storage.type.tsx + + + end + (?=\S) + include #destructuring-const diff --git a/tests/baselines/Issue203.baseline.txt b/tests/baselines/Issue203.baseline.txt index 4bc2060b..e60a65ea 100644 --- a/tests/baselines/Issue203.baseline.txt +++ b/tests/baselines/Issue203.baseline.txt @@ -14,7 +14,7 @@ Grammar: TypeScript.tmLanguage ^^^ source.ts meta.var.expr.ts storage.type.ts ^ - source.ts meta.var.expr.ts meta.array-binding-pattern-variable.ts + source.ts meta.var.expr.ts ^ source.ts meta.var.expr.ts meta.array-binding-pattern-variable.ts punctuation.definition.binding-pattern.array.ts ^ @@ -73,7 +73,7 @@ Grammar: TypeScript.tmLanguage ^^^ source.ts meta.var.expr.ts storage.type.ts ^ - source.ts meta.var.expr.ts meta.array-binding-pattern-variable.ts + source.ts meta.var.expr.ts ^ source.ts meta.var.expr.ts meta.array-binding-pattern-variable.ts punctuation.definition.binding-pattern.array.ts ^ diff --git a/tests/baselines/Issue219.baseline.txt b/tests/baselines/Issue219.baseline.txt index 0f590fd5..f77de80e 100644 --- a/tests/baselines/Issue219.baseline.txt +++ b/tests/baselines/Issue219.baseline.txt @@ -14,7 +14,7 @@ Grammar: TypeScript.tmLanguage ^^^^^ source.ts meta.var.expr.ts storage.type.ts ^ - source.ts meta.var.expr.ts meta.object-binding-pattern-variable.ts + source.ts meta.var.expr.ts ^ source.ts meta.var.expr.ts meta.object-binding-pattern-variable.ts punctuation.definition.binding-pattern.object.ts ^^ diff --git a/tests/baselines/Issue232.baseline.txt b/tests/baselines/Issue232.baseline.txt index 6d2bc21e..2b9d6f5a 100644 --- a/tests/baselines/Issue232.baseline.txt +++ b/tests/baselines/Issue232.baseline.txt @@ -17,7 +17,7 @@ Grammar: TypeScript.tmLanguage ^^^ source.ts meta.var.expr.ts storage.type.ts ^ - source.ts meta.var.expr.ts meta.array-binding-pattern-variable.ts + source.ts meta.var.expr.ts ^ source.ts meta.var.expr.ts meta.array-binding-pattern-variable.ts punctuation.definition.binding-pattern.array.ts ^ diff --git a/tests/baselines/Issue307.baseline.txt b/tests/baselines/Issue307.baseline.txt index 0b1e8477..c7bfb4c6 100644 --- a/tests/baselines/Issue307.baseline.txt +++ b/tests/baselines/Issue307.baseline.txt @@ -80,7 +80,7 @@ Grammar: TypeScript.tmLanguage ^^^^^ source.ts meta.class.ts meta.method.declaration.ts meta.block.ts meta.var.expr.ts storage.type.ts ^ - source.ts meta.class.ts meta.method.declaration.ts meta.block.ts meta.var.expr.ts meta.object-binding-pattern-variable.ts + source.ts meta.class.ts meta.method.declaration.ts meta.block.ts meta.var.expr.ts ^ source.ts meta.class.ts meta.method.declaration.ts meta.block.ts meta.var.expr.ts meta.object-binding-pattern-variable.ts punctuation.definition.binding-pattern.object.ts > a diff --git a/tests/baselines/Issue445.baseline.txt b/tests/baselines/Issue445.baseline.txt index 820d7a84..ecfe1972 100644 --- a/tests/baselines/Issue445.baseline.txt +++ b/tests/baselines/Issue445.baseline.txt @@ -71,7 +71,7 @@ Grammar: TypeScript.tmLanguage ^^^^^ source.ts meta.function.ts meta.block.ts meta.var.expr.ts storage.type.ts ^ - source.ts meta.function.ts meta.block.ts meta.var.expr.ts meta.object-binding-pattern-variable.ts + source.ts meta.function.ts meta.block.ts meta.var.expr.ts ^ source.ts meta.function.ts meta.block.ts meta.var.expr.ts meta.object-binding-pattern-variable.ts punctuation.definition.binding-pattern.object.ts ^ diff --git a/tests/baselines/Issue654.baseline.txt b/tests/baselines/Issue654.baseline.txt new file mode 100644 index 00000000..60abe0e6 --- /dev/null +++ b/tests/baselines/Issue654.baseline.txt @@ -0,0 +1,46 @@ +original file +----------------------------------- +let app = 1 +{ + 1 + 1 +} +----------------------------------- + +Grammar: TypeScript.tmLanguage +----------------------------------- +>let app = 1 + ^^^ + source.ts meta.var.expr.ts storage.type.ts + ^ + source.ts meta.var.expr.ts + ^^^ + source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.readwrite.ts + ^ + source.ts meta.var.expr.ts meta.var-single-variable.expr.ts + ^ + source.ts meta.var.expr.ts keyword.operator.assignment.ts + ^ + source.ts meta.var.expr.ts + ^ + source.ts meta.var.expr.ts constant.numeric.decimal.ts + ^ + source.ts meta.var.expr.ts +>{ + ^ + source.ts meta.block.ts punctuation.definition.block.ts +> 1 + 1 + ^ + source.ts meta.block.ts + ^ + source.ts meta.block.ts constant.numeric.decimal.ts + ^ + source.ts meta.block.ts + ^ + source.ts meta.block.ts keyword.operator.arithmetic.ts + ^ + source.ts meta.block.ts + ^ + source.ts meta.block.ts constant.numeric.decimal.ts +>} + ^ + source.ts meta.block.ts punctuation.definition.block.ts \ No newline at end of file diff --git a/tests/baselines/destructuringWithDefaults.baseline.txt b/tests/baselines/destructuringWithDefaults.baseline.txt index 51f4fc55..447c1e43 100644 --- a/tests/baselines/destructuringWithDefaults.baseline.txt +++ b/tests/baselines/destructuringWithDefaults.baseline.txt @@ -89,7 +89,7 @@ Grammar: TypeScript.tmLanguage ^^^ source.ts meta.var.expr.ts storage.type.ts ^ - source.ts meta.var.expr.ts meta.object-binding-pattern-variable.ts + source.ts meta.var.expr.ts ^ source.ts meta.var.expr.ts meta.object-binding-pattern-variable.ts punctuation.definition.binding-pattern.object.ts > check: isReportMode = false, @@ -273,7 +273,7 @@ Grammar: TypeScript.tmLanguage ^^^ source.ts meta.var.expr.ts storage.type.ts ^ - source.ts meta.var.expr.ts meta.array-binding-pattern-variable.ts + source.ts meta.var.expr.ts ^ source.ts meta.var.expr.ts meta.array-binding-pattern-variable.ts punctuation.definition.binding-pattern.array.ts > check2 = false, diff --git a/tests/baselines/propertyNameInObjectBindingElement.baseline.txt b/tests/baselines/propertyNameInObjectBindingElement.baseline.txt index c110add2..4f7b92cc 100644 --- a/tests/baselines/propertyNameInObjectBindingElement.baseline.txt +++ b/tests/baselines/propertyNameInObjectBindingElement.baseline.txt @@ -11,7 +11,7 @@ Grammar: TypeScript.tmLanguage ^^^ source.ts meta.var.expr.ts storage.type.ts ^ - source.ts meta.var.expr.ts meta.object-binding-pattern-variable.ts + source.ts meta.var.expr.ts ^ source.ts meta.var.expr.ts meta.object-binding-pattern-variable.ts punctuation.definition.binding-pattern.object.ts ^ diff --git a/tests/baselines/restAndSpreadExpression.baseline.txt b/tests/baselines/restAndSpreadExpression.baseline.txt index e810e224..e4a38eef 100644 --- a/tests/baselines/restAndSpreadExpression.baseline.txt +++ b/tests/baselines/restAndSpreadExpression.baseline.txt @@ -52,7 +52,7 @@ Grammar: TypeScript.tmLanguage ^^^ source.ts meta.var.expr.ts storage.type.ts ^ - source.ts meta.var.expr.ts meta.object-binding-pattern-variable.ts + source.ts meta.var.expr.ts ^ source.ts meta.var.expr.ts meta.object-binding-pattern-variable.ts punctuation.definition.binding-pattern.object.ts ^ @@ -200,7 +200,7 @@ Grammar: TypeScript.tmLanguage ^^^ source.ts meta.var.expr.ts storage.type.ts ^ - source.ts meta.var.expr.ts meta.object-binding-pattern-variable.ts + source.ts meta.var.expr.ts ^ source.ts meta.var.expr.ts meta.object-binding-pattern-variable.ts punctuation.definition.binding-pattern.object.ts ^ @@ -247,7 +247,7 @@ Grammar: TypeScript.tmLanguage ^^^^^ source.ts meta.var.expr.ts storage.type.ts ^ - source.ts meta.var.expr.ts meta.array-binding-pattern-variable.ts + source.ts meta.var.expr.ts ^ source.ts meta.var.expr.ts meta.array-binding-pattern-variable.ts punctuation.definition.binding-pattern.array.ts ^ diff --git a/tests/baselines/restInBindingPattern.baseline.txt b/tests/baselines/restInBindingPattern.baseline.txt index 30befef0..2066c9c9 100644 --- a/tests/baselines/restInBindingPattern.baseline.txt +++ b/tests/baselines/restInBindingPattern.baseline.txt @@ -14,7 +14,7 @@ Grammar: TypeScript.tmLanguage ^^^ source.ts meta.var.expr.ts storage.type.ts ^ - source.ts meta.var.expr.ts meta.array-binding-pattern-variable.ts + source.ts meta.var.expr.ts ^ source.ts meta.var.expr.ts meta.array-binding-pattern-variable.ts punctuation.definition.binding-pattern.array.ts ^^^ @@ -59,7 +59,7 @@ Grammar: TypeScript.tmLanguage ^^^ source.ts meta.var.expr.ts storage.type.ts ^ - source.ts meta.var.expr.ts meta.array-binding-pattern-variable.ts + source.ts meta.var.expr.ts ^ source.ts meta.var.expr.ts meta.array-binding-pattern-variable.ts punctuation.definition.binding-pattern.array.ts ^^^ diff --git a/tests/baselines/variableBindingPattern.baseline.txt b/tests/baselines/variableBindingPattern.baseline.txt index ff14fb1e..aaa8a981 100644 --- a/tests/baselines/variableBindingPattern.baseline.txt +++ b/tests/baselines/variableBindingPattern.baseline.txt @@ -247,7 +247,7 @@ Grammar: TypeScript.tmLanguage ^^^ source.ts meta.var.expr.ts storage.type.ts ^ - source.ts meta.var.expr.ts meta.object-binding-pattern-variable.ts + source.ts meta.var.expr.ts ^ source.ts meta.var.expr.ts meta.object-binding-pattern-variable.ts punctuation.definition.binding-pattern.object.ts ^ @@ -340,7 +340,7 @@ Grammar: TypeScript.tmLanguage ^^^ source.ts meta.var.expr.ts storage.type.ts ^ - source.ts meta.var.expr.ts meta.object-binding-pattern-variable.ts + source.ts meta.var.expr.ts ^ source.ts meta.var.expr.ts meta.object-binding-pattern-variable.ts punctuation.definition.binding-pattern.object.ts ^ @@ -666,7 +666,7 @@ Grammar: TypeScript.tmLanguage ^^^ source.ts meta.var.expr.ts storage.type.ts ^ - source.ts meta.var.expr.ts meta.array-binding-pattern-variable.ts + source.ts meta.var.expr.ts ^ source.ts meta.var.expr.ts meta.array-binding-pattern-variable.ts punctuation.definition.binding-pattern.array.ts ^ @@ -701,7 +701,7 @@ Grammar: TypeScript.tmLanguage ^^^ source.ts meta.var.expr.ts storage.type.ts ^ - source.ts meta.var.expr.ts meta.array-binding-pattern-variable.ts + source.ts meta.var.expr.ts ^ source.ts meta.var.expr.ts meta.array-binding-pattern-variable.ts punctuation.definition.binding-pattern.array.ts ^ diff --git a/tests/cases/Issue654.ts b/tests/cases/Issue654.ts new file mode 100644 index 00000000..cb95621b --- /dev/null +++ b/tests/cases/Issue654.ts @@ -0,0 +1,4 @@ +let app = 1 +{ + 1 + 1 +} \ No newline at end of file