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

Commit b9ba47b

Browse files
author
Alhadis
committed
Resolve conflicts with #408
2 parents 0ee5864 + 157241d commit b9ba47b

File tree

2 files changed

+272
-177
lines changed

2 files changed

+272
-177
lines changed

grammars/javascript.cson

Lines changed: 116 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -279,20 +279,8 @@
279279
]
280280
}
281281
{
282-
'match': '''(?x)
283-
(?<!\\.)\\b(?<!\\$)(super|this|arguments)(?!\\s*:|\\$)\\b
284-
|
285-
(?<=\\?)\\s*(super|this|arguments)(?=\\s*:)
286-
|
287-
(?<=[\\s}:;]case|^case)\\s+(super|this|arguments)(?=\\s*:)
288-
'''
289-
'captures':
290-
'1':
291-
'name': 'variable.language.js'
292-
'2':
293-
'name': 'variable.language.js'
294-
'3':
295-
'name': 'variable.language.js'
282+
'match': '(?<!\\.)\\b(super|this|arguments)(?!\\s*:)\\b'
283+
'name': 'variable.language.js'
296284
}
297285
{
298286
# [async] function [name](params)
@@ -896,25 +884,20 @@
896884
]
897885
}
898886
{
899-
'match': '(?<!\\.)\\b(yield)(?!\\s*:)\\b(?:\\s*(\\*))?|(?<=\\?)(?:\\s*)(yield)(?=\\s*:)',
887+
'match': '(?<!\\.)\\b(yield)(?!\\s*:)\\b(?:\\s*(\\*))?',
900888
'captures':
901889
'1':
902890
'name': 'keyword.control.js'
903891
'2':
904892
'name': 'storage.modifier.js'
905-
'3':
906-
'name': 'keyword.control.js'
907-
'4':
908-
'name': 'storage.modifier.js'
909893
'name': 'meta.control.yield.js'
910894
}
911895
{
912-
'match': '(?<!\\.)\\b(await|break|case|catch|continue|do|else|finally|for|if|import|package|return|switch|throw|try|while|with)(?!\\s*:)\\b'
896+
'match': '(?<!\\.)\\b(await|break|catch|continue|do|else|finally|for|if|import|package|return|throw|try|while|with)(?!\\s*:)\\b'
913897
'name': 'keyword.control.js'
914898
}
915899
{
916-
'match': '(?<!\\.)\\b(default)\\b'
917-
'name': 'keyword.control.js'
900+
'include': '#switch_statement'
918901
}
919902
{
920903
'match': '(?<!\\.)\\b(delete|in|of|instanceof|new|typeof|void)(?!\\s*:)\\b'
@@ -925,52 +908,16 @@
925908
'name': 'keyword.operator.spread.js'
926909
}
927910
{
928-
'match': '''(?x)
929-
(?<!\\.)\\b(true|false)(?!\\s*:)\\b
930-
|
931-
(?<=\\?)\\s*(true|false)(?=\\s*:)
932-
|
933-
(?<=[\\s}:;]case|^case)\\s+(true|false)(?=\\s*:)
934-
'''
935-
'captures':
936-
'1':
937-
'name': 'constant.language.boolean.$1.js'
938-
'2':
939-
'name': 'constant.language.boolean.$2.js'
940-
'3':
941-
'name': 'constant.language.boolean.$3.js'
911+
'match': '(?<!\\.)\\b(true|false)(?!\\s*:)\\b'
912+
'name': 'constant.language.boolean.$1.js'
942913
}
943914
{
944-
'match': '''(?x)
945-
(?<!\\.)\\b(null)(?!\\s*:)\\b
946-
|
947-
(?<=\\?)\\s*(null)(?=\\s*:)
948-
|
949-
(?<=[\\s}:;]case|^case)\\s+(null)(?=\\s*:)
950-
'''
951-
'captures':
952-
'1':
953-
'name': 'constant.language.null.js'
954-
'2':
955-
'name': 'constant.language.null.js'
956-
'3':
957-
'name': 'constant.language.null.js'
915+
'match': '(?<!\\.)\\b(null)(?!\\s*:)\\b'
916+
'name': 'constant.language.null.js'
958917
}
959918
{
960-
'match': '''(?x)
961-
(?<!\\.)\\b(debugger)(?!\\s*:)\\b
962-
|
963-
(?<=\\?)\\s*(debugger)(?=\\s*:)
964-
|
965-
(?<=[\\s}:;]case|^case)\\s+(debugger)(?=\\s*:)
966-
'''
967-
'captures':
968-
'1':
969-
'name': 'keyword.other.js'
970-
'2':
971-
'name': 'keyword.other.js'
972-
'3':
973-
'name': 'keyword.other.js'
919+
'match': '(?<!\\.)\\b(debugger)(?!\\s*:)\\b'
920+
'name': 'keyword.other.debugger.js'
974921
}
975922
{
976923
'match': '''(?x) (?<!\\$) \\b
@@ -1113,20 +1060,8 @@
11131060
'name': 'support.variable.property.dom.js'
11141061
}
11151062
{
1116-
'match': '''(?x)
1117-
(?<!\\.)\\b(module|exports|__filename|__dirname|global|process)(?!\\s*:)\\b
1118-
|
1119-
(?<=\\?)\\s*(module|exports|__filename|__dirname|global|process)(?=\\s*:)
1120-
|
1121-
(?<=[\\s}:;]case|^case)\\s+(module|exports|__filename|__dirname|global|process)(?=\\s*:)
1122-
'''
1123-
'captures':
1124-
'1':
1125-
'name': 'support.variable.js'
1126-
'2':
1127-
'name': 'support.variable.js'
1128-
'3':
1129-
'name': 'support.variable.js'
1063+
'match': '(?<!\\.)\\b(module|exports|__filename|__dirname|global|process)(?!\\s*:)\\b'
1064+
'name': 'support.variable.js'
11301065
}
11311066
{
11321067
'match': '\\b(Infinity|NaN|undefined)\\b'
@@ -1148,6 +1083,24 @@
11481083
}
11491084
]
11501085
}
1086+
{
1087+
'begin': '\\?'
1088+
'beginCaptures':
1089+
'0':
1090+
'name': 'keyword.operator.ternary.js'
1091+
'end': ':'
1092+
'endCaptures':
1093+
'0':
1094+
'name': 'keyword.operator.ternary.js'
1095+
'patterns': [
1096+
{
1097+
'include': '#prevent_object_keys_matching'
1098+
}
1099+
{
1100+
'include': '$self'
1101+
}
1102+
]
1103+
}
11511104
{
11521105
'include': '#operators'
11531106
}
@@ -1167,16 +1120,8 @@
11671120
'include': '#properties'
11681121
}
11691122
{
1170-
'match': '''(?x)
1171-
((?<!\\.|[\\w$])(?![_\\$]+[^A-Z0-9_$])\\$*\\b(?:[A-Z_$][A-Z0-9_$]*)\\b\\$*)(?!\\s*:)
1172-
|
1173-
(?<=\\?)(?:\\s*)([A-Z_$][A-Z0-9_$]*)(?=\\s*:)
1174-
'''
1175-
'captures':
1176-
'1':
1177-
'name': 'constant.other.js'
1178-
'2':
1179-
'name': 'constant.other.js'
1123+
'match': '(?<!\\.)\\b[A-Z][A-Z0-9_]+(?!\\s*:)\\b'
1124+
'name': 'constant.other.js'
11801125
}
11811126
{
11821127
'match': '(?<!\\$)\\b[0-9]+[\\w$]*'
@@ -1310,11 +1255,7 @@
13101255
'name': 'keyword.operator.bitwise.js'
13111256
}
13121257
{
1313-
'match': '\\?|:'
1314-
'name': 'keyword.operator.js'
1315-
}
1316-
{
1317-
'match': '='
1258+
'match': '=|:'
13181259
'name': 'keyword.operator.assignment.js'
13191260
}
13201261
{
@@ -1920,3 +1861,85 @@
19201861
]
19211862
}
19221863
]
1864+
'switch_statement':
1865+
'patterns': [
1866+
{
1867+
# switch(expression) {...}
1868+
'begin': '\\bswitch\\b'
1869+
'beginCaptures':
1870+
'0':
1871+
'name': 'keyword.control.switch.js'
1872+
'end': '}'
1873+
'endCaptures':
1874+
'0':
1875+
'name': 'punctuation.definition.section.switch-block.end.bracket.curly.js'
1876+
'name': 'meta.switch-statement.js'
1877+
'patterns': [
1878+
{
1879+
'begin': '\\('
1880+
'beginCaptures':
1881+
'0':
1882+
'name': 'punctuation.definition.switch-expression.begin.bracket.round.js'
1883+
'end': '\\)'
1884+
'endCaptures':
1885+
'0':
1886+
'name': 'punctuation.definition.switch-expression.end.bracket.round.js'
1887+
'patterns': [
1888+
'include': '$self'
1889+
]
1890+
}
1891+
{
1892+
'begin': '{'
1893+
'beginCaptures':
1894+
'0':
1895+
'name': 'punctuation.definition.section.switch-block.begin.bracket.curly.js'
1896+
'end': '(?=})'
1897+
'patterns': [
1898+
{
1899+
'begin': '\\bcase\\b'
1900+
'beginCaptures':
1901+
'0':
1902+
'name': 'keyword.control.case.js'
1903+
'end': ':'
1904+
'endCaptures':
1905+
'0':
1906+
'name': 'punctuation.definition.section.case-statement.js'
1907+
'patterns': [
1908+
{
1909+
'include': '#prevent_object_keys_matching'
1910+
}
1911+
{
1912+
'include': '$self'
1913+
}
1914+
]
1915+
}
1916+
{
1917+
'match': '(?:^\\s*)?\\b(default)\\b\\s*(:)'
1918+
'captures':
1919+
'1':
1920+
'name': 'keyword.control.default.js'
1921+
'2':
1922+
'name': 'punctuation.definition.section.case-statement.js'
1923+
}
1924+
{
1925+
'include': '$self'
1926+
}
1927+
]
1928+
}
1929+
]
1930+
}
1931+
]
1932+
'prevent_object_keys_matching':
1933+
'patterns': [
1934+
{
1935+
# e.g. don't treat null as an object key in
1936+
# ? null :
1937+
# case null:
1938+
'match': '(\\w+)(?=\\s*:)'
1939+
'captures':
1940+
'1':
1941+
'patterns': [
1942+
'include': '$self'
1943+
]
1944+
}
1945+
]

0 commit comments

Comments
 (0)