@@ -67,7 +67,7 @@ variables:
67
67
typeArgumentsInnerExpressionPart : ' [^<>\(]|{{matchingParenthesis}}|(?<==)\>'
68
68
typeArguments : ' <\s*{{typeArgumentsStart}}({{typeArgumentsInnerExpressionPart}}|\<\s*{{typeArgumentsStart}}(({{typeArgumentsInnerExpressionPart}}|\<\s*{{typeArgumentsStart}}({{typeArgumentsInnerExpressionPart}})*(?<!=)\>))*(?<!=)\>)*(?<!=)>'
69
69
functionCallLookup : \s*(?:(\?\.\s*)|(\!))?({{typeArguments}}\s*)?\(
70
- returnTypeOfArrow : \s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+
70
+ possiblyType : \s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+
71
71
typeparamertStartOfArrow : ' '
72
72
arrowLookup : |-
73
73
# sure shot arrow functions even if => is on new line
@@ -84,11 +84,15 @@ variables:
84
84
(
85
85
{{typeParameters}}? # typeparameters
86
86
\(\s*({{inlineComment}}\s*)*(([_$[:alpha:]]|{{matchingBraces}}|{{matchingBrackets}}|(\.\.\.\s*[_$[:alpha:]]))([^()]|{{matchingParenthesis}})*)?\) # parameters
87
- (\s*:{{returnTypeOfArrow }})? # return type
87
+ (\s*:{{possiblyType }})? # return type
88
88
\s*=> # arrow operator
89
89
)
90
90
possiblyMultilineArrowExpressionBeforeEndOfLine : ((({{typeParameters}})?\()|(<))
91
- possiblyMultilineArrow : ((<\s*$)|({{typeParameters}}?[\(]\s*([\{\[]\s*)?$)) # during lookup treat <typeparameters>?( followed by line end as arrow or < followed by new line
91
+ possiblyMultilineObjectBindingPattern : ' {{matchingBraces}}\s*((:\s*\{?$)|(({{possiblyType}}\s*)?=\s*))'
92
+ possiblyMultilineArrayBindingPattern : ' {{matchingBrackets}}\s*((:\s*\[?$)|(({{possiblyType}}\s*)?=\s*))'
93
+ possiblyMultilineArrowWParamters : ' ((([\{\[]\s*)?$)|({{possiblyMultilineObjectBindingPattern}})|({{possiblyMultilineArrayBindingPattern}}))'
94
+ possiblyMultilineArrowWithoutTypeParameters : ' [\(]\s*{{possiblyMultilineArrowWParamters}}'
95
+ possiblyMultilineArrow : ((<\s*$)|({{typeParameters}}?{{possiblyMultilineArrowWithoutTypeParameters}})) # during lookup treat <typeparameters>?( followed by line end as arrow or < followed by new line
92
96
functionOrArrowLookup : |-
93
97
\s*(
94
98
((async\s+)?(
@@ -1390,7 +1394,7 @@ repository:
1390
1394
' 0 ' : { name: meta.object-literal.key.ts punctuation.separator.key-value.ts }
1391
1395
end : (?=,|\})
1392
1396
patterns :
1393
- - begin : ' {{lookBehindOfObjectMemberPossiblyMultilineArrow}}\s*(async)?(?=\s*{{typeParameters}}\(\s*([\{\[]\s*)?$ )'
1397
+ - begin : ' {{lookBehindOfObjectMemberPossiblyMultilineArrow}}\s*(async)?(?=\s*{{typeParameters}}\(\s*{{possiblyMultilineArrowWParamters}} )'
1394
1398
beginCaptures :
1395
1399
' 1 ' : { name: storage.modifier.async.ts }
1396
1400
end : (?<=\))
@@ -1404,7 +1408,7 @@ repository:
1404
1408
' 0 ' : { name: meta.brace.round.ts }
1405
1409
patterns :
1406
1410
- include : ' #expression-inside-possibly-arrow-parens'
1407
- - begin : ' {{lookBehindOfObjectMemberPossiblyMultilineArrow}}\s*(async)?\s*(\()(?=\s*([\{\[]\s*)?$ )'
1411
+ - begin : ' {{lookBehindOfObjectMemberPossiblyMultilineArrow}}\s*(async)?\s*(\()(?=\s*{{possiblyMultilineArrowWParamters}} )'
1408
1412
beginCaptures :
1409
1413
' 1 ' : { name: storage.modifier.async.ts }
1410
1414
' 2 ' : { name: meta.brace.round.ts }
@@ -1480,7 +1484,7 @@ repository:
1480
1484
# but do this only from expression and as last resort
1481
1485
paren-expression-possibly-arrow :
1482
1486
patterns :
1483
- - begin : ' {{lookBehindOfPossiblyMultilineArrowWithDestructuring}}\s*(async)?(?=\s*({{typeParameters}})?\(\s*[\{\[]\s*$ )'
1487
+ - begin : ' {{lookBehindOfPossiblyMultilineArrowWithDestructuring}}\s*(async)?(?=\s*({{typeParameters}})?\(\s*{{possiblyMultilineArrowWParamters}} )'
1484
1488
beginCaptures :
1485
1489
' 1 ' : { name: storage.modifier.async.ts }
1486
1490
end : (?<=\))
@@ -2178,7 +2182,7 @@ repository:
2178
2182
2179
2183
# This is the check if the exoression '): something =>'' can be matched as return type of arrow
2180
2184
possibly-arrow-return-type :
2181
- begin : (?<=\)|^)\s*(:)(?={{returnTypeOfArrow }}\s*=>)
2185
+ begin : (?<=\)|^)\s*(:)(?={{possiblyType }}\s*=>)
2182
2186
beginCaptures :
2183
2187
' 1 ' : { name: meta.arrow.ts meta.return.type.arrow.ts keyword.operator.type.annotation.ts }
2184
2188
end : ' {{arrowFunctionEnd}}'
0 commit comments