Fix object literal detection after cast expression

Fixes Microsoft/TypeScript#24410
This commit is contained in:
Sheetal Nandi 2018-05-25 14:23:44 -07:00
Родитель b7358ce33f
Коммит ef418e5849
5 изменённых файлов: 113 добавлений и 3 удалений

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

@ -1089,7 +1089,7 @@ repository:
#object literals
after-operator-block-as-object-literal:
name: meta.objectliteral.ts
begin: (?<!\+\+|--)(?<=[:=(,\[?+!]|{{lookBehindAwait}}|{{lookBehindReturn}}|{{lookBehindYield}}|{{lookBehindThrow}}|{{lookBehindIn}}|{{lookBehindOf}}|{{lookBehindTypeof}}|&&|\|\||\*)\s*(\{)
begin: (?<!\+\+|--)(?<=[:=(,\[?+!>]|{{lookBehindAwait}}|{{lookBehindReturn}}|{{lookBehindYield}}|{{lookBehindThrow}}|{{lookBehindIn}}|{{lookBehindOf}}|{{lookBehindTypeof}}|&&|\|\||\*)\s*(\{)
beginCaptures:
'1': { name: punctuation.definition.block.ts }
end: \}

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

@ -3449,7 +3449,7 @@
<key>name</key>
<string>meta.objectliteral.ts</string>
<key>begin</key>
<string>(?&lt;!\+\+|--)(?&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>
<string>(?&lt;!\+\+|--)(?&lt;=[:=(,\[?+!&gt;]|^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>

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

@ -3453,7 +3453,7 @@
<key>name</key>
<string>meta.objectliteral.tsx</string>
<key>begin</key>
<string>(?&lt;!\+\+|--)(?&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>
<string>(?&lt;!\+\+|--)(?&lt;=[:=(,\[?+!&gt;]|^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>

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

@ -0,0 +1,100 @@
original file
-----------------------------------
// @onlyOwnGrammar - As this hasc cast
// From Microsoft/TypeScript#24410
a
.map(b => {
return <C>{
c: { }
};
})
// comment
-----------------------------------
Grammar: TypeScript.tmLanguage
-----------------------------------
>// @onlyOwnGrammar - As this hasc cast
^^
source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
source.ts comment.line.double-slash.ts
>// From Microsoft/TypeScript#24410
^^
source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
source.ts comment.line.double-slash.ts
>a
^
source.ts variable.other.readwrite.ts
> .map(b => {
^
source.ts
^
source.ts meta.function-call.ts punctuation.accessor.ts
^^^
source.ts meta.function-call.ts entity.name.function.ts
^
source.ts meta.brace.round.ts
^
source.ts meta.arrow.ts variable.parameter.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
> return <C>{
^^
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 cast.expr.ts
^
source.ts meta.arrow.ts meta.block.ts cast.expr.ts meta.brace.angle.ts
^
source.ts meta.arrow.ts meta.block.ts cast.expr.ts entity.name.type.ts
^
source.ts meta.arrow.ts meta.block.ts cast.expr.ts meta.brace.angle.ts
^
source.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts punctuation.definition.block.ts
> c: { }
^^^
source.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts
^
source.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts
^
source.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts punctuation.separator.key-value.ts
^
source.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts meta.object.member.ts
^
source.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts meta.object.member.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts meta.object.member.ts meta.objectliteral.ts
^
source.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts meta.object.member.ts meta.objectliteral.ts punctuation.definition.block.ts
> };
^^
source.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts meta.object.member.ts
^
source.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts punctuation.definition.block.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 punctuation.definition.block.ts
^
source.ts meta.brace.round.ts
>
^
source.ts
>// comment
^^
source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^^^^
source.ts comment.line.double-slash.ts

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

@ -0,0 +1,10 @@
// @onlyOwnGrammar - As this hasc cast
// From Microsoft/TypeScript#24410
a
.map(b => {
return <C>{
c: { }
};
})
// comment