diff --git a/JavaScript/JavaScript.sublime-syntax b/JavaScript/JavaScript.sublime-syntax index d3c8f47c83..0e2b26c224 100644 --- a/JavaScript/JavaScript.sublime-syntax +++ b/JavaScript/JavaScript.sublime-syntax @@ -271,8 +271,8 @@ contexts: - match: |- (?x) (?: - ((')((?:[^']|\\')*)('))| - ((")((?:[^"]|\\")*)(")) + ((')((?:[^'\\]+|\\.)*)('))| + ((")((?:[^"\\]+|\\.)*)(")) ) \s*(:) \s*(async)? @@ -298,8 +298,8 @@ contexts: - match: |- (?x) (?: - ((')((?:[^']|\\')*)('))| - ((")((?:[^"]|\\")*)(")) + ((')((?:[^'\\]+|\\.)*)('))| + ((")((?:[^"\\]+|\\.)*)(")) ) \s*(:) \s*(async)? @@ -350,6 +350,17 @@ contexts: - include: brackets - include: comments - include: literal-method + - match: '(?:(?:(static|async)|(get|set))\s+)?(?:\s*(\*)\s*)?([$_a-zA-Z][$\w]*)(?=\()' + captures: + 1: storage.type.js + 2: storage.type.accessor + 3: keyword.generator.asterisk.js + 4: entity.name.function.method.js + push: + - meta_scope: meta.method.js + - match: (?<=\)) + pop: true + - include: function-declaration-parameters literal-constructor: - match: '(new)\s+(?=[_$a-zA-Z][$\w.]*)' captures: @@ -462,6 +473,13 @@ contexts: pop: true - include: function-declaration-parameters literal-function-call: + - match: |- + (?x) + ((? qux) { + +} + +switch ($foo) { + case foo: + // ^ keyword.control.switch + // ^ - punctuation.separator.key-value + qux = 1; + break; + // ^ keyword.control.loop + case "baz": + // ^ keyword.control.switch + // ^ - punctuation.separator.key-value string + qux = 2; + break; + // ^ keyword.control.loop + default: + // ^ keyword.control.switch + // ^ - punctuation.separator.key-value + qux = 3; +} + +class MyClass extends TheirClass { + constructor(el) + // ^ entity.name.function + { + $.foo = ""; + super(el); + } + + get foo() + // <- storage.type.accessor + // ^ entity.name.function + { + return this._foo; + } + + static foo(baz) { + // ^ storage.type + // ^ entity.name.function + + } + + qux() + { } + + get bar () { + // <- storage.type.accessor + // ^ entity.name.function + return false; + } + + baz() { return null } + // <- entity.name.function +} + +MyClass.foo = function() {} +// ^ support.class +// ^ entity.name.function + +var simpleArrow = foo => bar +// ^ entity.name.function +// ^ variable.parameter.function +// ^ storage.type.function.arrow + +var Proto = () => { +// ^ entity.name.function +// ^ storage.type.function.arrow + this._var = 1; +} + +Proto.prototype.getVar = () => this._var +// ^ entity.name.class +// ^ support.constant.prototype +// ^ entity.name.function +// ^ storage.type.function.arrow