Skip to content

Commit 361867a

Browse files
Thomas SmithThomas Smith
authored andcommitted
Integrated upstream changes (properly).
1 parent a8ee58d commit 361867a

File tree

2 files changed

+78
-63
lines changed

2 files changed

+78
-63
lines changed

extensions/flow_types.yaml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,18 @@ contexts: !merge
113113
- match: '{{method_lookahead}}'
114114
set: method-declaration
115115

116+
- match: |-
117+
(?x)(?=
118+
\#? {{identifier}}
119+
\s* = \s*
120+
{{either_func_lookahead}}
121+
)
122+
set:
123+
- function-initializer
124+
- flow-type-annotation-optional
125+
- function-name-meta
126+
- field-name
127+
116128
- match: (?={{property_name}})
117129
set:
118130
- field-initializer-or-method-declaration
@@ -185,15 +197,6 @@ contexts: !merge
185197
- match: (?=\S)
186198
pop: true
187199

188-
# flow-type-comment-block:
189-
# - match: '/\*::'
190-
# scope: comment.block.js punctuation.definition.comment.begin.js
191-
# push:
192-
# - match: \*/
193-
# scope: comment.block.js punctuation.definition.comment.end.js
194-
# pop: true
195-
# - include: statements
196-
197200
flow-type-pragma:
198201
- match: '(//)\s*(?=@)'
199202
scope: comment.line.double-slash.pragma.js

src/JavaScript.yaml

Lines changed: 66 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ file_extensions:
88
first_line_match: ^#!\s*/.*\b(node|js)\b
99
scope: source.js
1010
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}})
1314
identifier_break: (?!{{identifier_part}})
1415

1516
identifier: (?:{{identifier_start}}{{identifier_part}}*{{identifier_break}})
@@ -384,7 +385,7 @@ contexts:
384385
scope: punctuation.section.block.end.js
385386
pop: true
386387
- include: variable-binding-spread
387-
- match: (?={{identifier}})
388+
- match: (?={{identifier}}|\[|'|")
388389
push:
389390
- initializer
390391
- variable-binding-object-alias
@@ -401,6 +402,8 @@ contexts:
401402
variable-binding-object-key:
402403
- match: '{{identifier}}(?=\s*:)'
403404
pop: true
405+
- include: literal-string
406+
- include: computed-property-name
404407
- include: variable-binding-name
405408
- include: else-pop
406409

@@ -477,7 +480,7 @@ contexts:
477480
scope: punctuation.section.block.end.js
478481
pop: true
479482
- include: function-parameter-binding-spread
480-
- match: (?={{identifier}})
483+
- match: (?={{identifier}}|\[|'|")
481484
push:
482485
- initializer
483486
- function-parameter-binding-object-alias
@@ -493,6 +496,8 @@ contexts:
493496
function-parameter-binding-object-key:
494497
- match: '{{identifier}}(?=\s*:)'
495498
pop: true
499+
- include: literal-string
500+
- include: computed-property-name
496501
- include: function-parameter-binding-name
497502
- include: else-pop
498503

@@ -696,23 +701,34 @@ contexts:
696701
- match: (?:const|let|var){{identifier_break}}
697702
scope: storage.type.js
698703
set:
699-
- - match: (?:of|in){{identifier_break}}
700-
scope: keyword.operator.word.js
701-
set: expression
704+
- - include: for-of-rest
702705
- match: (?=\S)
703706
set:
704-
- statements-in-parens
707+
- for-oldstyle-rest
705708
- variable-binding-list
706709
- initializer
707710
- variable-binding-pattern
708711

709712
- 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
711724

712-
statements-in-parens:
725+
for-oldstyle-rest:
713726
- match: (?=\))
714727
pop: true
715-
- include: statements
728+
- match: ;
729+
scope: punctuation.separator.expression.js
730+
- match: (?=\S)
731+
push: expression
716732

717733
block-scope:
718734
- include: block
@@ -829,6 +845,11 @@ contexts:
829845
pop: true
830846
- include: expression-end
831847

848+
expression-end-no-in:
849+
- match: (?=in{{identifier_break}})
850+
pop: true
851+
- include: expression-end
852+
832853
expression-begin:
833854
- include: expression-break
834855

@@ -1204,15 +1225,20 @@ contexts:
12041225
- match: '{{method_lookahead}}'
12051226
set: method-declaration
12061227

1207-
- match: (?={{property_name}})
1228+
- match: |-
1229+
(?x)(?=
1230+
\#? {{identifier}}
1231+
\s* = \s*
1232+
{{either_func_lookahead}}
1233+
)
12081234
set:
1209-
- field-initializer-or-method-declaration
1210-
- field-name
1235+
- function-initializer
1236+
- function-name-meta
1237+
- literal-variable-base
12111238
1212-
- match: (?=#{{identifier}})
1239+
- match: (?=#?{{property_name}})
12131240
set:
1214-
- class-field-rest
1215-
- initializer
1241+
- field-initializer-or-method-declaration
12161242
- field-name
12171243

12181244
- include: else-pop
@@ -1268,7 +1294,10 @@ contexts:
12681294
- match: 'prototype{{identifier_break}}'
12691295
scope: support.constant.prototype.js
12701296
pop: true
1271-
- include: function-declaration-single-identifier
1297+
- match: (?=#?{{identifier}})
1298+
set:
1299+
- function-name-meta
1300+
- literal-variable-base
12721301

12731302
expect-dot-accessor:
12741303
- match: '\.'
@@ -1294,39 +1323,9 @@ contexts:
12941323
pop: true
12951324
- include: else-pop
12961325

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
13301329

13311330
either-function-declaration:
13321331
- match: '(?={{func_lookahead}})'
@@ -1499,6 +1498,12 @@ contexts:
14991498
scope: punctuation.separator.key-value.js
15001499
push: expression-no-comma
15011500

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+
15021507
bare-property-name:
15031508
- match: '{{dollar_only_identifier}}'
15041509
scope: meta.object-literal.key.dollar.only.js punctuation.dollar.js
@@ -1518,7 +1523,6 @@ contexts:
15181523
pop: true
15191524
- match: (?=\S)
15201525
push: expression
1521-
- include: else-pop
15221526

15231527
object-literal-meta-key:
15241528
- meta_scope: meta.object-literal.key.js
@@ -1821,6 +1825,9 @@ contexts:
18211825
scope: variable.other.object.js
18221826
pop: true
18231827

1828+
- include: literal-variable-base
1829+
1830+
literal-variable-base:
18241831
- match: '{{dollar_only_identifier}}'
18251832
scope: variable.other.dollar.only.js punctuation.dollar.js
18261833
pop: true
@@ -1839,6 +1846,7 @@ contexts:
18391846
captures:
18401847
1: punctuation.definition.variable.js
18411848
2: variable.other.readwrite.js
1849+
pop: true
18421850

18431851
language-identifiers:
18441852
- match: arguments{{identifier_break}}
@@ -2224,13 +2232,18 @@ contexts:
22242232
)
22252233
set:
22262234
- function-initializer
2227-
- function-declaration-final-identifier
2235+
- function-name-meta
2236+
- object-property-base
22282237
22292238
- include: support-property
22302239

22312240
- match: '(?={{identifier}}\s*\()'
22322241
set: call-method-name
22332242

2243+
- include: object-property-base
2244+
- include: else-pop
2245+
2246+
object-property-base:
22342247
- match: '{{dollar_only_identifier}}'
22352248
scope: meta.property.object.dollar.only.js punctuation.dollar.js
22362249
pop: true
@@ -2245,7 +2258,6 @@ contexts:
22452258
- match: '{{identifier_part}}+{{identifier_break}}'
22462259
scope: invalid.illegal.illegal-identifier.js
22472260
pop: true
2248-
- include: else-pop
22492261

22502262
support-property:
22512263
- include: support-property-ecma

0 commit comments

Comments
 (0)