Fix the incorrect look behinds of cast expression when property name is yield

Fixes #562
This commit is contained in:
Sheetal Nandi 2018-01-25 12:55:16 -08:00
Родитель 74789e0f42
Коммит 53d555baa1
7 изменённых файлов: 320 добавлений и 39 удалений

Просмотреть файл

@ -16,6 +16,16 @@ variables:
nonIdentifierPropertyName: '{{quotedStrings}}|(\[([^\[\]]|\[[^\[\]]*\])+\])'
propertyName: (({{identifier}})|{{nonIdentifierPropertyName}})
constantVar: ({{constantIdentifier}})(?![_$[:alnum:]])
nonPropertyLookBehind: '[^\._$[:alnum:]]'
lookBehindReturn: '^return|{{nonPropertyLookBehind}}return'
lookBehindThrow: '^throw|{{nonPropertyLookBehind}}throw'
lookBehindYield: '^yield|{{nonPropertyLookBehind}}yield'
lookBehindAwait: '^await|{{nonPropertyLookBehind}}await'
lookBehindDefault: '^default|{{nonPropertyLookBehind}}default'
lookBehindIn: '^in|{{nonPropertyLookBehind}}in'
lookBehindOf: '^of|{{nonPropertyLookBehind}}of'
lookBehindTypeof: '^typeof|{{nonPropertyLookBehind}}typeof'
lookBehindCase: '^case|{{nonPropertyLookBehind}}case'
matchingParenthesis: (\([^\(\)]*\))
# Identifier start | matching braces | matching parenthesis | matching square brackets
typeParamersStart: ([_$[:alpha:]]|(\{[^\{\}]*\})|{{matchingParenthesis}}|(\[[^\[\]]*\]))
@ -226,14 +236,14 @@ repository:
destructuring-variable:
patterns:
- name: meta.object-binding-pattern-variable.ts
begin: (?<!=|:|of|in)\s*(?=\{)
begin: (?<!=|:|{{lookBehindOf}}|{{lookBehindIn}})\s*(?=\{)
end: (?=$|^|[;,=}]|(\s+(of|in)\s+))
patterns:
- include: '#object-binding-pattern'
- include: '#type-annotation'
- include: '#comment'
- name: meta.array-binding-pattern-variable.ts
begin: (?<!=|:|of|in)\s*(?=\[)
begin: (?<!=|:|{{lookBehindOf}}|{{lookBehindIn}})\s*(?=\[)
end: (?=$|^|[;,=}]|(\s+(of|in)\s+))
patterns:
- include: '#array-binding-pattern'
@ -965,7 +975,7 @@ repository:
#object literals
after-operator-block-as-object-literal:
name: meta.objectliteral.ts
begin: (?<=[=(,\[?+!]|await|return|yield|throw|in|of|typeof|&&|\|\||\*)\s*(\{)
begin: (?<=[=(,\[?+!]|{{lookBehindAwait}}|{{lookBehindReturn}}|{{lookBehindYield}}|{{lookBehindThrow}}|{{lookBehindIn}}|{{lookBehindOf}}|{{lookBehindTypeof}}|&&|\|\||\*)\s*(\{)
beginCaptures:
'1': { name: punctuation.definition.block.ts }
end: \}
@ -1113,7 +1123,7 @@ repository:
# If '<' is preceeded by 'return', 'throw', 'yield', or 'await', it's most likely a type assertion
# If '=', '(', ',', ':', or '>' are followed by a '<', it is also likely a type assertion as otherwise it would be a syntax error
# '<=' and '<<=' are cannot be type assertions, as they are assignment operators.
begin: (?:(?<=return|throw|yield|await|default|[=(,:>*?\&\|\^]|[^_$[:alnum:]](?:\+\+|\-\-)|[^\+]\+|[^\-]\-))\s*(<)(?!<?\=)
begin: (?:(?<={{lookBehindReturn}}|{{lookBehindThrow}}|{{lookBehindYield}}|{{lookBehindAwait}}|{{lookBehindDefault}}|[=(,:>*?\&\|\^]|[^_$[:alnum:]](?:\+\+|\-\-)|[^\+]\+|[^\-]\-))\s*(<)(?!<?\=)
beginCaptures:
'1': { name: meta.brace.angle.ts }
end: (\>)\s*
@ -1951,7 +1961,7 @@ repository:
regex:
patterns:
- name: string.regexp.ts
begin: (?<=[=(:,\[?+!]|return|case|=>|&&|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/(?![\/*])[gimuy]*(?!\s*[a-zA-Z0-9_$]))
begin: (?<=[=(:,\[?+!]|{{lookBehindReturn}}|{{lookBehindCase}}|=>|&&|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/(?![\/*])[gimuy]*(?!\s*[a-zA-Z0-9_$]))
beginCaptures:
'1': {name: punctuation.definition.string.begin.ts}
end: (/)([gimuy]*)

Просмотреть файл

@ -538,7 +538,7 @@
<key>name</key>
<string>meta.object-binding-pattern-variable.ts</string>
<key>begin</key>
<string>(?&lt;!=|:|of|in)\s*(?=\{)</string>
<string>(?&lt;!=|:|^of|[^\._$[:alnum:]]of|^in|[^\._$[:alnum:]]in)\s*(?=\{)</string>
<key>end</key>
<string>(?=$|^|[;,=}]|(\s+(of|in)\s+))</string>
<key>patterns</key>
@ -561,7 +561,7 @@
<key>name</key>
<string>meta.array-binding-pattern-variable.ts</string>
<key>begin</key>
<string>(?&lt;!=|:|of|in)\s*(?=\[)</string>
<string>(?&lt;!=|:|^of|[^\._$[:alnum:]]of|^in|[^\._$[:alnum:]]in)\s*(?=\[)</string>
<key>end</key>
<string>(?=$|^|[;,=}]|(\s+(of|in)\s+))</string>
<key>patterns</key>
@ -2979,7 +2979,7 @@
<key>name</key>
<string>meta.objectliteral.ts</string>
<key>begin</key>
<string>(?&lt;=[=(,\[?+!]|await|return|yield|throw|in|of|typeof|&amp;&amp;|\|\||\*)\s*(\{)</string>
<string>(?&lt;=[=(,\[?+!]|^await|[^\._$[:alnum:]]await|^return|[^\._$[:alnum:]]return|^yield|[^\._$[:alnum:]]yield|^throw|[^\._$[:alnum:]]throw|^in|[^\._$[:alnum:]]in|^of|[^\._$[:alnum:]]of|^typeof|[^\._$[:alnum:]]typeof|&amp;&amp;|\|\||\*)\s*(\{)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
@ -3441,7 +3441,7 @@
<key>name</key>
<string>cast.expr.ts</string>
<key>begin</key>
<string>(?:(?&lt;=return|throw|yield|await|default|[=(,:&gt;*?\&amp;\|\^]|[^_$[:alnum:]](?:\+\+|\-\-)|[^\+]\+|[^\-]\-))\s*(&lt;)(?!&lt;?\=)</string>
<string>(?:(?&lt;=^return|[^\._$[:alnum:]]return|^throw|[^\._$[:alnum:]]throw|^yield|[^\._$[:alnum:]]yield|^await|[^\._$[:alnum:]]await|^default|[^\._$[:alnum:]]default|[=(,:&gt;*?\&amp;\|\^]|[^_$[:alnum:]](?:\+\+|\-\-)|[^\+]\+|[^\-]\-))\s*(&lt;)(?!&lt;?\=)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
@ -5463,7 +5463,7 @@
<key>name</key>
<string>string.regexp.ts</string>
<key>begin</key>
<string>(?&lt;=[=(:,\[?+!]|return|case|=&gt;|&amp;&amp;|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/(?![\/*])[gimuy]*(?!\s*[a-zA-Z0-9_$]))</string>
<string>(?&lt;=[=(:,\[?+!]|^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case|=&gt;|&amp;&amp;|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/(?![\/*])[gimuy]*(?!\s*[a-zA-Z0-9_$]))</string>
<key>beginCaptures</key>
<dict>
<key>1</key>

Просмотреть файл

@ -33,7 +33,7 @@ repository:
jsx-tag-without-attributes-in-expression:
begin: |-
(?x)
(?<=[({\[,?=>:*]|&&|\|\||\?|\Wreturn|^return|\Wdefault|^)\s*
(?<=[({\[,?=>:*]|&&|\|\||\?|{{lookBehindReturn}}|{{lookBehindDefault}}|^)\s*
(?=(<)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>))
end: (?!\s*(<)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>))
patterns:
@ -61,7 +61,7 @@ repository:
# We need to differentiate between the relational '<' operator and the beginning of a tag using the surrounding context.
begin: |-
(?x)
(?<=[({\[,?=>:*]|&&|\|\||\?|\Wreturn|^return|\Wdefault|^)\s*
(?<=[({\[,?=>:*]|&&|\|\||\?|{{lookBehindReturn}}|{{lookBehindDefault}}|^)\s*
(?!<\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=>])|,)) # look ahead is not type parameter of arrow
(?=(<)\s*
([_$a-zA-Z][-$\w.]*(?<!\.|-))

Просмотреть файл

@ -542,7 +542,7 @@
<key>name</key>
<string>meta.object-binding-pattern-variable.tsx</string>
<key>begin</key>
<string>(?&lt;!=|:|of|in)\s*(?=\{)</string>
<string>(?&lt;!=|:|^of|[^\._$[:alnum:]]of|^in|[^\._$[:alnum:]]in)\s*(?=\{)</string>
<key>end</key>
<string>(?=$|^|[;,=}]|(\s+(of|in)\s+))</string>
<key>patterns</key>
@ -565,7 +565,7 @@
<key>name</key>
<string>meta.array-binding-pattern-variable.tsx</string>
<key>begin</key>
<string>(?&lt;!=|:|of|in)\s*(?=\[)</string>
<string>(?&lt;!=|:|^of|[^\._$[:alnum:]]of|^in|[^\._$[:alnum:]]in)\s*(?=\[)</string>
<key>end</key>
<string>(?=$|^|[;,=}]|(\s+(of|in)\s+))</string>
<key>patterns</key>
@ -2983,7 +2983,7 @@
<key>name</key>
<string>meta.objectliteral.tsx</string>
<key>begin</key>
<string>(?&lt;=[=(,\[?+!]|await|return|yield|throw|in|of|typeof|&amp;&amp;|\|\||\*)\s*(\{)</string>
<string>(?&lt;=[=(,\[?+!]|^await|[^\._$[:alnum:]]await|^return|[^\._$[:alnum:]]return|^yield|[^\._$[:alnum:]]yield|^throw|[^\._$[:alnum:]]throw|^in|[^\._$[:alnum:]]in|^of|[^\._$[:alnum:]]of|^typeof|[^\._$[:alnum:]]typeof|&amp;&amp;|\|\||\*)\s*(\{)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
@ -5409,7 +5409,7 @@
<key>name</key>
<string>string.regexp.tsx</string>
<key>begin</key>
<string>(?&lt;=[=(:,\[?+!]|return|case|=&gt;|&amp;&amp;|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/(?![\/*])[gimuy]*(?!\s*[a-zA-Z0-9_$]))</string>
<string>(?&lt;=[=(:,\[?+!]|^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case|=&gt;|&amp;&amp;|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/(?![\/*])[gimuy]*(?!\s*[a-zA-Z0-9_$]))</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
@ -6683,7 +6683,7 @@
<dict>
<key>begin</key>
<string>(?x)
(?&lt;=[({\[,?=&gt;:*]|&amp;&amp;|\|\||\?|\Wreturn|^return|\Wdefault|^)\s*
(?&lt;=[({\[,?=&gt;:*]|&amp;&amp;|\|\||\?|^return|[^\._$[:alnum:]]return|^default|[^\._$[:alnum:]]default|^)\s*
(?=(&lt;)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?&lt;!\.|-))?\s*(&gt;))</string>
<key>end</key>
<string>(?!\s*(&lt;)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?&lt;!\.|-))?\s*(&gt;))</string>
@ -6763,7 +6763,7 @@
<dict>
<key>begin</key>
<string>(?x)
(?&lt;=[({\[,?=&gt;:*]|&amp;&amp;|\|\||\?|\Wreturn|^return|\Wdefault|^)\s*
(?&lt;=[({\[,?=&gt;:*]|&amp;&amp;|\|\||\?|^return|[^\._$[:alnum:]]return|^default|[^\._$[:alnum:]]default|^)\s*
(?!&lt;\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=&gt;])|,)) # look ahead is not type parameter of arrow
(?=(&lt;)\s*
([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))

Просмотреть файл

@ -1,6 +1,6 @@
import fs = require('fs');
import path = require('path');
import yaml = require('js-yaml');
import yaml = require('js-yaml');
import plist = require('plist');
function writePlistFile(grammar: any, fileName: string) {
@ -39,8 +39,8 @@ function transformGrammarRepository(grammar: any, propertyNames: string[], trans
}
}
function changeTsToTsxGrammar(grammar: any) {
const tsxUpdates = readYaml("../TypeScriptReact.YAML-tmLanguage");
function changeTsToTsxGrammar(grammar: any, variables: any) {
const tsxUpdates = updateGrammarVariables(readYaml("../TypeScriptReact.YAML-tmLanguage"), variables);
// Update name, file types, scope name and uuid
for (let key in tsxUpdates) {
@ -62,7 +62,7 @@ function changeTsToTsxGrammar(grammar: any) {
repository[key].patterns.unshift(updatesRepository[key].patterns[0]);
break;
default:
// Add jsx
// Add jsx
repository[key] = updatesRepository[key];
}
}
@ -79,33 +79,33 @@ function replacePatternVariables(pattern: string, variableReplacers: VariableRep
}
type VariableReplacer = [RegExp, string];
function updateGrammarVariables(grammar: any) {
if (grammar.variables !== undefined) {
const variables = grammar.variables;
delete grammar.variables;
const variableReplacers: VariableReplacer[] = [];
for (const variableName in variables) {
// Replace the pattern with earlier variables
const pattern = replacePatternVariables(variables[variableName], variableReplacers);
variableReplacers.push([new RegExp(`{{${variableName}}}`, "gim"), pattern]);
}
transformGrammarRepository(
grammar,
["begin", "end", "match"],
pattern => replacePatternVariables(pattern, variableReplacers)
);
function updateGrammarVariables(grammar: any, variables: any) {
delete grammar.variables;
const variableReplacers: VariableReplacer[] = [];
for (const variableName in variables) {
// Replace the pattern with earlier variables
const pattern = replacePatternVariables(variables[variableName], variableReplacers);
variableReplacers.push([new RegExp(`{{${variableName}}}`, "gim"), pattern]);
}
transformGrammarRepository(
grammar,
["begin", "end", "match"],
pattern => replacePatternVariables(pattern, variableReplacers)
);
return grammar;
}
function buildGrammar() {
const tsGrammar = updateGrammarVariables(readYaml("../TypeScript.YAML-tmLanguage"));
const tsGrammarBeforeTransformation = readYaml("../TypeScript.YAML-tmLanguage");
const variables = tsGrammarBeforeTransformation.variables;
const tsGrammar = updateGrammarVariables(tsGrammarBeforeTransformation, variables);
// Write TypeScript.tmLanguage
writePlistFile(tsGrammar, "../TypeScript.tmLanguage");
// Write TypeScriptReact.tmLangauge
const tsxGrammar = changeTsToTsxGrammar(tsGrammar);
const tsxGrammar = changeTsToTsxGrammar(tsGrammar, variables);
writePlistFile(tsxGrammar, "../TypeScriptReact.tmLanguage");
}

Просмотреть файл

@ -0,0 +1,260 @@
original file
-----------------------------------
// @onlyOwnGrammar - As this has cast
yield <ClassD>10;
(yield <ClassD>10);
function foo() {
return <ClassD>10;
}
topYields.sort ((share1,share2) => {
if (share1.yield < share2.yield) { return 1; }
if (share1.yield > share2.yield) { return -1; }
return 0;
});
-----------------------------------
Grammar: TypeScript.tmLanguage
-----------------------------------
>// @onlyOwnGrammar - As this has cast
^^
source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
source.ts comment.line.double-slash.ts
>yield <ClassD>10;
^^^^^
source.ts keyword.control.flow.ts
^
source.ts cast.expr.ts
^
source.ts cast.expr.ts meta.brace.angle.ts
^^^^^^
source.ts cast.expr.ts entity.name.type.ts
^
source.ts cast.expr.ts meta.brace.angle.ts
^^
source.ts constant.numeric.decimal.ts
^
source.ts punctuation.terminator.statement.ts
^^
source.ts
>(yield <ClassD>10);
^
source.ts meta.brace.round.ts
^^^^^
source.ts keyword.control.flow.ts
^
source.ts cast.expr.ts
^
source.ts cast.expr.ts meta.brace.angle.ts
^^^^^^
source.ts cast.expr.ts entity.name.type.ts
^
source.ts cast.expr.ts meta.brace.angle.ts
^^
source.ts constant.numeric.decimal.ts
^
source.ts meta.brace.round.ts
^
source.ts punctuation.terminator.statement.ts
^^
source.ts
>function foo() {
^^^^^^^^
source.ts meta.function.ts storage.type.function.ts
^
source.ts meta.function.ts
^^^
source.ts meta.function.ts meta.definition.function.ts entity.name.function.ts
^
source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
^
source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.end.ts
^
source.ts meta.function.ts
^
source.ts meta.function.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts meta.function.ts meta.block.ts
> return <ClassD>10;
^^
source.ts meta.function.ts meta.block.ts
^^^^^^
source.ts meta.function.ts meta.block.ts keyword.control.flow.ts
^
source.ts meta.function.ts meta.block.ts cast.expr.ts
^
source.ts meta.function.ts meta.block.ts cast.expr.ts meta.brace.angle.ts
^^^^^^
source.ts meta.function.ts meta.block.ts cast.expr.ts entity.name.type.ts
^
source.ts meta.function.ts meta.block.ts cast.expr.ts meta.brace.angle.ts
^^
source.ts meta.function.ts meta.block.ts constant.numeric.decimal.ts
^
source.ts meta.function.ts meta.block.ts punctuation.terminator.statement.ts
^^
source.ts meta.function.ts meta.block.ts
>}
^
source.ts meta.function.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts
>topYields.sort ((share1,share2) => {
^^^^^^^^^
source.ts meta.function-call.ts variable.other.object.ts
^
source.ts meta.function-call.ts punctuation.accessor.ts
^^^^
source.ts meta.function-call.ts support.function.ts
^
source.ts
^
source.ts meta.brace.round.ts
^
source.ts meta.arrow.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
^^^^^^
source.ts meta.arrow.ts meta.parameters.ts variable.parameter.ts
^
source.ts meta.arrow.ts meta.parameters.ts punctuation.separator.parameter.ts
^^^^^^
source.ts meta.arrow.ts meta.parameters.ts variable.parameter.ts
^
source.ts meta.arrow.ts meta.parameters.ts punctuation.definition.parameters.end.ts
^
source.ts meta.arrow.ts
^^
source.ts meta.arrow.ts storage.type.function.arrow.ts
^
source.ts meta.arrow.ts
^
source.ts meta.arrow.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts meta.arrow.ts meta.block.ts
> if (share1.yield < share2.yield) { return 1; }
^^^^
source.ts meta.arrow.ts meta.block.ts
^^
source.ts meta.arrow.ts meta.block.ts keyword.control.conditional.ts
^
source.ts meta.arrow.ts meta.block.ts
^
source.ts meta.arrow.ts meta.block.ts meta.brace.round.ts
^^^^^^
source.ts meta.arrow.ts meta.block.ts variable.other.object.ts
^
source.ts meta.arrow.ts meta.block.ts punctuation.accessor.ts
^^^^^
source.ts meta.arrow.ts meta.block.ts variable.other.property.ts
^
source.ts meta.arrow.ts meta.block.ts
^
source.ts meta.arrow.ts meta.block.ts keyword.operator.relational.ts
^
source.ts meta.arrow.ts meta.block.ts
^^^^^^
source.ts meta.arrow.ts meta.block.ts variable.other.object.ts
^
source.ts meta.arrow.ts meta.block.ts punctuation.accessor.ts
^^^^^
source.ts meta.arrow.ts meta.block.ts variable.other.property.ts
^
source.ts meta.arrow.ts meta.block.ts meta.brace.round.ts
^
source.ts meta.arrow.ts meta.block.ts
^
source.ts meta.arrow.ts meta.block.ts meta.block.ts punctuation.definition.block.ts
^
source.ts meta.arrow.ts meta.block.ts meta.block.ts
^^^^^^
source.ts meta.arrow.ts meta.block.ts meta.block.ts keyword.control.flow.ts
^
source.ts meta.arrow.ts meta.block.ts meta.block.ts
^
source.ts meta.arrow.ts meta.block.ts meta.block.ts constant.numeric.decimal.ts
^
source.ts meta.arrow.ts meta.block.ts meta.block.ts punctuation.terminator.statement.ts
^
source.ts meta.arrow.ts meta.block.ts meta.block.ts
^
source.ts meta.arrow.ts meta.block.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts meta.arrow.ts meta.block.ts
> if (share1.yield > share2.yield) { return -1; }
^^^^
source.ts meta.arrow.ts meta.block.ts
^^
source.ts meta.arrow.ts meta.block.ts keyword.control.conditional.ts
^
source.ts meta.arrow.ts meta.block.ts
^
source.ts meta.arrow.ts meta.block.ts meta.brace.round.ts
^^^^^^
source.ts meta.arrow.ts meta.block.ts variable.other.object.ts
^
source.ts meta.arrow.ts meta.block.ts punctuation.accessor.ts
^^^^^
source.ts meta.arrow.ts meta.block.ts variable.other.property.ts
^
source.ts meta.arrow.ts meta.block.ts
^
source.ts meta.arrow.ts meta.block.ts keyword.operator.relational.ts
^
source.ts meta.arrow.ts meta.block.ts
^^^^^^
source.ts meta.arrow.ts meta.block.ts variable.other.object.ts
^
source.ts meta.arrow.ts meta.block.ts punctuation.accessor.ts
^^^^^
source.ts meta.arrow.ts meta.block.ts variable.other.property.ts
^
source.ts meta.arrow.ts meta.block.ts meta.brace.round.ts
^
source.ts meta.arrow.ts meta.block.ts
^
source.ts meta.arrow.ts meta.block.ts meta.block.ts punctuation.definition.block.ts
^
source.ts meta.arrow.ts meta.block.ts meta.block.ts
^^^^^^
source.ts meta.arrow.ts meta.block.ts meta.block.ts keyword.control.flow.ts
^
source.ts meta.arrow.ts meta.block.ts meta.block.ts
^
source.ts meta.arrow.ts meta.block.ts meta.block.ts keyword.operator.arithmetic.ts
^
source.ts meta.arrow.ts meta.block.ts meta.block.ts constant.numeric.decimal.ts
^
source.ts meta.arrow.ts meta.block.ts meta.block.ts punctuation.terminator.statement.ts
^
source.ts meta.arrow.ts meta.block.ts meta.block.ts
^
source.ts meta.arrow.ts meta.block.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts meta.arrow.ts meta.block.ts
> return 0;
^^^^
source.ts meta.arrow.ts meta.block.ts
^^^^^^
source.ts meta.arrow.ts meta.block.ts keyword.control.flow.ts
^
source.ts meta.arrow.ts meta.block.ts
^
source.ts meta.arrow.ts meta.block.ts constant.numeric.decimal.ts
^
source.ts meta.arrow.ts meta.block.ts punctuation.terminator.statement.ts
^^
source.ts meta.arrow.ts meta.block.ts
> });
^^
source.ts meta.arrow.ts meta.block.ts
^
source.ts meta.arrow.ts meta.block.ts punctuation.definition.block.ts
^
source.ts meta.brace.round.ts
^
source.ts punctuation.terminator.statement.ts
^^
source.ts
>
^
source.ts

11
tests/cases/Issue562.ts Normal file
Просмотреть файл

@ -0,0 +1,11 @@
// @onlyOwnGrammar - As this has cast
yield <ClassD>10;
(yield <ClassD>10);
function foo() {
return <ClassD>10;
}
topYields.sort ((share1,share2) => {
if (share1.yield < share2.yield) { return 1; }
if (share1.yield > share2.yield) { return -1; }
return 0;
});