Skip to content

Commit e4d1aef

Browse files
committed
Port the changes to react files
1 parent dad3eea commit e4d1aef

File tree

4 files changed

+107
-17
lines changed

4 files changed

+107
-17
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,9 @@ repository:
386386
- include: '#arithmetic-operator'
387387
- include: '#logic-operator'
388388
- include: '#assignment-operator'
389-
- include: '#switch-case'
390389
- include: '#storage-keyword'
391390
- include: '#function-call'
391+
- include: '#switch-case'
392392
- include: '#control-statement'
393393

394394
switch-variable:

TypeScript.tmLanguage

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,15 @@
365365
</dict>
366366
<dict>
367367
<key>include</key>
368-
<string>#switch-case</string>
368+
<string>#storage-keyword</string>
369369
</dict>
370370
<dict>
371371
<key>include</key>
372-
<string>#storage-keyword</string>
372+
<string>#function-call</string>
373373
</dict>
374374
<dict>
375375
<key>include</key>
376-
<string>#function-call</string>
376+
<string>#switch-case</string>
377377
</dict>
378378
<dict>
379379
<key>include</key>

TypeScriptReact.YAML-tmLanguage

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@ repository:
2828
name: keyword.control.tsx
2929
match: (?<!\.)\b(break|catch|continue|debugger|declare|do|else|finally|for|if|return|switch|throw|try|while|with|super|switch|case)\b
3030

31-
switch-case:
32-
name: case.expr.tsx
33-
begin: '(?<!\.)\b(case|default)\b'
34-
beginCaptures:
35-
'1': { name: keyword.control.tsx }
36-
end: ':'
37-
patterns:
38-
- include: '#expression'
39-
4031
declaration:
4132
name: meta.declaration.tsx
4233
patterns:
@@ -160,7 +151,7 @@ repository:
160151
'4': { name: keyword.operator.tsx }
161152
'5': { name: entity.name.function.tsx }
162153
'6': { name: keyword.operator.tsx }
163-
end: '(?=\}|;|,|$)|(?<=\})'
154+
end: '(?=\}|;|,)|(?<=\})'
164155
patterns:
165156
- include: '#comment'
166157
- include: '#type-parameters'
@@ -385,6 +376,7 @@ repository:
385376
- include: '#var-expr'
386377
- include: '#declaration'
387378
- include: '#new-expr'
379+
- include: '#switch-expression'
388380
- include: '#block'
389381
- include: '#expression-operator'
390382
- include: '#relational-operator'
@@ -396,6 +388,40 @@ repository:
396388
- include: '#switch-case'
397389
- include: '#control-statement'
398390

391+
switch-variable:
392+
name: switch-variable.expr.ts
393+
begin: \b(switch)\b\s*\(
394+
beginCaptures:
395+
'1': { name: keyword.operator.ts }
396+
end: \)
397+
patterns:
398+
- include: '#expression'
399+
400+
switch-block:
401+
name: switch-block.expr.ts
402+
begin: '{'
403+
end: (?=\})
404+
patterns:
405+
- include: '#expression'
406+
407+
switch-case:
408+
name: case.expr.ts
409+
begin: '(?<!\.)\b(case|default)\b'
410+
beginCaptures:
411+
'1': { name: keyword.control.ts }
412+
end: ':'
413+
patterns:
414+
- include: '#expression'
415+
416+
switch-expression:
417+
name: switch-expr.expr.ts
418+
begin: (?=\bswitch\b\s*\()
419+
end: '}'
420+
patterns:
421+
- include: '#switch-variable'
422+
- include: '#switch-block'
423+
424+
399425
for-in-simple:
400426
name: forin.expr.tsx
401427
match: (?<=\()\s*\b(var|let|const)\s+([a-zA-Z_$][\w$]*)\s+(in|of)\b

TypeScriptReact.tmLanguage

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@
296296
<key>include</key>
297297
<string>#new-expr</string>
298298
</dict>
299+
<dict>
300+
<key>include</key>
301+
<string>#switch-expression</string>
302+
</dict>
299303
<dict>
300304
<key>include</key>
301305
<string>#block</string>
@@ -1068,7 +1072,7 @@
10681072
</dict>
10691073
</dict>
10701074
<key>end</key>
1071-
<string>(?=\}|;|,|$)|(?&lt;=\})</string>
1075+
<string>(?=\}|;|,)|(?&lt;=\})</string>
10721076
<key>name</key>
10731077
<string>meta.method.declaration.tsx</string>
10741078
<key>patterns</key>
@@ -1562,6 +1566,22 @@
15621566
<key>name</key>
15631567
<string>constant.character.escape</string>
15641568
</dict>
1569+
<key>switch-block</key>
1570+
<dict>
1571+
<key>begin</key>
1572+
<string>{</string>
1573+
<key>end</key>
1574+
<string>(?=\})</string>
1575+
<key>name</key>
1576+
<string>switch-block.expr.ts</string>
1577+
<key>patterns</key>
1578+
<array>
1579+
<dict>
1580+
<key>include</key>
1581+
<string>#expression</string>
1582+
</dict>
1583+
</array>
1584+
</dict>
15651585
<key>switch-case</key>
15661586
<dict>
15671587
<key>begin</key>
@@ -1571,13 +1591,57 @@
15711591
<key>1</key>
15721592
<dict>
15731593
<key>name</key>
1574-
<string>keyword.control.tsx</string>
1594+
<string>keyword.control.ts</string>
15751595
</dict>
15761596
</dict>
15771597
<key>end</key>
15781598
<string>:</string>
15791599
<key>name</key>
1580-
<string>case.expr.tsx</string>
1600+
<string>case.expr.ts</string>
1601+
<key>patterns</key>
1602+
<array>
1603+
<dict>
1604+
<key>include</key>
1605+
<string>#expression</string>
1606+
</dict>
1607+
</array>
1608+
</dict>
1609+
<key>switch-expression</key>
1610+
<dict>
1611+
<key>begin</key>
1612+
<string>(?=\bswitch\b\s*\()</string>
1613+
<key>end</key>
1614+
<string>}</string>
1615+
<key>name</key>
1616+
<string>switch-expr.expr.ts</string>
1617+
<key>patterns</key>
1618+
<array>
1619+
<dict>
1620+
<key>include</key>
1621+
<string>#switch-variable</string>
1622+
</dict>
1623+
<dict>
1624+
<key>include</key>
1625+
<string>#switch-block</string>
1626+
</dict>
1627+
</array>
1628+
</dict>
1629+
<key>switch-variable</key>
1630+
<dict>
1631+
<key>begin</key>
1632+
<string>\b(switch)\b\s*\(</string>
1633+
<key>beginCaptures</key>
1634+
<dict>
1635+
<key>1</key>
1636+
<dict>
1637+
<key>name</key>
1638+
<string>keyword.operator.ts</string>
1639+
</dict>
1640+
</dict>
1641+
<key>end</key>
1642+
<string>\)</string>
1643+
<key>name</key>
1644+
<string>switch-variable.expr.ts</string>
15811645
<key>patterns</key>
15821646
<array>
15831647
<dict>

0 commit comments

Comments
 (0)