javascript.cson 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335
  1. # "?." means "?." or "."
  2. # Even though sometimes it doesn't seem like using the chaining operator would make any sense, it's still supported.
  3. # Example: Math?.PI
  4. # Negative look-behinds for "." should cover "?."
  5. 'scopeName': 'source.js'
  6. 'fileTypes': [
  7. 'js'
  8. '_js'
  9. 'cjs'
  10. 'es'
  11. 'es6'
  12. 'gs'
  13. 'htc'
  14. 'jscad'
  15. 'jscript'
  16. 'jse'
  17. 'jslib'
  18. 'jsm'
  19. 'json5'
  20. 'jspre'
  21. 'mjs'
  22. 'pac'
  23. 'pjs'
  24. 'sjs'
  25. 'snap'
  26. 'xsjs'
  27. 'xsjslib'
  28. ]
  29. 'firstLineMatch': '''(?x)
  30. # Hashbang
  31. ^\\#!.*(?:\\s|\\/|(?<=!)\\b)
  32. (?:node|iojs|JavaScript)
  33. (?:$|\\s)
  34. |
  35. # Modeline
  36. (?i:
  37. # Emacs
  38. -\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*)
  39. (?:js|javascript)
  40. (?=[\\s;]|(?<![-*])-\\*-).*?-\\*-
  41. |
  42. # Vim
  43. (?:(?:\\s|^)vi(?:m[<=>]?\\d+|m)?|\\sex)(?=:(?=\\s*set?\\s[^\\n:]+:)|:(?!\\s*set?\\s))(?:(?:\\s|\\s*:\\s*)\\w*(?:\\s*=(?:[^\\n\\\\\\s]|\\\\.)*)?)*[\\s:](?:filetype|ft|syntax)\\s*=
  44. javascript
  45. (?=\\s|:|$)
  46. )
  47. '''
  48. 'name': 'JavaScript'
  49. 'patterns': [
  50. {
  51. # ES6 import
  52. 'begin': '(?<!\\.)\\b(import)(?!\\s*[:(])\\b'
  53. 'beginCaptures':
  54. '1':
  55. 'name': 'keyword.control.js'
  56. 'end': '(?=;|$)'
  57. 'name': 'meta.import.js'
  58. 'patterns': [
  59. {
  60. # { member1 , member2 as alias2 , [...] }
  61. 'begin': '{'
  62. 'beginCaptures':
  63. 0:
  64. 'name': 'punctuation.definition.modules.begin.js'
  65. 'end': '}'
  66. 'endCaptures':
  67. 0:
  68. 'name': 'punctuation.definition.modules.end.js'
  69. 'patterns': [
  70. {
  71. # (default|name) as alias
  72. 'match': '''(?x)
  73. (?: \\b(default)\\b | \\b([a-zA-Z_$][\\w$]*)\\b)
  74. \\s*
  75. (\\b as \\b)
  76. \\s*
  77. (?: (\\b default \\b | \\*) | \\b([a-zA-Z_$][\\w$]*)\\b)
  78. '''
  79. 'captures':
  80. '1':
  81. 'name': 'variable.language.default.js'
  82. '2':
  83. 'name': 'variable.other.module.js'
  84. '3':
  85. 'name': 'keyword.control.js'
  86. '4':
  87. 'name': 'invalid.illegal.js'
  88. '5':
  89. 'name': 'variable.other.module-alias.js'
  90. }
  91. {
  92. 'match': ','
  93. 'name': 'meta.delimiter.object.comma.js'
  94. }
  95. {
  96. 'include': '#comments'
  97. }
  98. {
  99. 'match': '\\b([a-zA-Z_$][\\w$]*)\\b'
  100. 'name': 'variable.other.module.js'
  101. }
  102. ]
  103. }
  104. {
  105. # (default|*|name) as alias
  106. 'match': '''(?x)
  107. (?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][\\w$]*)\\b)
  108. \\s*
  109. (\\b as \\b)
  110. \\s*
  111. (?: (\\b default \\b | \\*) | \\b([a-zA-Z_$][\\w$]*)\\b)
  112. '''
  113. 'captures':
  114. '1':
  115. 'name': 'variable.language.default.js'
  116. '2':
  117. 'name': 'variable.language.import-all.js'
  118. '3':
  119. 'name': 'variable.other.module.js'
  120. '4':
  121. 'name': 'keyword.control.js'
  122. '5':
  123. 'name': 'invalid.illegal.js'
  124. '6':
  125. 'name': 'variable.other.module-alias.js'
  126. }
  127. {
  128. 'match': '\\*'
  129. 'name': 'variable.language.import-all.js'
  130. }
  131. {
  132. 'match': '\\b(default)\\b'
  133. 'name': 'variable.language.default.js'
  134. }
  135. {
  136. 'include': '#strings'
  137. }
  138. {
  139. 'include': '#comments'
  140. }
  141. {
  142. 'match': '\\b(from)\\b'
  143. 'name': 'keyword.control.js'
  144. }
  145. {
  146. 'match': '\\b([a-zA-Z_$][\\w$]*)\\b(?=.*\\bfrom\\b)'
  147. 'name': 'variable.other.module.js'
  148. }
  149. {
  150. 'match': ','
  151. 'name': 'meta.delimiter.object.comma.js'
  152. }
  153. ]
  154. }
  155. {
  156. # ES6 export: export default (variable|class|function, etc.)
  157. 'match': '''(?x)
  158. \\b(export)\\b\\s*
  159. \\b(default)\\b\\s*
  160. \\b((?!\\b(?:function|class|let|var|const)\\b)[a-zA-Z_$][\\w$]*)?\\b
  161. '''
  162. 'captures':
  163. '0':
  164. 'name': 'meta.export.js'
  165. '1':
  166. 'name': 'keyword.control.js'
  167. '2':
  168. 'name': 'variable.language.default.js'
  169. '3':
  170. 'name': 'variable.other.module.js'
  171. }
  172. {
  173. # ES6 export, re-export: export {member as alias, [...]} [from ...]
  174. 'begin': '(?<!\\.)\\b(export)(?!\\s*[:(])\\b'
  175. 'beginCaptures':
  176. '1':
  177. 'name': 'keyword.control.js'
  178. 'end': '(?=;|\\bfunction\\b|\\bclass\\b|\\blet\\b|\\bvar\\b|\\bconst\\b|$)'
  179. 'name': 'meta.export.js'
  180. 'patterns': [
  181. {
  182. 'include': '#numbers'
  183. }
  184. {
  185. # { member1 , member2 as alias2 , [...] }
  186. 'begin': '(?![a-zA-Z_$0-9]){'
  187. 'beginCaptures':
  188. 0:
  189. 'name': 'punctuation.definition.modules.begin.js'
  190. 'end': '}'
  191. 'endCaptures':
  192. 0:
  193. 'name': 'punctuation.definition.modules.end.js'
  194. 'patterns': [
  195. {
  196. # name as (default|alias)
  197. 'captures':
  198. '1':
  199. 'name': 'variable.language.default.js'
  200. '2':
  201. 'name': 'variable.other.module.js'
  202. '3':
  203. 'name': 'keyword.control.js'
  204. '4':
  205. 'name': 'variable.language.default.js'
  206. '5':
  207. 'name': 'invalid.illegal.js'
  208. '6':
  209. 'name': 'variable.other.module-alias.js'
  210. 'match': '''(?x)
  211. (?: \\b(default)\\b | \\b([a-zA-Z_$][\\w$]*)\\b)
  212. \\s*
  213. (\\b as \\b)
  214. \\s*
  215. (?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][\\w$]*)\\b)
  216. '''
  217. }
  218. {
  219. 'include': '#comments'
  220. }
  221. {
  222. 'match': ','
  223. 'name': 'meta.delimiter.object.comma.js'
  224. }
  225. {
  226. 'match': '\\b([a-zA-Z_$][\\w$]*)\\b'
  227. 'name': 'variable.other.module.js'
  228. }
  229. ]
  230. }
  231. {
  232. 'match': '\\*(?=.*\\bfrom\\b)'
  233. 'name': 'variable.language.import-all.js'
  234. }
  235. {
  236. 'match': '\\b(default)\\b'
  237. 'name': 'variable.language.default.js'
  238. }
  239. {
  240. 'include': '#strings'
  241. }
  242. {
  243. 'include': '#comments'
  244. }
  245. {
  246. 'match': '\\b(from)\\b'
  247. 'name': 'keyword.control.js'
  248. }
  249. {
  250. 'match': '\\b([a-zA-Z_$][\\w$]*)\\b'
  251. 'name': 'variable.other.module.js'
  252. }
  253. {
  254. 'match': ','
  255. 'name': 'meta.delimiter.object.comma.js'
  256. }
  257. {
  258. 'include': '#operators'
  259. }
  260. ]
  261. }
  262. {
  263. 'match': '(?:(?<=\\.{3})|(?<!\\.)\\b)(?<!\\$)(super|this|arguments)(?!\\s*:|\\$)\\b'
  264. 'name': 'variable.language.js'
  265. }
  266. {
  267. # [async] function [name](params)
  268. # function* name(params) – generator function declaration
  269. 'begin': '(?=(\\basync\\b\\s*)?\\bfunction\\b(?!\\s*:))'
  270. 'end': '(?<=})'
  271. 'patterns': [
  272. {
  273. 'include': '#comments'
  274. }
  275. {
  276. 'include': '#function_body'
  277. }
  278. {
  279. 'begin': '\\G'
  280. 'end': '(?<=\\))'
  281. 'name': 'meta.function.js'
  282. 'patterns': [
  283. {
  284. 'include': '#function_innards'
  285. }
  286. ]
  287. }
  288. ]
  289. }
  290. {
  291. # [?.]foo = function...
  292. 'begin': '(?=(\\?\\.|\\.)?[a-zA-Z_$][\\w$]*\\s*=\\s*(\\basync\\b\\s*)?\\bfunction\\b)'
  293. 'end': '(?<=})'
  294. 'patterns': [
  295. {
  296. 'include': '#comments'
  297. }
  298. {
  299. 'include': '#function_body'
  300. }
  301. {
  302. 'begin': '\\G'
  303. 'end': '(?!\\G)(?<=\\))'
  304. 'name': 'meta.function.js'
  305. 'patterns': [
  306. {
  307. 'match': '(\\?\\.|\\.)?([a-zA-Z_$][\\w$]*)\\s*(=)\\s*'
  308. 'captures':
  309. '1':
  310. 'patterns': [
  311. {
  312. 'include': '#period_or_illegal_optional_method'
  313. }
  314. ]
  315. '2':
  316. 'name': 'entity.name.function.js'
  317. '3':
  318. 'name': 'keyword.operator.assignment.js'
  319. }
  320. {
  321. 'include': '#function_innards'
  322. }
  323. ]
  324. }
  325. ]
  326. }
  327. {
  328. # foo: function...
  329. 'begin': '(?=\\b[a-zA-Z_$][\\w$]*\\s*:\\s*(\\basync\\b\\s*)?\\bfunction\\b)'
  330. 'end': '(?<=})'
  331. 'patterns': [
  332. {
  333. 'include': '#comments'
  334. }
  335. {
  336. 'include': '#function_body'
  337. }
  338. {
  339. 'begin': '\\G'
  340. 'end': '(?<=\\))'
  341. 'name': 'meta.function.json.js'
  342. 'patterns': [
  343. {
  344. 'match': '\\b([a-zA-Z_$][\\w$]*)\\s*(:)\\s*'
  345. 'captures':
  346. '1':
  347. 'name': 'entity.name.function.js'
  348. '2':
  349. 'name': 'keyword.operator.assignment.js'
  350. }
  351. {
  352. 'include': '#function_innards'
  353. }
  354. ]
  355. }
  356. ]
  357. }
  358. {
  359. # "foo": function...
  360. 'begin': '(?=((\'[^\']*?\')|("[^"]*?"))\\s*:\\s*(\\basync\\b\\s*)?\\bfunction\\b)'
  361. 'end': '(?<=})'
  362. 'patterns': [
  363. {
  364. 'include': '#comments'
  365. }
  366. {
  367. 'include': '#function_body'
  368. }
  369. {
  370. 'begin': '\\G'
  371. 'end': '(?<=\\))'
  372. 'name': 'meta.function.json.js'
  373. 'patterns': [
  374. {
  375. 'match': '(?:((\')([^\']*?)(\'))|((")([^"]*?)(")))\\s*(:)'
  376. 'captures':
  377. '1':
  378. 'name': 'string.quoted.single.js'
  379. '2':
  380. 'name': 'punctuation.definition.string.begin.js'
  381. '3':
  382. 'name': 'entity.name.function.js'
  383. '4':
  384. 'name': 'punctuation.definition.string.end.js'
  385. '5':
  386. 'name': 'string.quoted.double.js'
  387. '6':
  388. 'name': 'punctuation.definition.string.begin.js'
  389. '7':
  390. 'name': 'entity.name.function.js'
  391. '8':
  392. 'name': 'punctuation.definition.string.end.js'
  393. '9':
  394. 'name': 'keyword.operator.assignment.js'
  395. }
  396. {
  397. 'include': '#function_innards'
  398. }
  399. ]
  400. }
  401. ]
  402. }
  403. {
  404. 'begin': '(?=\\bconstructor\\b\\s*)'
  405. 'end': '(?<=})'
  406. 'patterns': [
  407. {
  408. 'include': '#comments'
  409. }
  410. {
  411. 'include': '#function_body'
  412. }
  413. {
  414. 'begin': '\\G'
  415. 'end': '(?<=\\))'
  416. 'name': 'meta.function.js'
  417. 'patterns': [
  418. {
  419. 'match': '\\b(constructor)\\s*'
  420. 'name': 'entity.name.function.constructor.js'
  421. }
  422. {
  423. 'include': '#function_innards'
  424. }
  425. ]
  426. }
  427. ]
  428. }
  429. {
  430. # ES6 method definitions: foo() {}
  431. 'begin': '''(?x)
  432. (?=
  433. (?!
  434. (break|case|catch|continue|do|else|finally|for|function|if|
  435. return|switch|throw|try|while|with)
  436. [\\s\\(]
  437. )
  438. (
  439. \\b(get|set) # Property getter/setter: get foo(){}
  440. (?:\\s+|(?=\\[)) # Followed by whitespace or square bracket
  441. )?+
  442. ( # Method name
  443. \\b[a-zA-Z_$][\\w$]* # Fixed name
  444. |
  445. \\[ # Computed property key
  446. [^\\[\\]]++ # Contains at least one non-brace character
  447. \\]
  448. )
  449. \\s*\\(\\s* # Start of arguments list
  450. (
  451. "[^"]*" | # Double-quoted string
  452. '[^']*' | # Single-quoted string
  453. [^"()'] # Any non-bracket or non-quote
  454. )*
  455. \\)\\s* # End of arguments
  456. { # Beginning of body
  457. )
  458. '''
  459. 'end': '(?<=})'
  460. 'patterns': [
  461. {
  462. 'include': '#comments'
  463. }
  464. {
  465. 'include': '#function_body'
  466. }
  467. {
  468. 'begin': '\\G'
  469. 'end': '(?<=\\))'
  470. 'name': 'meta.function.method.definition.js'
  471. 'patterns': [
  472. {
  473. 'match': '(\\[)(.+)(\\])(?=\\s*\\()'
  474. 'captures':
  475. '1':
  476. 'name': 'punctuation.definition.computed-key.begin.bracket.square.js'
  477. '2':
  478. 'patterns': [
  479. {
  480. 'include': '$self'
  481. }
  482. {
  483. 'match': '[a-zA-Z_$][\\w$]*'
  484. 'name': 'variable.parameter.property.js'
  485. }
  486. ]
  487. '3':
  488. 'name': 'punctuation.definition.computed-key.end.bracket.square.js'
  489. 'name': 'meta.computed-key.js'
  490. }
  491. {
  492. 'match': '\\b(get|set)(?=\\s*\\[.+\\]\\s*\\(|\\s+[^\\s\\[(]+\\s*\\()'
  493. 'name': 'keyword.operator.$1ter.js'
  494. }
  495. {
  496. 'match': '\\b([a-zA-Z_$][\\w$]*)'
  497. 'name': 'entity.name.function.js'
  498. }
  499. {
  500. 'include': '#function_params'
  501. }
  502. ]
  503. }
  504. ]
  505. }
  506. {
  507. # [param|(params)] => [expression|{statements}]
  508. 'begin': '''(?x)
  509. (?=
  510. (?<![A-Za-z0-9])
  511. ((\\(([^\\(\\)]*)?\\))|[\\w$]+)
  512. \\s*=>
  513. )
  514. '''
  515. 'end': '''(?x)
  516. (?<=})|
  517. ((?!
  518. \\s*{|
  519. \\G\\(|
  520. \\G[\\w$]+|
  521. \\s*/\\*|\\s*//
  522. )(?=\\s*\\S))
  523. '''
  524. 'patterns': [
  525. {
  526. 'include': '#comments'
  527. }
  528. {
  529. 'include': '#function_body'
  530. }
  531. {
  532. 'begin': '\\G'
  533. 'end': '(?<=(=>))'
  534. 'name': 'meta.function.arrow.js'
  535. 'patterns': [
  536. {
  537. 'include': '#arrow_function_innards'
  538. }
  539. ]
  540. }
  541. ]
  542. }
  543. {
  544. # [?.]foo = ... => ...
  545. 'begin': '''(?x)
  546. (?=
  547. (\\?\\.|\\.)?[a-zA-Z_$][\\w$]*
  548. \\s*(=)\\s*
  549. ((\\(([^\\(\\)]*)?\\))|[\\w$]+)
  550. \\s*=>
  551. )
  552. '''
  553. 'end': '''(?x)
  554. (?<=})|
  555. ((?!
  556. \\s*{|
  557. \\G(\\?\\.|\\.)?[a-zA-Z_$][\\w$]*\\s*(=)\\s*\\(|
  558. \\G(\\?\\.|\\.)?[a-zA-Z_$][\\w$]*\\s*(=)\\s*[\\w$]+|
  559. \\s*/\\*|\\s*//
  560. )(?=\\s*\\S))
  561. '''
  562. 'patterns': [
  563. {
  564. 'include': '#comments'
  565. }
  566. {
  567. 'include': '#function_body'
  568. }
  569. {
  570. 'begin': '\\G'
  571. 'end': '(?<=(=>))'
  572. 'name': 'meta.function.arrow.js'
  573. 'patterns': [
  574. {
  575. 'match': '\\G(\\?\\.|\\.)?([a-zA-Z_$][\\w$]*)\\s*(=)'
  576. 'captures':
  577. '1':
  578. 'patterns': [
  579. {
  580. 'include': '#period_or_illegal_optional_method'
  581. }
  582. ]
  583. '2':
  584. 'name': 'entity.name.function.js'
  585. '3':
  586. 'name': 'keyword.operator.assignment.js'
  587. }
  588. {
  589. 'include': '#arrow_function_innards'
  590. }
  591. ]
  592. }
  593. ]
  594. }
  595. {
  596. # foo: ... => ...
  597. 'begin': '''(?x)
  598. (?=
  599. \\b[a-zA-Z_$][\\w$]*
  600. \\s*:\\s*
  601. ((\\(([^\\(\\)]*)?\\))|[\\w$]+)
  602. \\s*=>
  603. )
  604. '''
  605. 'end': '''(?x)
  606. (?<=})|
  607. ((?!
  608. \\s*{|
  609. \\G[\\w$]+\\s*:|
  610. \\s*/\\*|\\s*//
  611. )(?=\\s*\\S))
  612. '''
  613. 'patterns': [
  614. {
  615. 'include': '#comments'
  616. }
  617. {
  618. 'include': '#function_body'
  619. }
  620. {
  621. 'begin': '\\G'
  622. 'end': '(?<=(=>))'
  623. 'name': 'meta.function.arrow.json.js'
  624. 'patterns': [
  625. {
  626. 'match': '\\b([a-zA-Z_$][\\w$]*)\\s*(:)\\s*'
  627. 'captures':
  628. '1':
  629. 'name': 'entity.name.function.js'
  630. '2':
  631. 'name': 'keyword.operator.assignment.js'
  632. }
  633. {
  634. 'include': '#arrow_function_innards'
  635. }
  636. ]
  637. }
  638. ]
  639. }
  640. {
  641. # "foo": ... => ...
  642. 'begin': '''(?x)
  643. (?=
  644. ((\'[^\']*?\')|("[^"]*?"))
  645. \\s*:\\s*
  646. ((\\(([^\\(\\)]*)?\\))|[\\w$]+)
  647. \\s*=>
  648. )
  649. '''
  650. 'end': '''(?x)
  651. (?<=})|
  652. ((?!
  653. \\G((\'[^\']*?\')|("[^"]*?"))|
  654. \\s*{|
  655. \\s*/\\*|\\s*//
  656. )(?=\\s*\\S))
  657. '''
  658. 'patterns': [
  659. {
  660. 'include': '#comments'
  661. }
  662. {
  663. 'include': '#function_body'
  664. }
  665. {
  666. 'begin': '\\G'
  667. 'end': '(?<=(=>))'
  668. 'name': 'meta.function.arrow.json.js'
  669. 'patterns': [
  670. {
  671. 'match': '(?:((\')([^\']*?)(\'))|((")([^"]*?)(")))\\s*(:)'
  672. 'captures':
  673. '1':
  674. 'name': 'string.quoted.single.js'
  675. '2':
  676. 'name': 'punctuation.definition.string.begin.js'
  677. '3':
  678. 'name': 'entity.name.function.js'
  679. '4':
  680. 'name': 'punctuation.definition.string.end.js'
  681. '5':
  682. 'name': 'string.quoted.double.js'
  683. '6':
  684. 'name': 'punctuation.definition.string.begin.js'
  685. '7':
  686. 'name': 'entity.name.function.js'
  687. '8':
  688. 'name': 'punctuation.definition.string.end.js'
  689. '9':
  690. 'name': 'keyword.operator.assignment.js'
  691. }
  692. {
  693. 'include': '#arrow_function_innards'
  694. }
  695. ]
  696. }
  697. ]
  698. }
  699. {
  700. 'match': '(=>)'
  701. 'captures':
  702. '0':
  703. 'name': 'meta.function.arrow.js'
  704. '1':
  705. 'name': 'storage.type.function.arrow.js'
  706. }
  707. {
  708. 'match': '''(?x)
  709. \\b(class)
  710. (?:
  711. (?:\\s+(extends)\\s+([a-zA-Z_$][\\w$]*))
  712. |
  713. (?:
  714. (?:\\s+([a-zA-Z_$][\\w$]*))
  715. (?:\\s+(extends)\\s+([a-zA-Z_$][\\w$]*))?
  716. )
  717. )
  718. '''
  719. 'captures':
  720. '1':
  721. 'name': 'storage.type.class.js'
  722. '2':
  723. 'name': 'storage.modifier.js'
  724. '3':
  725. 'name': 'entity.other.inherited-class.js'
  726. '4':
  727. 'name': 'entity.name.type.class.js'
  728. '5':
  729. 'name': 'storage.modifier.js'
  730. '6':
  731. 'name': 'entity.other.inherited-class.js'
  732. 'name': 'meta.class.js'
  733. }
  734. {
  735. 'match': '(new)\\s+([\\w$]+(?:\\??\\.[\\w$]*)*)'
  736. 'name': 'meta.class.instance.constructor.js'
  737. 'captures':
  738. '1':
  739. 'name': 'keyword.operator.new.js'
  740. '2':
  741. 'name': 'entity.name.type.instance.js'
  742. 'patterns': [
  743. {
  744. 'include': '#period_or_illegal_optional_property'
  745. }
  746. ]
  747. }
  748. {
  749. # console
  750. # console.log(arg1, "arg2", [...])
  751. 'begin': '(?<![\\w$])console(?![\\w$]|\\s*:)'
  752. 'beginCaptures':
  753. '0':
  754. 'name': 'entity.name.type.object.console.js'
  755. 'end': '''(?x)
  756. (?<=\\)) | (?=
  757. (?! (\\s*//)|(\\s*/\\*)|(\\s*(\\?\\.|\\.)\\s*
  758. (assert|clear|count|countReset|debug|dir|dirxml|error|group|groupCollapsed|
  759. groupEnd|info|log|profile|profileEnd|table|time|timeEnd|timeLog|trace|
  760. timeStamp|warn)
  761. \\s*\\(
  762. )) \\s*\\S
  763. )
  764. '''
  765. 'patterns': [
  766. {
  767. 'include': '#comments'
  768. }
  769. {
  770. 'begin': '\\s*(\\?\\.|\\.)\\s*(\\w+)\\s*(?=\\()'
  771. 'beginCaptures':
  772. '1':
  773. 'patterns': [
  774. {
  775. 'include': '#period_or_optional_method'
  776. }
  777. ]
  778. '2':
  779. 'name': 'support.function.console.js'
  780. 'end': '(?<=\\))'
  781. 'name': 'meta.method-call.js'
  782. 'patterns': [
  783. {
  784. 'include': '#arguments'
  785. }
  786. ]
  787. }
  788. ]
  789. }
  790. {
  791. # JSON
  792. 'begin': '(?<![\\w$])JSON(?![\\w$]|\\s*:)'
  793. 'beginCaptures':
  794. '0':
  795. 'name': 'support.class.json.js'
  796. 'end': '''(?x)
  797. (?<=\\)) | (?=
  798. (?! (\\s*//)|(\\s*/\\*)|(\\s*(\\?\\.|\\.)\\s*
  799. (parse|stringify)
  800. \\s*\\(
  801. )) \\s*\\S
  802. )
  803. '''
  804. 'patterns': [
  805. {
  806. 'include': '#comments'
  807. }
  808. {
  809. 'begin': '\\s*(\\?\\.|\\.)\\s*(\\w+)\\s*(?=\\()'
  810. 'beginCaptures':
  811. '1':
  812. 'patterns': [
  813. {
  814. 'include': '#period_or_optional_method'
  815. }
  816. ]
  817. '2':
  818. 'name': 'support.function.json.js'
  819. 'end': '(?<=\\))'
  820. 'name': 'meta.method-call.js'
  821. 'patterns': [
  822. {
  823. 'include': '#arguments'
  824. }
  825. ]
  826. }
  827. ]
  828. }
  829. {
  830. # Math
  831. 'begin': '(?<![\\w$])Math(?![\\w$]|\\s*:)'
  832. 'beginCaptures':
  833. '0':
  834. 'name': 'support.class.math.js'
  835. 'end': '''(?x)
  836. (?<=E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2|\\)
  837. ) | (?=
  838. (?! (\\s*//)|(\\s*/\\*)|(\\s*(\\?\\.|\\.)\\s* (
  839. ((abs|acos|acosh|asin|asinh|atan|atan2|atanh|cbrt|ceil|clz32|cos|cosh|exp|
  840. expm1|floor|fround|hypot|imul|log|log10|log1p|log2|max|min|pow|random|
  841. round|sign|sin|sinh|sqrt|tan|tanh|trunc)\\s*\\(
  842. ) | (E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2)(?!\\s*[\\w$(]))
  843. )) \\s*\\S
  844. )
  845. '''
  846. 'patterns': [
  847. {
  848. 'include': '#comments'
  849. }
  850. {
  851. # Math.random()
  852. 'begin': '\\s*(\\?\\.|\\.)\\s*(\\w+)\\s*(?=\\()'
  853. 'beginCaptures':
  854. '1':
  855. 'patterns': [
  856. {
  857. 'include': '#period_or_optional_method'
  858. }
  859. ]
  860. '2':
  861. 'name': 'support.function.math.js'
  862. 'end': '(?<=\\))'
  863. 'name': 'meta.method-call.js'
  864. 'patterns': [
  865. {
  866. 'include': '#arguments'
  867. }
  868. ]
  869. }
  870. {
  871. # Math.PI
  872. 'match': '\\s*(\\?\\.|\\.)\\s*(\\w+)\\b'
  873. 'captures':
  874. '1':
  875. 'patterns': [
  876. {
  877. 'include': '#period_or_optional_property'
  878. }
  879. ]
  880. '2':
  881. 'name': 'support.constant.property.math.js'
  882. }
  883. ]
  884. }
  885. {
  886. # Promise
  887. 'begin': '(?<![\\w$])Promise(?![\\w$]|\\s*:)'
  888. 'beginCaptures':
  889. '0':
  890. 'name': 'support.class.promise.js'
  891. 'end': '''(?x)
  892. (?<=\\)) | (?=
  893. (?! (\\s*//)|(\\s*/\\*)|(\\s*(\\?\\.|\\.)\\s*(all|allSettled|any|race|reject|resolve)\\s*\\() )\\s*\\S
  894. )
  895. '''
  896. 'patterns': [
  897. {
  898. 'include': '#comments'
  899. }
  900. {
  901. # Promise.all()
  902. 'begin': '\\s*(\\?\\.|\\.)\\s*(\\w+)\\s*(?=\\()'
  903. 'beginCaptures':
  904. '1':
  905. 'patterns': [
  906. {
  907. 'include': '#period_or_optional_method'
  908. }
  909. ]
  910. '2':
  911. 'name': 'support.function.promise.js'
  912. 'end': '(?<=\\))'
  913. 'name': 'meta.method-call.js'
  914. 'patterns': [
  915. {
  916. 'include': '#arguments'
  917. }
  918. ]
  919. }
  920. ]
  921. }
  922. {
  923. 'include': '#strings'
  924. }
  925. {
  926. 'include': '#comments'
  927. }
  928. {
  929. 'match': '(<!--|-->)'
  930. 'captures':
  931. '0':
  932. 'name': 'punctuation.definition.comment.html.js'
  933. '2':
  934. 'name': 'punctuation.definition.comment.html.js'
  935. 'name': 'comment.block.html.js'
  936. }
  937. {
  938. 'match': '(?<!\\.)\\b(class|enum|function|interface)(?!\\s*:)\\b'
  939. 'name': 'storage.type.js'
  940. }
  941. {
  942. 'match': '(?<!\\.)\\b(async|export|extends|implements|private|protected|public|static)(?!\\s*:)\\b'
  943. 'name': 'storage.modifier.js'
  944. }
  945. {
  946. 'match': '(?<!\\.)\\b(let|var)(?!\\s*:)\\b'
  947. 'name': 'storage.type.var.js'
  948. }
  949. {
  950. 'begin': '(?<!\\.)\\b(const)(?!\\s*:)\\b'
  951. 'beginCaptures':
  952. '1':
  953. 'name': 'storage.type.const.js'
  954. 'end': '(\\bof\\b|\\bin\\b)|(;)|(=)|(?<![,{])\\n'
  955. 'endCaptures':
  956. '1':
  957. 'name': 'keyword.operator.$1.js'
  958. '2':
  959. 'name': 'punctuation.terminator.statement.js'
  960. '3':
  961. 'name': 'keyword.operator.assignment.js'
  962. 'patterns': [
  963. {
  964. 'match': '([$_a-zA-Z][$_a-zA-Z0-9]*)\\s*(:)\\s*([$_a-zA-Z][$_a-zA-Z0-9]*)?'
  965. 'captures':
  966. '2':
  967. 'name': 'keyword.operator.assignment.js'
  968. '3':
  969. 'name': 'constant.other.js'
  970. }
  971. {
  972. 'match': '([$_a-zA-Z][$_a-zA-Z0-9]*)'
  973. 'captures':
  974. '1':
  975. 'name': 'constant.other.js'
  976. }
  977. {
  978. 'match': '\\.\\.\\.'
  979. 'name': 'keyword.operator.spread.js'
  980. }
  981. {
  982. 'match': ','
  983. 'name': 'meta.delimiter.object.comma.js'
  984. }
  985. {
  986. 'match': '\\(|\\)'
  987. 'name': 'meta.brace.round.js'
  988. }
  989. {
  990. 'match': '{|}'
  991. 'name': 'meta.brace.curly.js'
  992. }
  993. {
  994. 'match': '\\[|\\]'
  995. 'name': 'meta.brace.square.js'
  996. }
  997. {
  998. 'include': '#comments'
  999. }
  1000. ]
  1001. }
  1002. {
  1003. 'match': '(?<!\\.)\\b(yield)(?!\\s*:)\\b(?:\\s*(\\*))?',
  1004. 'captures':
  1005. '1':
  1006. 'name': 'keyword.control.js'
  1007. '2':
  1008. 'name': 'storage.modifier.js'
  1009. 'name': 'meta.control.yield.js'
  1010. }
  1011. {
  1012. # This is "..." so don't need to check "?."
  1013. 'match': '(?:(?<=\\.{3})|(?<!\\.))\\b(await)(?!\\s*:)\\b'
  1014. 'name': 'keyword.control.js'
  1015. }
  1016. {
  1017. 'match': '(?<!\\.)\\b(break|catch|continue|do|else|finally|for|if|import|package|return|throw|try|while|with)(?!\\s*:)\\b'
  1018. 'name': 'keyword.control.js'
  1019. }
  1020. {
  1021. 'include': '#switch_statement'
  1022. }
  1023. {
  1024. 'match': '(?<!\\.)\\b(delete|in|of|instanceof|new|typeof|void)(?!\\s*:)\\b'
  1025. 'name': 'keyword.operator.$1.js'
  1026. }
  1027. # By default, three dots = spread
  1028. # `keyword.operator.rest.js` is only done in specific cases in functions
  1029. {
  1030. 'match': '\\.\\.\\.'
  1031. 'name': 'keyword.operator.spread.js'
  1032. }
  1033. {
  1034. 'match': '(?<!\\.)\\b(true|false)(?!\\s*:)\\b'
  1035. 'name': 'constant.language.boolean.$1.js'
  1036. }
  1037. {
  1038. 'match': '(?<!\\.)\\b(null)(?!\\s*:)\\b'
  1039. 'name': 'constant.language.null.js'
  1040. }
  1041. {
  1042. 'match': '(?<!\\.)\\b(debugger)(?!\\s*:)\\b'
  1043. 'name': 'keyword.other.debugger.js'
  1044. }
  1045. {
  1046. 'match': '''(?x) (?<!\\$) \\b
  1047. (AggregateError|Array|ArrayBuffer|AsyncFunction|AsyncGeneratorFunction|Atomics|BigInt|BigInt64Array
  1048. |BigUInt64Array|Boolean|DataView|Date|Error|EvalError|FinalizationRegistry|Float32Array|Float64Array
  1049. |Function|Generator|GeneratorFunction|Int16Array|Int32Array|Int8Array|InternalError|Intl|Map|Number
  1050. |Object|Proxy|RangeError|ReferenceError|Reflect|RegExp|Set|SharedArrayBuffer|SIMD|String|Symbol|SyntaxError
  1051. |TypedArray|TypeError|Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|URIError|WeakMap|WeakRef|WeakSet)
  1052. \\b
  1053. '''
  1054. 'name': 'support.class.js'
  1055. }
  1056. {
  1057. 'match': '''(?x) (\\?\\.|\\.) \\s* (?:
  1058. (constructor|length|prototype) |
  1059. (EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY)
  1060. )\\b
  1061. '''
  1062. 'captures':
  1063. '1':
  1064. 'patterns': [
  1065. {
  1066. 'include': '#period_or_optional_property'
  1067. }
  1068. ]
  1069. '2':
  1070. 'name': 'support.variable.property.js'
  1071. '3':
  1072. 'name': 'support.constant.js'
  1073. }
  1074. {
  1075. 'match': '''(?x) (?<!\\$) \\b (?:
  1076. (document|event|navigator|performance|screen|window|self|frames)
  1077. |
  1078. (AnalyserNode|ArrayBufferView|Attr|AudioBuffer|AudioBufferSourceNode|AudioContext|AudioDestinationNode|AudioListener
  1079. |AudioNode|AudioParam|BatteryManager|BeforeUnloadEvent|BiquadFilterNode|Blob|BufferSource|ByteString|CSS|CSSConditionRule
  1080. |CSSCounterStyleRule|CSSGroupingRule|CSSMatrix|CSSMediaRule|CSSPageRule|CSSPrimitiveValue|CSSRule|CSSRuleList|CSSStyleDeclaration
  1081. |CSSStyleRule|CSSStyleSheet|CSSSupportsRule|CSSValue|CSSValueList|CanvasGradient|CanvasImageSource|CanvasPattern
  1082. |CanvasRenderingContext2D|ChannelMergerNode|ChannelSplitterNode|CharacterData|ChromeWorker|CloseEvent|Comment|CompositionEvent
  1083. |Console|ConvolverNode|Coordinates|Credential|CredentialsContainer|Crypto|CryptoKey|CustomEvent|DOMError|DOMException
  1084. |DOMHighResTimeStamp|DOMImplementation|DOMString|DOMStringList|DOMStringMap|DOMTimeStamp|DOMTokenList|DataTransfer
  1085. |DataTransferItem|DataTransferItemList|DedicatedWorkerGlobalScope|DelayNode|DeviceProximityEvent|DirectoryEntry
  1086. |DirectoryEntrySync|DirectoryReader|DirectoryReaderSync|Document|DocumentFragment|DocumentTouch|DocumentType|DragEvent
  1087. |DynamicsCompressorNode|Element|Entry|EntrySync|ErrorEvent|Event|EventListener|EventSource|EventTarget|FederatedCredential
  1088. |FetchEvent|File|FileEntry|FileEntrySync|FileException|FileList|FileReader|FileReaderSync|FileSystem|FileSystemSync
  1089. |FontFace|FormData|GainNode|Gamepad|GamepadButton|GamepadEvent|Geolocation|GlobalEventHandlers|HTMLAnchorElement
  1090. |HTMLAreaElement|HTMLAudioElement|HTMLBRElement|HTMLBaseElement|HTMLBodyElement|HTMLButtonElement|HTMLCanvasElement
  1091. |HTMLCollection|HTMLContentElement|HTMLDListElement|HTMLDataElement|HTMLDataListElement|HTMLDialogElement|HTMLDivElement
  1092. |HTMLDocument|HTMLElement|HTMLEmbedElement|HTMLFieldSetElement|HTMLFontElement|HTMLFormControlsCollection|HTMLFormElement
  1093. |HTMLHRElement|HTMLHeadElement|HTMLHeadingElement|HTMLHtmlElement|HTMLIFrameElement|HTMLImageElement|HTMLInputElement
  1094. |HTMLKeygenElement|HTMLLIElement|HTMLLabelElement|HTMLLegendElement|HTMLLinkElement|HTMLMapElement|HTMLMediaElement
  1095. |HTMLMetaElement|HTMLMeterElement|HTMLModElement|HTMLOListElement|HTMLObjectElement|HTMLOptGroupElement|HTMLOptionElement
  1096. |HTMLOptionsCollection|HTMLOutputElement|HTMLParagraphElement|HTMLParamElement|HTMLPreElement|HTMLProgressElement
  1097. |HTMLQuoteElement|HTMLScriptElement|HTMLSelectElement|HTMLShadowElement|HTMLSourceElement|HTMLSpanElement|HTMLStyleElement
  1098. |HTMLTableCaptionElement|HTMLTableCellElement|HTMLTableColElement|HTMLTableDataCellElement|HTMLTableElement|HTMLTableHeaderCellElement
  1099. |HTMLTableRowElement|HTMLTableSectionElement|HTMLTextAreaElement|HTMLTimeElement|HTMLTitleElement|HTMLTrackElement
  1100. |HTMLUListElement|HTMLUnknownElement|HTMLVideoElement|HashChangeEvent|History|IDBCursor|IDBCursorWithValue|IDBDatabase
  1101. |IDBEnvironment|IDBFactory|IDBIndex|IDBKeyRange|IDBMutableFile|IDBObjectStore|IDBOpenDBRequest|IDBRequest|IDBTransaction
  1102. |IDBVersionChangeEvent|IIRFilterNode|IdentityManager|ImageBitmap|ImageBitmapFactories|ImageData|Index|InputDeviceCapabilities
  1103. |InputEvent|InstallEvent|InstallTrigger|KeyboardEvent|LinkStyle|LocalFileSystem|LocalFileSystemSync|Location|MIDIAccess
  1104. |MIDIConnectionEvent|MIDIInput|MIDIInputMap|MIDIOutputMap|MediaElementAudioSourceNode|MediaError|MediaKeyMessageEvent
  1105. |MediaKeySession|MediaKeyStatusMap|MediaKeySystemAccess|MediaKeySystemConfiguration|MediaKeys|MediaRecorder|MediaStream
  1106. |MediaStreamAudioDestinationNode|MediaStreamAudioSourceNode|MessageChannel|MessageEvent|MessagePort|MouseEvent
  1107. |MutationObserver|MutationRecord|NamedNodeMap|Navigator|NavigatorConcurrentHardware|NavigatorGeolocation|NavigatorID
  1108. |NavigatorLanguage|NavigatorOnLine|Node|NodeFilter|NodeIterator|NodeList|NonDocumentTypeChildNode|Notification
  1109. |OfflineAudioCompletionEvent|OfflineAudioContext|OscillatorNode|PageTransitionEvent|PannerNode|ParentNode|PasswordCredential
  1110. |Path2D|PaymentAddress|PaymentRequest|PaymentResponse|Performance|PerformanceEntry|PerformanceFrameTiming|PerformanceMark
  1111. |PerformanceMeasure|PerformanceNavigation|PerformanceNavigationTiming|PerformanceObserver|PerformanceObserverEntryList
  1112. |PerformanceResourceTiming|PerformanceTiming|PeriodicSyncEvent|PeriodicWave|Plugin|Point|PointerEvent|PopStateEvent
  1113. |PortCollection|Position|PositionError|PositionOptions|PresentationConnectionClosedEvent|PresentationConnectionList
  1114. |PresentationReceiver|ProcessingInstruction|ProgressEvent|PromiseRejectionEvent|PushEvent|PushRegistrationManager
  1115. |RTCCertificate|RTCConfiguration|RTCPeerConnection|RTCSessionDescriptionCallback|RTCStatsReport|RadioNodeList|RandomSource
  1116. |Range|ReadableByteStream|RenderingContext|SVGAElement|SVGAngle|SVGAnimateColorElement|SVGAnimateElement|SVGAnimateMotionElement
  1117. |SVGAnimateTransformElement|SVGAnimatedAngle|SVGAnimatedBoolean|SVGAnimatedEnumeration|SVGAnimatedInteger|SVGAnimatedLength
  1118. |SVGAnimatedLengthList|SVGAnimatedNumber|SVGAnimatedNumberList|SVGAnimatedPoints|SVGAnimatedPreserveAspectRatio
  1119. |SVGAnimatedRect|SVGAnimatedString|SVGAnimatedTransformList|SVGAnimationElement|SVGCircleElement|SVGClipPathElement
  1120. |SVGCursorElement|SVGDefsElement|SVGDescElement|SVGElement|SVGEllipseElement|SVGEvent|SVGFilterElement|SVGFontElement
  1121. |SVGFontFaceElement|SVGFontFaceFormatElement|SVGFontFaceNameElement|SVGFontFaceSrcElement|SVGFontFaceUriElement
  1122. |SVGForeignObjectElement|SVGGElement|SVGGlyphElement|SVGGradientElement|SVGHKernElement|SVGImageElement|SVGLength
  1123. |SVGLengthList|SVGLineElement|SVGLinearGradientElement|SVGMPathElement|SVGMaskElement|SVGMatrix|SVGMissingGlyphElement
  1124. |SVGNumber|SVGNumberList|SVGPathElement|SVGPatternElement|SVGPoint|SVGPolygonElement|SVGPolylineElement|SVGPreserveAspectRatio
  1125. |SVGRadialGradientElement|SVGRect|SVGRectElement|SVGSVGElement|SVGScriptElement|SVGSetElement|SVGStopElement|SVGStringList
  1126. |SVGStylable|SVGStyleElement|SVGSwitchElement|SVGSymbolElement|SVGTRefElement|SVGTSpanElement|SVGTests|SVGTextElement
  1127. |SVGTextPositioningElement|SVGTitleElement|SVGTransform|SVGTransformList|SVGTransformable|SVGUseElement|SVGVKernElement
  1128. |SVGViewElement|ServiceWorker|ServiceWorkerContainer|ServiceWorkerGlobalScope|ServiceWorkerRegistration|ServiceWorkerState
  1129. |ShadowRoot|SharedWorker|SharedWorkerGlobalScope|SourceBufferList|StereoPannerNode|Storage|StorageEvent|StyleSheet
  1130. |StyleSheetList|SubtleCrypto|SyncEvent|Text|TextMetrics|TimeEvent|TimeRanges|Touch|TouchEvent|TouchList|Transferable
  1131. |TreeWalker|UIEvent|USVString|VRDisplayCapabilities|ValidityState|WaveShaperNode|WebGL|WebGLActiveInfo|WebGLBuffer
  1132. |WebGLContextEvent|WebGLFramebuffer|WebGLProgram|WebGLRenderbuffer|WebGLRenderingContext|WebGLShader|WebGLShaderPrecisionFormat
  1133. |WebGLTexture|WebGLTimerQueryEXT|WebGLTransformFeedback|WebGLUniformLocation|WebGLVertexArrayObject|WebGLVertexArrayObjectOES
  1134. |WebSocket|WebSockets|WebVTT|WheelEvent|Window|WindowBase64|WindowEventHandlers|WindowTimers|Worker|WorkerGlobalScope
  1135. |WorkerLocation|WorkerNavigator|XMLHttpRequest|XMLHttpRequestEventTarget|XMLSerializer|XPathExpression|XPathResult
  1136. |XSLTProcessor)
  1137. )\\b
  1138. '''
  1139. 'captures':
  1140. '1':
  1141. 'name': 'support.variable.dom.js'
  1142. '2':
  1143. 'name': 'support.class.dom.js'
  1144. }
  1145. {
  1146. 'match': '''(?x) (\\?\\.|\\.) \\s*
  1147. (?:
  1148. (ATTRIBUTE_NODE|CDATA_SECTION_NODE|COMMENT_NODE|DOCUMENT_FRAGMENT_NODE|DOCUMENT_NODE|DOCUMENT_TYPE_NODE
  1149. |DOMSTRING_SIZE_ERR|ELEMENT_NODE|ENTITY_NODE|ENTITY_REFERENCE_NODE|HIERARCHY_REQUEST_ERR|INDEX_SIZE_ERR
  1150. |INUSE_ATTRIBUTE_ERR|INVALID_CHARACTER_ERR|NO_DATA_ALLOWED_ERR|NO_MODIFICATION_ALLOWED_ERR|NOT_FOUND_ERR
  1151. |NOT_SUPPORTED_ERR|NOTATION_NODE|PROCESSING_INSTRUCTION_NODE|TEXT_NODE|WRONG_DOCUMENT_ERR)
  1152. |
  1153. (_content|[xyz]|abbr|above|accept|acceptCharset|accessKey|action|align|[av]Link(?:color)?|all|alt|anchors|appCodeName
  1154. |appCore|applets|appMinorVersion|appName|appVersion|archive|areas|arguments|attributes|availHeight|availLeft|availTop
  1155. |availWidth|axis|background|backgroundColor|backgroundImage|below|bgColor|body|border|borderBottomWidth|borderColor
  1156. |borderLeftWidth|borderRightWidth|borderStyle|borderTopWidth|borderWidth|bottom|bufferDepth|callee|caller|caption
  1157. |cellPadding|cells|cellSpacing|ch|characterSet|charset|checked|childNodes|chOff|cite|classes|className|clear
  1158. |clientInformation|clip|clipBoardData|closed|code|codeBase|codeType|color|colorDepth|cols|colSpan|compact|complete
  1159. |components|content|controllers|cookie|cookieEnabled|cords|cpuClass|crypto|current|data|dateTime|declare|defaultCharset
  1160. |defaultChecked|defaultSelected|defaultStatus|defaultValue|defaultView|defer|description|dialogArguments|dialogHeight
  1161. |dialogLeft|dialogTop|dialogWidth|dir|directories|disabled|display|docmain|doctype|documentElement|elements|embeds
  1162. |enabledPlugin|encoding|enctype|entities|event|expando|external|face|fgColor|filename|firstChild|fontFamily|fontSize
  1163. |fontWeight|form|formName|forms|frame|frameBorder|frameElement|frames|hasFocus|hash|headers|height|history|host
  1164. |hostname|href|hreflang|hspace|htmlFor|httpEquiv|id|ids|ignoreCase|images|implementation|index|innerHeight|innerWidth
  1165. |input|isMap|label|lang|language|lastChild|lastIndex|lastMatch|lastModified|lastParen|layer[sXY]|left|leftContext
  1166. |lineHeight|link|linkColor|links|listStyleType|localName|location|locationbar|longDesc|lowsrc|lowSrc|marginBottom
  1167. |marginHeight|marginLeft|marginRight|marginTop|marginWidth|maxLength|media|menubar|method|mimeTypes|multiline|multiple
  1168. |name|nameProp|namespaces|namespaceURI|next|nextSibling|nodeName|nodeType|nodeValue|noHref|noResize|noShade|notationName
  1169. |notations|noWrap|object|offscreenBuffering|onLine|onreadystatechange|opener|opsProfile|options|oscpu|outerHeight
  1170. |outerWidth|ownerDocument|paddingBottom|paddingLeft|paddingRight|paddingTop|page[XY]|page[XY]Offset|parent|parentLayer
  1171. |parentNode|parentWindow|pathname|personalbar|pixelDepth|pkcs11|platform|plugins|port|prefix|previous|previousDibling
  1172. |product|productSub|profile|profileend|prompt|prompter|protocol|publicId|readOnly|readyState|referrer|rel|responseText
  1173. |responseXML|rev|right|rightContext|rowIndex|rows|rowSpan|rules|scheme|scope|screen[XY]|screenLeft|screenTop|scripts
  1174. |scrollbars|scrolling|sectionRowIndex|security|securityPolicy|selected|selectedIndex|selection|self|shape|siblingAbove
  1175. |siblingBelow|size|source|specified|standby|start|status|statusbar|statusText|style|styleSheets|suffixes|summary
  1176. |systemId|systemLanguage|tagName|tags|target|tBodies|text|textAlign|textDecoration|textIndent|textTransform|tFoot|tHead
  1177. |title|toolbar|top|type|undefined|uniqueID|updateInterval|URL|URLUnencoded|useMap|userAgent|userLanguage|userProfile
  1178. |vAlign|value|valueType|vendor|vendorSub|version|visibility|vspace|whiteSpace|width|X[MS]LDocument|zIndex)
  1179. )
  1180. \\b
  1181. '''
  1182. 'captures':
  1183. '1':
  1184. 'patterns': [
  1185. {
  1186. 'include': '#period_or_optional_property'
  1187. }
  1188. ]
  1189. '2':
  1190. 'name': 'support.constant.dom.js'
  1191. '3':
  1192. 'name': 'support.variable.property.dom.js'
  1193. }
  1194. {
  1195. 'match': '(?<!\\.)\\b(module|exports|__filename|__dirname|global|globalThis|process)(?!\\s*:)\\b'
  1196. 'name': 'support.variable.js'
  1197. }
  1198. {
  1199. 'match': '\\b(Infinity|NaN|undefined)\\b'
  1200. 'name': 'constant.language.js'
  1201. }
  1202. {
  1203. 'begin': '(?<=[\\[{=(?:+*,!~-]|^|return|=>|&&|\\|\\|)\\s*(/)(?![/*+?])(?=.*/)'
  1204. 'beginCaptures':
  1205. '1':
  1206. 'name': 'punctuation.definition.string.begin.js'
  1207. 'end': '(/)([gimsuy]*)'
  1208. 'endCaptures':
  1209. '1':
  1210. 'name': 'punctuation.definition.string.end.js'
  1211. '2':
  1212. 'name': 'meta.flag.regexp'
  1213. 'name': 'string.regexp.js'
  1214. 'patterns': [
  1215. {
  1216. 'include': 'source.js.regexp'
  1217. }
  1218. ]
  1219. }
  1220. {
  1221. 'begin': '(?<!\\?)\\?(?!\\.|\\?)'
  1222. 'beginCaptures':
  1223. '0':
  1224. 'name': 'keyword.operator.ternary.js'
  1225. 'end': ':'
  1226. 'endCaptures':
  1227. '0':
  1228. 'name': 'keyword.operator.ternary.js'
  1229. 'patterns': [
  1230. {
  1231. 'include': '#prevent_object_keys_matching'
  1232. }
  1233. {
  1234. 'include': '$self'
  1235. }
  1236. ]
  1237. }
  1238. {
  1239. 'include': '#operators'
  1240. }
  1241. {
  1242. 'include': '#method_calls'
  1243. }
  1244. {
  1245. 'include': '#function_calls'
  1246. }
  1247. {
  1248. 'include': '#numbers'
  1249. }
  1250. {
  1251. 'include': '#objects'
  1252. }
  1253. {
  1254. 'include': '#properties'
  1255. }
  1256. {
  1257. 'match': '((?<!\\.|[\\w$])(?![_\\$]+[^A-Z0-9_$])\\$*\\b(?:[A-Z_$][A-Z0-9_$]*)\\b\\$*)'
  1258. 'name': 'constant.other.js'
  1259. }
  1260. {
  1261. 'match': '(?<!\\$)\\b[0-9]+[\\w$]*'
  1262. 'name': 'invalid.illegal.identifier.js'
  1263. }
  1264. {
  1265. 'match': '\\;'
  1266. 'name': 'punctuation.terminator.statement.js'
  1267. }
  1268. {
  1269. 'match': ','
  1270. 'name': 'meta.delimiter.object.comma.js'
  1271. }
  1272. {
  1273. # Allows the special return snippet to fire.
  1274. 'match': '({)(})'
  1275. 'captures':
  1276. '1':
  1277. 'name': 'punctuation.section.scope.begin.js'
  1278. '2':
  1279. 'name': 'punctuation.section.scope.end.js'
  1280. }
  1281. {
  1282. 'begin': '{'
  1283. 'beginCaptures':
  1284. '0':
  1285. 'name': 'meta.brace.curly.js'
  1286. 'end': '}'
  1287. 'endCaptures':
  1288. '0':
  1289. 'name': 'meta.brace.curly.js'
  1290. 'patterns': [
  1291. {
  1292. 'include': '$self'
  1293. }
  1294. ]
  1295. }
  1296. {
  1297. 'begin': '\\('
  1298. 'beginCaptures':
  1299. '0':
  1300. 'name': 'meta.brace.round.js'
  1301. 'end': '\\)'
  1302. 'endCaptures':
  1303. '0':
  1304. 'name': 'meta.brace.round.js'
  1305. 'patterns': [
  1306. {
  1307. 'include': '$self'
  1308. }
  1309. ]
  1310. }
  1311. {
  1312. # This is inconsistent with the () and {}, however the current tests *rely* on this
  1313. 'match': '\\[|\\]'
  1314. 'name': 'meta.brace.square.js'
  1315. }
  1316. {
  1317. 'match': '\\A#!.*$'
  1318. 'name': 'comment.line.shebang.js'
  1319. }
  1320. ]
  1321. 'repository':
  1322. 'numbers':
  1323. 'patterns': [
  1324. {
  1325. 'match': '\\b(?<!\\$)0(x|X)[0-9a-fA-F]+(?:_[0-9a-fA-F]+)*n?\\b(?!\\$)'
  1326. 'name': 'constant.numeric.hex.js'
  1327. 'captures':
  1328. '0':
  1329. 'patterns': [
  1330. {
  1331. 'include': '#numeric_separators'
  1332. }
  1333. ]
  1334. }
  1335. {
  1336. 'match': '\\b(?<!\\$)0(b|B)[01]+(?:_[01]+)*n?\\b(?!\\$)'
  1337. 'name': 'constant.numeric.binary.js'
  1338. 'captures':
  1339. '0':
  1340. 'patterns': [
  1341. {
  1342. 'include': '#numeric_separators'
  1343. }
  1344. ]
  1345. }
  1346. {
  1347. 'match': '\\b(?<!\\$)0(o|O)?[0-7]+(?:_[0-7]+)*n?\\b(?!\\$)'
  1348. 'name': 'constant.numeric.octal.js'
  1349. 'captures':
  1350. '0':
  1351. 'patterns': [
  1352. {
  1353. 'include': '#numeric_separators'
  1354. }
  1355. ]
  1356. }
  1357. {
  1358. 'match': '''(?x)
  1359. (?<!\\$)(?:
  1360. (?:\\b[0-9]+(?:_[0-9]+)*\\.[0-9]+(?:_[0-9]+)*[eE][+-]?[0-9]+(?:_[0-9]+)*\\b)| # 1.1E+3
  1361. (?:\\b[0-9]+(?:_[0-9]+)*\\.[eE][+-]?[0-9]+(?:_[0-9]+)*\\b)| # 1.E+3
  1362. (?:\\B\\.[0-9]+(?:_[0-9]+)*[eE][+-]?[0-9]+(?:_[0-9]+)*\\b)| # .1E+3
  1363. (?:\\b[0-9]+(?:_[0-9]+)*[eE][+-]?[0-9]+(?:_[0-9]+)*\\b)| # 1E+3
  1364. (?:\\b[0-9]+(?:_[0-9]+)*\\.[0-9]+(?:_[0-9]+)*\\b)| # 1.1
  1365. (?:\\b[0-9]+(?:_[0-9]+)*\\.\\B)| # 1.
  1366. (?:\\B\\.[0-9]+(?:_[0-9]+)*\\b)| # .1
  1367. (?:\\b[0-9]+(?:_[0-9]+)*n?\\b(?!\\.)) # 1n
  1368. )(?!\\$)
  1369. '''
  1370. 'name': 'constant.numeric.decimal.js'
  1371. 'captures':
  1372. '0':
  1373. 'patterns': [
  1374. {
  1375. 'include': '#numeric_separators'
  1376. }
  1377. ]
  1378. }
  1379. ]
  1380. 'numeric_separators':
  1381. 'patterns': [
  1382. {
  1383. 'match': '(_)|(\\.)'
  1384. 'captures':
  1385. '1':
  1386. 'name': 'meta.delimiter.numeric.separator.js'
  1387. '2':
  1388. 'name': 'meta.delimiter.decimal.period.js'
  1389. }
  1390. ]
  1391. 'operators':
  1392. 'patterns': [
  1393. {
  1394. # %= **= *= /= += -=
  1395. 'match': '%=|\\*\\*=|\\*=|(?<!\\()/=|\\+=|-='
  1396. 'name': 'keyword.operator.assignment.compound.js'
  1397. }
  1398. {
  1399. # &&= ||= ??=
  1400. 'match': '&&=|\\|\\|=|\\?\\?='
  1401. 'name': 'keyword.operator.assignment.compound.logical.js'
  1402. }
  1403. {
  1404. 'match': '&=|\\^=|\\|='
  1405. 'name': 'keyword.operator.assignment.compound.bitwise.js'
  1406. }
  1407. {
  1408. 'match': '<<=|>>=|>>>='
  1409. 'name': 'keyword.operator.assignment.compound.bitwise.shift.js'
  1410. }
  1411. # Bitwise shift to match >> instead of >
  1412. # Then comparison to match != instead of !
  1413. {
  1414. 'match': '<<|>>>|>>'
  1415. 'name': 'keyword.operator.bitwise.shift.js'
  1416. }
  1417. {
  1418. 'match': '!==|!=|<=|>=|===|==|<|>'
  1419. 'name': 'keyword.operator.comparison.js'
  1420. }
  1421. {
  1422. # One of: && !! ! || ??
  1423. 'match': '&&|!!|!|\\|\\||\\?\\?'
  1424. 'name': 'keyword.operator.logical.js'
  1425. }
  1426. {
  1427. 'match': '&|\\||\\^|~'
  1428. 'name': 'keyword.operator.bitwise.js'
  1429. }
  1430. {
  1431. 'match': '=|:'
  1432. 'name': 'keyword.operator.assignment.js'
  1433. }
  1434. {
  1435. 'match': '--'
  1436. 'name': 'keyword.operator.decrement.js'
  1437. }
  1438. {
  1439. 'match': '\\+\\+'
  1440. 'name': 'keyword.operator.increment.js'
  1441. }
  1442. {
  1443. 'match': '%|\\*\\*|\\*|/|-|\\+'
  1444. 'name': 'keyword.operator.js'
  1445. }
  1446. ]
  1447. 'strings':
  1448. 'patterns': [
  1449. {
  1450. 'begin': '\''
  1451. 'beginCaptures':
  1452. '0':
  1453. 'name': 'punctuation.definition.string.begin.js'
  1454. 'end': '\''
  1455. 'endCaptures':
  1456. '0':
  1457. 'name': 'punctuation.definition.string.end.js'
  1458. 'name': 'string.quoted.single.js'
  1459. 'patterns': [
  1460. {
  1461. 'include': '#string_escapes'
  1462. }
  1463. ]
  1464. }
  1465. {
  1466. 'begin': '"'
  1467. 'beginCaptures':
  1468. '0':
  1469. 'name': 'punctuation.definition.string.begin.js'
  1470. 'end': '"'
  1471. 'endCaptures':
  1472. '0':
  1473. 'name': 'punctuation.definition.string.end.js'
  1474. 'name': 'string.quoted.double.js'
  1475. 'patterns': [
  1476. {
  1477. 'include': '#string_escapes'
  1478. }
  1479. ]
  1480. }
  1481. {
  1482. 'begin': '((\\w+)?(html|HTML|Html))\\s*(`)'
  1483. 'beginCaptures':
  1484. '1':
  1485. 'name': 'entity.name.function.js'
  1486. '4':
  1487. 'name': 'punctuation.definition.string.begin.js'
  1488. 'end': '`'
  1489. 'endCaptures':
  1490. '0':
  1491. 'name': 'punctuation.definition.string.end.js'
  1492. 'name': 'string.quoted.template.html.js'
  1493. 'patterns': [
  1494. {
  1495. 'include': '#string_escapes'
  1496. }
  1497. {
  1498. 'include': '#interpolated_js'
  1499. }
  1500. {
  1501. 'include': 'text.html.basic'
  1502. }
  1503. ]
  1504. }
  1505. {
  1506. 'begin': '(?<=innerHTML)\\s*(\\+?=)\\s*(?=`)'
  1507. 'beginCaptures':
  1508. '1':
  1509. 'name': 'keyword.operator.assignment.js'
  1510. 'end': '(?<=`)'
  1511. 'endCaptures':
  1512. '0':
  1513. 'name': 'punctuation.definition.string.end.js'
  1514. 'contentName': 'string.quoted.template.html.js'
  1515. 'patterns': [
  1516. {
  1517. 'begin': '`'
  1518. 'beginCaptures':
  1519. '0':
  1520. 'name': 'punctuation.definition.string.begin.js'
  1521. 'end': '`'
  1522. 'endCaptures':
  1523. '0':
  1524. 'name': 'punctuation.definition.string.end.js'
  1525. 'patterns': [
  1526. {
  1527. 'include': '#string_escapes'
  1528. }
  1529. {
  1530. 'include': '#interpolated_js'
  1531. }
  1532. {
  1533. 'include': 'text.html.basic'
  1534. }
  1535. ]
  1536. }
  1537. ]
  1538. }
  1539. {
  1540. 'begin': '(Relay(\\?\\.|\\.)QL|gql)\\s*(`)'
  1541. 'beginCaptures':
  1542. '1':
  1543. 'name': 'entity.name.function.js'
  1544. '2':
  1545. 'patterns': [
  1546. {
  1547. 'include': '#period_or_optional_method'
  1548. }
  1549. ]
  1550. '3':
  1551. 'name': 'punctuation.definition.string.begin.js'
  1552. 'end': '`'
  1553. 'endCaptures':
  1554. '0':
  1555. 'name': 'punctuation.definition.string.end.js'
  1556. 'name': 'string.quoted.template.graphql.js'
  1557. 'patterns': [
  1558. {
  1559. 'include': '#string_escapes'
  1560. }
  1561. {
  1562. 'include': '#interpolated_js'
  1563. }
  1564. {
  1565. 'include': 'source.graphql'
  1566. }
  1567. ]
  1568. }
  1569. {
  1570. 'begin': '(sql|SQL|Sql)\\s*(`)'
  1571. 'beginCaptures':
  1572. '1':
  1573. 'name': 'entity.name.function.js'
  1574. '2':
  1575. 'name': 'punctuation.definition.string.begin.js'
  1576. 'end': '`'
  1577. 'endCaptures':
  1578. '0':
  1579. 'name': 'punctuation.definition.string.end.js'
  1580. 'name': 'string.quoted.template.sql.js'
  1581. 'patterns': [
  1582. {
  1583. 'include': '#string_escapes'
  1584. }
  1585. {
  1586. 'include': '#interpolated_js'
  1587. }
  1588. {
  1589. 'include': 'source.sql'
  1590. }
  1591. ]
  1592. }
  1593. {
  1594. 'begin': '`'
  1595. 'beginCaptures':
  1596. '0':
  1597. 'name': 'punctuation.definition.string.begin.js'
  1598. 'end': '`'
  1599. 'endCaptures':
  1600. '0':
  1601. 'name': 'punctuation.definition.string.end.js'
  1602. 'name': 'string.quoted.template.js'
  1603. 'patterns': [
  1604. {
  1605. 'include': '#string_escapes'
  1606. }
  1607. {
  1608. 'include': '#interpolated_js'
  1609. }
  1610. ]
  1611. }
  1612. ]
  1613. 'string_escapes':
  1614. 'patterns': [
  1615. {
  1616. 'match': '\\\\u(?![A-Fa-f0-9]{4}|{[A-Fa-f0-9]+})[^\'"]*'
  1617. 'name': 'invalid.illegal.unicode-escape.js'
  1618. }
  1619. {
  1620. 'match': '\\\\u(?:[A-Fa-f0-9]{4}|({)([A-Fa-f0-9]+)(}))'
  1621. 'name': 'constant.character.escape.js'
  1622. 'captures':
  1623. '1':
  1624. 'name': 'punctuation.definition.unicode-escape.begin.bracket.curly.js'
  1625. '2':
  1626. 'patterns': [
  1627. {
  1628. # Max codepoint: \u{10FFFF}
  1629. 'match': '[A-Fa-f\\d]{7,}|(?!10)[A-Fa-f\\d]{6}'
  1630. 'name': 'invalid.illegal.unicode-escape.js'
  1631. }
  1632. ]
  1633. '3':
  1634. 'name': 'punctuation.definition.unicode-escape.end.bracket.curly.js'
  1635. }
  1636. {
  1637. 'match': '\\\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)'
  1638. 'name': 'constant.character.escape.js'
  1639. }
  1640. ]
  1641. 'function_params':
  1642. 'patterns': [
  1643. {
  1644. 'begin': '\\('
  1645. 'beginCaptures':
  1646. '0':
  1647. 'name': 'punctuation.definition.parameters.begin.bracket.round.js'
  1648. 'end': '\\)'
  1649. 'endCaptures':
  1650. '0':
  1651. 'name': 'punctuation.definition.parameters.end.bracket.round.js'
  1652. 'name': 'meta.parameters.js'
  1653. 'patterns': [
  1654. {
  1655. 'match': '(\\.\\.\\.)([a-zA-Z_$][\\w$]*)'
  1656. 'captures':
  1657. '1':
  1658. 'name': 'keyword.operator.rest.js'
  1659. '2':
  1660. 'name': 'variable.parameter.rest.function.js'
  1661. }
  1662. {
  1663. 'include': '$self'
  1664. }
  1665. {
  1666. 'match': '[a-zA-Z_$][\\w$]*'
  1667. 'name': 'variable.parameter.function.js'
  1668. }
  1669. ]
  1670. }
  1671. {
  1672. # Or starting with optional chaining
  1673. 'begin': '(\\?\\.)(\\()'
  1674. 'beginCaptures':
  1675. '1':
  1676. 'name': 'meta.delimiter.method.optional.js'
  1677. '2':
  1678. 'name': 'punctuation.definition.parameters.begin.bracket.round.js'
  1679. 'end': '\\)'
  1680. 'endCaptures':
  1681. '0':
  1682. 'name': 'punctuation.definition.parameters.end.bracket.round.js'
  1683. 'name': 'meta.parameters.js'
  1684. 'patterns': [
  1685. {
  1686. 'match': '(\\.\\.\\.)([a-zA-Z_$][\\w$]*)'
  1687. 'captures':
  1688. '1':
  1689. 'name': 'keyword.operator.rest.js'
  1690. '2':
  1691. 'name': 'variable.parameter.rest.function.js'
  1692. }
  1693. {
  1694. 'include': '$self'
  1695. }
  1696. {
  1697. 'match': '[a-zA-Z_$][\\w$]*'
  1698. 'name': 'variable.parameter.function.js'
  1699. }
  1700. ]
  1701. }
  1702. ]
  1703. 'function_body':
  1704. 'patterns': [
  1705. {
  1706. 'begin': '{'
  1707. 'beginCaptures':
  1708. '0':
  1709. 'name': 'punctuation.definition.function.body.begin.bracket.curly.js'
  1710. 'end': '}'
  1711. 'endCaptures':
  1712. '0':
  1713. 'name': 'punctuation.definition.function.body.end.bracket.curly.js'
  1714. 'patterns': [
  1715. {
  1716. 'include': '$self'
  1717. }
  1718. ]
  1719. }
  1720. ]
  1721. 'function_innards':
  1722. 'patterns': [
  1723. {
  1724. 'match': '(?:\\b(async)\\b\\s*)?\\b(function)\\b(?:\\s*(\\*))?'
  1725. 'captures':
  1726. '1':
  1727. 'name': 'storage.modifier.async.js'
  1728. '2':
  1729. 'name': 'storage.type.function.js'
  1730. '3':
  1731. 'name': 'storage.modifier.generator.js'
  1732. }
  1733. {
  1734. 'match': '[a-zA-Z_$][\\w$]*(?=\\s*\\()'
  1735. 'name': 'entity.name.function.js'
  1736. }
  1737. {
  1738. 'include': '#function_params'
  1739. }
  1740. {
  1741. 'include': '#comments'
  1742. }
  1743. ]
  1744. 'arrow_function_innards':
  1745. 'patterns': [
  1746. {
  1747. 'match': '=>'
  1748. 'name': 'storage.type.function.arrow.js'
  1749. }
  1750. {
  1751. 'include': '#function_params'
  1752. }
  1753. {
  1754. 'match': '([a-zA-Z_$][\\w$]*)(?=\\s*=>)'
  1755. 'captures':
  1756. '0':
  1757. 'name': 'meta.parameters.js'
  1758. '1':
  1759. 'name': 'variable.parameter.function.js'
  1760. }
  1761. {
  1762. 'match': '(\\d[\\w$]*)'
  1763. 'captures':
  1764. '0':
  1765. 'name': 'meta.parameters.js'
  1766. '1':
  1767. 'name': 'invalid.illegal.identifier.js'
  1768. }
  1769. ]
  1770. 'arguments':
  1771. 'patterns': [
  1772. {
  1773. 'begin': '\\('
  1774. 'beginCaptures':
  1775. '0':
  1776. 'name': 'punctuation.definition.arguments.begin.bracket.round.js'
  1777. 'end': '\\)'
  1778. 'endCaptures':
  1779. '0':
  1780. 'name': 'punctuation.definition.arguments.end.bracket.round.js'
  1781. 'name': 'meta.arguments.js'
  1782. 'patterns': [
  1783. {
  1784. 'include': '$self'
  1785. }
  1786. ]
  1787. }
  1788. ]
  1789. 'method_calls':
  1790. 'patterns': [
  1791. {
  1792. # [?].methodCall(arg1, "arg2", [...])
  1793. 'begin': '(\\?\\.|\\.)\\s*([\\w$]+)\\s*(?=\\()'
  1794. 'beginCaptures':
  1795. '1':
  1796. 'patterns': [
  1797. {
  1798. 'include': '#period_or_optional_method'
  1799. }
  1800. ]
  1801. '2':
  1802. 'patterns': [
  1803. {
  1804. 'include': '#method_names'
  1805. }
  1806. ]
  1807. 'end': '(?<=\\))'
  1808. 'name': 'meta.method-call.js'
  1809. 'patterns': [
  1810. {
  1811. 'include': '#arguments'
  1812. }
  1813. ]
  1814. }
  1815. {
  1816. # [?].methodCall?.(arg1, "arg2", [...])
  1817. 'begin': '(\\?\\.|\\.)\\s*([\\w$]+)\\s*(\\?\\.)\\s*(?=\\()'
  1818. 'beginCaptures':
  1819. '1':
  1820. 'patterns': [
  1821. {
  1822. 'include': '#period_or_optional_method'
  1823. }
  1824. ]
  1825. '2':
  1826. 'patterns': [
  1827. {
  1828. 'include': '#method_names'
  1829. }
  1830. ]
  1831. '3':
  1832. 'name': 'meta.delimiter.method.optional.js'
  1833. 'end': '(?<=\\))'
  1834. 'name': 'meta.method-call.js'
  1835. 'patterns': [
  1836. {
  1837. 'include': '#arguments'
  1838. }
  1839. ]
  1840. }
  1841. {
  1842. # [array]?.(arg1, "arg2", [...])
  1843. # The array itself is not in the method-call scope, maybe later
  1844. 'begin': '(?<=\\])\\s*(\\?\\.)\\s*(?=\\()'
  1845. 'beginCaptures':
  1846. '1':
  1847. 'name': 'meta.delimiter.method.optional.js'
  1848. 'end': '(?<=\\))'
  1849. 'name': 'meta.method-call.js'
  1850. 'patterns': [
  1851. {
  1852. 'include': '#arguments'
  1853. }
  1854. ]
  1855. }
  1856. ]
  1857. 'method_names':
  1858. 'patterns': [
  1859. {
  1860. 'match': '''(?x)
  1861. \\bon(Rowsinserted|Rowsdelete|Rowenter|Rowexit|Resize|Resizestart|Resizeend|Reset|
  1862. Readystatechange|Mouseout|Mouseover|Mousedown|Mouseup|Mousemove|
  1863. Before(cut|deactivate|unload|update|paste|print|editfocus|activate)|
  1864. Blur|Scrolltop|Submit|Select|Selectstart|Selectionchange|Hover|Help|
  1865. Change|Contextmenu|Controlselect|Cut|Cellchange|Clock|Close|Deactivate|
  1866. Datasetchanged|Datasetcomplete|Dataavailable|Drop|Drag|Dragstart|Dragover|
  1867. Dragdrop|Dragenter|Dragend|Dragleave|Dblclick|Unload|Paste|Propertychange|Error|
  1868. Errorupdate|Keydown|Keyup|Keypress|Focus|Load|Activate|Afterupdate|Afterprint|Abort)\\b
  1869. '''
  1870. 'name': 'support.function.event-handler.js'
  1871. }
  1872. {
  1873. 'match': '''(?x)
  1874. \\b(catch|finally|then|shift|showModelessDialog|showModalDialog|showHelp|scroll|scrollX|scrollByPages|
  1875. scrollByLines|scrollY|scrollTo|stop|strike|sizeToContent|sidebar|signText|sort|
  1876. sup|sub|substr|substring|splice|split|send|set(Milliseconds|Seconds|Minutes|Hours|
  1877. Month|Year|FullYear|Date|UTC(Milliseconds|Seconds|Minutes|Hours|Month|FullYear|Date)|
  1878. Time|Hotkeys|Cursor|ZOptions|Active|Resizable|RequestHeader)|search|slice|
  1879. savePreferences|small|home|handleEvent|navigate|char|charCodeAt|charAt|concat|
  1880. contextual|confirm|compile|clear|captureEvents|call|createStyleSheet|createPopup|
  1881. createEventObject|to(GMTString|UTCString|String|Source|UpperCase|LowerCase|LocaleString)|
  1882. test|taint|taintEnabled|indexOf|italics|disableExternalCapture|dump|detachEvent|unshift|
  1883. untaint|unwatch|updateCommands|join|javaEnabled|pop|push|plugins.refresh|paddings|parse|stringify|
  1884. print|prompt|preference|enableExternalCapture|exec|execScript|valueOf|UTC|find|file|
  1885. fileModifiedDate|fileSize|fileCreatedDate|fileUpdatedDate|fixed|fontsize|fontcolor|
  1886. forward|fromCharCode|watch|link|load|lastIndexOf|anchor|attachEvent|atob|apply|alert|
  1887. abort|routeEvents|resize|resizeBy|resizeTo|recalc|returnValue|replace|reverse|reload|
  1888. releaseCapture|releaseEvents|go|get(Milliseconds|Seconds|Minutes|Hours|Month|Day|Year|FullYear|
  1889. Time|Date|TimezoneOffset|UTC(Milliseconds|Seconds|Minutes|Hours|Day|Month|FullYear|Date)|
  1890. Attention|Selection|ResponseHeader|AllResponseHeaders)|moveBy|moveBelow|moveTo|
  1891. moveToAbsolute|moveAbove|mergeAttributes|match|margins|btoa|big|bold|borderWidths|blink|back)\\b
  1892. '''
  1893. 'name': 'support.function.js'
  1894. }
  1895. {
  1896. 'match': '''(?x)
  1897. \\b(acceptNode|add|addEventListener|addTextTrack|adoptNode|after|animate|append|
  1898. appendChild|appendData|before|blur|canPlayType|captureStream|
  1899. caretPositionFromPoint|caretRangeFromPoint|checkValidity|clear|click|
  1900. cloneContents|cloneNode|cloneRange|close|closest|collapse|
  1901. compareBoundaryPoints|compareDocumentPosition|comparePoint|contains|
  1902. convertPointFromNode|convertQuadFromNode|convertRectFromNode|createAttribute|
  1903. createAttributeNS|createCaption|createCDATASection|createComment|
  1904. createContextualFragment|createDocument|createDocumentFragment|
  1905. createDocumentType|createElement|createElementNS|createEntityReference|
  1906. createEvent|createExpression|createHTMLDocument|createNodeIterator|
  1907. createNSResolver|createProcessingInstruction|createRange|createShadowRoot|
  1908. createTBody|createTextNode|createTFoot|createTHead|createTreeWalker|delete|
  1909. deleteCaption|deleteCell|deleteContents|deleteData|deleteRow|deleteTFoot|
  1910. deleteTHead|detach|disconnect|dispatchEvent|elementFromPoint|elementsFromPoint|
  1911. enableStyleSheetsForSet|entries|evaluate|execCommand|exitFullscreen|
  1912. exitPointerLock|expand|extractContents|fastSeek|firstChild|focus|forEach|get|
  1913. getAll|getAnimations|getAttribute|getAttributeNames|getAttributeNode|
  1914. getAttributeNodeNS|getAttributeNS|getBoundingClientRect|getBoxQuads|
  1915. getClientRects|getContext|getDestinationInsertionPoints|getElementById|
  1916. getElementsByClassName|getElementsByName|getElementsByTagName|
  1917. getElementsByTagNameNS|getItem|getNamedItem|getSelection|getStartDate|
  1918. getVideoPlaybackQuality|has|hasAttribute|hasAttributeNS|hasAttributes|
  1919. hasChildNodes|hasFeature|hasFocus|importNode|initEvent|insertAdjacentElement|
  1920. insertAdjacentHTML|insertAdjacentText|insertBefore|insertCell|insertData|
  1921. insertNode|insertRow|intersectsNode|isDefaultNamespace|isEqualNode|
  1922. isPointInRange|isSameNode|item|key|keys|lastChild|load|lookupNamespaceURI|
  1923. lookupPrefix|matches|move|moveAttribute|moveAttributeNode|moveChild|
  1924. moveNamedItem|namedItem|nextNode|nextSibling|normalize|observe|open|
  1925. parentNode|pause|play|postMessage|prepend|preventDefault|previousNode|
  1926. previousSibling|probablySupportsContext|queryCommandEnabled|
  1927. queryCommandIndeterm|queryCommandState|queryCommandSupported|queryCommandValue|
  1928. querySelector|querySelectorAll|registerContentHandler|registerElement|
  1929. registerProtocolHandler|releaseCapture|releaseEvents|remove|removeAttribute|
  1930. removeAttributeNode|removeAttributeNS|removeChild|removeEventListener|
  1931. removeItem|replace|replaceChild|replaceData|replaceWith|reportValidity|
  1932. requestFullscreen|requestPointerLock|reset|scroll|scrollBy|scrollIntoView|
  1933. scrollTo|seekToNextFrame|select|selectNode|selectNodeContents|set|setAttribute|
  1934. setAttributeNode|setAttributeNodeNS|setAttributeNS|setCapture|
  1935. setCustomValidity|setEnd|setEndAfter|setEndBefore|setItem|setNamedItem|
  1936. setRangeText|setSelectionRange|setSinkId|setStart|setStartAfter|setStartBefore|
  1937. slice|splitText|stepDown|stepUp|stopImmediatePropagation|stopPropagation|
  1938. submit|substringData|supports|surroundContents|takeRecords|terminate|toBlob|
  1939. toDataURL|toggle|toString|values|write|writeln)\\b
  1940. '''
  1941. 'name': 'support.function.dom.js'
  1942. }
  1943. {
  1944. 'match': "[a-zA-Z_$][\\w$]*"
  1945. 'name': 'entity.name.function.js'
  1946. }
  1947. {
  1948. 'match': '\\d[\\w$]*'
  1949. 'name': 'invalid.illegal.identifier.js'
  1950. }
  1951. ]
  1952. 'function_calls':
  1953. 'patterns': [
  1954. {
  1955. # functionCall(arg1, "arg2", [...])
  1956. 'begin': '([\\w$]+)\\s*(?=\\()'
  1957. 'beginCaptures':
  1958. '1':
  1959. 'patterns': [
  1960. {
  1961. 'match': '''(?x)
  1962. \\b(isNaN|isFinite|eval|uneval|parseInt|parseFloat|decodeURI|
  1963. decodeURIComponent|encodeURI|encodeURIComponent|escape|unescape|
  1964. require|set(Interval|Timeout)|clear(Interval|Timeout))\\b
  1965. '''
  1966. 'name': 'support.function.js'
  1967. }
  1968. {
  1969. 'match': "[a-zA-Z_$][\\w$]*"
  1970. 'name': 'entity.name.function.js'
  1971. }
  1972. {
  1973. 'match': '\\d[\\w$]*'
  1974. 'name': 'invalid.illegal.identifier.js'
  1975. }
  1976. ]
  1977. 'end': '(?<=\\))'
  1978. 'name': 'meta.function-call.js'
  1979. 'patterns': [
  1980. {
  1981. 'include': '#arguments'
  1982. }
  1983. ]
  1984. }
  1985. {
  1986. # functionCall?.(arg1, "arg2", [...])
  1987. 'begin': '([\\w$]+)\\s*(\\?\\.)(?=\\()'
  1988. 'beginCaptures':
  1989. '1':
  1990. 'patterns': [
  1991. {
  1992. 'match': '''(?x)
  1993. \\b(isNaN|isFinite|eval|uneval|parseInt|parseFloat|decodeURI|
  1994. decodeURIComponent|encodeURI|encodeURIComponent|escape|unescape|
  1995. require|set(Interval|Timeout)|clear(Interval|Timeout))\\b
  1996. '''
  1997. 'name': 'support.function.js'
  1998. }
  1999. {
  2000. 'match': "[a-zA-Z_$][\\w$]*"
  2001. 'name': 'entity.name.function.js'
  2002. }
  2003. {
  2004. 'match': '\\d[\\w$]*'
  2005. 'name': 'invalid.illegal.identifier.js'
  2006. }
  2007. ]
  2008. '2':
  2009. 'name': 'meta.delimiter.method.optional.js'
  2010. 'end': '(?<=\\))'
  2011. 'name': 'meta.function-call.js'
  2012. 'patterns': [
  2013. {
  2014. 'include': '#arguments'
  2015. }
  2016. ]
  2017. }
  2018. ]
  2019. 'objects':
  2020. 'patterns': [
  2021. # "Obj." is already enough to prove objectness,
  2022. # however "Obj.[8]" is impossible, and
  2023. # "Obj?.()" is a function
  2024. {
  2025. # OBJ in OBJ.prop, OBJ.methodCall()
  2026. 'match': '[A-Z][A-Z0-9_$]*(?=\\s*\\??\\.\\s*[a-zA-Z_$]\\w*)'
  2027. 'name': 'constant.other.object.js'
  2028. }
  2029. {
  2030. # obj in obj.prop, obj.methodCall()
  2031. 'match': '[a-zA-Z_$][\\w$]*(?=\\s*\\??\\.\\s*[a-zA-Z_$]\\w*)'
  2032. 'name': 'variable.other.object.js'
  2033. }
  2034. {
  2035. # OBJ in OBJ[8], OBJ?.[8]
  2036. 'match': '[A-Z][A-Z0-9_$]*(?=\\s*(\\?\\.)?\\s*\\[)'
  2037. 'name': 'constant.other.object.js'
  2038. }
  2039. {
  2040. # obj in obj[8], obj?.[8]
  2041. 'match': '[a-zA-Z_$][\\w$]*(?=\\s*(\\?\\.)?\\s*\\[)'
  2042. 'name': 'variable.other.object.js'
  2043. }
  2044. ]
  2045. 'properties':
  2046. 'patterns': [
  2047. # object.prop includes object?.prop
  2048. {
  2049. # Specifically ?.[], for example divArray?.[8]
  2050. 'begin': '(\\?\\.)\\s*(\\[)'
  2051. 'beginCaptures':
  2052. '1':
  2053. 'name': 'meta.delimiter.property.optional.js'
  2054. '2':
  2055. 'name': 'meta.brace.square.js'
  2056. 'end': '\\]'
  2057. 'endCaptures':
  2058. '0':
  2059. 'name': 'meta.brace.square.js'
  2060. 'patterns': [
  2061. {
  2062. 'include': '$self'
  2063. }
  2064. ]
  2065. }
  2066. {
  2067. # PROP1 in obj.PROP1.prop2, func().PROP1.prop2
  2068. 'match': '(\\?\\.|\\.)\\s*([A-Z][A-Z0-9_$]*\\b\\$*)(?=\\s*(\\?\\.|\\.)\\s*[a-zA-Z_$]\\w*)'
  2069. 'captures':
  2070. '1':
  2071. 'patterns': [
  2072. {
  2073. 'include': '#period_or_optional_property'
  2074. }
  2075. ]
  2076. '2':
  2077. 'name': 'constant.other.object.property.js'
  2078. }
  2079. {
  2080. # prop1 in obj.prop1.prop2, func().prop1.prop2
  2081. 'match': '(\\?\\.|\\.)\\s*(\\$*[a-zA-Z_$][\\w$]*)(?=\\s*(\\?\\.|\\.)\\s*[a-zA-Z_$]\\w*)'
  2082. 'captures':
  2083. '1':
  2084. 'patterns': [
  2085. {
  2086. 'include': '#period_or_optional_property'
  2087. }
  2088. ]
  2089. '2':
  2090. 'name': 'variable.other.object.property.js'
  2091. }
  2092. {
  2093. # PROP in obj.PROP, func().PROP
  2094. 'match': '(\\?\\.|\\.)\\s*([A-Z][A-Z0-9_$]*\\b\\$*)'
  2095. 'captures':
  2096. '1':
  2097. 'patterns': [
  2098. {
  2099. 'include': '#period_or_optional_property'
  2100. }
  2101. ]
  2102. '2':
  2103. 'name': 'constant.other.property.js'
  2104. }
  2105. {
  2106. # prop in obj.prop, func().prop
  2107. 'match': '(\\?\\.|\\.)\\s*(\\$*[a-zA-Z_$][\\w$]*)'
  2108. 'captures':
  2109. '1':
  2110. 'patterns': [
  2111. {
  2112. 'include': '#period_or_optional_property'
  2113. }
  2114. ]
  2115. '2':
  2116. 'name': 'variable.other.property.js'
  2117. }
  2118. {
  2119. # 123illegal in obj.123illegal, func().123illegal
  2120. 'match': '(\\?\\.|\\.)\\s*([0-9][\\w$]*)'
  2121. 'captures':
  2122. '1':
  2123. 'patterns': [
  2124. {
  2125. 'include': '#period_or_optional_property'
  2126. }
  2127. ]
  2128. '2':
  2129. 'name': 'invalid.illegal.identifier.js'
  2130. }
  2131. ]
  2132. 'interpolated_js':
  2133. 'patterns': [
  2134. {
  2135. 'begin': '\\${'
  2136. 'captures':
  2137. '0':
  2138. 'name': 'punctuation.section.embedded.js'
  2139. 'end': '}'
  2140. 'name': 'source.js.embedded.source'
  2141. 'patterns': [
  2142. {
  2143. 'begin': '{'
  2144. 'beginCaptures':
  2145. '0':
  2146. 'name': 'meta.brace.curly.js'
  2147. 'end': '}'
  2148. 'endCaptures':
  2149. '0':
  2150. 'name': 'meta.brace.curly.js'
  2151. 'patterns': [
  2152. {
  2153. 'include': '$self'
  2154. }
  2155. ]
  2156. }
  2157. {
  2158. 'include': '$self'
  2159. }
  2160. ]
  2161. }
  2162. ]
  2163. 'comments':
  2164. 'patterns': [
  2165. {
  2166. 'captures':
  2167. '1':
  2168. 'name': 'punctuation.definition.comment.begin.js'
  2169. '2':
  2170. 'name': 'punctuation.definition.comment.end.js'
  2171. 'match': '(/\\*)(\\*/)'
  2172. 'name': 'comment.block.empty.js'
  2173. }
  2174. {
  2175. 'begin': '/\\*\\*'
  2176. 'beginCaptures':
  2177. '0':
  2178. 'name': 'punctuation.definition.comment.begin.js'
  2179. 'end': '\\*/'
  2180. 'endCaptures':
  2181. '0':
  2182. 'name': 'punctuation.definition.comment.end.js'
  2183. 'name': 'comment.block.documentation.js'
  2184. 'patterns': [
  2185. {
  2186. 'include': 'source.jsdoc'
  2187. }
  2188. ]
  2189. }
  2190. {
  2191. 'begin': '/\\*'
  2192. 'beginCaptures':
  2193. '0':
  2194. 'name': 'punctuation.definition.comment.begin.js'
  2195. 'end': '\\*/'
  2196. 'endCaptures':
  2197. '0':
  2198. 'name': 'punctuation.definition.comment.end.js'
  2199. 'name': 'comment.block.js'
  2200. }
  2201. {
  2202. 'begin': '//'
  2203. 'beginCaptures':
  2204. '0':
  2205. 'name': 'punctuation.definition.comment.js'
  2206. 'end': '$'
  2207. 'name': 'comment.line.double-slash.js'
  2208. }
  2209. ]
  2210. 'switch_statement':
  2211. 'patterns': [
  2212. {
  2213. # switch(expression) {...}
  2214. 'begin': '\\bswitch\\b'
  2215. 'beginCaptures':
  2216. '0':
  2217. 'name': 'keyword.control.switch.js'
  2218. 'end': '}'
  2219. 'endCaptures':
  2220. '0':
  2221. 'name': 'punctuation.definition.section.switch-block.end.bracket.curly.js'
  2222. 'name': 'meta.switch-statement.js'
  2223. 'patterns': [
  2224. {
  2225. 'begin': '\\('
  2226. 'beginCaptures':
  2227. '0':
  2228. 'name': 'punctuation.definition.switch-expression.begin.bracket.round.js'
  2229. 'end': '\\)'
  2230. 'endCaptures':
  2231. '0':
  2232. 'name': 'punctuation.definition.switch-expression.end.bracket.round.js'
  2233. 'patterns': [
  2234. 'include': '$self'
  2235. ]
  2236. }
  2237. {
  2238. 'begin': '{'
  2239. 'beginCaptures':
  2240. '0':
  2241. 'name': 'punctuation.definition.section.switch-block.begin.bracket.curly.js'
  2242. 'end': '(?=})'
  2243. 'patterns': [
  2244. {
  2245. 'begin': '\\bcase\\b'
  2246. 'beginCaptures':
  2247. '0':
  2248. 'name': 'keyword.control.case.js'
  2249. 'end': ':'
  2250. 'endCaptures':
  2251. '0':
  2252. 'name': 'punctuation.definition.section.case-statement.js'
  2253. 'patterns': [
  2254. {
  2255. 'include': '#prevent_object_keys_matching'
  2256. }
  2257. {
  2258. 'include': '$self'
  2259. }
  2260. ]
  2261. }
  2262. {
  2263. 'match': '(?:^\\s*)?\\b(default)\\b\\s*(:)'
  2264. 'captures':
  2265. '1':
  2266. 'name': 'keyword.control.default.js'
  2267. '2':
  2268. 'name': 'punctuation.definition.section.case-statement.js'
  2269. }
  2270. {
  2271. 'include': '$self'
  2272. }
  2273. ]
  2274. }
  2275. ]
  2276. }
  2277. ]
  2278. 'prevent_object_keys_matching':
  2279. 'patterns': [
  2280. {
  2281. # e.g. don't treat null as an object key in
  2282. # ? null :
  2283. # case null:
  2284. 'match': '(\\w+)(?=\\s*:)'
  2285. 'captures':
  2286. '1':
  2287. 'patterns': [
  2288. 'include': '$self'
  2289. ]
  2290. }
  2291. ]
  2292. 'period_or_illegal_optional_property':
  2293. 'patterns': [
  2294. {
  2295. 'match': '\\.'
  2296. 'name': 'meta.delimiter.property.period.js'
  2297. }
  2298. {
  2299. 'match': '\\?\\.'
  2300. 'name': 'invalid.illegal.meta.delimiter.property.optional.js'
  2301. }
  2302. ]
  2303. 'period_or_illegal_optional_method':
  2304. 'patterns': [
  2305. {
  2306. 'match': '\\.'
  2307. 'name': 'meta.delimiter.method.period.js'
  2308. }
  2309. {
  2310. 'match': '\\?\\.'
  2311. 'name': 'invalid.illegal.meta.delimiter.method.optional.js'
  2312. }
  2313. ]
  2314. 'period_or_optional_property':
  2315. 'patterns': [
  2316. {
  2317. 'match': '\\.'
  2318. 'name': 'meta.delimiter.property.period.js'
  2319. }
  2320. {
  2321. 'match': '\\?\\.'
  2322. 'name': 'meta.delimiter.property.optional.js'
  2323. }
  2324. ]
  2325. 'period_or_optional_method':
  2326. 'patterns': [
  2327. {
  2328. 'match': '\\.'
  2329. 'name': 'meta.delimiter.method.period.js'
  2330. }
  2331. {
  2332. 'match': '\\?\\.'
  2333. 'name': 'meta.delimiter.method.optional.js'
  2334. }
  2335. ]