Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JavaScript] Use prototype for comments #1007

Merged
merged 1 commit into from
Jun 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 16 additions & 24 deletions JavaScript/JavaScript.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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: ','
Expand All @@ -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
Expand All @@ -135,7 +133,6 @@ contexts:
pop: true
- include: expressions
- include: export-escape
- include: comments
- match: '\bdefault\b'
scope: keyword.control.import-export.js
set:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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: ','
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -352,7 +344,6 @@ contexts:
- include: block-scope

block-scope:
- include: comments
- match: '\}'
scope: meta.block.js punctuation.section.block.js
pop: true
Expand All @@ -367,7 +358,6 @@ contexts:
pop: true

expressions:
- include: comments
- include: regexp-complete
- include: literal-string
- include: literal-string-template
Expand Down Expand Up @@ -424,20 +414,23 @@ contexts:
- match: /\*\*(?!/)
scope: punctuation.definition.comment.js
push:
- meta_include_prototype: false
- meta_scope: comment.block.documentation.js
- match: \*/
scope: punctuation.definition.comment.js
pop: true
- match: /\*
scope: punctuation.definition.comment.js
push:
- meta_include_prototype: false
- meta_scope: comment.block.js
- match: \*/
scope: punctuation.definition.comment.js
pop: true
- match: //
scope: punctuation.definition.comment.js
push:
- meta_include_prototype: false
- meta_scope: comment.line.double-slash.js
- match: \n
pop: true
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -500,6 +496,7 @@ contexts:
push: regexp

regexp:
- meta_include_prototype: false
- meta_scope: string.regexp.js
- match: "(/)([gimyu]*)"
captures:
Expand All @@ -508,6 +505,7 @@ contexts:
set: after-identifier
- match: '(?=.|\n)'
push:
- meta_include_prototype: false
- match: '(?=/)'
pop: true
- include: scope:source.regexp.js
Expand Down Expand Up @@ -677,11 +675,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
Expand Down Expand Up @@ -856,7 +852,6 @@ contexts:
push: arrow-function-declaration

function-declaration:
- include: comments
- match: '\b(async)\b\s*'
scope: meta.function.declaration.js
captures:
Expand Down Expand Up @@ -898,7 +893,6 @@ contexts:

arrow-function-declaration-continuation:
- meta_content_scope: meta.function.declaration.js
- include: comments
- match: '(?=\{)'
set: function-block
- match: '(?=\S)'
Expand Down Expand Up @@ -982,7 +976,6 @@ contexts:
- match: "(?=[,)])"
pop: true
- include: expressions
- include: comments

label:
- match: '^\s*((?!default){{identifier}})\s*(:)'
Expand All @@ -998,7 +991,6 @@ contexts:
- match: '\}'
scope: punctuation.section.block.js
set: after-identifier
- include: comments
- match: \[
scope: punctuation.section.brackets.js
push:
Expand Down Expand Up @@ -1036,6 +1028,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)
Expand All @@ -1047,6 +1040,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)
Expand Down Expand Up @@ -1091,7 +1085,6 @@ contexts:
- match: "(?=\\}|,|('[^']*'|\"[^\"]*\"|{{identifier}})\\s*:)"
pop: true
- include: expressions
- include: comments

method-declaration:
- match: \b(get|set)\b(?!\s*\()\s*
Expand Down Expand Up @@ -1122,7 +1115,6 @@ contexts:
scope: punctuation.section.block.js
pop: true
- include: statements
- include: comments
- match: '(?=\S)'
pop: true
- match: (?=('[^\\]*'|"[^\\]*")\s*\()
Expand All @@ -1131,6 +1123,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)
Expand All @@ -1142,6 +1135,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)
Expand All @@ -1160,7 +1154,6 @@ contexts:
scope: punctuation.section.block.js
pop: true
- include: statements
- include: comments
- match: '(?=\S)'
pop: true
- match: '({{identifier}})\s*(?=\()'
Expand All @@ -1177,7 +1170,6 @@ contexts:
scope: punctuation.section.block.js
pop: true
- include: statements
- include: comments
- match: '(?=\S)'
pop: true

Expand Down Expand Up @@ -1442,4 +1434,4 @@ contexts:
- match: \;
scope: punctuation.terminator.statement.js
- match: ","
scope: punctuation.separator.comma.js
scope: punctuation.separator.comma.js
42 changes: 41 additions & 1 deletion JavaScript/syntax_test_js.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -810,6 +845,11 @@ a = /\//u + 0;
// ^ keyword.operator
// ^ constant.numeric

1 /**/ / 2 / /**/ 3;
// ^ keyword.operator
// ^ constant.numeric
// ^ keyword.operator

var π = 3.141592653
// ^ variable.other.readwrite

Expand Down Expand Up @@ -1019,4 +1059,4 @@ var str = `Hello, ${name}!`;
// ^ punctuation.definition.template-expression.end

let str = navigator.userAgent.toLowerCase();
// ^^^^^^^^^ support.type.object
// ^^^^^^^^^ support.type.object