Skip to content

Commit

Permalink
Rebase from JS Custom 4.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Thom1729 committed May 10, 2023
1 parent 2e81fcb commit 2b3608c
Show file tree
Hide file tree
Showing 18 changed files with 3,933 additions and 2,687 deletions.
5,385 changes: 2,736 additions & 2,649 deletions JavaScript (Babel).sublime-syntax

Large diffs are not rendered by default.

29 changes: 26 additions & 3 deletions Styled Components.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ first_line_match:
contexts:
main:
- meta_prepend: true
- match: (?={{html_tags}}|{{svg_tags}})
push: selector-content
- match: (?=(?:{{html_tags}}|{{svg_tags}})(?!:))
push: styled-components-selector-body
- include: property-identifiers
- include: property-values

rule-list-body:
- meta_prepend: true
- include: main

comments:
Expand All @@ -29,9 +30,31 @@ contexts:
selectors:
- meta_prepend: true
- match: (?=&)
push: selector-content
push: styled-components-selector-body

selector-body:
- meta_prepend: true
- match: \&
scope: variable.language.css.styled-components

selector-content:
- meta_prepend: true
- match: \&
scope: variable.language.css.styled-components

# Make sure that we handle both the old and new CSS context names
styled-components-selector-body:
- meta_scope: meta.selector.css
- include: selector-body
- include: selector-content

at-keyframe-block-body:
- meta_prepend: true

at-keyframe-block-content:
- meta_prepend: true

styled-components-keyframe-body:
- meta_scope: meta.at-rule.keyframe.css
- include: at-keyframe-block-body
- include: at-keyframe-block-content
2 changes: 1 addition & 1 deletion tests/syntax_test_flow.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax"
// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax"
/* Built-in types */

const x:boolean;
Expand Down
112 changes: 94 additions & 18 deletions tests/syntax_test_js.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax"
// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax"

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

var obj = {
// ^ meta.mapping punctuation.section.block.begin - meta.block
// ^ meta.mapping punctuation.section.mapping.begin - meta.block
key: bar,
// <- meta.mapping.key
$key2: "string value",
Expand Down Expand Up @@ -476,7 +476,7 @@ var obj = {
// ^ keyword.operator
// ^ constant.language
};
// <- meta.mapping punctuation.section.block.end
// <- meta.mapping punctuation.section.mapping.end

({
// <- meta.mapping
Expand All @@ -488,10 +488,10 @@ var obj = {
});

[ a, b, c ];
// <- meta.sequence punctuation.section.brackets.begin
// <- meta.sequence punctuation.section.sequence.begin
// ^ meta.sequence punctuation.separator.comma
// ^^^^^^^^ meta.sequence
// ^ meta.sequence punctuation.section.brackets.end
// ^ meta.sequence punctuation.section.sequence.end

function x() {}
[ a, b, c ];
Expand Down Expand Up @@ -723,9 +723,83 @@ class MyClass extends TheirClass {
// ^^^^^^^^^^ meta.group
// ^^^ entity.name.function

['foo']() {}
@foo`bar` bar() {}
// ^^^^^^^^^^ meta.annotation
// ^ punctuation.definition.annotation
// ^^^ variable.function.tagged-template
// ^^^^^ meta.string string.quoted.other
// ^ punctuation.definition.string.begin
// ^ punctuation.definition.string.end
// ^^^ meta.function entity.name.function
@foo['bar']() {}
// ^^^^ meta.annotation
// ^ punctuation.definition.annotation
// ^^^ variable.annotation
// ^^^^^^^^^^^^ meta.function - meta.annotation
@foo
// ^^^^ meta.annotation
// ^ - meta.annotation
bar() {}
// ^^^^^^^^ meta.function
@foo
// ^^^^ meta.annotation
// ^ - meta.annotation
['bar']() {}
// ^^^^^^^^^^^^ meta.function
@foo()
// ^^^^^^ meta.annotation
// ^ - meta.annotation
bar() {}
@(foo)
// ^^^^^^ meta.annotation
// ^ - meta.annotation
bar() {}
@foo // comment
// ^^^^ meta.annotation - comment
// ^ - comment - meta.annotation.js
// ^^^^^^^^^^^ comment.line - meta.annotation
bar() {}
//^^ - meta.annotation
// ^^^^^^^^ meta.function - meta.annotation
@foo /* comment
// ^^^^ meta.annotation - comment
// ^ - comment - meta.annotation.js
// ^^^^^^^^^^^ comment.block.js - meta.annotation
*/bar() {}
//^^^^ comment.block.js - meta.annotation
// ^^^^^^^^ meta.function - meta.annotation
@foo /* block */ /* comment
// ^^^^ meta.annotation - comment
// ^ - comment - meta.annotation.js
// ^^^^^^^^^^^^^^^^^^^^^^^ - meta.annotation
// ^^^^^^^^^^^ comment.block.js
// ^^^^^^^^^^^ comment.block.js
bar() {}
// ^^^^^^^^^ comment.block.js
*/bar() {}
//^^^^ comment.block.js - meta.annotation
// ^^^^^^^^ meta.function - meta.annotation
@foo /* block */ /* comment
// ^^^^^ meta.annotation.js - comment
// ^^^^^^^^^^^ meta.annotation.js comment.block.js
// ^ meta.annotation.js - comment
// ^^^^^^^^^^^ meta.annotation.js comment.block.js
bar() {}
// ^^^^^^^^^meta.annotation.js comment.block.js
*/ . bar baz() {}
//^^^^ meta.annotation.js comment.block.js
// ^^^^^^ meta.annotation.js - comment
// ^^^^^^^^ meta.function - meta.annotation
static ['foo']() {}
// ^^^^^^^^^^^^ meta.function
Expand Down Expand Up @@ -854,7 +928,7 @@ const test = ({a, b, c=()=>({active:false}) }) => {};
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring
// ^ punctuation.section.block.begin
// ^ punctuation.section.mapping.begin
// ^ variable.parameter
// ^ variable.parameter
// ^ variable.parameter
Expand All @@ -864,7 +938,7 @@ const test = ({a, b, c=()=>({active:false}) }) => {};
// ^ punctuation.section.group.end
// ^^^^^^^^^^^^^^^^ meta.group
// ^ constant.language
// ^ punctuation.section.block.end
// ^ punctuation.section.mapping.end
([a,
b]) => { return x; }
Expand All @@ -883,7 +957,7 @@ const test = ({a, b, c=()=>({active:false}) }) => {};
({
a = {},
// ^ keyword.operator.assignment
// ^^ punctuation.section.block
// ^^ punctuation.section.mapping
// ^ punctuation.separator.parameter - keyword.operator.comma
b,
// ^ punctuation.separator.parameter - keyword.operator.comma
Expand Down Expand Up @@ -955,6 +1029,7 @@ sources.DOM
// <- variable.other.readwrite
.status()
// ^ meta.function-call.method variable.function
// ^ - meta.function-call
foo.#bar();
// ^^^^^^^^^^ meta.function-call.method.js
Expand Down Expand Up @@ -987,7 +1062,7 @@ var foo = ~{a:function(){}.a()}
// ^^^ variable.other.readwrite
// ^ keyword.operator.assignment
// ^ keyword.operator.bitwise
// ^ punctuation.section.block.begin
// ^ punctuation.section.mapping.begin
// ^^^^^^^^^^^^^^^^^^^^ meta.mapping
// ^^^^^^^^^^^^ meta.function
// ^ entity.name.function
Expand All @@ -1002,14 +1077,14 @@ var foo = ~{a:function(){}.a()}
// ^ variable.function - entity.name.function
// ^ punctuation.section.group.begin
// ^ punctuation.section.group.end
// ^ punctuation.section.block.end
// ^ punctuation.section.mapping.end
// ^ - meta
baz(foo(x => x('bar')));
// ^ meta.function-call meta.function-call punctuation.section.group.end
// ^ meta.function-call punctuation.section.group.end
func(a, b);
func(a, b) ;
//^^^^^^^^ meta.function-call
// ^ variable.function
// ^^^^^^ meta.group
Expand All @@ -1018,6 +1093,7 @@ func(a, b);
// ^ punctuation.separator.comma
// ^ variable.other.readwrite
// ^ punctuation.section.group.end
// ^ - meta.function-call
var instance = new Constructor(param1, param2)
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.constructor
Expand Down Expand Up @@ -1105,7 +1181,7 @@ void {
// ^ meta.brackets
'test3': "asdf"
}
// <- meta.mapping punctuation.section.block.end
// <- meta.mapping punctuation.section.mapping.end
// This tests parsing semi-broken object literals, which should help while a
// user is in the middle of typing code
Expand Down Expand Up @@ -1299,7 +1375,7 @@ new FooBar(function(){
var test =
{a: 1}
// <- meta.mapping punctuation.section.block.begin
// <- meta.mapping punctuation.section.mapping.begin
var arrowFuncBraceNextLine = () => /* comments! */
// ^ entity.name.function
Expand Down Expand Up @@ -1351,7 +1427,7 @@ $var.fn.name = () => {}
// ^ variable.other.dollar - punctuation.dollar
someFunction(() => [() => 'X']);
// ^ punctuation.section.brackets.end
// ^ punctuation.section.sequence.end
string = 'invalid
// ^ invalid.illegal.newline
Expand Down Expand Up @@ -1431,10 +1507,10 @@ var query = {
// ^ keyword.operator.ternary
// ^^^^ constant.language.null
// ^ keyword.operator.ternary
// ^ punctuation.section.block.begin
// ^ punctuation.section.mapping.begin
// ^^ meta.mapping.key.js
// ^ punctuation.separator.key-value.js
// ^ punctuation.section.block.end
// ^ punctuation.section.mapping.end
};
var str = `Hello, ${name}!`;
Expand Down Expand Up @@ -1597,7 +1673,7 @@ debugger
// <- meta.sequence

a ?? b;
// ^^ keyword.operator.logical
// ^^ keyword.operator.null-coalescing

a &&= b;
// ^^^ keyword.operator.assignment.augmented
Expand Down
21 changes: 20 additions & 1 deletion tests/syntax_test_js_bindings.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax"
// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax"


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

function f ([ $x, [$a, $b], $z]) {}
// ^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence
// ^ meta.binding.name variable.parameter.function punctuation.dollar
// ^ meta.binding.name variable.parameter.function - punctuation.dollar
// ^^^^^^^^ meta.binding.destructuring.sequence meta.binding.destructuring.sequence
// ^ meta.binding.name variable.parameter.function punctuation.dollar
// ^ meta.binding.name variable.parameter.function - punctuation.dollar
// ^ meta.binding.name variable.parameter.function punctuation.dollar
// ^ meta.binding.name variable.parameter.function - punctuation.dollar
// ^ meta.binding.name variable.parameter.function punctuation.dollar
// ^ meta.binding.name variable.parameter.function - punctuation.dollar

function f ([ x = 42, y = [a, b, c] ]) {}
// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence
// ^ keyword.operator.assignment
Expand Down Expand Up @@ -137,6 +149,13 @@ function f (a, ...rest) {}
// ^^^ keyword.operator.spread
// ^^^^ variable.parameter.function

function f ($a, ...$rest) {}
// ^ meta.binding.name variable.parameter.function punctuation.dollar
// ^ meta.binding.name variable.parameter.function - punctuation.dollar
// ^^^ keyword.operator.spread
// ^ meta.binding.name variable.parameter.function punctuation.dollar
// ^^^^ meta.binding.name variable.parameter.function - punctuation.dollar

function f (new) {}
// ^^^^^^^^^^^^^^^^ meta.function
// ^^^ invalid.illegal.identifier meta.binding.name variable.parameter.function
Expand Down
14 changes: 13 additions & 1 deletion tests/syntax_test_js_class.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax"
// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax"

class MyClass extends TheirClass {
// <- keyword.declaration.class
Expand Down Expand Up @@ -31,12 +31,20 @@ class MyClass extends TheirClass {
// ^ keyword.operator.assignment
// ^^ constant.numeric

[w]
get other() {}
// ^^^ storage.type.accessor.js

#v = 42;
// ^ punctuation.definition.variable
// ^ variable.other.readwrite
// ^ keyword.operator.assignment
// ^^ constant.numeric

#u
get other() {}
// ^^^ storage.type.accessor.js

f = a => b;
// ^ entity.name.function variable.other.readwrite
// ^^^^^^ meta.function
Expand Down Expand Up @@ -117,6 +125,10 @@ class MyClass extends TheirClass {
// ^^^^^^^^^^^ meta.function
// ^^^^^^ entity.name.function

accessor foo;
// ^^^^^^^^ storage.modifier
// ^^^ variable.other.readwrite

foo // You thought I was a field...
() { return '...but was a method all along!'; }
// ^^ meta.class meta.block meta.function
Expand Down
5 changes: 3 additions & 2 deletions tests/syntax_test_js_control.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax"
// SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax"

if ( true ) { } ;
// ^^^^^^^^^^^^^^^ meta.conditional
Expand Down Expand Up @@ -336,7 +336,8 @@ try {
// <- meta.block
//^^^^^^^^^^^^ meta.catch
//^^^^^ keyword.control.exception.catch
// ^ meta.group
// ^^^ meta.group
// ^ meta.binding.name variable.other.readwrite
// ^ meta.block
foobar = 0
// ^^^^^^^^^^ meta.catch meta.block
Expand Down
Loading

0 comments on commit 2b3608c

Please sign in to comment.