diff --git a/JavaScript/JavaScript.sublime-syntax b/JavaScript/JavaScript.sublime-syntax index a731104453..6c90f8ce56 100644 --- a/JavaScript/JavaScript.sublime-syntax +++ b/JavaScript/JavaScript.sublime-syntax @@ -21,6 +21,9 @@ contexts: - include: keywords-top-level - include: statements + prototype: + - include: comments + keywords-top-level: - match: \bimport\b scope: meta.import.js keyword.control.import-export.js @@ -40,7 +43,6 @@ contexts: import-extended: - meta_content_scope: meta.import.js - include: import-escape - - include: comments - match: '\{' scope: meta.block.js punctuation.section.block.js set: import-brace @@ -66,7 +68,6 @@ contexts: import-extended-continue: - meta_scope: meta.import.js - include: import-escape - - include: comments - match: ',' scope: punctuation.separator.comma.js set: import-extended @@ -76,7 +77,6 @@ contexts: import-brace: - meta_content_scope: meta.import.js meta.block.js - include: import-escape - - include: comments - match: '\}' scope: punctuation.section.block.js set: import-extended-as @@ -102,7 +102,6 @@ contexts: import-brace-continue: - meta_scope: meta.import.js meta.block.js - include: import-escape - - include: comments - match: '(?=\})' set: import-brace - match: ',' @@ -113,7 +112,6 @@ contexts: import-final: - meta_scope: meta.import.js - - include: comments - match: '\bfrom\b' scope: keyword.control.import-export.js - include: literal-string @@ -135,7 +133,6 @@ contexts: pop: true - include: expressions - include: export-escape - - include: comments - match: '\bdefault\b' scope: keyword.control.import-export.js set: @@ -165,7 +162,6 @@ contexts: export-extended-continue: - meta_scope: meta.export.js - include: export-escape - - include: comments - match: ',' scope: punctuation.separator.comma.js set: export-extended @@ -175,7 +171,6 @@ contexts: export-brace: - meta_content_scope: meta.export.js meta.block.js - include: export-escape - - include: comments - match: '\}' scope: punctuation.section.block.js set: export-extended-as @@ -205,7 +200,6 @@ contexts: export-brace-continue: - meta_scope: meta.export.js meta.block.js - include: export-escape - - include: comments - match: '(?=\})' set: export-brace - match: ',' @@ -216,7 +210,6 @@ contexts: export-final: - meta_scope: meta.export.js - - include: comments - match: '\bfrom\b' scope: keyword.control.import-export.js - include: literal-string @@ -270,7 +263,6 @@ contexts: scope: keyword.control.loop.js push: - meta_scope: meta.do-while.js - - include: comments - match: '\{' scope: punctuation.section.block.js push: @@ -352,7 +344,6 @@ contexts: - include: block-scope block-scope: - - include: comments - match: '\}' scope: meta.block.js punctuation.section.block.js pop: true @@ -367,7 +358,6 @@ contexts: pop: true expressions: - - include: comments - include: regexp-complete - include: literal-string - include: literal-string-template @@ -424,6 +414,7 @@ contexts: - match: /\*\*(?!/) scope: punctuation.definition.comment.js push: + - meta_include_prototype: false - meta_scope: comment.block.documentation.js - match: \*/ scope: punctuation.definition.comment.js @@ -431,6 +422,7 @@ contexts: - match: /\* scope: punctuation.definition.comment.js push: + - meta_include_prototype: false - meta_scope: comment.block.js - match: \*/ scope: punctuation.definition.comment.js @@ -438,6 +430,7 @@ contexts: - match: // scope: punctuation.definition.comment.js push: + - meta_include_prototype: false - meta_scope: comment.line.double-slash.js - match: \n pop: true @@ -446,6 +439,7 @@ contexts: - match: "'" scope: punctuation.definition.string.begin.js push: + - meta_include_prototype: false - meta_scope: string.quoted.single.js - match: (')|(\n) captures: @@ -457,6 +451,7 @@ contexts: captures: 0: punctuation.definition.string.begin.js push: + - meta_include_prototype: false - meta_scope: string.quoted.double.js - match: (")|(\n) captures: @@ -471,6 +466,7 @@ contexts: 1: variable.function.tagged-template.js 2: punctuation.definition.string.template.begin.js push: + - meta_include_prototype: false - meta_scope: string.template.js - match: "`" scope: punctuation.definition.string.template.end.js @@ -495,11 +491,22 @@ contexts: scope: constant.character.escape.js regexp-complete: - - match: '/(?=(?:[^/\\\[]|\\.|\[([^\]\\]|\\.)+\])+/(?![/*])[gimyu]*(?!\s*[a-zA-Z0-9_$]))' + - match: >- + (?x) / (?= + (?: + [^ / \\ \[ ] + | \\. + | \[ ([^\]\\]|\\.)+ \] + )+ + / + [gimyu]* + (?!\s*[a-zA-Z0-9_$]) + ) scope: punctuation.definition.string.begin.js push: regexp regexp: + - meta_include_prototype: false - meta_scope: string.regexp.js - match: "(/)([gimyu]*)" captures: @@ -508,6 +515,7 @@ contexts: set: after-identifier - match: '(?=.|\n)' push: + - meta_include_prototype: false - match: '(?=/)' pop: true - include: scope:source.regexp.js @@ -677,11 +685,9 @@ contexts: pop: true - match: '{{identifier}}' scope: entity.name.class.js - - include: comments class-body: - meta_scope: meta.class.js meta.block.js - - include: comments - match: '\}' scope: punctuation.section.block.js pop: true @@ -856,7 +862,6 @@ contexts: push: arrow-function-declaration function-declaration: - - include: comments - match: '\b(async)\b\s*' scope: meta.function.declaration.js captures: @@ -898,7 +903,6 @@ contexts: arrow-function-declaration-continuation: - meta_content_scope: meta.function.declaration.js - - include: comments - match: '(?=\{)' set: function-block - match: '(?=\S)' @@ -982,7 +986,6 @@ contexts: - match: "(?=[,)])" pop: true - include: expressions - - include: comments label: - match: '^\s*((?!default){{identifier}})\s*(:)' @@ -998,7 +1001,6 @@ contexts: - match: '\}' scope: punctuation.section.block.js set: after-identifier - - include: comments - match: \[ scope: punctuation.section.brackets.js push: @@ -1036,6 +1038,7 @@ contexts: - match: "'" scope: punctuation.definition.string.begin.js push: + - meta_include_prototype: false - meta_scope: string.quoted.single.js - meta_content_scope: entity.name.function.js - match: (')|(\n) @@ -1047,6 +1050,7 @@ contexts: - match: '"' scope: punctuation.definition.string.begin.js push: + - meta_include_prototype: false - meta_scope: string.quoted.double.js - meta_content_scope: entity.name.function.js - match: (")|(\n) @@ -1091,7 +1095,6 @@ contexts: - match: "(?=\\}|,|('[^']*'|\"[^\"]*\"|{{identifier}})\\s*:)" pop: true - include: expressions - - include: comments method-declaration: - match: \b(get|set)\b(?!\s*\()\s* @@ -1122,7 +1125,6 @@ contexts: scope: punctuation.section.block.js pop: true - include: statements - - include: comments - match: '(?=\S)' pop: true - match: (?=('[^\\]*'|"[^\\]*")\s*\() @@ -1131,6 +1133,7 @@ contexts: - match: "'" scope: punctuation.definition.string.begin.js push: + - meta_include_prototype: false - meta_scope: string.quoted.single.js - meta_content_scope: entity.name.function.js - match: (')|(\n) @@ -1142,6 +1145,7 @@ contexts: - match: '"' scope: punctuation.definition.string.begin.js push: + - meta_include_prototype: false - meta_scope: string.quoted.double.js - meta_content_scope: entity.name.function.js - match: (")|(\n) @@ -1160,7 +1164,6 @@ contexts: scope: punctuation.section.block.js pop: true - include: statements - - include: comments - match: '(?=\S)' pop: true - match: '({{identifier}})\s*(?=\()' @@ -1177,7 +1180,6 @@ contexts: scope: punctuation.section.block.js pop: true - include: statements - - include: comments - match: '(?=\S)' pop: true diff --git a/JavaScript/syntax_test_js.js b/JavaScript/syntax_test_js.js index b908a1af59..fd981850d6 100644 --- a/JavaScript/syntax_test_js.js +++ b/JavaScript/syntax_test_js.js @@ -167,6 +167,41 @@ x --> y; /*@if /*/ // ^^ punctuation.definition.comment.js +// /* +not_a_comment; +// <- -comment + +/* // */ +not_a_comment; +// <- -comment + +/* /* */ +not_a_comment; +// <- -comment + +'// /* not a comment'; +// ^^^^^^^^^^^^^^^^^^^ -comment + +"// /* not a comment"; +// ^^^^^^^^^^^^^^^^^^^ -comment + +`// /* not a comment`; +// ^^^^^^^^^^^^^^^^^^^ -comment + +({ + '// /* not a comment': x => x, +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -comment + + "// /* not a comment": x => x, +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -comment + + '// /* not a comment'() {}, +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -comment() {} + + "// /* not a comment"() {}, +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -comment() {} +}); + var str = '\':'; var str2 = NaN; // <- storage.type @@ -810,6 +845,23 @@ a = /\//u + 0; // ^ keyword.operator // ^ constant.numeric +1 /**/ / 2 / /**/ 3; +// ^ keyword.operator +// ^ constant.numeric +// ^ keyword.operator + +/test// 1; +// <- string.regexp.js +// ^ keyword.operator.arithmetic.js + +/test/* 1; +// <- string.regexp.js +// ^ keyword.operator.arithmetic.js + +/test/** 1; +// <- string.regexp.js +// ^^ keyword.operator.arithmetic.js + var π = 3.141592653 // ^ variable.other.readwrite