Treat ( followed by new line as parameter context for arrow, falling back to expression
Handles #481, #498, #507, #524, #539, #550
This commit is contained in:
Родитель
1d2625adfc
Коммит
fb1064ac57
|
@ -20,6 +20,7 @@ variables:
|
|||
typeArgumentsStart: ({{typeParamersStart}}|(\'[^\']*\')|(\"[^\"]*\")|(\`[^\`]*\`))
|
||||
typeArgumentsInnerExpressionPart: '[^<>\(]|{{matchingParenthesis}}'
|
||||
typeArguments: (<\s*{{typeArgumentsStart}}({{typeArgumentsInnerExpressionPart}}|\<\s*{{typeArgumentsStart}}({{typeArgumentsInnerExpressionPart}})*\>)*>\s*)
|
||||
returnTypeOfArrow: '\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+'
|
||||
arrowLookup: |-
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
|
@ -36,7 +37,7 @@ variables:
|
|||
(
|
||||
{{typeParameters}}? # typeparameters
|
||||
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
(\s*:{{returnTypeOfArrow}})? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
functionOrArrowLookup: |-
|
||||
|
@ -47,6 +48,7 @@ variables:
|
|||
({{identifier}}\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
([\(]\s*$) | # during lookup treat ( followed by line end as arrow
|
||||
{{arrowLookup}}
|
||||
))
|
||||
)
|
||||
|
@ -66,6 +68,7 @@ variables:
|
|||
))
|
||||
))
|
||||
))
|
||||
arrowFunctionEnd: (?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))
|
||||
|
||||
patterns:
|
||||
- include: '#directives'
|
||||
|
@ -147,6 +150,7 @@ repository:
|
|||
- include: '#function-call'
|
||||
- include: '#literal'
|
||||
- include: '#support-objects'
|
||||
- include: '#paren-expression-possibly-arrow'
|
||||
- include: '#paren-expression'
|
||||
|
||||
expressionPunctuations:
|
||||
|
@ -548,7 +552,7 @@ repository:
|
|||
)
|
||||
beginCaptures:
|
||||
'1': { name: storage.modifier.async.ts }
|
||||
end: (?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))
|
||||
end: '{{arrowFunctionEnd}}'
|
||||
patterns:
|
||||
- include: '#comment'
|
||||
- include: '#type-parameters'
|
||||
|
@ -603,6 +607,10 @@ repository:
|
|||
endCaptures:
|
||||
'0': { name: punctuation.definition.parameters.end.ts }
|
||||
patterns:
|
||||
- include: '#function-parameters-body'
|
||||
|
||||
function-parameters-body:
|
||||
patterns:
|
||||
- include: '#comment'
|
||||
- include: '#decorator'
|
||||
- include: '#destructuring-parameter'
|
||||
|
@ -1084,6 +1092,23 @@ repository:
|
|||
- include: '#class-declaration'
|
||||
- include: '#type'
|
||||
|
||||
# when ( is followed by end of line, it could be arrow parameter decarations, so inside this match as if parameter falling back to expression
|
||||
# but do this only from expression and as last resort
|
||||
paren-expression-possibly-arrow:
|
||||
patterns:
|
||||
- begin: (\()(?=\s*$)
|
||||
beginCaptures:
|
||||
'1': {name: meta.brace.round.ts }
|
||||
end: \)
|
||||
endCaptures:
|
||||
'0': {name: meta.brace.round.ts }
|
||||
patterns:
|
||||
- include: '#expressionWithoutIdentifiers'
|
||||
- include: '#function-parameters-body'
|
||||
- include: '#identifiers'
|
||||
- include: '#expressionPunctuations'
|
||||
- include: '#possibly-arrow-return-type'
|
||||
|
||||
paren-expression:
|
||||
begin: \(
|
||||
beginCaptures:
|
||||
|
@ -1093,7 +1118,6 @@ repository:
|
|||
'0': {name: meta.brace.round.ts }
|
||||
patterns:
|
||||
- include: '#expression'
|
||||
- include: '#punctuation-comma'
|
||||
|
||||
#cast expression
|
||||
cast:
|
||||
|
@ -1645,7 +1669,21 @@ repository:
|
|||
begin: '(?<=\))\s*(:)'
|
||||
beginCaptures:
|
||||
'1': { name: keyword.operator.type.annotation.ts }
|
||||
end: (?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))
|
||||
end: '{{arrowFunctionEnd}}'
|
||||
patterns:
|
||||
- include: '#arrow-return-type-body'
|
||||
|
||||
#This is the check if the exoression '): something =>'' can be matched as return type of arrow
|
||||
possibly-arrow-return-type:
|
||||
begin: (?<=\))\s*(:)(?={{returnTypeOfArrow}}\s*=>)
|
||||
beginCaptures:
|
||||
'1': { name: meta.arrow.ts meta.return.type.arrow.ts keyword.operator.type.annotation.ts }
|
||||
end: '{{arrowFunctionEnd}}'
|
||||
contentName: meta.arrow.ts meta.return.type.arrow.ts
|
||||
patterns:
|
||||
- include: '#arrow-return-type-body'
|
||||
|
||||
arrow-return-type-body:
|
||||
patterns:
|
||||
# TODO: handle the fn and constructor type specifically.
|
||||
# Handle returning of object type specifically here so as to not confuse it with the start of function block
|
||||
|
|
|
@ -275,6 +275,10 @@
|
|||
<key>include</key>
|
||||
<string>#support-objects</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#paren-expression-possibly-arrow</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#paren-expression</string>
|
||||
|
@ -414,6 +418,7 @@
|
|||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
([\(]\s*$) | # during lookup treat ( followed by line end as arrow
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
[(]\s*
|
||||
|
@ -429,7 +434,7 @@
|
|||
(
|
||||
(<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
|
||||
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
|
@ -802,6 +807,7 @@
|
|||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
([\(]\s*$) | # during lookup treat ( followed by line end as arrow
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
[(]\s*
|
||||
|
@ -817,7 +823,7 @@
|
|||
(
|
||||
(<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
|
||||
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
|
@ -1188,6 +1194,7 @@
|
|||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
([\(]\s*$) | # during lookup treat ( followed by line end as arrow
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
[(]\s*
|
||||
|
@ -1203,7 +1210,7 @@
|
|||
(
|
||||
(<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
|
||||
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
|
@ -1644,7 +1651,7 @@
|
|||
(
|
||||
(<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
|
||||
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
)
|
||||
|
@ -1831,6 +1838,16 @@
|
|||
<string>punctuation.definition.parameters.end.ts</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#function-parameters-body</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>function-parameters-body</key>
|
||||
<dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
|
@ -3100,6 +3117,7 @@
|
|||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
([\(]\s*$) | # during lookup treat ( followed by line end as arrow
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
[(]\s*
|
||||
|
@ -3115,7 +3133,7 @@
|
|||
(
|
||||
(<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
|
||||
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
|
@ -3383,6 +3401,57 @@
|
|||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>paren-expression-possibly-arrow</key>
|
||||
<dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>(\()(?=\s*$)</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>meta.brace.round.ts</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>end</key>
|
||||
<string>\)</string>
|
||||
<key>endCaptures</key>
|
||||
<dict>
|
||||
<key>0</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>meta.brace.round.ts</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#expressionWithoutIdentifiers</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#function-parameters-body</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#identifiers</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#expressionPunctuations</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#possibly-arrow-return-type</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>paren-expression</key>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
|
@ -3411,10 +3480,6 @@
|
|||
<key>include</key>
|
||||
<string>#expression</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#punctuation-comma</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>cast</key>
|
||||
|
@ -4337,6 +4402,7 @@
|
|||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
([\(]\s*$) | # during lookup treat ( followed by line end as arrow
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
[(]\s*
|
||||
|
@ -4352,7 +4418,7 @@
|
|||
(
|
||||
(<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
|
||||
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
|
@ -4627,6 +4693,40 @@
|
|||
</dict>
|
||||
<key>end</key>
|
||||
<string>(?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#arrow-return-type-body</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>possibly-arrow-return-type</key>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>(?<=\))\s*(:)(?=\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+\s*=>)</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>meta.arrow.ts meta.return.type.arrow.ts keyword.operator.type.annotation.ts</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>end</key>
|
||||
<string>(?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))</string>
|
||||
<key>contentName</key>
|
||||
<string>meta.arrow.ts meta.return.type.arrow.ts</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#arrow-return-type-body</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>arrow-return-type-body</key>
|
||||
<dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
|
|
|
@ -279,6 +279,10 @@
|
|||
<key>include</key>
|
||||
<string>#support-objects</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#paren-expression-possibly-arrow</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#paren-expression</string>
|
||||
|
@ -418,6 +422,7 @@
|
|||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
([\(]\s*$) | # during lookup treat ( followed by line end as arrow
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
[(]\s*
|
||||
|
@ -433,7 +438,7 @@
|
|||
(
|
||||
(<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
|
||||
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
|
@ -806,6 +811,7 @@
|
|||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
([\(]\s*$) | # during lookup treat ( followed by line end as arrow
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
[(]\s*
|
||||
|
@ -821,7 +827,7 @@
|
|||
(
|
||||
(<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
|
||||
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
|
@ -1192,6 +1198,7 @@
|
|||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
([\(]\s*$) | # during lookup treat ( followed by line end as arrow
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
[(]\s*
|
||||
|
@ -1207,7 +1214,7 @@
|
|||
(
|
||||
(<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
|
||||
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
|
@ -1648,7 +1655,7 @@
|
|||
(
|
||||
(<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
|
||||
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
)
|
||||
|
@ -1835,6 +1842,16 @@
|
|||
<string>punctuation.definition.parameters.end.tsx</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#function-parameters-body</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>function-parameters-body</key>
|
||||
<dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
|
@ -3104,6 +3121,7 @@
|
|||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
([\(]\s*$) | # during lookup treat ( followed by line end as arrow
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
[(]\s*
|
||||
|
@ -3119,7 +3137,7 @@
|
|||
(
|
||||
(<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
|
||||
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
|
@ -3387,6 +3405,57 @@
|
|||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>paren-expression-possibly-arrow</key>
|
||||
<dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>(\()(?=\s*$)</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>meta.brace.round.tsx</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>end</key>
|
||||
<string>\)</string>
|
||||
<key>endCaptures</key>
|
||||
<dict>
|
||||
<key>0</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>meta.brace.round.tsx</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#expressionWithoutIdentifiers</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#function-parameters-body</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#identifiers</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#expressionPunctuations</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#possibly-arrow-return-type</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>paren-expression</key>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
|
@ -3415,10 +3484,6 @@
|
|||
<key>include</key>
|
||||
<string>#expression</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#punctuation-comma</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>cast</key>
|
||||
|
@ -4283,6 +4348,7 @@
|
|||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
([\(]\s*$) | # during lookup treat ( followed by line end as arrow
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
[(]\s*
|
||||
|
@ -4298,7 +4364,7 @@
|
|||
(
|
||||
(<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
|
||||
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
|
@ -4573,6 +4639,40 @@
|
|||
</dict>
|
||||
<key>end</key>
|
||||
<string>(?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#arrow-return-type-body</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>possibly-arrow-return-type</key>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>(?<=\))\s*(:)(?=\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+\s*=>)</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>meta.arrow.tsx meta.return.type.arrow.tsx keyword.operator.type.annotation.tsx</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>end</key>
|
||||
<string>(?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))</string>
|
||||
<key>contentName</key>
|
||||
<string>meta.arrow.tsx meta.return.type.arrow.tsx</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#arrow-return-type-body</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>arrow-return-type-body</key>
|
||||
<dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
|
|
|
@ -135,19 +135,21 @@ Grammar: TypeScriptReact.tmLanguage
|
|||
^^
|
||||
source.tsx
|
||||
^
|
||||
source.tsx variable.other.readwrite.tsx
|
||||
^^
|
||||
source.tsx
|
||||
source.tsx variable.parameter.tsx
|
||||
^
|
||||
source.tsx meta.type.annotation.tsx keyword.operator.type.annotation.tsx
|
||||
^
|
||||
source.tsx meta.type.annotation.tsx
|
||||
^
|
||||
source.tsx variable.other.constant.tsx
|
||||
source.tsx meta.type.annotation.tsx entity.name.type.tsx
|
||||
^
|
||||
source.tsx keyword.operator.relational.tsx
|
||||
source.tsx meta.type.annotation.tsx meta.type.parameters.tsx punctuation.definition.typeparameters.begin.tsx
|
||||
^
|
||||
source.tsx variable.other.constant.tsx
|
||||
source.tsx meta.type.annotation.tsx meta.type.parameters.tsx entity.name.type.tsx
|
||||
^
|
||||
source.tsx keyword.operator.relational.tsx
|
||||
^^
|
||||
source.tsx
|
||||
source.tsx meta.type.annotation.tsx meta.type.parameters.tsx punctuation.definition.typeparameters.end.tsx
|
||||
^
|
||||
source.tsx meta.type.annotation.tsx
|
||||
>) => {
|
||||
^
|
||||
source.tsx meta.brace.round.tsx
|
||||
|
|
|
@ -0,0 +1,198 @@
|
|||
original file
|
||||
-----------------------------------
|
||||
export const foo = (firstVariable: string, secondVariable: number): string => {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
export const bar = (
|
||||
firstVariable: string,
|
||||
secondVariable: number,
|
||||
thirdVariable: string
|
||||
): string => {
|
||||
return "baz"
|
||||
}
|
||||
-----------------------------------
|
||||
|
||||
Grammar: TypeScript.tmLanguage
|
||||
-----------------------------------
|
||||
>export const foo = (firstVariable: string, secondVariable: number): string => {
|
||||
^^^^^^
|
||||
source.ts meta.var.expr.ts keyword.control.export.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^^^^^
|
||||
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 variable.parameter.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.parameters.ts meta.type.annotation.ts
|
||||
^^^^^^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.parameters.ts meta.type.annotation.ts support.type.primitive.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.parameters.ts punctuation.separator.parameter.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.parameters.ts
|
||||
^^^^^^^^^^^^^^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.parameters.ts variable.parameter.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.parameters.ts meta.type.annotation.ts
|
||||
^^^^^^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.parameters.ts meta.type.annotation.ts support.type.primitive.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 meta.return.type.arrow.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.return.type.arrow.ts
|
||||
^^^^^^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.return.type.arrow.ts support.type.primitive.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.return.type.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.block.ts punctuation.definition.block.ts
|
||||
^^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts
|
||||
> return "foo"
|
||||
^^^^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts
|
||||
^^^^^^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts keyword.control.flow.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts string.quoted.double.ts punctuation.definition.string.begin.ts
|
||||
^^^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts string.quoted.double.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts string.quoted.double.ts punctuation.definition.string.end.ts
|
||||
^^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts
|
||||
>}
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts punctuation.definition.block.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
>
|
||||
^^
|
||||
source.ts
|
||||
>export const bar = (
|
||||
^^^^^^
|
||||
source.ts meta.var.expr.ts keyword.control.export.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^^^^^
|
||||
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
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.brace.round.ts
|
||||
^^
|
||||
source.ts meta.var.expr.ts
|
||||
> firstVariable: string,
|
||||
^^^^
|
||||
source.ts meta.var.expr.ts
|
||||
^^^^^^^^^^^^^
|
||||
source.ts meta.var.expr.ts variable.parameter.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.type.annotation.ts
|
||||
^^^^^^
|
||||
source.ts meta.var.expr.ts meta.type.annotation.ts support.type.primitive.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts punctuation.separator.parameter.ts
|
||||
^^
|
||||
source.ts meta.var.expr.ts
|
||||
> secondVariable: number,
|
||||
^^^^
|
||||
source.ts meta.var.expr.ts
|
||||
^^^^^^^^^^^^^^
|
||||
source.ts meta.var.expr.ts variable.parameter.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.type.annotation.ts
|
||||
^^^^^^
|
||||
source.ts meta.var.expr.ts meta.type.annotation.ts support.type.primitive.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts punctuation.separator.parameter.ts
|
||||
^^
|
||||
source.ts meta.var.expr.ts
|
||||
> thirdVariable: string
|
||||
^^^^
|
||||
source.ts meta.var.expr.ts
|
||||
^^^^^^^^^^^^^
|
||||
source.ts meta.var.expr.ts variable.parameter.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.type.annotation.ts
|
||||
^^^^^^
|
||||
source.ts meta.var.expr.ts meta.type.annotation.ts support.type.primitive.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.type.annotation.ts
|
||||
>): string => {
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.brace.round.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.return.type.arrow.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.return.type.arrow.ts
|
||||
^^^^^^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.return.type.arrow.ts support.type.primitive.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.return.type.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.block.ts punctuation.definition.block.ts
|
||||
^^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts
|
||||
> return "baz"
|
||||
^^^^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts
|
||||
^^^^^^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts keyword.control.flow.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts string.quoted.double.ts punctuation.definition.string.begin.ts
|
||||
^^^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts string.quoted.double.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts string.quoted.double.ts punctuation.definition.string.end.ts
|
||||
^^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts
|
||||
>}
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts punctuation.definition.block.ts
|
|
@ -287,7 +287,7 @@ Grammar: TypeScriptReact.tmLanguage
|
|||
^
|
||||
source.tsx meta.var.expr.tsx
|
||||
^^^^
|
||||
source.tsx meta.var.expr.tsx meta.var-single-variable.expr.tsx meta.definition.variable.tsx variable.other.readwrite.tsx
|
||||
source.tsx meta.var.expr.tsx meta.var-single-variable.expr.tsx meta.definition.variable.tsx entity.name.function.tsx
|
||||
^
|
||||
source.tsx meta.var.expr.tsx meta.var-single-variable.expr.tsx
|
||||
^
|
||||
|
@ -390,7 +390,7 @@ Grammar: TypeScriptReact.tmLanguage
|
|||
^
|
||||
source.tsx meta.var.expr.tsx
|
||||
^^^^^^^
|
||||
source.tsx meta.var.expr.tsx meta.var-single-variable.expr.tsx meta.definition.variable.tsx variable.other.readwrite.tsx
|
||||
source.tsx meta.var.expr.tsx meta.var-single-variable.expr.tsx meta.definition.variable.tsx entity.name.function.tsx
|
||||
^
|
||||
source.tsx meta.var.expr.tsx meta.var-single-variable.expr.tsx
|
||||
^
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
export const foo = (firstVariable: string, secondVariable: number): string => {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
export const bar = (
|
||||
firstVariable: string,
|
||||
secondVariable: number,
|
||||
thirdVariable: string
|
||||
): string => {
|
||||
return "baz"
|
||||
}
|
Загрузка…
Ссылка в новой задаче