Relax the parameter matching lookup rule for arrow detection

Fixes #540 partly (only case 7)
This commit is contained in:
Sheetal Nandi 2017-11-09 10:18:32 -08:00
Родитель b6e350046e
Коммит 8361b1a232
5 изменённых файлов: 663 добавлений и 13 удалений

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

@ -29,7 +29,7 @@ variables:
# arrow function possible to detect only with => on same line
(
{{typeParameters}}? # typeparameters
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
\s*=> # arrow operator
)

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

@ -408,7 +408,7 @@
# arrow function possible to detect only with =&gt; on same line
(
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
\s*=&gt; # arrow operator
)
@ -796,7 +796,7 @@
# arrow function possible to detect only with =&gt; on same line
(
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
\s*=&gt; # arrow operator
)
@ -1182,7 +1182,7 @@
# arrow function possible to detect only with =&gt; on same line
(
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
\s*=&gt; # arrow operator
)
@ -1623,7 +1623,7 @@
# arrow function possible to detect only with =&gt; on same line
(
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
\s*=&gt; # arrow operator
)
@ -3098,7 +3098,7 @@
# arrow function possible to detect only with =&gt; on same line
(
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
\s*=&gt; # arrow operator
)
@ -4335,7 +4335,7 @@
# arrow function possible to detect only with =&gt; on same line
(
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
\s*=&gt; # arrow operator
)

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

@ -412,7 +412,7 @@
# arrow function possible to detect only with =&gt; on same line
(
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
\s*=&gt; # arrow operator
)
@ -800,7 +800,7 @@
# arrow function possible to detect only with =&gt; on same line
(
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
\s*=&gt; # arrow operator
)
@ -1186,7 +1186,7 @@
# arrow function possible to detect only with =&gt; on same line
(
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
\s*=&gt; # arrow operator
)
@ -1627,7 +1627,7 @@
# arrow function possible to detect only with =&gt; on same line
(
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
\s*=&gt; # arrow operator
)
@ -3102,7 +3102,7 @@
# arrow function possible to detect only with =&gt; on same line
(
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
\s*=&gt; # arrow operator
)
@ -4281,7 +4281,7 @@
# arrow function possible to detect only with =&gt; on same line
(
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
\s*=&gt; # arrow operator
)

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

@ -0,0 +1,610 @@
original file
-----------------------------------
// 1. Correct highlighting
doSomething = (param, { a = "default" } = {}) => {
//noop
}
// 2. Incorrect highlighting - limitation of grammar
doSomething = (param, {
a = "default"
} = {}) => {
//noop
}
// 3. Correct highlighting
doSomething(param, {
a = "default"
} = {}) {
//noop
}
// 4. Correct highlighting
doSomething(param, { a = "default" } = {}) {
//noop
}
// 5. Correct highlighting (notice config module)
doSomething(param, {
a = config.get("a")
} = {}) {
//noop
}
// 6. Correct highlighting (notice config module)
doSomething(param, { a = config.get("a") } = {}) {
//noop
}
// 7. Incorrect highlighting (notice config module) while 1. does
doSomething = (param, { a = config.get("a") } = {}) => {
//noop
}
-----------------------------------
Grammar: TypeScript.tmLanguage
-----------------------------------
>// 1. Correct highlighting
^^
source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^^^^^^^^^^^^^^^^^^^^^
source.ts comment.line.double-slash.ts
>doSomething = (param, { a = "default" } = {}) => {
^^^^^^^^^^^
source.ts entity.name.function.ts
^
source.ts
^
source.ts keyword.operator.assignment.ts
^
source.ts meta.arrow.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 meta.parameter.object-binding-pattern.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts punctuation.definition.binding-pattern.object.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts variable.parameter.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts keyword.operator.assignment.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^^^^^^^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts string.quoted.double.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts string.quoted.double.ts punctuation.definition.string.end.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts punctuation.definition.binding-pattern.object.ts
^
source.ts meta.arrow.ts meta.parameters.ts
^
source.ts meta.arrow.ts meta.parameters.ts keyword.operator.assignment.ts
^
source.ts meta.arrow.ts meta.parameters.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.objectliteral.ts punctuation.definition.block.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
> //noop
^^^^
source.ts meta.arrow.ts meta.block.ts punctuation.whitespace.comment.leading.ts
^^
source.ts meta.arrow.ts meta.block.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^
source.ts meta.arrow.ts meta.block.ts comment.line.double-slash.ts
>}
^
source.ts meta.arrow.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts
>
^^
source.ts
>// 2. Incorrect highlighting - limitation of grammar
^^
source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
source.ts comment.line.double-slash.ts
>doSomething = (param, {
^^^^^^^^^^^
source.ts variable.other.readwrite.ts
^
source.ts
^
source.ts keyword.operator.assignment.ts
^
source.ts
^
source.ts meta.brace.round.ts
^^^^^
source.ts variable.other.readwrite.ts
^
source.ts punctuation.separator.comma.ts
^
source.ts
^
source.ts meta.objectliteral.ts punctuation.definition.block.ts
^^^
source.ts meta.objectliteral.ts
> a = "default"
^^^^
source.ts meta.objectliteral.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts variable.other.readwrite.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts keyword.operator.assignment.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^^^^^^^
source.ts meta.objectliteral.ts meta.object.member.ts string.quoted.double.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts string.quoted.double.ts punctuation.definition.string.end.ts
^^
source.ts meta.objectliteral.ts meta.object.member.ts
>} = {}) => {
^
source.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts
^
source.ts keyword.operator.assignment.ts
^
source.ts
^
source.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts meta.brace.round.ts
^
source.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
> //noop
^^^^
source.ts meta.arrow.ts meta.block.ts punctuation.whitespace.comment.leading.ts
^^
source.ts meta.arrow.ts meta.block.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^
source.ts meta.arrow.ts meta.block.ts comment.line.double-slash.ts
>}
^
source.ts meta.arrow.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts
>
^^
source.ts
>// 3. Correct highlighting
^^
source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^^^^^^^^^^^^^^^^^^^^^
source.ts comment.line.double-slash.ts
>doSomething(param, {
^^^^^^^^^^^
source.ts meta.function-call.ts entity.name.function.ts
^
source.ts meta.brace.round.ts
^^^^^
source.ts variable.other.readwrite.ts
^
source.ts punctuation.separator.comma.ts
^
source.ts
^
source.ts meta.objectliteral.ts punctuation.definition.block.ts
^^
source.ts meta.objectliteral.ts
> a = "default"
^^^^
source.ts meta.objectliteral.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts variable.other.readwrite.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts keyword.operator.assignment.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^^^^^^^
source.ts meta.objectliteral.ts meta.object.member.ts string.quoted.double.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts string.quoted.double.ts punctuation.definition.string.end.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts
>} = {}) {
^
source.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts
^
source.ts keyword.operator.assignment.ts
^
source.ts
^
source.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts meta.brace.round.ts
^
source.ts
^
source.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts meta.block.ts
> //noop
^^^^
source.ts meta.block.ts punctuation.whitespace.comment.leading.ts
^^
source.ts meta.block.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^
source.ts meta.block.ts comment.line.double-slash.ts
>}
^
source.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts
>
^^
source.ts
>// 4. Correct highlighting
^^
source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^^^^^^^^^^^^^^^^^^^^^
source.ts comment.line.double-slash.ts
>doSomething(param, { a = "default" } = {}) {
^^^^^^^^^^^
source.ts meta.function-call.ts entity.name.function.ts
^
source.ts meta.brace.round.ts
^^^^^
source.ts variable.other.readwrite.ts
^
source.ts punctuation.separator.comma.ts
^
source.ts
^
source.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts meta.objectliteral.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts variable.other.readwrite.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts keyword.operator.assignment.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^^^^^^^
source.ts meta.objectliteral.ts meta.object.member.ts string.quoted.double.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts string.quoted.double.ts punctuation.definition.string.end.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts
^
source.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts
^
source.ts keyword.operator.assignment.ts
^
source.ts
^
source.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts meta.brace.round.ts
^
source.ts
^
source.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts meta.block.ts
> //noop
^^^^
source.ts meta.block.ts punctuation.whitespace.comment.leading.ts
^^
source.ts meta.block.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^
source.ts meta.block.ts comment.line.double-slash.ts
>}
^
source.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts
>
^^
source.ts
>// 5. Correct highlighting (notice config module)
^^
source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
source.ts comment.line.double-slash.ts
>doSomething(param, {
^^^^^^^^^^^
source.ts meta.function-call.ts entity.name.function.ts
^
source.ts meta.brace.round.ts
^^^^^
source.ts variable.other.readwrite.ts
^
source.ts punctuation.separator.comma.ts
^
source.ts
^
source.ts meta.objectliteral.ts punctuation.definition.block.ts
^^
source.ts meta.objectliteral.ts
> a = config.get("a")
^^^^
source.ts meta.objectliteral.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts variable.other.readwrite.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts keyword.operator.assignment.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts
^^^^^^
source.ts meta.objectliteral.ts meta.object.member.ts meta.function-call.ts variable.other.object.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts meta.function-call.ts punctuation.accessor.ts
^^^
source.ts meta.objectliteral.ts meta.object.member.ts meta.function-call.ts support.function.dom.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts meta.brace.round.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts string.quoted.double.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts string.quoted.double.ts punctuation.definition.string.end.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts meta.brace.round.ts
^^
source.ts meta.objectliteral.ts meta.object.member.ts
>} = {}) {
^
source.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts
^
source.ts keyword.operator.assignment.ts
^
source.ts
^
source.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts meta.brace.round.ts
^
source.ts
^
source.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts meta.block.ts
> //noop
^^^^
source.ts meta.block.ts punctuation.whitespace.comment.leading.ts
^^
source.ts meta.block.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^
source.ts meta.block.ts comment.line.double-slash.ts
>}
^
source.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts
>
^^
source.ts
>// 6. Correct highlighting (notice config module)
^^
source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
source.ts comment.line.double-slash.ts
>doSomething(param, { a = config.get("a") } = {}) {
^^^^^^^^^^^
source.ts meta.function-call.ts entity.name.function.ts
^
source.ts meta.brace.round.ts
^^^^^
source.ts variable.other.readwrite.ts
^
source.ts punctuation.separator.comma.ts
^
source.ts
^
source.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts meta.objectliteral.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts variable.other.readwrite.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts keyword.operator.assignment.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts
^^^^^^
source.ts meta.objectliteral.ts meta.object.member.ts meta.function-call.ts variable.other.object.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts meta.function-call.ts punctuation.accessor.ts
^^^
source.ts meta.objectliteral.ts meta.object.member.ts meta.function-call.ts support.function.dom.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts meta.brace.round.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts string.quoted.double.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts string.quoted.double.ts punctuation.definition.string.end.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts meta.brace.round.ts
^
source.ts meta.objectliteral.ts meta.object.member.ts
^
source.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts
^
source.ts keyword.operator.assignment.ts
^
source.ts
^
source.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts meta.brace.round.ts
^
source.ts
^
source.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts meta.block.ts
> //noop
^^^^
source.ts meta.block.ts punctuation.whitespace.comment.leading.ts
^^
source.ts meta.block.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^
source.ts meta.block.ts comment.line.double-slash.ts
>}
^
source.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts
>
^^
source.ts
>// 7. Incorrect highlighting (notice config module) while 1. does
^^
source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
source.ts comment.line.double-slash.ts
>doSomething = (param, { a = config.get("a") } = {}) => {
^^^^^^^^^^^
source.ts entity.name.function.ts
^
source.ts
^
source.ts keyword.operator.assignment.ts
^
source.ts meta.arrow.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 meta.parameter.object-binding-pattern.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts punctuation.definition.binding-pattern.object.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts variable.parameter.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts keyword.operator.assignment.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts
^^^^^^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts meta.function-call.ts variable.other.object.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts meta.function-call.ts punctuation.accessor.ts
^^^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts meta.function-call.ts support.function.dom.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts meta.brace.round.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts string.quoted.double.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts string.quoted.double.ts punctuation.definition.string.end.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts meta.brace.round.ts
^^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.parameter.object-binding-pattern.ts punctuation.definition.binding-pattern.object.ts
^
source.ts meta.arrow.ts meta.parameters.ts
^
source.ts meta.arrow.ts meta.parameters.ts keyword.operator.assignment.ts
^
source.ts meta.arrow.ts meta.parameters.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts meta.arrow.ts meta.parameters.ts meta.objectliteral.ts punctuation.definition.block.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
> //noop
^^^^
source.ts meta.arrow.ts meta.block.ts punctuation.whitespace.comment.leading.ts
^^
source.ts meta.arrow.ts meta.block.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^
source.ts meta.arrow.ts meta.block.ts comment.line.double-slash.ts
>}
^
source.ts meta.arrow.ts meta.block.ts punctuation.definition.block.ts

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

@ -0,0 +1,40 @@
// 1. Correct highlighting
doSomething = (param, { a = "default" } = {}) => {
//noop
}
// 2. Incorrect highlighting - limitation of grammar
doSomething = (param, {
a = "default"
} = {}) => {
//noop
}
// 3. Correct highlighting
doSomething(param, {
a = "default"
} = {}) {
//noop
}
// 4. Correct highlighting
doSomething(param, { a = "default" } = {}) {
//noop
}
// 5. Correct highlighting (notice config module)
doSomething(param, {
a = config.get("a")
} = {}) {
//noop
}
// 6. Correct highlighting (notice config module)
doSomething(param, { a = config.get("a") } = {}) {
//noop
}
// 7. Incorrect highlighting (notice config module) while 1. does
doSomething = (param, { a = config.get("a") } = {}) => {
//noop
}