Skip to content

Commit ed77a58

Browse files
authored
[JavaScript] Fix scope of generator operator (#4509)
This commit scopes `*` after `yield` and `function` `storage.modifier.generator` as current scope is not part of scope naming guideline. The asterisk turns a function into a generator when following the `function` keyword. The `yield*` expression delegates value generation to another generator like `yield from` in Python.
1 parent d24455a commit ed77a58

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

JavaScript/JavaScript.sublime-syntax

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,7 +1662,7 @@ contexts:
16621662
- match: $
16631663
pop: 1
16641664
- match: \*
1665-
scope: keyword.generator.asterisk.js
1665+
scope: storage.modifier.generator.js
16661666
set: expression-begin
16671667
- match: (?=\S)
16681668
set: expression-begin
@@ -1867,7 +1867,7 @@ contexts:
18671867

18681868
function-declaration-expect-generator-star:
18691869
- match: \*
1870-
scope: keyword.declaration.generator.js
1870+
scope: storage.modifier.generator.js
18711871
pop: 1
18721872
- include: else-pop
18731873

JavaScript/tests/syntax_test_js.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ someFunction({
160160
// ^^^ entity.name.function variable.other.readwrite
161161
// ^^^^^^^^^^^ meta.function - meta.function meta.function
162162
// ^^^^^^^^ keyword.declaration.function
163-
// ^ keyword.declaration.generator
163+
// ^ storage.modifier.generator.js
164164
{
165165

166166
}

JavaScript/tests/syntax_test_js_control.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,13 @@ while (true)
385385
x = yield;
386386
// ^^^^^ keyword.control.flow.yield
387387

388+
x = yield* 42;
389+
// ^^^^^ keyword.control.flow.yield
390+
// ^ storage.modifier.generator.js
391+
388392
x = yield * 42;
389393
// ^^^^^ keyword.control.flow.yield
390-
// ^ keyword.generator.asterisk
394+
// ^ storage.modifier.generator.js
391395

392396
x = yield
393397
function f() {}

0 commit comments

Comments
 (0)