Fixes the cast expression matching

Fixes #496
This commit is contained in:
Sheetal Nandi 2017-09-13 14:40:50 -07:00
Родитель f0fc7a0a00
Коммит cf95b1ec37
4 изменённых файлов: 96 добавлений и 2 удалений

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

@ -1554,7 +1554,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|[=(,:>*?]))\s*(<)(?!<?\=)
begin: (?:(?<=return|throw|yield|await|default|[=(,:>+*?]))\s*(<)(?!<?\=)
beginCaptures:
'1': { name: meta.brace.angle.ts }
end: (\>)\s*

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

@ -4255,7 +4255,7 @@
<key>name</key>
<string>cast.expr.ts</string>
<key>begin</key>
<string>(?:(?&lt;=return|throw|yield|await|default|[=(,:&gt;*?]))\s*(&lt;)(?!&lt;?\=)</string>
<string>(?:(?&lt;=return|throw|yield|await|default|[=(,:&gt;+*?]))\s*(&lt;)(?!&lt;?\=)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>

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

@ -0,0 +1,90 @@
original file
-----------------------------------
// @onlyOwnGrammar - As this has cast expression
var x = 0;
var y = 1;
var z = <number>x + <number>y;
-----------------------------------
Grammar: TypeScript.tmLanguage
-----------------------------------
>// @onlyOwnGrammar - As this has cast expression
^^
source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
source.ts comment.line.double-slash.ts
>var x = 0;
^^^
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 punctuation.terminator.statement.ts
^^
source.ts
>var y = 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 punctuation.terminator.statement.ts
^^
source.ts
>var z = <number>x + <number>y;
^^^
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 cast.expr.ts
^
source.ts meta.var.expr.ts cast.expr.ts meta.brace.angle.ts
^^^^^^
source.ts meta.var.expr.ts cast.expr.ts support.type.primitive.ts
^
source.ts meta.var.expr.ts cast.expr.ts meta.brace.angle.ts
^
source.ts meta.var.expr.ts variable.other.readwrite.ts
^
source.ts meta.var.expr.ts
^
source.ts meta.var.expr.ts keyword.operator.arithmetic.ts
^
source.ts meta.var.expr.ts cast.expr.ts
^
source.ts meta.var.expr.ts cast.expr.ts meta.brace.angle.ts
^^^^^^
source.ts meta.var.expr.ts cast.expr.ts support.type.primitive.ts
^
source.ts meta.var.expr.ts cast.expr.ts meta.brace.angle.ts
^
source.ts meta.var.expr.ts variable.other.readwrite.ts
^
source.ts punctuation.terminator.statement.ts

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

@ -0,0 +1,4 @@
// @onlyOwnGrammar - As this has cast expression
var x = 0;
var y = 1;
var z = <number>x + <number>y;