Skip to content

Commit 00e47b7

Browse files
committed
Merge pull request #67 from Microsoft/updateJsx
Sync tsx grammar with recent changes of the ts gammar
2 parents 82a19fe + 6be6600 commit 00e47b7

File tree

2 files changed

+74
-23
lines changed

2 files changed

+74
-23
lines changed

TypeScriptReact.YAML-tmLanguage

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ repository:
3535

3636
control-statement:
3737
name: keyword.control.tsx
38-
match: (?<!\.)\b(break|catch|continue|debugger|declare|do|else|finally|for|if|return|switch|throw|try|while|with|super|switch|case)\b
38+
match: (?<!\.)\b(break|catch|continue|debugger|declare|do|else|finally|for|if|return|switch|throw|try|while|with|super|case|default)\b
3939

4040
declaration:
4141
name: meta.declaration.tsx
@@ -153,14 +153,15 @@ repository:
153153

154154
method-declaration:
155155
name: meta.method.declaration.tsx
156-
begin: '\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?(?:(get|set)\s+)?(?:(new)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\<)'
156+
begin: '\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\<)'
157157
beginCaptures:
158158
'1': { name: storage.modifier.tsx }
159159
'2': { name: storage.modifier.tsx }
160-
'3': { name: storage.type.property.tsx }
161-
'4': { name: keyword.operator.tsx }
162-
'5': { name: entity.name.function.tsx }
163-
'6': { name: keyword.operator.tsx }
160+
'3': { name: storage.modifier.tsx }
161+
'4': { name: storage.type.property.tsx }
162+
'5': { name: keyword.operator.tsx }
163+
'6': { name: entity.name.function.tsx }
164+
'7': { name: keyword.operator.tsx }
164165
end: '(?=\}|;|,)|(?<=\})'
165166
patterns:
166167
- include: '#comment'
@@ -172,12 +173,15 @@ repository:
172173

173174
method-overload-declaration:
174175
name: meta.method.overload.declaration.tsx
175-
match: '\b(?:(public|private|protected)\s+)?(?:(new)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\<)'
176+
match: '\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\<)'
176177
captures:
177178
'1': { name: storage.modifier.tsx }
178-
'2': { name: keyword.operator.tsx }
179-
'3': { name: entity.name.function.tsx }
180-
'4': { name: keyword.operator.tsx }
179+
'2': { name: storage.modifier.tsx }
180+
'3': { name: storage.modifier.tsx }
181+
'4': { name: storage.type.property.tsx }
182+
'5': { name: keyword.operator.tsx }
183+
'6': { name: entity.name.function.tsx }
184+
'7': { name: keyword.operator.tsx }
181185

182186
indexer-declaration:
183187
name: meta.indexer.declaration.tsx
@@ -201,11 +205,12 @@ repository:
201205

202206
function-declaration:
203207
name: meta.function.tsx
204-
begin: \b(?:(export)\s+)?(function\b)(?:\s+([a-zA-Z_$][\w$]*))?\s*
208+
begin: \b(?:(export)\s+)?(?:(async)\s+)?(function\b)(?:\s+([a-zA-Z_$][\w$]*))?\s*
205209
beginCaptures:
206210
'1': { name: storage.modifier.tsx }
207-
'2': { name: storage.type.function.tsx }
208-
'3': { name: entity.name.function.tsx }
211+
'2': { name: storage.modifier.tsx }
212+
'3': { name: storage.type.function.tsx }
213+
'4': { name: entity.name.function.tsx }
209214
end: (?=;|\})|(?<=\})
210215
patterns:
211216
- include: '#comment'
@@ -318,6 +323,10 @@ repository:
318323
- include: '#type'
319324
- include: '#function-type-parameters'
320325

326+
await-modifier:
327+
name: storage.modifier.tsx
328+
match: 'await'
329+
321330
type-operator:
322331
name: keyword.operator.type.tsx
323332
match: '[.|]'
@@ -442,6 +451,7 @@ repository:
442451
function-call:
443452
name: functioncall.expr.tsx
444453
patterns:
454+
- include: '#await-modifier'
445455
- include: '#type-parameters'
446456
- include: '#paren-expression'
447457

@@ -454,6 +464,7 @@ repository:
454464
end: '(?=[(;]|$)'
455465
patterns:
456466
- include: '#type'
467+
- include: '#comment'
457468

458469
object-member:
459470
name: meta.object.member.tsx

TypeScriptReact.tmLanguage

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@
7070
<key>name</key>
7171
<string>keyword.operator.assignment.tsx</string>
7272
</dict>
73+
<key>await-modifier</key>
74+
<dict>
75+
<key>match</key>
76+
<string>await</string>
77+
<key>name</key>
78+
<string>storage.modifier.tsx</string>
79+
</dict>
7380
<key>block</key>
7481
<dict>
7582
<key>begin</key>
@@ -185,7 +192,7 @@
185192
<key>control-statement</key>
186193
<dict>
187194
<key>match</key>
188-
<string>(?&lt;!\.)\b(break|catch|continue|debugger|declare|do|else|finally|for|if|return|switch|throw|try|while|with|super|switch|case)\b</string>
195+
<string>(?&lt;!\.)\b(break|catch|continue|debugger|declare|do|else|finally|for|if|return|switch|throw|try|while|with|super|case|default)\b</string>
189196
<key>name</key>
190197
<string>keyword.control.tsx</string>
191198
</dict>
@@ -428,6 +435,10 @@
428435
<string>functioncall.expr.tsx</string>
429436
<key>patterns</key>
430437
<array>
438+
<dict>
439+
<key>include</key>
440+
<string>#await-modifier</string>
441+
</dict>
431442
<dict>
432443
<key>include</key>
433444
<string>#type-parameters</string>
@@ -441,7 +452,7 @@
441452
<key>function-declaration</key>
442453
<dict>
443454
<key>begin</key>
444-
<string>\b(?:(export)\s+)?(function\b)(?:\s+([a-zA-Z_$][\w$]*))?\s*</string>
455+
<string>\b(?:(export)\s+)?(?:(async)\s+)?(function\b)(?:\s+([a-zA-Z_$][\w$]*))?\s*</string>
445456
<key>beginCaptures</key>
446457
<dict>
447458
<key>1</key>
@@ -452,9 +463,14 @@
452463
<key>2</key>
453464
<dict>
454465
<key>name</key>
455-
<string>storage.type.function.tsx</string>
466+
<string>storage.modifier.tsx</string>
456467
</dict>
457468
<key>3</key>
469+
<dict>
470+
<key>name</key>
471+
<string>storage.type.function.tsx</string>
472+
</dict>
473+
<key>4</key>
458474
<dict>
459475
<key>name</key>
460476
<string>entity.name.function.tsx</string>
@@ -1061,7 +1077,7 @@
10611077
<key>method-declaration</key>
10621078
<dict>
10631079
<key>begin</key>
1064-
<string>\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?(?:(get|set)\s+)?(?:(new)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\&lt;)</string>
1080+
<string>\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\&lt;)</string>
10651081
<key>beginCaptures</key>
10661082
<dict>
10671083
<key>1</key>
@@ -1077,19 +1093,24 @@
10771093
<key>3</key>
10781094
<dict>
10791095
<key>name</key>
1080-
<string>storage.type.property.tsx</string>
1096+
<string>storage.modifier.tsx</string>
10811097
</dict>
10821098
<key>4</key>
10831099
<dict>
10841100
<key>name</key>
1085-
<string>keyword.operator.tsx</string>
1101+
<string>storage.type.property.tsx</string>
10861102
</dict>
10871103
<key>5</key>
10881104
<dict>
10891105
<key>name</key>
1090-
<string>entity.name.function.tsx</string>
1106+
<string>keyword.operator.tsx</string>
10911107
</dict>
10921108
<key>6</key>
1109+
<dict>
1110+
<key>name</key>
1111+
<string>entity.name.function.tsx</string>
1112+
</dict>
1113+
<key>7</key>
10931114
<dict>
10941115
<key>name</key>
10951116
<string>keyword.operator.tsx</string>
@@ -1139,21 +1160,36 @@
11391160
<key>2</key>
11401161
<dict>
11411162
<key>name</key>
1142-
<string>keyword.operator.tsx</string>
1163+
<string>storage.modifier.tsx</string>
11431164
</dict>
11441165
<key>3</key>
11451166
<dict>
11461167
<key>name</key>
1147-
<string>entity.name.function.tsx</string>
1168+
<string>storage.modifier.tsx</string>
11481169
</dict>
11491170
<key>4</key>
1171+
<dict>
1172+
<key>name</key>
1173+
<string>storage.type.property.tsx</string>
1174+
</dict>
1175+
<key>5</key>
1176+
<dict>
1177+
<key>name</key>
1178+
<string>keyword.operator.tsx</string>
1179+
</dict>
1180+
<key>6</key>
1181+
<dict>
1182+
<key>name</key>
1183+
<string>entity.name.function.tsx</string>
1184+
</dict>
1185+
<key>7</key>
11501186
<dict>
11511187
<key>name</key>
11521188
<string>keyword.operator.tsx</string>
11531189
</dict>
11541190
</dict>
11551191
<key>match</key>
1156-
<string>\b(?:(public|private|protected)\s+)?(?:(new)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\&lt;)</string>
1192+
<string>\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\&lt;)</string>
11571193
<key>name</key>
11581194
<string>meta.method.overload.declaration.tsx</string>
11591195
</dict>
@@ -1179,6 +1215,10 @@
11791215
<key>include</key>
11801216
<string>#type</string>
11811217
</dict>
1218+
<dict>
1219+
<key>include</key>
1220+
<string>#comment</string>
1221+
</dict>
11821222
</array>
11831223
</dict>
11841224
<key>null-literal</key>

0 commit comments

Comments
 (0)