Skip to content

Commit f7d0692

Browse files
Merge pull request dotnet#68 from kiootic/ref-local-return
Add support for ref local/return
2 parents 257d9ac + bf73af7 commit f7d0692

12 files changed

+314
-14
lines changed

grammars/csharp.tmLanguage

+46-3
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,7 @@
879879
(?:\b(delegate)\b)\s+
880880
(?<type-name>
881881
(?:
882+
(?:ref\s+)? # ref return
882883
(?:
883884
(?:(?<identifier>[_[:alpha:]][_[:alnum:]]*)\s*\:\:\s*)? # alias-qualification
884885
(?<name-and-type-args> # identifier + type arguments (if any)
@@ -1498,6 +1499,7 @@
14981499
(?<return-type>
14991500
(?<type-name>
15001501
(?:
1502+
(?:ref\s+)? # ref return
15011503
(?:
15021504
(?:(?<identifier>[_[:alpha:]][_[:alnum:]]*)\s*\:\:\s*)? # alias-qualification
15031505
(?<name-and-type-args> # identifier + type arguments (if any)
@@ -1581,6 +1583,7 @@
15811583
(?<return-type>
15821584
(?<type-name>
15831585
(?:
1586+
(?:ref\s+)? # ref return
15841587
(?:
15851588
(?:(?<identifier>[_[:alpha:]][_[:alnum:]]*)\s*\:\:\s*)? # alias-qualification
15861589
(?<name-and-type-args> # identifier + type arguments (if any)
@@ -1878,6 +1881,7 @@
18781881
(?<return-type>
18791882
(?<type-name>
18801883
(?:
1884+
(?:ref\s+)? # ref return
18811885
(?:
18821886
(?:(?<identifier>[_[:alpha:]][_[:alnum:]]*)\s*\:\:\s*)? # alias-qualification
18831887
(?<name-and-type-args> # identifier + type arguments (if any)
@@ -2100,6 +2104,7 @@
21002104
<string>(?x)
21012105
(?&lt;type-name&gt;
21022106
(?:
2107+
(?:ref\s+)? # ref return
21032108
(?:
21042109
(?:(?&lt;identifier&gt;[_[:alpha:]][_[:alnum:]]*)\s*\:\:\s*)? # alias-qualification
21052110
(?&lt;name-and-type-args&gt; # identifier + type arguments (if any)
@@ -2170,6 +2175,7 @@
21702175
(?&lt;operator-keyword&gt;(?:\b(?:operator)))\s*
21712176
(?&lt;type-name&gt;
21722177
(?:
2178+
(?:ref\s+)? # ref return
21732179
(?:
21742180
(?:(?&lt;identifier&gt;[_[:alpha:]][_[:alnum:]]*)\s*\:\:\s*)? # alias-qualification
21752181
(?&lt;name-and-type-args&gt; # identifier + type arguments (if any)
@@ -2301,6 +2307,10 @@
23012307
<string>(?=[,\)\];}])</string>
23022308
<key>patterns</key>
23032309
<array>
2310+
<dict>
2311+
<key>include</key>
2312+
<string>#ref-modifier</string>
2313+
</dict>
23042314
<dict>
23052315
<key>include</key>
23062316
<string>#expression</string>
@@ -2323,6 +2333,10 @@
23232333
<string>(?=[,\);}])</string>
23242334
<key>patterns</key>
23252335
<array>
2336+
<dict>
2337+
<key>include</key>
2338+
<string>#ref-modifier</string>
2339+
</dict>
23262340
<dict>
23272341
<key>include</key>
23282342
<string>#expression</string>
@@ -2402,6 +2416,10 @@
24022416
<string>(?=;)</string>
24032417
<key>patterns</key>
24042418
<array>
2419+
<dict>
2420+
<key>include</key>
2421+
<string>#ref-modifier</string>
2422+
</dict>
24052423
<dict>
24062424
<key>include</key>
24072425
<string>#expression</string>
@@ -3359,9 +3377,10 @@
33593377
<key>begin</key>
33603378
<string>(?x)
33613379
(?:
3362-
(\bvar\b)|
3380+
(?:(\bref)\s+)?(\bvar\b)| # ref local
33633381
(?&lt;type-name&gt;
33643382
(?:
3383+
(?:ref\s+)? # ref local
33653384
(?:
33663385
(?:(?&lt;identifier&gt;[_[:alpha:]][_[:alnum:]]*)\s*\:\:\s*)? # alias-qualification
33673386
(?&lt;name-and-type-args&gt; # identifier + type arguments (if any)
@@ -3384,9 +3403,14 @@
33843403
<key>1</key>
33853404
<dict>
33863405
<key>name</key>
3387-
<string>keyword.other.var.cs</string>
3406+
<string>storage.modifier.cs</string>
33883407
</dict>
33893408
<key>2</key>
3409+
<dict>
3410+
<key>name</key>
3411+
<string>keyword.other.var.cs</string>
3412+
</dict>
3413+
<key>3</key>
33903414
<dict>
33913415
<key>patterns</key>
33923416
<array>
@@ -3396,7 +3420,7 @@
33963420
</dict>
33973421
</array>
33983422
</dict>
3399-
<key>7</key>
3423+
<key>8</key>
34003424
<dict>
34013425
<key>name</key>
34023426
<string>entity.name.variable.local.cs</string>
@@ -5686,6 +5710,10 @@
56865710
<key>include</key>
56875711
<string>#block</string>
56885712
</dict>
5713+
<dict>
5714+
<key>include</key>
5715+
<string>#ref-modifier</string>
5716+
</dict>
56895717
<dict>
56905718
<key>include</key>
56915719
<string>#expression</string>
@@ -5729,6 +5757,10 @@
57295757
<key>include</key>
57305758
<string>#block</string>
57315759
</dict>
5760+
<dict>
5761+
<key>include</key>
5762+
<string>#ref-modifier</string>
5763+
</dict>
57325764
<dict>
57335765
<key>include</key>
57345766
<string>#expression</string>
@@ -5872,6 +5904,10 @@
58725904
<key>include</key>
58735905
<string>#comment</string>
58745906
</dict>
5907+
<dict>
5908+
<key>include</key>
5909+
<string>#ref-modifier</string>
5910+
</dict>
58755911
<dict>
58765912
<key>include</key>
58775913
<string>#tuple-type</string>
@@ -5898,6 +5934,13 @@
58985934
</dict>
58995935
</array>
59005936
</dict>
5937+
<key>ref-modifier</key>
5938+
<dict>
5939+
<key>name</key>
5940+
<string>storage.modifier.cs</string>
5941+
<key>match</key>
5942+
<string>ref</string>
5943+
</dict>
59015944
<key>tuple-type</key>
59025945
<dict>
59035946
<key>begin</key>

grammars/csharp.tmLanguage.cson

+33-3
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ repository:
562562
(?:\\b(delegate)\\b)\\s+
563563
(?<type-name>
564564
(?:
565+
(?:ref\\s+)? # ref return
565566
(?:
566567
(?:(?<identifier>[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification
567568
(?<name-and-type-args> # identifier + type arguments (if any)
@@ -939,6 +940,7 @@ repository:
939940
(?<return-type>
940941
(?<type-name>
941942
(?:
943+
(?:ref\\s+)? # ref return
942944
(?:
943945
(?:(?<identifier>[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification
944946
(?<name-and-type-args> # identifier + type arguments (if any)
@@ -1000,6 +1002,7 @@ repository:
10001002
(?<return-type>
10011003
(?<type-name>
10021004
(?:
1005+
(?:ref\\s+)? # ref return
10031006
(?:
10041007
(?:(?<identifier>[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification
10051008
(?<name-and-type-args> # identifier + type arguments (if any)
@@ -1199,6 +1202,7 @@ repository:
11991202
(?<return-type>
12001203
(?<type-name>
12011204
(?:
1205+
(?:ref\\s+)? # ref return
12021206
(?:
12031207
(?:(?<identifier>[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification
12041208
(?<name-and-type-args> # identifier + type arguments (if any)
@@ -1339,6 +1343,7 @@ repository:
13391343
(?x)
13401344
(?<type-name>
13411345
(?:
1346+
(?:ref\\s+)? # ref return
13421347
(?:
13431348
(?:(?<identifier>[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification
13441349
(?<name-and-type-args> # identifier + type arguments (if any)
@@ -1390,6 +1395,7 @@ repository:
13901395
(?<operator-keyword>(?:\\b(?:operator)))\\s*
13911396
(?<type-name>
13921397
(?:
1398+
(?:ref\\s+)? # ref return
13931399
(?:
13941400
(?:(?<identifier>[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification
13951401
(?<name-and-type-args> # identifier + type arguments (if any)
@@ -1466,6 +1472,9 @@ repository:
14661472
name: "keyword.operator.assignment.cs"
14671473
end: "(?=[,\\)\\];}])"
14681474
patterns: [
1475+
{
1476+
include: "#ref-modifier"
1477+
}
14691478
{
14701479
include: "#expression"
14711480
}
@@ -1477,6 +1486,9 @@ repository:
14771486
name: "keyword.operator.arrow.cs"
14781487
end: "(?=[,\\);}])"
14791488
patterns: [
1489+
{
1490+
include: "#ref-modifier"
1491+
}
14801492
{
14811493
include: "#expression"
14821494
}
@@ -1518,6 +1530,9 @@ repository:
15181530
name: "keyword.control.flow.return.cs"
15191531
end: "(?=;)"
15201532
patterns: [
1533+
{
1534+
include: "#ref-modifier"
1535+
}
15211536
{
15221537
include: "#expression"
15231538
}
@@ -2039,9 +2054,10 @@ repository:
20392054
begin: '''
20402055
(?x)
20412056
(?:
2042-
(\\bvar\\b)|
2057+
(?:(\\bref)\\s+)?(\\bvar\\b)| # ref local
20432058
(?<type-name>
20442059
(?:
2060+
(?:ref\\s+)? # ref local
20452061
(?:
20462062
(?:(?<identifier>[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification
20472063
(?<name-and-type-args> # identifier + type arguments (if any)
@@ -2062,14 +2078,16 @@ repository:
20622078
'''
20632079
beginCaptures:
20642080
"1":
2065-
name: "keyword.other.var.cs"
2081+
name: "storage.modifier.cs"
20662082
"2":
2083+
name: "keyword.other.var.cs"
2084+
"3":
20672085
patterns: [
20682086
{
20692087
include: "#type"
20702088
}
20712089
]
2072-
"7":
2090+
"8":
20732091
name: "entity.name.variable.local.cs"
20742092
end: "(?=;|\\))"
20752093
patterns: [
@@ -3434,6 +3452,9 @@ repository:
34343452
{
34353453
include: "#block"
34363454
}
3455+
{
3456+
include: "#ref-modifier"
3457+
}
34373458
{
34383459
include: "#expression"
34393460
}
@@ -3462,6 +3483,9 @@ repository:
34623483
{
34633484
include: "#block"
34643485
}
3486+
{
3487+
include: "#ref-modifier"
3488+
}
34653489
{
34663490
include: "#expression"
34673491
}
@@ -3555,6 +3579,9 @@ repository:
35553579
{
35563580
include: "#comment"
35573581
}
3582+
{
3583+
include: "#ref-modifier"
3584+
}
35583585
{
35593586
include: "#tuple-type"
35603587
}
@@ -3574,6 +3601,9 @@ repository:
35743601
include: "#type-nullable-suffix"
35753602
}
35763603
]
3604+
"ref-modifier":
3605+
name: "storage.modifier.cs"
3606+
match: "ref"
35773607
"tuple-type":
35783608
begin: "\\("
35793609
beginCaptures:

0 commit comments

Comments
 (0)