Handle the scenario of => ( followed by new line where we treat that as possibly arrow

This adds string literal matching in the binding pattern for parameter declarations as object literals will be treated as destructured parameters
Fixes #608
This commit is contained in:
Sheetal Nandi 2018-04-27 16:07:22 -07:00
Родитель 23b94ac95d
Коммит 2b74d88c64
5 изменённых файлов: 87 добавлений и 0 удалений

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

@ -310,6 +310,7 @@ repository:
binding-element:
patterns:
- include: '#comment'
- include: '#string'
- include: '#object-binding-pattern'
- include: '#array-binding-pattern'
- include: '#destructuring-variable-rest'
@ -404,6 +405,7 @@ repository:
parameter-binding-element:
patterns:
- include: '#comment'
- include: '#string'
- include: '#parameter-object-binding-pattern'
- include: '#parameter-array-binding-pattern'
- include: '#destructuring-parameter-rest'

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

@ -726,6 +726,10 @@
<key>include</key>
<string>#comment</string>
</dict>
<dict>
<key>include</key>
<string>#string</string>
</dict>
<dict>
<key>include</key>
<string>#object-binding-pattern</string>
@ -1121,6 +1125,10 @@
<key>include</key>
<string>#comment</string>
</dict>
<dict>
<key>include</key>
<string>#string</string>
</dict>
<dict>
<key>include</key>
<string>#parameter-object-binding-pattern</string>

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

@ -730,6 +730,10 @@
<key>include</key>
<string>#comment</string>
</dict>
<dict>
<key>include</key>
<string>#string</string>
</dict>
<dict>
<key>include</key>
<string>#object-binding-pattern</string>
@ -1125,6 +1129,10 @@
<key>include</key>
<string>#comment</string>
</dict>
<dict>
<key>include</key>
<string>#string</string>
</dict>
<dict>
<key>include</key>
<string>#parameter-object-binding-pattern</string>

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

@ -0,0 +1,66 @@
original file
-----------------------------------
const example = () => (
{example: "`x=y`"} // everything after this line is highlighted like a string
)
-----------------------------------
Grammar: TypeScript.tmLanguage
-----------------------------------
>const example = () => (
^^^^^
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 entity.name.function.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 meta.arrow.ts
^
source.ts meta.var.expr.ts meta.arrow.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
^
source.ts meta.var.expr.ts meta.arrow.ts meta.parameters.ts punctuation.definition.parameters.end.ts
^
source.ts meta.var.expr.ts meta.arrow.ts
^^
source.ts meta.var.expr.ts meta.arrow.ts storage.type.function.arrow.ts
^
source.ts meta.var.expr.ts meta.arrow.ts
^
source.ts meta.var.expr.ts meta.arrow.ts meta.brace.round.ts
> {example: "`x=y`"} // everything after this line is highlighted like a string
^^
source.ts meta.var.expr.ts meta.arrow.ts meta.parameter.object-binding-pattern.ts
^
source.ts meta.var.expr.ts meta.arrow.ts meta.parameter.object-binding-pattern.ts punctuation.definition.binding-pattern.object.ts
^^^^^^^
source.ts meta.var.expr.ts meta.arrow.ts meta.parameter.object-binding-pattern.ts variable.object.property.ts
^
source.ts meta.var.expr.ts meta.arrow.ts meta.parameter.object-binding-pattern.ts punctuation.destructuring.ts
^
source.ts meta.var.expr.ts meta.arrow.ts meta.parameter.object-binding-pattern.ts
^
source.ts meta.var.expr.ts meta.arrow.ts meta.parameter.object-binding-pattern.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^^^^^
source.ts meta.var.expr.ts meta.arrow.ts meta.parameter.object-binding-pattern.ts string.quoted.double.ts
^
source.ts meta.var.expr.ts meta.arrow.ts meta.parameter.object-binding-pattern.ts string.quoted.double.ts punctuation.definition.string.end.ts
^
source.ts meta.var.expr.ts meta.arrow.ts meta.parameter.object-binding-pattern.ts punctuation.definition.binding-pattern.object.ts
^
source.ts meta.var.expr.ts meta.arrow.ts
^^
source.ts meta.var.expr.ts meta.arrow.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
source.ts meta.var.expr.ts meta.arrow.ts comment.line.double-slash.ts
>)
^
source.ts meta.var.expr.ts meta.arrow.ts meta.brace.round.ts
>
^
source.ts

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

@ -0,0 +1,3 @@
const example = () => (
{example: "`x=y`"} // everything after this line is highlighted like a string
)