Skip to content

Commit 8361b1a

Browse files
committed
Relax the parameter matching lookup rule for arrow detection
Fixes #540 partly (only case 7)
1 parent b6e3500 commit 8361b1a

File tree

5 files changed

+663
-13
lines changed

5 files changed

+663
-13
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ variables:
2929
# arrow function possible to detect only with => on same line
3030
(
3131
{{typeParameters}}? # typeparameters
32-
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
32+
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
3333
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
3434
\s*=> # arrow operator
3535
)

TypeScript.tmLanguage

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@
408408
# arrow function possible to detect only with =&gt; on same line
409409
(
410410
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
411-
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
411+
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
412412
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
413413
\s*=&gt; # arrow operator
414414
)
@@ -796,7 +796,7 @@
796796
# arrow function possible to detect only with =&gt; on same line
797797
(
798798
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
799-
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
799+
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
800800
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
801801
\s*=&gt; # arrow operator
802802
)
@@ -1182,7 +1182,7 @@
11821182
# arrow function possible to detect only with =&gt; on same line
11831183
(
11841184
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
1185-
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
1185+
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
11861186
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
11871187
\s*=&gt; # arrow operator
11881188
)
@@ -1623,7 +1623,7 @@
16231623
# arrow function possible to detect only with =&gt; on same line
16241624
(
16251625
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
1626-
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
1626+
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
16271627
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
16281628
\s*=&gt; # arrow operator
16291629
)
@@ -3098,7 +3098,7 @@
30983098
# arrow function possible to detect only with =&gt; on same line
30993099
(
31003100
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
3101-
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
3101+
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
31023102
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
31033103
\s*=&gt; # arrow operator
31043104
)
@@ -4335,7 +4335,7 @@
43354335
# arrow function possible to detect only with =&gt; on same line
43364336
(
43374337
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
4338-
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
4338+
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
43394339
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
43404340
\s*=&gt; # arrow operator
43414341
)

TypeScriptReact.tmLanguage

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@
412412
# arrow function possible to detect only with =&gt; on same line
413413
(
414414
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
415-
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
415+
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
416416
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
417417
\s*=&gt; # arrow operator
418418
)
@@ -800,7 +800,7 @@
800800
# arrow function possible to detect only with =&gt; on same line
801801
(
802802
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
803-
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
803+
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
804804
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
805805
\s*=&gt; # arrow operator
806806
)
@@ -1186,7 +1186,7 @@
11861186
# arrow function possible to detect only with =&gt; on same line
11871187
(
11881188
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
1189-
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
1189+
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
11901190
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
11911191
\s*=&gt; # arrow operator
11921192
)
@@ -1627,7 +1627,7 @@
16271627
# arrow function possible to detect only with =&gt; on same line
16281628
(
16291629
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
1630-
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
1630+
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
16311631
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
16321632
\s*=&gt; # arrow operator
16331633
)
@@ -3102,7 +3102,7 @@
31023102
# arrow function possible to detect only with =&gt; on same line
31033103
(
31043104
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
3105-
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
3105+
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
31063106
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
31073107
\s*=&gt; # arrow operator
31083108
)
@@ -4281,7 +4281,7 @@
42814281
# arrow function possible to detect only with =&gt; on same line
42824282
(
42834283
(&lt;\s*[_$[:alpha:]\{\(\[]([^&lt;&gt;=]|=[^&lt;]|\&lt;\s*[_$[:alpha:]\{\(\[]([^=&lt;&gt;]|=[^&lt;])+\&gt;)+&gt;\s*)? # typeparameters
4284-
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[_$[:alpha:]\{\[][^()]*)?\))*)?\) # parameteres
4284+
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
42854285
(\s*:\s*([^&lt;&gt;\(\)]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\))+)? # return type
42864286
\s*=&gt; # arrow operator
42874287
)

0 commit comments

Comments
 (0)