Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

[art] Reorder groups #276

Closed
wants to merge 1 commit into from
Closed
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
82 changes: 38 additions & 44 deletions grammars/javascript.cson
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
'beginCaptures':
'1':
'name': 'keyword.control.js'
'end': '(?=;|$)'
'name': 'meta.import.js'
'patterns': [
{
'comment': '{ member1 , member2 as alias2 , [...] }'
Expand Down Expand Up @@ -70,6 +72,11 @@
}
{
'comment': '(default|*|name) as alias'
'match': '''(?x)
(?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b)
\\s*\\b(as)\\b\\s*
(?: (\\b default \\b | \\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b)
'''
'captures':
'1':
'name': 'variable.language.default.js'
Expand All @@ -83,13 +90,6 @@
'name': 'invalid.illegal.js'
'6':
'name': 'variable.other.module-alias.js'
'match': '(?x)
(?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b)
\\s*
(\\b as \\b)
\\s*
(?: (\\b default \\b | \\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b)
'
}
{
'match': '\\*'
Expand Down Expand Up @@ -118,8 +118,6 @@
'name': 'meta.delimiter.object.comma.js'
}
]
'end': '(?=;|$)'
'name': 'meta.import.js'
}
{
'comment': 'ES6 export: `export default (variable|class|function, etc.)`'
Expand All @@ -140,6 +138,8 @@
'beginCaptures':
'1':
'name': 'keyword.control.js'
'end': '(?=;|\\bfunction\\b|\\bclass\\b|\\blet\\b|\\bvar\\b|\\bconst\\b|$)'
'name': 'meta.export.js'
'patterns': [
{
'include': '#numbers'
Expand All @@ -157,6 +157,11 @@
'patterns': [
{
'comment': '(default|name) as alias'
'match': '''(?x)
(?: \\b(default)\\b | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b)
\\s*\\b(as)\\b\\s*
(?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b)
'''
'captures':
'1':
'name': 'variable.language.default.js'
Expand All @@ -170,13 +175,6 @@
'name': 'invalid.illegal.js'
'6':
'name': 'variable.other.module-alias.js'
'match': '(?x)
(?: \\b(default)\\b | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b)
\\s*
(\\b as \\b)
\\s*
(?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b)
'
}
{
'match': ','
Expand Down Expand Up @@ -204,6 +202,11 @@
'patterns': [
{
'comment': 'name as (default|alias)'
'match': '''(?x)
(?: \\b(default)\\b | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b)
\\s*\\b(as)\\b\\s*
(?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b)
'''
'captures':
'1':
'name': 'invalid.illegal.js'
Expand All @@ -217,13 +220,6 @@
'name': 'invalid.illegal.js'
'6':
'name': 'variable.other.module-alias.js'
'match': '(?x)
(?: \\b(default)\\b | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b)
\\s*
(\\b as \\b)
\\s*
(?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b)
'
}
{
'include': '#comments'
Expand Down Expand Up @@ -268,8 +264,6 @@
'include': '#operators'
}
]
'end': '(?=;|\\bfunction\\b|\\bclass\\b|\\blet\\b|\\bvar\\b|\\bconst\\b|$)'
'name': 'meta.export.js'
}
{
'match': '(?<!\\.)\\b(super|this)(?!\\s*:)\\b|(?<=\\?)(?:\\s*)(super|this)(?=\\s*:)'
Expand All @@ -280,18 +274,19 @@
'name': 'variable.language.js'
}
{
'comment': 'match stuff like: Sound.prototype = { … } when extending an object'
'match': '([a-zA-Z_?.$][\\w?.$]*)\\.(prototype)\\s*(=)\\s*'
'captures':
'1':
'name': 'support.class.js'
'2':
'name': 'support.constant.js'
'3':
'name': 'keyword.operator.assignment.js'
'comment': 'match stuff like: Sound.prototype = { … } when extending an object'
'match': '([a-zA-Z_?.$][\\w?.$]*)\\.(prototype)\\s*(=)\\s*'
'name': 'meta.class.js'
}
{
'comment': 'match stuff like: Sound.prototype.play = function() { … }'
'begin': '([a-zA-Z_?.$][\\w?.$]*)\\.(prototype)\\.([a-zA-Z_?.$][\\w?.$]*)\\s*(=)\\s*(?:(async)(?:\\s+))?(function\\*?)\\s*(\\*?)(\\()'
'beginCaptures':
'1':
Expand All @@ -310,7 +305,6 @@
'name': 'storage.type.function.js'
'8':
'name': 'punctuation.definition.parameters.begin.js'
'comment': 'match stuff like: Sound.prototype.play = function() { … }'
'end': '(\\))'
'endCaptures':
'1':
Expand All @@ -323,6 +317,8 @@
]
}
{
'comment': 'match stuff like: Sound.prototype.play = myfunc'
'match': '([a-zA-Z_?.$][\\w?.$]*)\\.(prototype)\\.([a-zA-Z_?.$][\\w?.$]*)\\s*(=)\\s*'
'captures':
'1':
'name': 'support.class.js'
Expand All @@ -332,11 +328,10 @@
'name': 'entity.name.function.js'
'4':
'name': 'keyword.operator.assignment.js'
'comment': 'match stuff like: Sound.prototype.play = myfunc'
'match': '([a-zA-Z_?.$][\\w?.$]*)\\.(prototype)\\.([a-zA-Z_?.$][\\w?.$]*)\\s*(=)\\s*'
'name': 'meta.function.js'
}
{
'comment': 'match stuff like: Sound.play = function() { … }'
'begin': '([a-zA-Z_?.$][\\w?.$]*)\\.([a-zA-Z_?.$][\\w?.$]*)\\s*(=)\\s*(?:(async)(?:\\s+))?(function\\*?)\\s*(\\*?)\\s*([a-zA-Z_?$][\\w?$]*)?\\s*(\\()'
'beginCaptures':
'1':
Expand All @@ -355,7 +350,6 @@
'name': 'entity.name.function.js'
'8':
'name': 'punctuation.definition.parameters.begin.js'
'comment': 'match stuff like: Sound.play = function() { … }'
'end': '(\\))'
'endCaptures':
'1':
Expand All @@ -368,6 +362,7 @@
]
}
{
'comment': 'match stuff like: play = function() { … }'
'begin': '([a-zA-Z_?$][\\w?$]*)\\s*(=)\\s*(?:(async)(?:\\s+))?(function\\*?)\\s*(\\*?)\\s*([a-zA-Z_?$][\\w?$]*)?\\s*(\\()'
'beginCaptures':
'1':
Expand All @@ -384,7 +379,6 @@
'name': 'entity.name.function.js'
'7':
'name': 'punctuation.definition.parameters.begin.js'
'comment': 'match stuff like: play = function() { … }'
'end': '(\\))'
'endCaptures':
'1':
Expand All @@ -397,6 +391,7 @@
]
}
{
'comment': 'match regular function like: function myFunc(arg) { … }'
'begin': '\\b(?:(async)(?:\\s+))?(function\\*?)\\s*((\\*)|(?:(?:\\s+)(\\*?[a-zA-Z_$][\\w$]*)))?\\s*(\\()'
'beginCaptures':
'1':
Expand All @@ -409,7 +404,6 @@
'name': 'entity.name.function.js'
'6':
'name': 'punctuation.definition.parameters.begin.js'
'comment': 'match regular function like: function myFunc(arg) { … }'
'end': '(\\))'
'endCaptures':
'1':
Expand All @@ -422,6 +416,7 @@
]
}
{
'comment': 'match stuff like: foobar: function() { … }'
'begin': '\\b([a-zA-Z_?.$][\\w?.$]*)\\s*(:)\\s*\\b(?:(async)(?:\\s+))?(function\\*?)\\s*(\\*?)\\s*([a-zA-Z_?$][\\w?$]*)?\\s*(\\()'
'beginCaptures':
'1':
Expand All @@ -438,7 +433,6 @@
'name': 'entity.name.function.js'
'7':
'name': 'punctuation.definition.parameters.begin.js'
'comment': 'match stuff like: foobar: function() { … }'
'end': '(\\))'
'endCaptures':
'1':
Expand All @@ -451,6 +445,7 @@
]
}
{
'comment': 'Attempt to match "foo": function'
'begin': '(?:((\')([^\']*?)(\'))|((")([^"]*?)(")))\\s*(:)\\s*\\b(?:(async)(?:\\s+))?(function\\*?)\\s*(\\*?)\\s*([a-zA-Z_?$][\\w?$]*)?\\s*(\\()'
'beginCaptures':
'1':
Expand Down Expand Up @@ -481,7 +476,6 @@
'name': 'entity.name.function.js'
'14':
'name': 'punctuation.definition.parameters.begin.js'
'comment': 'Attempt to match "foo": function'
'end': '(\\))'
'endCaptures':
'1':
Expand Down Expand Up @@ -560,7 +554,6 @@
}
{
'comment': 'match stuff like: play = (a,b) => { … }'
'name': 'meta.function.arrow.js'
'begin': '([a-zA-Z_?$][\\w?$]*)\\s*(=)\\s*(\\()(?=(?:[^\\(\\)]*)?\\)\\s*=>)'
'beginCaptures':
'1':
Expand All @@ -575,6 +568,7 @@
'name': 'punctuation.definition.parameters.end.js'
'2':
'name': 'storage.type.arrow.js'
'name': 'meta.function.arrow.js'
'patterns': [
{
'include': '#function-params'
Expand All @@ -583,7 +577,6 @@
}
{
'comment': 'match stuff like: Sound.play = (a,b) => { … }'
'name': 'meta.function.arrow.js'
'begin': '([a-zA-Z_?$]*)\\.([a-zA-Z_?$][\\w?$]*)\\s*(=)\\s*(\\()(?=(?:[^\\(\\)]*)?\\)\\s*=>)'
'beginCaptures':
'1':
Expand All @@ -600,19 +593,20 @@
'name': 'punctuation.definition.parameters.end.js'
'2':
'name': 'storage.type.arrow.js'
'name': 'meta.function.arrow.js'
'patterns': [
{
'include': '#function-params'
}
]
}
{
'match': '(new)\\s+(\\$?\\w+(?:\\.\\w*)?)'
'captures':
'1':
'name': 'keyword.operator.new.js'
'2':
'name': 'entity.name.type.instance.js'
'match': '(new)\\s+(\\$?\\w+(?:\\.\\w*)?)'
'name': 'meta.class.instance.constructor'
}
{
Expand Down Expand Up @@ -640,12 +634,12 @@
'include': '#comments'
}
{
'match': '(<!--|-->)'
'captures':
'0':
'name': 'punctuation.definition.comment.html.js'
'2':
'name': 'punctuation.definition.comment.html.js'
'match': '(<!--|-->)'
'name': 'comment.block.html.js'
}
{
Expand Down Expand Up @@ -871,13 +865,13 @@
'name': 'meta.delimiter.method.period.js'
}
{
'comment': 'Allows the special return snippet to fire.'
'match': '({)(})'
'captures':
'1':
'name': 'punctuation.section.scope.begin.js'
'2':
'name': 'punctuation.section.scope.end.js'
'comment': 'Allows the special return snippet to fire.'
'match': '({)(})'
}
{
'match': '{|}'
Expand Down Expand Up @@ -1015,7 +1009,6 @@
'methods':
'patterns': [
{
'name': 'meta.method.js'
'comment': 'match regular function like: function myFunc(arg) { … }'
'begin': '\\b((?!(?:break|case|catch|continue|do|else|finally|for|function|if|export|import|package|return|switch|throw|try|while|with)[\\s\\(])(?:[a-zA-Z_$][a-zA-Z_$0-9]*))\\s*(\\()(?=(?:[^\\(\\)]*)?\\)\\s*\\{)'
'beginCaptures':
Expand All @@ -1027,6 +1020,7 @@
'endCaptures':
'1':
'name': 'punctuation.definition.parameters.end.js'
'name': 'meta.method.js'
'patterns': [
{
'include': '#function-params'
Expand Down Expand Up @@ -1200,13 +1194,13 @@
'captures':
'0':
'name': 'punctuation.definition.comment.js'
'end': '\\*/'
'name': 'comment.block.documentation.js'
'patterns': [
{
'include': '#docblock'
}
]
'end': '\\*/'
'name': 'comment.block.documentation.js'
}
{
'begin': '/\\*'
Expand Down
2 changes: 1 addition & 1 deletion grammars/regular expressions (javascript).cson
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
'name': 'constant.other.character-class.set.regexp'
'patterns': [
{
'match': '(?:.|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))\\-(?:[^\\]\\\\]|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))'
'captures':
'1':
'name': 'constant.character.numeric.regexp'
Expand All @@ -107,7 +108,6 @@
'name': 'constant.character.control.regexp'
'6':
'name': 'constant.character.escape.backslash.regexp'
'match': '(?:.|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))\\-(?:[^\\]\\\\]|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))'
'name': 'constant.other.character-class.range.regexp'
}
{
Expand Down