@@ -8,8 +8,9 @@ file_extensions:
8
8
first_line_match : ^#!\s*/.*\b(node|js)\b
9
9
scope : source.js
10
10
variables :
11
- identifier_start : ' [_$\p{L}\p{Nl}]'
12
- identifier_part : ' [_$\p{L}\p{Nl}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]'
11
+ identifier_escape : (?:\\u(?:\h{4}|\{\h+\}))
12
+ identifier_start : (?:[_$\p{L}\p{Nl}]|{{identifier_escape}})
13
+ identifier_part : (?:[_$\p{L}\p{Nl}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]|{{identifier_escape}})
13
14
identifier_break : (?!{{identifier_part}})
14
15
15
16
identifier : (?:{{identifier_start}}{{identifier_part}}*{{identifier_break}})
@@ -384,7 +385,7 @@ contexts:
384
385
scope : punctuation.section.block.end.js
385
386
pop : true
386
387
- include : variable-binding-spread
387
- - match : (?={{identifier}})
388
+ - match : (?={{identifier}}|\[|'|" )
388
389
push :
389
390
- initializer
390
391
- variable-binding-object-alias
@@ -401,6 +402,8 @@ contexts:
401
402
variable-binding-object-key :
402
403
- match : ' {{identifier}}(?=\s*:)'
403
404
pop : true
405
+ - include : literal-string
406
+ - include : computed-property-name
404
407
- include : variable-binding-name
405
408
- include : else-pop
406
409
@@ -477,7 +480,7 @@ contexts:
477
480
scope : punctuation.section.block.end.js
478
481
pop : true
479
482
- include : function-parameter-binding-spread
480
- - match : (?={{identifier}})
483
+ - match : (?={{identifier}}|\[|'|" )
481
484
push :
482
485
- initializer
483
486
- function-parameter-binding-object-alias
@@ -493,6 +496,8 @@ contexts:
493
496
function-parameter-binding-object-key :
494
497
- match : ' {{identifier}}(?=\s*:)'
495
498
pop : true
499
+ - include : literal-string
500
+ - include : computed-property-name
496
501
- include : function-parameter-binding-name
497
502
- include : else-pop
498
503
@@ -696,23 +701,34 @@ contexts:
696
701
- match : (?:const|let|var){{identifier_break}}
697
702
scope : storage.type.js
698
703
set :
699
- - - match : (?:of|in){{identifier_break}}
700
- scope : keyword.operator.word.js
701
- set : expression
704
+ - - include : for-of-rest
702
705
- match : (?=\S)
703
706
set :
704
- - statements-in-parens
707
+ - for-oldstyle-rest
705
708
- variable-binding-list
706
709
- initializer
707
710
- variable-binding-pattern
708
711
709
712
- match : (?=\S)
710
- set : statements-in-parens
713
+ set :
714
+ - - include : for-of-rest
715
+ - match : (?=\S)
716
+ set : for-oldstyle-rest
717
+ - expression-end-no-in
718
+ - expression-begin
719
+
720
+ for-of-rest :
721
+ - match : (?:of|in){{identifier_break}}
722
+ scope : keyword.operator.word.js
723
+ set : expression
711
724
712
- statements-in-parens :
725
+ for-oldstyle-rest :
713
726
- match : (?=\))
714
727
pop : true
715
- - include : statements
728
+ - match : ;
729
+ scope : punctuation.separator.expression.js
730
+ - match : (?=\S)
731
+ push : expression
716
732
717
733
block-scope :
718
734
- include : block
@@ -829,6 +845,11 @@ contexts:
829
845
pop : true
830
846
- include : expression-end
831
847
848
+ expression-end-no-in :
849
+ - match : (?=in{{identifier_break}})
850
+ pop : true
851
+ - include : expression-end
852
+
832
853
expression-begin :
833
854
- include : expression-break
834
855
@@ -1204,15 +1225,20 @@ contexts:
1204
1225
- match : ' {{method_lookahead}}'
1205
1226
set : method-declaration
1206
1227
1207
- - match : (?={{property_name}})
1228
+ - match : |-
1229
+ (?x)(?=
1230
+ \#? {{identifier}}
1231
+ \s* = \s*
1232
+ {{either_func_lookahead}}
1233
+ )
1208
1234
set:
1209
- - field-initializer-or-method-declaration
1210
- - field-name
1235
+ - function-initializer
1236
+ - function-name-meta
1237
+ - literal-variable-base
1211
1238
1212
- - match : (?=#{{identifier }})
1239
+ - match : (?=#?{{property_name }})
1213
1240
set :
1214
- - class-field-rest
1215
- - initializer
1241
+ - field-initializer-or-method-declaration
1216
1242
- field-name
1217
1243
1218
1244
- include : else-pop
@@ -1268,7 +1294,10 @@ contexts:
1268
1294
- match : ' prototype{{identifier_break}}'
1269
1295
scope : support.constant.prototype.js
1270
1296
pop : true
1271
- - include : function-declaration-single-identifier
1297
+ - match : (?=#?{{identifier}})
1298
+ set :
1299
+ - function-name-meta
1300
+ - literal-variable-base
1272
1301
1273
1302
expect-dot-accessor :
1274
1303
- match : ' \.'
@@ -1294,39 +1323,9 @@ contexts:
1294
1323
pop : true
1295
1324
- include : else-pop
1296
1325
1297
- function-declaration-final-identifier :
1298
- - match : ' {{dollar_only_identifier}}'
1299
- scope : meta.property.object.dollar.only.js punctuation.dollar.js entity.name.function.js
1300
- pop : true
1301
- - match : ' {{dollar_identifier}}'
1302
- scope : meta.property.object.dollar.js entity.name.function.js
1303
- captures :
1304
- 1 : punctuation.dollar.js
1305
- pop : true
1306
- - match : ' {{constant_identifier}}'
1307
- scope : meta.property.object.constant.js entity.name.function.js
1308
- pop : true
1309
- - match : ' {{identifier}}'
1310
- scope : meta.property.object.readwrite.js entity.name.function.js
1311
- pop : true
1312
- - include : else-pop
1313
-
1314
- function-declaration-single-identifier :
1315
- - match : ' {{dollar_only_identifier}}'
1316
- scope : variable.other.dollar.only.js punctuation.dollar.js entity.name.function.js
1317
- pop : true
1318
- - match : ' {{dollar_identifier}}'
1319
- scope : variable.other.dollar.js entity.name.function.js
1320
- captures :
1321
- 1 : punctuation.dollar.js
1322
- pop : true
1323
- - match : ' {{constant_identifier}}'
1324
- scope : variable.other.constant.js entity.name.function.js
1325
- pop : true
1326
- - match : ' {{identifier}}'
1327
- scope : variable.other.readwrite.js entity.name.function.js
1328
- pop : true
1329
- - include : else-pop
1326
+ function-name-meta :
1327
+ - meta_scope : entity.name.function.js
1328
+ - include : immediately-pop
1330
1329
1331
1330
either-function-declaration :
1332
1331
- match : ' (?={{func_lookahead}})'
@@ -1499,6 +1498,12 @@ contexts:
1499
1498
scope : punctuation.separator.key-value.js
1500
1499
push : expression-no-comma
1501
1500
1501
+ # In case we're inside a destructured arrow function parameter that we
1502
+ # misidentified as an object literal.
1503
+ - match : ' ='
1504
+ scope : keyword.operator.assignment.js
1505
+ push : expression-no-comma
1506
+
1502
1507
bare-property-name :
1503
1508
- match : ' {{dollar_only_identifier}}'
1504
1509
scope : meta.object-literal.key.dollar.only.js punctuation.dollar.js
@@ -1518,7 +1523,6 @@ contexts:
1518
1523
pop : true
1519
1524
- match : (?=\S)
1520
1525
push : expression
1521
- - include : else-pop
1522
1526
1523
1527
object-literal-meta-key :
1524
1528
- meta_scope : meta.object-literal.key.js
@@ -1821,6 +1825,9 @@ contexts:
1821
1825
scope : variable.other.object.js
1822
1826
pop : true
1823
1827
1828
+ - include : literal-variable-base
1829
+
1830
+ literal-variable-base :
1824
1831
- match : ' {{dollar_only_identifier}}'
1825
1832
scope : variable.other.dollar.only.js punctuation.dollar.js
1826
1833
pop : true
@@ -1839,6 +1846,7 @@ contexts:
1839
1846
captures :
1840
1847
1 : punctuation.definition.variable.js
1841
1848
2 : variable.other.readwrite.js
1849
+ pop : true
1842
1850
1843
1851
language-identifiers :
1844
1852
- match : arguments{{identifier_break}}
@@ -2224,13 +2232,18 @@ contexts:
2224
2232
)
2225
2233
set:
2226
2234
- function-initializer
2227
- - function-declaration-final-identifier
2235
+ - function-name-meta
2236
+ - object-property-base
2228
2237
2229
2238
- include : support-property
2230
2239
2231
2240
- match : ' (?={{identifier}}\s*\()'
2232
2241
set : call-method-name
2233
2242
2243
+ - include : object-property-base
2244
+ - include : else-pop
2245
+
2246
+ object-property-base :
2234
2247
- match : ' {{dollar_only_identifier}}'
2235
2248
scope : meta.property.object.dollar.only.js punctuation.dollar.js
2236
2249
pop : true
@@ -2245,7 +2258,6 @@ contexts:
2245
2258
- match : ' {{identifier_part}}+{{identifier_break}}'
2246
2259
scope : invalid.illegal.illegal-identifier.js
2247
2260
pop : true
2248
- - include : else-pop
2249
2261
2250
2262
support-property :
2251
2263
- include : support-property-ecma
0 commit comments