Fix the cast expression detection logic to include few more expression locations that would be operator location
Fixes #450
This commit is contained in:
Родитель
d61f62a8f2
Коммит
ac0314e5fa
|
@ -1485,7 +1485,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: \>
|
||||
|
|
|
@ -4058,7 +4058,7 @@
|
|||
<key>name</key>
|
||||
<string>cast.expr.ts</string>
|
||||
<key>begin</key>
|
||||
<string>(?:(?<=return|throw|yield|await|default|[=(,:>*]))\s*(<)(?!<?\=)</string>
|
||||
<string>(?:(?<=return|throw|yield|await|default|[=(,:>*?]))\s*(<)(?!<?\=)</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
original file
|
||||
-----------------------------------
|
||||
// @onlyOwnGrammar - As this has type assertion
|
||||
let a = true ? <number>1 : <number>2;
|
||||
-----------------------------------
|
||||
|
||||
Grammar: TypeScript.tmLanguage
|
||||
-----------------------------------
|
||||
>// @onlyOwnGrammar - As this has type assertion
|
||||
^^
|
||||
source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
source.ts comment.line.double-slash.ts
|
||||
>let a = true ? <number>1 : <number>2;
|
||||
^^^
|
||||
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.language.boolean.true.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts keyword.operator.ternary.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 constant.numeric.decimal.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts keyword.operator.ternary.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 constant.numeric.decimal.ts
|
||||
^
|
||||
source.ts punctuation.terminator.statement.ts
|
|
@ -0,0 +1,2 @@
|
|||
// @onlyOwnGrammar - As this has type assertion
|
||||
let a = true ? <number>1 : <number>2;
|
Загрузка…
Ссылка в новой задаче