Skip to content

Commit 2b3608c

Browse files
committed
Rebase from JS Custom 4.3.0
1 parent 2e81fcb commit 2b3608c

18 files changed

+3933
-2687
lines changed

JavaScript (Babel).sublime-syntax

+2,736-2,649
Large diffs are not rendered by default.

Styled Components.sublime-syntax

+26-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ first_line_match:
99
contexts:
1010
main:
1111
- meta_prepend: true
12-
- match: (?={{html_tags}}|{{svg_tags}})
13-
push: selector-content
12+
- match: (?=(?:{{html_tags}}|{{svg_tags}})(?!:))
13+
push: styled-components-selector-body
1414
- include: property-identifiers
1515
- include: property-values
1616

1717
rule-list-body:
18+
- meta_prepend: true
1819
- include: main
1920

2021
comments:
@@ -29,9 +30,31 @@ contexts:
2930
selectors:
3031
- meta_prepend: true
3132
- match: (?=&)
32-
push: selector-content
33+
push: styled-components-selector-body
34+
35+
selector-body:
36+
- meta_prepend: true
37+
- match: \&
38+
scope: variable.language.css.styled-components
3339

3440
selector-content:
3541
- meta_prepend: true
3642
- match: \&
3743
scope: variable.language.css.styled-components
44+
45+
# Make sure that we handle both the old and new CSS context names
46+
styled-components-selector-body:
47+
- meta_scope: meta.selector.css
48+
- include: selector-body
49+
- include: selector-content
50+
51+
at-keyframe-block-body:
52+
- meta_prepend: true
53+
54+
at-keyframe-block-content:
55+
- meta_prepend: true
56+
57+
styled-components-keyframe-body:
58+
- meta_scope: meta.at-rule.keyframe.css
59+
- include: at-keyframe-block-body
60+
- include: at-keyframe-block-content

tests/syntax_test_flow.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax"
1+
// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax"
22
/* Built-in types */
33

44
const x:boolean;

tests/syntax_test_js.js

+94-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax"
1+
// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax"
22

33
// comment
44
// <- comment.line.double-slash.js punctuation.definition.comment.js
@@ -296,7 +296,7 @@ a = test ? a + b : c;
296296
// ^ meta.block meta.block variable.other.readwrite
297297

298298
var obj = {
299-
// ^ meta.mapping punctuation.section.block.begin - meta.block
299+
// ^ meta.mapping punctuation.section.mapping.begin - meta.block
300300
key: bar,
301301
// <- meta.mapping.key
302302
$key2: "string value",
@@ -476,7 +476,7 @@ var obj = {
476476
// ^ keyword.operator
477477
// ^ constant.language
478478
};
479-
// <- meta.mapping punctuation.section.block.end
479+
// <- meta.mapping punctuation.section.mapping.end
480480

481481
({
482482
// <- meta.mapping
@@ -488,10 +488,10 @@ var obj = {
488488
});
489489

490490
[ a, b, c ];
491-
// <- meta.sequence punctuation.section.brackets.begin
491+
// <- meta.sequence punctuation.section.sequence.begin
492492
// ^ meta.sequence punctuation.separator.comma
493493
// ^^^^^^^^ meta.sequence
494-
// ^ meta.sequence punctuation.section.brackets.end
494+
// ^ meta.sequence punctuation.section.sequence.end
495495

496496
function x() {}
497497
[ a, b, c ];
@@ -723,9 +723,83 @@ class MyClass extends TheirClass {
723723
// ^^^^^^^^^^ meta.group
724724
// ^^^ entity.name.function
725725

726-
['foo']() {}
726+
@foo`bar` bar() {}
727+
// ^^^^^^^^^^ meta.annotation
728+
// ^ punctuation.definition.annotation
729+
// ^^^ variable.function.tagged-template
730+
// ^^^^^ meta.string string.quoted.other
731+
// ^ punctuation.definition.string.begin
732+
// ^ punctuation.definition.string.end
733+
// ^^^ meta.function entity.name.function
734+
735+
@foo['bar']() {}
736+
// ^^^^ meta.annotation
737+
// ^ punctuation.definition.annotation
738+
// ^^^ variable.annotation
739+
// ^^^^^^^^^^^^ meta.function - meta.annotation
740+
741+
@foo
742+
// ^^^^ meta.annotation
743+
// ^ - meta.annotation
744+
bar() {}
745+
// ^^^^^^^^ meta.function
746+
747+
@foo
748+
// ^^^^ meta.annotation
749+
// ^ - meta.annotation
750+
['bar']() {}
727751
// ^^^^^^^^^^^^ meta.function
728752
753+
@foo()
754+
// ^^^^^^ meta.annotation
755+
// ^ - meta.annotation
756+
bar() {}
757+
758+
@(foo)
759+
// ^^^^^^ meta.annotation
760+
// ^ - meta.annotation
761+
bar() {}
762+
763+
@foo // comment
764+
// ^^^^ meta.annotation - comment
765+
// ^ - comment - meta.annotation.js
766+
// ^^^^^^^^^^^ comment.line - meta.annotation
767+
bar() {}
768+
//^^ - meta.annotation
769+
// ^^^^^^^^ meta.function - meta.annotation
770+
771+
@foo /* comment
772+
// ^^^^ meta.annotation - comment
773+
// ^ - comment - meta.annotation.js
774+
// ^^^^^^^^^^^ comment.block.js - meta.annotation
775+
*/bar() {}
776+
//^^^^ comment.block.js - meta.annotation
777+
// ^^^^^^^^ meta.function - meta.annotation
778+
779+
@foo /* block */ /* comment
780+
// ^^^^ meta.annotation - comment
781+
// ^ - comment - meta.annotation.js
782+
// ^^^^^^^^^^^^^^^^^^^^^^^ - meta.annotation
783+
// ^^^^^^^^^^^ comment.block.js
784+
// ^^^^^^^^^^^ comment.block.js
785+
bar() {}
786+
// ^^^^^^^^^ comment.block.js
787+
*/bar() {}
788+
//^^^^ comment.block.js - meta.annotation
789+
// ^^^^^^^^ meta.function - meta.annotation
790+
791+
@foo /* block */ /* comment
792+
// ^^^^^ meta.annotation.js - comment
793+
// ^^^^^^^^^^^ meta.annotation.js comment.block.js
794+
// ^ meta.annotation.js - comment
795+
// ^^^^^^^^^^^ meta.annotation.js comment.block.js
796+
bar() {}
797+
// ^^^^^^^^^meta.annotation.js comment.block.js
798+
*/ . bar baz() {}
799+
//^^^^ meta.annotation.js comment.block.js
800+
// ^^^^^^ meta.annotation.js - comment
801+
// ^^^^^^^^ meta.function - meta.annotation
802+
729803
static ['foo']() {}
730804
// ^^^^^^^^^^^^ meta.function
731805
@@ -854,7 +928,7 @@ const test = ({a, b, c=()=>({active:false}) }) => {};
854928
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function
855929
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters
856930
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring
857-
// ^ punctuation.section.block.begin
931+
// ^ punctuation.section.mapping.begin
858932
// ^ variable.parameter
859933
// ^ variable.parameter
860934
// ^ variable.parameter
@@ -864,7 +938,7 @@ const test = ({a, b, c=()=>({active:false}) }) => {};
864938
// ^ punctuation.section.group.end
865939
// ^^^^^^^^^^^^^^^^ meta.group
866940
// ^ constant.language
867-
// ^ punctuation.section.block.end
941+
// ^ punctuation.section.mapping.end
868942
869943
([a,
870944
b]) => { return x; }
@@ -883,7 +957,7 @@ const test = ({a, b, c=()=>({active:false}) }) => {};
883957
({
884958
a = {},
885959
// ^ keyword.operator.assignment
886-
// ^^ punctuation.section.block
960+
// ^^ punctuation.section.mapping
887961
// ^ punctuation.separator.parameter - keyword.operator.comma
888962
b,
889963
// ^ punctuation.separator.parameter - keyword.operator.comma
@@ -955,6 +1029,7 @@ sources.DOM
9551029
// <- variable.other.readwrite
9561030
.status()
9571031
// ^ meta.function-call.method variable.function
1032+
// ^ - meta.function-call
9581033
9591034
foo.#bar();
9601035
// ^^^^^^^^^^ meta.function-call.method.js
@@ -987,7 +1062,7 @@ var foo = ~{a:function(){}.a()}
9871062
// ^^^ variable.other.readwrite
9881063
// ^ keyword.operator.assignment
9891064
// ^ keyword.operator.bitwise
990-
// ^ punctuation.section.block.begin
1065+
// ^ punctuation.section.mapping.begin
9911066
// ^^^^^^^^^^^^^^^^^^^^ meta.mapping
9921067
// ^^^^^^^^^^^^ meta.function
9931068
// ^ entity.name.function
@@ -1002,14 +1077,14 @@ var foo = ~{a:function(){}.a()}
10021077
// ^ variable.function - entity.name.function
10031078
// ^ punctuation.section.group.begin
10041079
// ^ punctuation.section.group.end
1005-
// ^ punctuation.section.block.end
1080+
// ^ punctuation.section.mapping.end
10061081
// ^ - meta
10071082
10081083
baz(foo(x => x('bar')));
10091084
// ^ meta.function-call meta.function-call punctuation.section.group.end
10101085
// ^ meta.function-call punctuation.section.group.end
10111086
1012-
func(a, b);
1087+
func(a, b) ;
10131088
//^^^^^^^^ meta.function-call
10141089
// ^ variable.function
10151090
// ^^^^^^ meta.group
@@ -1018,6 +1093,7 @@ func(a, b);
10181093
// ^ punctuation.separator.comma
10191094
// ^ variable.other.readwrite
10201095
// ^ punctuation.section.group.end
1096+
// ^ - meta.function-call
10211097
10221098
var instance = new Constructor(param1, param2)
10231099
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.constructor
@@ -1105,7 +1181,7 @@ void {
11051181
// ^ meta.brackets
11061182
'test3': "asdf"
11071183
}
1108-
// <- meta.mapping punctuation.section.block.end
1184+
// <- meta.mapping punctuation.section.mapping.end
11091185
11101186
// This tests parsing semi-broken object literals, which should help while a
11111187
// user is in the middle of typing code
@@ -1299,7 +1375,7 @@ new FooBar(function(){
12991375
13001376
var test =
13011377
{a: 1}
1302-
// <- meta.mapping punctuation.section.block.begin
1378+
// <- meta.mapping punctuation.section.mapping.begin
13031379
13041380
var arrowFuncBraceNextLine = () => /* comments! */
13051381
// ^ entity.name.function
@@ -1351,7 +1427,7 @@ $var.fn.name = () => {}
13511427
// ^ variable.other.dollar - punctuation.dollar
13521428
13531429
someFunction(() => [() => 'X']);
1354-
// ^ punctuation.section.brackets.end
1430+
// ^ punctuation.section.sequence.end
13551431
13561432
string = 'invalid
13571433
// ^ invalid.illegal.newline
@@ -1431,10 +1507,10 @@ var query = {
14311507
// ^ keyword.operator.ternary
14321508
// ^^^^ constant.language.null
14331509
// ^ keyword.operator.ternary
1434-
// ^ punctuation.section.block.begin
1510+
// ^ punctuation.section.mapping.begin
14351511
// ^^ meta.mapping.key.js
14361512
// ^ punctuation.separator.key-value.js
1437-
// ^ punctuation.section.block.end
1513+
// ^ punctuation.section.mapping.end
14381514
};
14391515
14401516
var str = `Hello, ${name}!`;
@@ -1597,7 +1673,7 @@ debugger
15971673
// <- meta.sequence
15981674

15991675
a ?? b;
1600-
// ^^ keyword.operator.logical
1676+
// ^^ keyword.operator.null-coalescing
16011677

16021678
a &&= b;
16031679
// ^^^ keyword.operator.assignment.augmented

tests/syntax_test_js_bindings.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax"
1+
// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax"
22

33

44
// Variable declarations
@@ -102,6 +102,18 @@ function f ([ x, [a, b], z]) {}
102102
// ^ meta.binding.name variable.parameter.function
103103
// ^ meta.binding.name variable.parameter.function
104104

105+
function f ([ $x, [$a, $b], $z]) {}
106+
// ^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence
107+
// ^ meta.binding.name variable.parameter.function punctuation.dollar
108+
// ^ meta.binding.name variable.parameter.function - punctuation.dollar
109+
// ^^^^^^^^ meta.binding.destructuring.sequence meta.binding.destructuring.sequence
110+
// ^ meta.binding.name variable.parameter.function punctuation.dollar
111+
// ^ meta.binding.name variable.parameter.function - punctuation.dollar
112+
// ^ meta.binding.name variable.parameter.function punctuation.dollar
113+
// ^ meta.binding.name variable.parameter.function - punctuation.dollar
114+
// ^ meta.binding.name variable.parameter.function punctuation.dollar
115+
// ^ meta.binding.name variable.parameter.function - punctuation.dollar
116+
105117
function f ([ x = 42, y = [a, b, c] ]) {}
106118
// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence
107119
// ^ keyword.operator.assignment
@@ -137,6 +149,13 @@ function f (a, ...rest) {}
137149
// ^^^ keyword.operator.spread
138150
// ^^^^ variable.parameter.function
139151

152+
function f ($a, ...$rest) {}
153+
// ^ meta.binding.name variable.parameter.function punctuation.dollar
154+
// ^ meta.binding.name variable.parameter.function - punctuation.dollar
155+
// ^^^ keyword.operator.spread
156+
// ^ meta.binding.name variable.parameter.function punctuation.dollar
157+
// ^^^^ meta.binding.name variable.parameter.function - punctuation.dollar
158+
140159
function f (new) {}
141160
// ^^^^^^^^^^^^^^^^ meta.function
142161
// ^^^ invalid.illegal.identifier meta.binding.name variable.parameter.function

tests/syntax_test_js_class.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax"
1+
// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax"
22

33
class MyClass extends TheirClass {
44
// <- keyword.declaration.class
@@ -31,12 +31,20 @@ class MyClass extends TheirClass {
3131
// ^ keyword.operator.assignment
3232
// ^^ constant.numeric
3333

34+
[w]
35+
get other() {}
36+
// ^^^ storage.type.accessor.js
37+
3438
#v = 42;
3539
// ^ punctuation.definition.variable
3640
// ^ variable.other.readwrite
3741
// ^ keyword.operator.assignment
3842
// ^^ constant.numeric
3943

44+
#u
45+
get other() {}
46+
// ^^^ storage.type.accessor.js
47+
4048
f = a => b;
4149
// ^ entity.name.function variable.other.readwrite
4250
// ^^^^^^ meta.function
@@ -117,6 +125,10 @@ class MyClass extends TheirClass {
117125
// ^^^^^^^^^^^ meta.function
118126
// ^^^^^^ entity.name.function
119127

128+
accessor foo;
129+
// ^^^^^^^^ storage.modifier
130+
// ^^^ variable.other.readwrite
131+
120132
foo // You thought I was a field...
121133
() { return '...but was a method all along!'; }
122134
// ^^ meta.class meta.block meta.function

tests/syntax_test_js_control.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax"
1+
// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax"
22

33
if ( true ) { } ;
44
// ^^^^^^^^^^^^^^^ meta.conditional
@@ -336,7 +336,8 @@ try {
336336
// <- meta.block
337337
//^^^^^^^^^^^^ meta.catch
338338
//^^^^^ keyword.control.exception.catch
339-
// ^ meta.group
339+
// ^^^ meta.group
340+
// ^ meta.binding.name variable.other.readwrite
340341
// ^ meta.block
341342
foobar = 0
342343
// ^^^^^^^^^^ meta.catch meta.block

0 commit comments

Comments
 (0)