Fix multiline type annotation in parameters

Fixes #715
This commit is contained in:
Sheetal Nandi 2019-01-29 14:22:02 -08:00
Родитель 4cf78724e8
Коммит a42e5cbe14
9 изменённых файлов: 262 добавлений и 9 удалений

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

@ -859,7 +859,7 @@ repository:
- include: '#decorator'
- include: '#destructuring-parameter'
- include: '#parameter-name'
- include: '#type-annotation'
- include: '#parameter-type-annotation'
- include: '#variable-initializer'
- name: punctuation.separator.parameter.ts
match: ','
@ -2074,6 +2074,16 @@ repository:
patterns:
- include: '#type'
parameter-type-annotation:
patterns:
- name: meta.type.annotation.ts
begin: (:)
beginCaptures:
'1': { name: keyword.operator.type.annotation.ts }
end: (?=[,)])|(?==[^>])
patterns:
- include: '#type'
#return type
return-type:
patterns:

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

@ -2766,7 +2766,7 @@
</dict>
<dict>
<key>include</key>
<string>#type-annotation</string>
<string>#parameter-type-annotation</string>
</dict>
<dict>
<key>include</key>
@ -6330,6 +6330,35 @@
</dict>
</array>
</dict>
<key>parameter-type-annotation</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>name</key>
<string>meta.type.annotation.ts</string>
<key>begin</key>
<string>(:)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.operator.type.annotation.ts</string>
</dict>
</dict>
<key>end</key>
<string>(?=[,)])|(?==[^&gt;])</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#type</string>
</dict>
</array>
</dict>
</array>
</dict>
<key>return-type</key>
<dict>
<key>patterns</key>

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

@ -2770,7 +2770,7 @@
</dict>
<dict>
<key>include</key>
<string>#type-annotation</string>
<string>#parameter-type-annotation</string>
</dict>
<dict>
<key>include</key>
@ -6252,6 +6252,35 @@
</dict>
</array>
</dict>
<key>parameter-type-annotation</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>name</key>
<string>meta.type.annotation.tsx</string>
<key>begin</key>
<string>(:)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.operator.type.annotation.tsx</string>
</dict>
</dict>
<key>end</key>
<string>(?=[,)])|(?==[^&gt;])</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#type</string>
</dict>
</array>
</dict>
</array>
</dict>
<key>return-type</key>
<dict>
<key>patterns</key>

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

@ -132,7 +132,7 @@ Grammar: TypeScript.tmLanguage
source.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts support.type.primitive.ts
> ) { }
^^^^
source.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts
source.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts
^
source.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts punctuation.definition.parameters.end.ts
^

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

@ -211,7 +211,7 @@ Grammar: TypeScript.tmLanguage
source.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.function.return.ts support.type.primitive.ts
> ): void {
^^
source.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts
source.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts
^
source.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts punctuation.definition.parameters.end.ts
^

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

@ -0,0 +1,174 @@
original file
-----------------------------------
interface TestCafeFactory {
Selector(
init:
| string
| ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection)
| Selector
| NodeSnapshot
| SelectorPromise,
options?: SelectorOptions
): Selector;
}
-----------------------------------
Grammar: TypeScript.tmLanguage
-----------------------------------
>interface TestCafeFactory {
^^^^^^^^^
source.ts meta.interface.ts storage.type.interface.ts
^
source.ts meta.interface.ts
^^^^^^^^^^^^^^^
source.ts meta.interface.ts entity.name.type.interface.ts
^
source.ts meta.interface.ts
^
source.ts meta.interface.ts punctuation.definition.block.ts
> Selector(
^^
source.ts meta.interface.ts meta.method.declaration.ts
^^^^^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.definition.method.ts entity.name.function.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
> init:
^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts
^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts variable.parameter.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
> | string
^^^^^^^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts
^^^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts support.type.primitive.ts
> | ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection)
^^^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.brace.round.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.ts meta.parameters.ts keyword.operator.rest.ts
^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.ts meta.parameters.ts variable.parameter.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.ts meta.parameters.ts meta.type.annotation.ts
^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.ts meta.parameters.ts meta.type.annotation.ts support.type.primitive.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.ts meta.parameters.ts meta.type.annotation.ts meta.type.tuple.ts meta.brace.square.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.ts meta.parameters.ts meta.type.annotation.ts meta.type.tuple.ts meta.brace.square.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.ts meta.parameters.ts punctuation.definition.parameters.end.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts
^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.return.ts storage.type.function.arrow.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.return.ts
^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.return.ts entity.name.type.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.return.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.return.ts keyword.operator.type.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.return.ts
^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.return.ts entity.name.type.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.return.ts meta.type.tuple.ts meta.brace.square.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.return.ts meta.type.tuple.ts meta.brace.square.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.return.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.return.ts keyword.operator.type.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.return.ts
^^^^^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.return.ts entity.name.type.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.return.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.return.ts keyword.operator.type.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.return.ts
^^^^^^^^^^^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.type.function.return.ts entity.name.type.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.brace.round.ts
> | Selector
^^^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts
^^^^^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts entity.name.type.ts
> | NodeSnapshot
^^^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts
^^^^^^^^^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts entity.name.type.ts
> | SelectorPromise,
^^^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts
^^^^^^^^^^^^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts entity.name.type.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts punctuation.separator.parameter.ts
> options?: SelectorOptions
^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts
^^^^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts variable.parameter.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts keyword.operator.optional.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts
^^^^^^^^^^^^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts entity.name.type.ts
> ): Selector;
^^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.parameters.ts punctuation.definition.parameters.end.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.return.type.ts keyword.operator.type.annotation.ts
^
source.ts meta.interface.ts meta.method.declaration.ts meta.return.type.ts
^^^^^^^^
source.ts meta.interface.ts meta.method.declaration.ts meta.return.type.ts entity.name.type.ts
^
source.ts meta.interface.ts punctuation.terminator.statement.ts
>}
^
source.ts meta.interface.ts punctuation.definition.block.ts

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

@ -73,12 +73,12 @@ Grammar: TypeScript.tmLanguage
^
source.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.function.return.ts
^^
source.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts comment.line.double-slash.ts punctuation.definition.comment.ts
source.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
source.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts comment.line.double-slash.ts
source.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts comment.line.double-slash.ts
> ) {
^^^^
source.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts
source.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts
^
source.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts punctuation.definition.parameters.end.ts
^

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

@ -27,7 +27,7 @@ Grammar: TypeScript.tmLanguage
^
[4, 31]: source.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts meta.type.function.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[4, 44]: source.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts comment.line.double-slash.ts
[4, 44]: source.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts comment.line.double-slash.ts
> ) {
>
^^^^^^^^^

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

@ -0,0 +1,11 @@
interface TestCafeFactory {
Selector(
init:
| string
| ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection)
| Selector
| NodeSnapshot
| SelectorPromise,
options?: SelectorOptions
): Selector;
}