├── .gitignore
├── Default.sublime-keymap
├── JavaScript (Babel).sublime-syntax
├── LICENSE
├── Next.YAML-tmTheme
├── Next.tmTheme
├── README.md
├── Styled Components.sublime-syntax
├── build
└── build.py
├── messages.json
├── messages
├── 10.0.0.txt
├── 11.0.0.txt
├── 3.0.0.txt
├── 4.0.0.txt
├── 5.0.0.txt
├── 7.1.0.txt
├── 8.0.0.txt
└── 9.0.0.txt
├── package.json
├── plugin.py
├── screenshots
└── compare-builtin-jsx@2x.png
├── support
├── Comments.tmPreferences
├── Completion Rules.tmPreferences
├── Indentation Rules.tmPreferences
├── JSX Comments.tmPreferences
├── JavaScript (Babel).sublime-settings
├── Regular Expressions (JavaScript).sublime-syntax
├── Symbol List - Exports.tmPreferences
└── Symbol List.tmPreferences
└── tests
├── syntax_test_flow.js
├── syntax_test_js.js
├── syntax_test_js_bindings.js
├── syntax_test_js_class.js
├── syntax_test_js_control.js
├── syntax_test_js_import_export.js
├── syntax_test_js_indent_common.js
├── syntax_test_js_jsdoc.js
├── syntax_test_js_not_typescript.js
├── syntax_test_js_regexp.js
├── syntax_test_js_support_builtin.js
├── syntax_test_js_support_console.js
├── syntax_test_js_support_dom.js
├── syntax_test_js_support_node.js
├── syntax_test_jsx.jsx
└── syntax_test_string_object_keys.js
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
--------------------------------------------------------------------------------
/Default.sublime-keymap:
--------------------------------------------------------------------------------
1 | [
2 | // Auto-pair backticks
3 | { "keys": ["`"], "command": "insert_snippet", "args": {"contents": "`$0`"}, "context":
4 | [
5 | { "key": "selector", "operator": "equal", "operand": "source.js", "match_all": true },
6 | { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
7 | { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
8 | { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|>|$)", "match_all": true },
9 | { "key": "preceding_text", "operator": "not_regex_contains", "operand": "[`a-zA-Z0-9_]$", "match_all": true },
10 | { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.template", "match_all": true }
11 | ]
12 | },
13 | { "keys": ["`"], "command": "insert_snippet", "args": {"contents": "`${0:$SELECTION}`"}, "context":
14 | [
15 | { "key": "selector", "operator": "equal", "operand": "source.js", "match_all": true },
16 | { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
17 | { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
18 | ]
19 | },
20 | { "keys": ["`"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
21 | [
22 | { "key": "selector", "operator": "equal", "operand": "source.js", "match_all": true },
23 | { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
24 | { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
25 | { "key": "following_text", "operator": "regex_contains", "operand": "^`", "match_all": true }
26 | ]
27 | },
28 |
29 | // Auto-pair interpolation
30 | { "keys": ["{"], "command": "insert_snippet", "args": {"contents": "{$0}"}, "context":
31 | [
32 | { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
33 | { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
34 | { "key": "selector", "operator": "equal", "operand": "source.js string.template.js - meta.template.expression.js", "match_all": true },
35 | { "key": "preceding_text", "operator": "regex_contains", "operand": "\\$$", "match_all": true }
36 | ]
37 | },
38 | { "keys": ["$"], "command": "insert_snippet", "args": {"contents": "\\${${0:$SELECTION}}"}, "context":
39 | [
40 | { "key": "selector", "operator": "equal", "operand": "source.js string.template.js - meta.template.expression.js", "match_all": true },
41 | { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
42 | { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
43 | ]
44 | },
45 |
46 | // JSX close tag (inside JSX)
47 | { "keys": ["/"], "command": "close_tag", "args": { "insert_slash": true }, "context":
48 | [
49 | { "key": "selector", "operator": "equal", "operand": "source.js meta.jsx.js - meta.embedded.expression - string - comment", "match_all": true },
50 | { "key": "preceding_text", "operator": "regex_match", "operand": ".*<$", "match_all": true },
51 | { "key": "setting.auto_close_tags" }
52 | ]
53 | },
54 | // JSX close tag (outer-most tag)
55 | { "keys": ["/"], "command": "close_tag", "args": { "insert_slash": true }, "context":
56 | [
57 | { "key": "selector", "operator": "equal", "operand": "source.js - string - comment", "match_all": true },
58 | { "key": "preceding_text", "operator": "regex_match", "operand": "^\\s*<$", "match_all": true },
59 | { "key": "setting.auto_close_tags" }
60 | ]
61 | }
62 | ]
63 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2015 Andres Suarez
2 |
3 | MIT License
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining
6 | a copy of this software and associated documentation files (the
7 | "Software"), to deal in the Software without restriction, including
8 | without limitation the rights to use, copy, modify, merge, publish,
9 | distribute, sublicense, and/or sell copies of the Software, and to
10 | permit persons to whom the Software is furnished to do so, subject to
11 | the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be
14 | included in all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/Next.YAML-tmTheme:
--------------------------------------------------------------------------------
1 | # [PackageDev] target_format: plist, ext: tmTheme
2 | name: Next
3 | uuid: 35279c3b-adad-473e-b960-fee631f4d9a5
4 |
5 | settings:
6 | - settings:
7 | activeGuide: '#3333FFFF'
8 | background: '#000000'
9 | bracketsBackground: '#FF00AA66'
10 | bracketsOptions: background
11 | caret: '#FF0099'
12 | foreground: '#E6E6E6'
13 | guide: '#33333388'
14 | gutter: '#6600FF33'
15 | invisibles: '#404040'
16 | lineHighlight: '#FF009933'
17 | multiEditHighlight: '#00FF0022'
18 | searchHighlight: '#FF00AA99'
19 | selection: '#00FFFF44'
20 | stackGuide: '#333333CC'
21 |
22 | - name: bracket.curly
23 | scope: bracket.curly
24 | settings:
25 | background: '#FF44AA'
26 | foreground: '#3399FF'
27 |
28 | - name: bracket.square
29 | scope: bracket.square
30 | settings:
31 | background: '#2266CC'
32 | foreground: '#FF8800'
33 |
34 | - name: bracket.round
35 | scope: bracket.round
36 | settings:
37 | background: '#9922FF'
38 | foreground: '#00FF00'
39 |
40 | - name: bracket.quote
41 | scope: bracket.quote
42 | settings:
43 | background: '#00FF00'
44 |
45 | - name: comment
46 | scope: comment
47 | settings:
48 | fontStyle: italic
49 | foreground: '#646464FF'
50 |
51 | - name: Invalid
52 | scope: invalid
53 | settings:
54 | background: '#FF000022'
55 |
56 | - name: constant
57 | scope: constant
58 | settings:
59 | foreground: '#3387CCFF'
60 |
61 | - name: Keyword
62 | scope: keyword
63 | settings:
64 | foreground: '#E28964'
65 |
66 | - name: constant.numeric
67 | scope: constant.numeric
68 | settings:
69 | foreground: '#FFFF66'
70 |
71 | - name: Storage
72 | scope: storage
73 | settings:
74 | foreground: '#99CF50'
75 |
76 | - name: storage.modifier
77 | scope: storage.modifier
78 | settings:
79 | foreground: '#CF5099'
80 |
81 | - name: storage.self
82 | scope: storage.self
83 | settings:
84 | fontStyle: bold
85 | foreground: '#CC0033'
86 |
87 | - name: storage.type
88 | scope: storage.type
89 | settings:
90 | foreground: '#CF9950'
91 |
92 | - name: Support
93 | scope: support
94 | settings:
95 | foreground: '#8A5C8DFF'
96 |
97 | - name: entity.name.function
98 | scope: entity.name.function
99 | settings:
100 | foreground: '#BB00FF'
101 |
102 | - name: keyword control
103 | scope: keyword.control
104 | settings:
105 | foreground: '#FF00FF'
106 |
107 | - name: keyword.control.declaration
108 | scope: keyword.control.declaration
109 | settings:
110 | foreground: '#8888AA'
111 |
112 | - name: keyword.control.module
113 | scope: keyword.control.module
114 | settings:
115 | background: '#FFFF3333'
116 | foreground: '#FFFF33'
117 | options: underline
118 |
119 | - name: keyword.control.flow
120 | scope: keyword.control.flow
121 | settings:
122 | background: '#110300'
123 | fontStyle: bold
124 | foreground: '#FF6600'
125 |
126 | - name: keyword.control.conditional
127 | scope: keyword.control.conditional
128 | settings:
129 | foreground: '#FF00FF'
130 |
131 | - name: keyword.control.trycatch
132 | scope: keyword.control.trycatch
133 | settings:
134 | foreground: '#FF0033'
135 |
136 | - name: keyword.control.loop
137 | scope: keyword.control.loop
138 | settings:
139 | foreground: '#009999'
140 |
141 | - name: keyword.control.switch
142 | scope: keyword.control.switch
143 | settings:
144 | foreground: '#999999'
145 |
146 | - name: keyword operator
147 | scope: keyword.operator
148 | settings:
149 | foreground: '#FF0080'
150 |
151 | - name: Function arg
152 | scope: meta.function.argument, variable.parameter, meta.parens.c
153 | settings:
154 | foreground: '#77FF11'
155 |
156 | - name: ''
157 | scope: punctuation.section.embedded
158 | settings:
159 | background: '#0D0D0D37'
160 | foreground: '#00D3FFFF'
161 |
162 | - name: keyword.other.unit
163 | scope: keyword.other.unit, keyword.unit.css
164 | settings:
165 | foreground: '#80FF00FF'
166 |
167 | - name: invalid.illegal
168 | scope: invalid.illegal
169 | settings:
170 | background: '#562D56BF'
171 | foreground: '#FD5FF1FF'
172 |
173 | - name: string.quoted source
174 | scope: string.quoted source
175 | settings:
176 | foreground: '#DAEFA3'
177 |
178 | - name: string constant
179 | scope: string constant
180 | settings:
181 | foreground: '#CFED81'
182 |
183 | - name: string.regexp
184 | scope: string.regexp
185 | settings:
186 | foreground: '#6FFF17'
187 |
188 | - name: punctuation.definition.string
189 | scope: punctuation.definition.string
190 | settings:
191 | background: '#15151501'
192 | foreground: '#B4FF82'
193 |
194 | - name: string.regexp.special
195 | scope: "string.regexp constant.character.escape, string.regexp source.ruby.embedded, string.regexp string.regexp.arbitrary-repitition"
196 | settings:
197 | foreground: '#00D505'
198 |
199 | - name: string.regexp punctuation keyword
200 | scope: string.regexp punctuation keyword
201 | settings:
202 | foreground: '#C559FF'
203 |
204 | - name: string variable
205 | scope: string variable
206 | settings:
207 | foreground: '#8A9A95'
208 |
209 | - name: support.function
210 | scope: support.function
211 | settings:
212 | foreground: '#FCF352FF'
213 |
214 | - name: meta.tag
215 | scope: meta.tag
216 | settings:
217 | foreground: '#4F9EFFFF'
218 |
219 | - name: meta.tag entity
220 | scope: meta.tag entity
221 | settings:
222 | foreground: '#157EFF'
223 |
224 | - name: HTML/XML tag attribute value
225 | scope: meta.tag string.quoted.double.html
226 | settings:
227 | foreground: '#E07D2C'
228 |
229 | - name: html5 tag
230 | scope: meta.tag.block.any.html.html5
231 | settings:
232 | foreground: '#E88BFCFF'
233 |
234 | - name: html5 tag entity
235 | scope: meta.tag.block.any.html.html5 entity
236 | settings:
237 | foreground: '#D730FAFF'
238 |
239 | - name: meta.tag.inline
240 | scope: "source entity.name.tag, source entity.other.attribute-name,meta.tag.inline, meta.tag.inline entity"
241 | settings:
242 | foreground: '#87A7E2FF'
243 |
244 | - name: html js tag
245 | scope: source.js.embedded.html entity.name.tag.script.html
246 | settings:
247 | foreground: '#FF3535'
248 |
249 | - name: html js tag braces
250 | scope: source.js.embedded.html punctuation.definition.tag.html
251 | settings:
252 | foreground: '#FF1E1E'
253 |
254 | - name: html js tag url
255 | scope: source.js.embedded.html string.quoted.double.html
256 | settings:
257 | foreground: '#FF9D9D'
258 |
259 | - name: Attribute
260 | scope: entity.other.attribute-name
261 | settings:
262 | foreground: '#7349BEFF'
263 |
264 | - name: Meta Toc List
265 | scope: meta.toc-list
266 | settings:
267 | background: '#162C1AFF'
268 | foreground: '#BEFEC7FF'
269 | options: underline
270 |
271 | - name: js variable readwrite
272 | scope: meta.initialization, variable.other.readwrite.js
273 | settings:
274 | foreground: '#FF9122'
275 |
276 | - name: js variable dollar
277 | scope: meta.initialization, variable.other.dollar.js
278 | settings:
279 | fontStyle: italic
280 | foreground: '#FF9122'
281 |
282 | - name: js object
283 | scope: variable.other.object.js
284 | settings:
285 | foreground: '#FFEE00'
286 |
287 | - name: js object with parent
288 | scope: meta.property-name.js variable.other.object.js
289 | settings:
290 | foreground: '#FFFF88'
291 |
292 | - name: support.variable.property.js
293 | scope: support.variable.property.js
294 | settings:
295 | foreground: '#3399FF'
296 |
297 | - name: variable.other.dot-access
298 | scope: variable.other.dot-access
299 | settings:
300 | foreground: '#66FFDD'
301 |
302 | - name: variable.other.property.js
303 | scope: variable.other.property.js
304 | settings:
305 | foreground: '#37C1BE'
306 |
307 | - name: punctuation.section.scope.square.js
308 | scope: punctuation.section.scope.square.js
309 | settings:
310 | foreground: '#FF2404'
311 |
312 | - name: punctuation.section.scope.round.js, meta.brace.round
313 | scope: punctuation.section.scope.round.js, meta.brace.round
314 | settings:
315 | foreground: '#1C38FF'
316 |
317 | - name: punctuation.definition.arrow.js
318 | scope: punctuation.definition.arrow.js
319 | settings:
320 | background: '#001133'
321 | fontStyle: bold
322 | foreground: '#AA00FF'
323 |
324 | - name: entity.arrow.function.js
325 | scope: entity.arrow.function.js
326 | settings:
327 | background: '#001133'
328 | fontStyle: bold
329 | foreground: '#AA00FF'
330 |
331 | - name: variable.language
332 | scope: variable.language
333 | settings:
334 | foreground: '#AA0044'
335 |
336 | - name: variable.language.prototype
337 | scope: variable.language.prototype
338 | settings:
339 | foreground: '#FF6600'
340 |
341 | - name: support.class.error.js
342 | scope: support.class.error.js
343 | settings:
344 | foreground: '#FF5522'
345 |
346 | - name: support.class.builtin.js
347 | scope: support.class.builtin.js
348 | settings:
349 | fontStyle: italic
350 | foreground: '#FFEE00'
351 |
352 | - name: support.class.node.js
353 | scope: support.class.node.js
354 | settings:
355 | foreground: '#1224FE'
356 |
357 | - name: entity.name.function.node.js
358 | scope: entity.name.function.node.js
359 | settings:
360 | foreground: '#D84014'
361 |
362 | - name: support.keyword.node.js
363 | scope: support.keyword.node.js
364 | settings:
365 | fontStyle: bold
366 | foreground: '#99EF25'
367 |
368 | - name: variable.import.destructuring.js
369 | scope: variable.import.destructuring.js
370 | settings:
371 | foreground: '#00BBFF'
372 |
373 | - name: other.object.key.js
374 | scope: other.object.key.js
375 | settings:
376 | foreground: '#1C98C1'
377 |
378 | - name: meta.accessor.js punctuation.definition.parameters
379 | scope: meta.accessor.js punctuation.definition.parameters
380 | settings:
381 | foreground: '#005588'
382 |
383 | - name: storage.type.accessor.js
384 | scope: storage.type.accessor.js
385 | settings:
386 | background: '#001122'
387 | fontStyle: bold italic
388 | foreground: '#0066AA'
389 |
390 | - name: entity.name.module.js, variable.import.parameter.js, variable.other.class.js
391 | scope: entity.name.module.js, variable.import.parameter.js, variable.other.class.js
392 | settings:
393 | background: '#220011'
394 | foreground: '#FF0044'
395 |
396 | - name: storage.type.module.js, storage.type.export.js, storage.type.import.js, storage.type.from.js
397 | scope: storage.type.module.js, storage.type.export.js, storage.type.import.js, storage.type.from.js
398 | settings:
399 | background: '#222211'
400 | foreground: '#CCCC44'
401 |
402 | - name: storage.type.class.js, storage.type.extends.js
403 | scope: storage.type.class.js, storage.type.extends.js
404 | settings:
405 | background: '#001122'
406 | foreground: '#0044AA'
407 |
408 | - name: 'meta.function.call.class.static.js '
409 | scope: 'meta.function.call.class.static.js '
410 | settings:
411 | foreground: '#880011'
412 |
413 | - name: variable.other.class.static.js
414 | scope: variable.other.class.static.js
415 | settings:
416 | foreground: '#AA0066'
417 |
418 | - name: entity.name.accessor.js
419 | scope: entity.name.accessor.js
420 | settings:
421 | background: '#001122'
422 | fontStyle: bold italic
423 | foreground: '#00FFCC'
424 |
425 | - name: entity.name.method.js
426 | scope: entity.name.method.js
427 | settings:
428 | background: '#110022'
429 | fontStyle: italic bold
430 | foreground: '#AA00FF'
431 |
432 | - name: meta.method.js
433 | scope: meta.method.js
434 | settings:
435 | fontStyle: bold
436 | foreground: '#660099'
437 |
438 | - name: storage.type.function.js
439 | scope: storage.type.function.js
440 | settings:
441 | fontStyle: bold
442 | foreground: '#99CC44'
443 |
444 | - name: string.quoted.single
445 | scope: string.quoted.single
446 | settings:
447 | foreground: '#88FFAAAA'
448 |
449 | - name: variable.other.quasi.js
450 | scope: variable.other.quasi.js
451 | settings:
452 | foreground: '#FF0099'
453 |
454 | - name: string.quasi.js
455 | scope: string.quasi.js
456 | settings:
457 | foreground: '#00FF00'
458 |
459 | - name: punctuation.quasi.element
460 | scope: punctuation.quasi.element
461 | settings:
462 | foreground: '#008800'
463 |
464 | - name: entity.quasi.tag.name.js
465 | scope: entity.quasi.tag.name.js
466 | settings:
467 | foreground: '#FFFF00'
468 |
469 | - name: meta.group.braces.square, punctuation.destructuring
470 | scope: meta.group.braces.square string.quoted.single, punctuation.destructuring
471 | settings:
472 | foreground: '#47E9AC'
473 |
474 | - name: string.quoted.double
475 | scope: string.quoted.double
476 | settings:
477 | foreground: '#11BB11'
478 |
479 | - name: punctuation.section.scope.curly.js
480 | scope: punctuation.section.scope.curly.js
481 | settings:
482 | foreground: '#F9044E'
483 |
484 | - name: meta.delimiter.object.comma.js
485 | scope: meta.delimiter.object.comma.js
486 | settings:
487 | foreground: '#00FFFF'
488 |
489 | - name: meta.group.braces.curly string.quoted.single
490 | scope: meta.group.braces.curly string.quoted.single
491 | settings:
492 | foreground: '#16B853'
493 |
494 | - name: support.function
495 | scope: support.function
496 | settings:
497 | foreground: '#B532FF'
498 |
499 | - name: punctuation.definition.string.begin.js
500 | scope: punctuation.definition.string.begin.js
501 | settings:
502 | foreground: '#D2E20C'
503 |
504 | - name: punctuation.definition.string.end.js
505 | scope: punctuation.definition.string.end.js
506 | settings:
507 | foreground: '#CEA30D'
508 |
509 | - name: instance constructor
510 | scope: meta.class.inheritance, meta.instance.constructor
511 | settings:
512 | fontStyle: italic underline
513 | foreground: '#E81E41'
514 |
515 | - name: entity.name.class.js
516 | scope: entity.name.class.js
517 | settings:
518 | background: '#00FFFF33'
519 | fontStyle: italic
520 | foreground: '#00FFFF'
521 |
522 | - name: entity.name.extends.js
523 | scope: entity.name.extends.js
524 | settings:
525 | background: '#00FF9933'
526 | fontStyle: italic
527 | foreground: '#00FF99'
528 |
529 | - name: function call
530 | scope: meta.function-call entity.name.function
531 | settings:
532 | foreground: '#5B24FF'
533 |
534 | - name: function call with args
535 | scope: meta.function-call.function.with-arguments.js
536 | settings:
537 | foreground: '#33FF00'
538 |
539 | - name: js brace
540 | scope: meta.brace.curly.js
541 | settings:
542 | foreground: '#FF0099'
543 |
544 | - name: js paren
545 | scope: meta.brace.round.js
546 | settings:
547 | background: '#000000FF'
548 | foreground: '#D0C5FEFF'
549 |
550 | - name: js constant escape
551 | scope: constant.character.escape
552 | settings:
553 | foreground: '#10CF62FF'
554 |
555 | - name: pseudo-class
556 | scope: "meta.selector.css entity.other.attribute-name.tag.pseudo-class"
557 | settings:
558 | foreground: '#4FBC4B'
559 |
560 | - name: css selectors
561 | scope: entity.namespace.unicode.css
562 | settings:
563 | foreground: '#FF4F4F'
564 |
565 | - name: entity.other.attribute-name.id
566 | scope: entity.other.attribute-name.id
567 | settings:
568 | background: '#0B0028FF'
569 | foreground: '#F20073FF'
570 |
571 | - name: class name
572 | scope: meta.prototype support.class
573 | settings:
574 | foreground: '#FF0099'
575 |
576 | - name: support object
577 | scope: support.object
578 | settings:
579 | fontStyle: bold
580 | foreground: '#FFEE00'
581 |
582 | - name: class name prototype
583 | scope: meta.prototype support.constant
584 | settings:
585 | foreground: '#FF6600'
586 |
587 | - name: prototype declaration
588 | scope: meta.prototype.declaration.js
589 | settings:
590 | fontStyle: bold
591 |
592 | - name: js undefined
593 | scope: constant.language.undefined.js
594 | settings:
595 | foreground: '#555588'
596 |
597 | - name: variable.other.constant.js
598 | scope: variable.other.constant.js
599 | settings:
600 | background: '#003311'
601 | foreground: '#00FF33'
602 |
603 | - name: 'false'
604 | scope: constant.language.boolean.false
605 | settings:
606 | foreground: '#AAAA55'
607 |
608 | - name: 'true'
609 | scope: constant.language.boolean.true
610 | settings:
611 | foreground: '#CC7744'
612 |
613 | - name: js null
614 | scope: constant.language.null.js
615 | settings:
616 | foreground: '#558855'
617 |
618 | - name: css#id punctuation
619 | scope: punctuation.definition.entity.id.css
620 | settings:
621 | background: '#0B0028'
622 | foreground: '#FF489F'
623 |
624 | - name: css.class
625 | scope: "entity.other.attribute-name.class, source.css.less entity.other.attribute-name.class.css"
626 | settings:
627 | background: '#0B0028'
628 | foreground: '#9529B8'
629 |
630 | - name: css.class puntuation
631 | scope: punctuation.definition.entity.class.css
632 | settings:
633 | background: '#0B0028FF'
634 | foreground: '#CD87E4FF'
635 |
636 | - name: css pseudo element
637 | scope: entity.other.attribute-name.pseudo-element.css
638 | settings:
639 | background: '#0B0028FF'
640 | foreground: '#FF00FFFF'
641 |
642 | - name: css property-name
643 | scope: support.type.property-name.css
644 | settings:
645 | foreground: '#B8EFECFF'
646 |
647 | - name: css @at-rule
648 | scope: meta.preprocessor.at-rule keyword.control.at-rule
649 | settings:
650 | foreground: '#D7C271FF'
651 |
652 | - name: css color
653 | scope: "constant.other.color.rgb-value.css, support.constant.color.w3c-standard-color-name.css"
654 | settings:
655 | foreground: '#FB7720FF'
656 |
657 | - name: css constants
658 | scope: support.constant.property-value.css
659 | settings:
660 | foreground: '#7CE85EFF'
661 |
662 | - name: Puncation Termination
663 | scope: punctuation.terminator, punctuation.separator
664 | settings:
665 | foreground: '#4BFCF8FF'
666 |
667 | - name: css constructor.argument
668 | scope: meta.constructor.argument.css
669 | settings:
670 | foreground: '#8F9D6AFF'
671 |
672 | - name: diff.header
673 | scope: meta.diff, meta.diff.header, entity.name.namespace
674 | settings:
675 | background: '#0E2231FF'
676 | foreground: '#F8F8F8FF'
677 |
678 | - name: diff.deleted
679 | scope: markup.deleted
680 | settings:
681 | background: '#420E09FF'
682 | foreground: '#F8F8F8FF'
683 |
684 | - name: diff.changed
685 | scope: markup.changed
686 | settings:
687 | background: '#4A410DFF'
688 | foreground: '#F8F8F8FF'
689 |
690 | - name: diff.inserted
691 | scope: markup.inserted
692 | settings:
693 | background: '#253B22FF'
694 | foreground: '#F8F8F8FF'
695 |
696 | - name: 'Markup: Italic'
697 | scope: markup.italic
698 | settings:
699 | fontStyle: italic
700 | foreground: '#6AD500FF'
701 |
702 | - name: 'Markup: Underline'
703 | scope: markup.underline
704 | settings:
705 | foreground: '#E18964FF'
706 | options: underline
707 |
708 | - name: 'Markup: Quote'
709 | scope: markup.quote
710 | settings:
711 | background: '#FEE09C12'
712 | fontStyle: italic
713 | foreground: '#E1D4B9FF'
714 |
715 | - name: 'Markup: Heading'
716 | scope: markup.heading, markup.heading entity
717 | settings:
718 | background: '#DE3280FF'
719 | foreground: '#FFFFFFFF'
720 |
721 | - name: 'Markup: List'
722 | scope: markup.list
723 | settings:
724 | foreground: '#6657EAFF'
725 |
726 | - name: 'Markup: Raw'
727 | scope: markup.raw
728 | settings:
729 | background: '#B1B3BA08'
730 | foreground: '#578BB3FF'
731 |
732 | - name: 'Markup: Comment'
733 | scope: markup comment
734 | settings:
735 | foreground: '#F67B37FF'
736 |
737 | - name: 'Markup: Separator'
738 | scope: meta.separator
739 | settings:
740 | background: '#242424FF'
741 | foreground: '#60A633FF'
742 |
743 | - name: Log Entry
744 | scope: meta.line.entry.logfile, meta.line.exit.logfile
745 | settings:
746 | background: '#EEEEEE29'
747 | foreground: '#F8F8F8FF'
748 |
749 | - name: Log Entry Error
750 | scope: meta.line.error.logfile
751 | settings:
752 | background: '#751012'
753 | foreground: '#F8F8F8'
754 |
755 | - name: JSON property top
756 | scope: meta.structure.dictionary.json string.quoted.double
757 | settings:
758 | background: '#111111'
759 | foreground: '#1144BB'
760 |
761 | - name: JSON property level 2
762 | scope: "meta.structure meta.structure.dictionary.json string.quoted.double"
763 | settings:
764 | foreground: '#1122BB'
765 |
766 | - name: JSON property level 3
767 | scope: "meta.structure meta.structure meta.structure meta.structure.dictionary.json string.quoted.double"
768 | settings:
769 | foreground: '#2938EB'
770 |
771 | - name: JSON property level 4
772 | scope: "meta.structure meta.structure meta.structure meta.structure meta.structure meta.structure.dictionary.json string.quoted.double"
773 | settings:
774 | foreground: '#6D7EF1'
775 |
776 | - name: JSON property level 5
777 | scope: "meta.structure meta.structure meta.structure meta.structure meta.structure meta.structure meta.structure meta.structure.dictionary.json string.quoted.double"
778 | settings:
779 | foreground: '#B3BBF7'
780 |
781 | - name: JSON value
782 | scope: meta.structure.dictionary.value.json string.quoted.double
783 | settings:
784 | foreground: '#AA00AA'
785 |
786 | - name: JSON value level 2
787 | scope: "meta.structure meta.structure meta.structure.dictionary.value.json string.quoted.double"
788 | settings:
789 | foreground: '#BF00BF'
790 |
791 | - name: JSON value level 3
792 | scope: "meta.structure meta.structure meta.structure meta.structure meta.structure.dictionary.value.json string.quoted.double"
793 | settings:
794 | foreground: '#FF00FF'
795 |
796 | - name: JSON value level 4
797 | scope: "meta.structure meta.structure meta.structure meta.structure meta.structure meta.structure meta.structure.dictionary.value.json string.quoted.double"
798 | settings:
799 | foreground: '#FF40FF'
800 |
801 | - name: JSON value level 5
802 | scope: "meta.structure meta.structure meta.structure meta.structure meta.structure meta.structure meta.structure meta.structure meta.structure.dictionary.value.json string.quoted.double"
803 | settings:
804 | foreground: '#FF80FF'
805 |
806 | - name: JSON value string punctuation
807 | scope: "meta.structure.dictionary.value.json string punctuation.definition.string.double"
808 | settings:
809 | foreground: '#8409FF'
810 |
811 | - name: JSON array value
812 | scope: meta.structure.array.json string.quoted.double
813 | settings:
814 | foreground: '#5522AA'
815 |
816 | - name: JSON array value level 1
817 | scope: "meta.structure meta.structure meta.structure.array.json string.quoted.double"
818 | settings:
819 | foreground: '#7017C8FF'
820 |
821 | - name: JSON array value level 2
822 | scope: "meta.structure meta.structure meta.structure meta.structure meta.structure.array.json string.quoted.double"
823 | settings:
824 | foreground: '#9541E9FF'
825 |
826 | - name: JSON array value level 3
827 | scope: "meta.structure meta.structure meta.structure meta.structure meta.structure.array.json string.quoted.double"
828 | settings:
829 | foreground: '#BA83F1FF'
830 |
831 | - name: JSON array value level 4
832 | scope: "meta.structure meta.structure meta.structure meta.structure meta.structure meta.structure meta.structure.array.json string.quoted.double"
833 | settings:
834 | foreground: '#DFC6F9FF'
835 |
836 | - name: JSON prop string punctuation
837 | scope: "meta.structure.dictionary.json string punctuation.definition.string"
838 | settings:
839 | foreground: '#66BBDDFF'
840 |
841 | - name: JSON array string puntuation
842 | scope: "meta.structure.array.json string punctuation.definition.string"
843 | settings:
844 | foreground: '#416BE9FF'
845 |
846 | - name: JSON array brackets
847 | scope: meta.structure.array.json punctuation.definition.array
848 | settings:
849 | foreground: '#FCC401FF'
850 |
851 | - name: JSON object braces
852 | scope: "meta.structure.dictionary.json punctuation.definition.dictionary"
853 | settings:
854 | foreground: '#FEDF76FF'
855 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # babel-sublime
2 |
3 | Language definition for [modern JavaScript](http://kangax.github.io/compat-table/es2016plus/) with [JSX syntax](http://facebook.github.io/react/docs/jsx-in-depth.html), [Flow typing](https://flow.org/), and [Styled Components](https://styled-components.com/).
4 |
5 | ## Installation
6 |
7 | Find it as [**Babel**](https://packagecontrol.io/packages/Babel) through [Package Control](https://packagecontrol.io/).
8 |
9 | #### Setting as the default syntax
10 |
11 | To set it as the default syntax for a particular extension:
12 |
13 | 1. Open a file with that extension,
14 | 2. From the `View` menu, select `Syntax` → `Open all with current extension as…` → `Babel` → `JavaScript (Babel)`
15 | 3. Repeat this for each extension (e.g.: `.js` and `.jsx`).
16 |
17 | #### Setting a Color Scheme
18 |
19 | `Babel` comes bundled with `Next` from [Benvie/JavaScriptNext.tmLanguage](https://github.com/Benvie/JavaScriptNext.tmLanguage). From the command palette, select `UI: Select Color Scheme` and select `Next`.
20 |
21 | ## Screenshots
22 |
23 | 
24 |
25 | ## Snippets
26 |
27 | Find them separately at [babel/babel-sublime-snippets](https://github.com/babel/babel-sublime-snippets) or as [**Babel Snippets**](https://packagecontrol.io/packages/Babel%20Snippets) through [Package Control](https://packagecontrol.io/).
28 |
29 | ## About
30 |
31 | Under the hood, `babel-sublime`'s syntax definition is built using [JS Custom](https://github.com/Thom1729/Sublime-JS-Custom). JS Custom is based on Sublime's [core JavaScript syntax](https://github.com/sublimehq/Packages), which is in turn descended from [Benvie/JavaScriptNext.tmLanguage](https://github.com/Benvie/JavaScriptNext.tmLanguage). Special thanks go to [@jgebhardt](https://github.com/jgebhardt) and [@zpao](https://github.com/zpao).
32 |
33 | ## Contributing
34 |
35 | The `JavaScript (Babel).sublime-syntax` file itself is generated by JS Custom and should not be manually modified — any bug fixes or enhancements to the syntax itself should go through [JS Custom](https://github.com/Thom1729/Sublime-JS-Custom).
36 |
37 | If you modify the commenting rules or Next theme, make sure to do so by editing the appropriate `YAML-tmPreferences` or `YAML-tmTheme` file and converting that file using [PackageDev](https://github.com/SublimeText/PackageDev). Then, commit both the source (YAML) file and the converted (XML) file.
38 |
--------------------------------------------------------------------------------
/Styled Components.sublime-syntax:
--------------------------------------------------------------------------------
1 | %YAML 1.2
2 | ---
3 | version: 2
4 | extends: Packages/CSS/CSS.sublime-syntax
5 | hidden: true
6 | scope: source.js.css
7 | file_extensions: []
8 | first_line_match:
9 | contexts:
10 | main:
11 | - meta_prepend: true
12 | - match: (?=(?:{{html_tags}}|{{svg_tags}})(?!:))
13 | push: styled-components-selector-body
14 | - include: property-identifiers
15 | - include: property-values
16 |
17 | rule-list-body:
18 | - meta_prepend: true
19 | - include: main
20 |
21 | comments:
22 | - meta_prepend: true
23 | - match: //
24 | scope: punctuation.definition.comment.begin.css.styled-components
25 | push:
26 | - meta_scope: comment.line.double-slash.css.styled-components
27 | - match: ^
28 | pop: true
29 |
30 | selectors:
31 | - meta_prepend: true
32 | - match: (?=&)
33 | push: styled-components-selector-body
34 |
35 | selector-body:
36 | - meta_prepend: true
37 | - match: \&
38 | scope: variable.language.css.styled-components
39 |
40 | selector-content:
41 | - meta_prepend: true
42 | - match: \&
43 | scope: variable.language.css.styled-components
44 |
45 | # Make sure that we handle both the old and new CSS context names
46 | styled-components-selector-body:
47 | - meta_scope: meta.selector.css
48 | - include: selector-body
49 | - include: selector-content
50 |
51 | at-keyframe-block-body:
52 | - meta_prepend: true
53 |
54 | at-keyframe-block-content:
55 | - meta_prepend: true
56 |
57 | styled-components-keyframe-body:
58 | - meta_scope: meta.at-rule.keyframe.css
59 | - include: at-keyframe-block-body
60 | - include: at-keyframe-block-content
61 |
--------------------------------------------------------------------------------
/build/build.py:
--------------------------------------------------------------------------------
1 | import sublime
2 | import sublime_plugin
3 |
4 |
5 | __all__ = ['BuildBabelPackageCommand']
6 |
7 |
8 | BABEL_CONFIGURATION = {
9 | 'name': 'JavaScript (Babel)',
10 | 'scope': 'source.js',
11 | 'file_extensions': [ 'js', 'jsx', 'es6', 'babel' ],
12 | 'flow_types': True,
13 | 'jsx': True,
14 | 'string_object_keys': True,
15 | 'custom_templates': {
16 | 'styled_components': True,
17 | },
18 | }
19 |
20 |
21 | class BuildBabelPackageCommand(sublime_plugin.ApplicationCommand):
22 | def run(self):
23 | from sublime_lib import ResourcePath
24 | from pathlib import Path
25 | from shutil import rmtree
26 |
27 | package_path = Path(__file__).parent.parent
28 | syntax_path = ResourcePath.from_file_path(package_path) / 'JavaScript (Babel).sublime-syntax'
29 | test_directory = package_path / 'tests'
30 |
31 |
32 | rmtree(str(test_directory), ignore_errors=True)
33 | test_directory.mkdir()
34 |
35 | print("Building syntax…")
36 | sublime.active_window().run_command('build_js_custom_syntax', {
37 | 'name': 'Babel',
38 | 'configuration': BABEL_CONFIGURATION,
39 | 'destination_path': str(syntax_path.file_path()),
40 | })
41 |
42 | ResourcePath('Packages/JSCustom/styled_components/Styled Components.sublime-syntax').copy(
43 | (ResourcePath.from_file_path(package_path) / 'Styled Components.sublime-syntax').file_path()
44 | )
45 |
46 | print("Building tests…")
47 | sublime.run_command('build_js_custom_tests', {
48 | 'syntax_path': str(syntax_path),
49 | 'suites': ['js', 'flow', 'jsx', 'string_object_keys'],
50 | 'destination_directory': str(test_directory),
51 | })
52 | print('Done.')
53 |
--------------------------------------------------------------------------------
/messages.json:
--------------------------------------------------------------------------------
1 | {
2 | "3.0.0": "messages/3.0.0.txt",
3 | "4.0.0": "messages/4.0.0.txt",
4 | "5.0.0": "messages/5.0.0.txt",
5 | "7.1.0": "messages/7.1.0.txt",
6 | "7.1.1": "messages/7.1.0.txt",
7 | "8.0.0": "messages/8.0.0.txt",
8 | "10.0.0": "messages/10.0.0.txt",
9 | "11.0.0": "messages/11.0.0.txt"
10 | }
11 |
--------------------------------------------------------------------------------
/messages/10.0.0.txt:
--------------------------------------------------------------------------------
1 | babel-sublime
2 | -------------
3 |
4 | Syntax highlighting has been completely overhauled. The new syntax definition provides better support for modern JavaScript and better compatibility with existing color schemes and tools.
5 |
6 | A few examples of improvements and bug fixes:
7 |
8 | - JSX fragments are fully supported.
9 | - Anonymous classes work correctly.
10 | - Missing optional semicolons do not break highlighting.
11 | - Regular expressions are always correctly detected.
12 |
13 | This is a major change. The new syntax definition has been extensively tested in beta, but if you have any problems then please don't hesitate to report them at https://github.com/babel/babel-sublime/issues.
14 |
--------------------------------------------------------------------------------
/messages/11.0.0.txt:
--------------------------------------------------------------------------------
1 | babel-sublime
2 | -------------
3 |
4 | Version 11 features significantly improved highlighting using new features from Sublime Text 4. Highlights include:
5 |
6 | - Recognition of multiline arrow function parameter lists. (#340)
7 | - Better commenting in JSX. (#390)
8 |
--------------------------------------------------------------------------------
/messages/3.0.0.txt:
--------------------------------------------------------------------------------
1 | babel-sublime (previously 6to5-sublime)
2 | ---------------------------------------
3 |
4 | 6to5 is now Babel, so 6to5-sublime is now babel-sublime.
5 |
--------------------------------------------------------------------------------
/messages/4.0.0.txt:
--------------------------------------------------------------------------------
1 | babel-sublime (previously 6to5-sublime)
2 | ---------------------------------------
3 |
4 | Snippets have been removed. For more info see https://github.com/babel/babel-sublime/blob/master/SNIPPETS.md
5 |
--------------------------------------------------------------------------------
/messages/5.0.0.txt:
--------------------------------------------------------------------------------
1 | babel-sublime
2 | -------------
3 |
4 | babel-sublime no longer relies on the stock JavaScript package for any functionality. This means you can disable the stock package completely and rely solely on babel-sublime. Why would you want to that though? A few reasons:
5 |
6 | * node scripts without an extension that have a shebang will open with "JavaScript (Babel)" instead of the stock package.
7 | - babel-sublime has always supported this, but because the stock package takes precedence over babel-sublime, it never really worked.
8 | * Less clutter in the syntax menu :)
9 | * No stock snippets. No snippets period. Since babel-sublime doesn't ship with any snippets, only your user defined ones will show up.
10 |
11 | See https://github.com/babel/babel-sublime#advanced-usage for more info.
12 |
--------------------------------------------------------------------------------
/messages/7.1.0.txt:
--------------------------------------------------------------------------------
1 | babel-sublime
2 | -------------
3 |
4 | Big improvements are coming soon to support flow type annotations. You may
5 | already start to notice some of them, like ES7 property initializers getting
6 | properly matched. But it's coming at a cost:
7 |
8 | There are currently two syntax definitions supporting different builds of
9 | Sublime Text 3 (ST2 doesn't work with either). One is the evolution of the
10 | other using Sublime's new "sublime-syntax" format. That new format allows for
11 | more complex matches, thus paving the way for flow support. If you're using
12 | Sublime Text 3 dev then you're already using the new syntax, if you're
13 | using the beta, then you're still using the old syntax.
14 |
15 | Here's the plan:
16 |
17 | 1. Once the next Sublime Text 3 beta build comes out (whenever that is), I'll
18 | be removing the old syntax from the package. Since, that means that most
19 | (if not all) users will be able to use the new syntax. If you still need
20 | the old syntax, Don't Panic, you can clone the repo and run it like that.
21 | I'll put up instructions if that's thing someone wants.
22 |
23 | 2. "Monokai Phoenix" will also go away. If you're running ST3 dev, and you're
24 | using Monokai Phoenix, you can already switch the stock Monokai and things
25 | will look mostly the same. The new syntax uses more generic scope names that
26 | make it more theme friendly.
27 |
28 | That's all.
29 |
--------------------------------------------------------------------------------
/messages/8.0.0.txt:
--------------------------------------------------------------------------------
1 | babel-sublime
2 | -------------
3 |
4 | If you're on the Sublime Text 3 dev channel and using the latest Sublime
5 | build, you should now see substantially improved JSX matching:
6 |
7 | 1. A few lingering edge-cases w.r.t. JSXText have been fixed.
8 |
9 | 2. JSX matching won't interfere with Flow annotations. This is a huge step
10 | towards full Flow support. Before, some Flow arrays got matched as JSX
11 | and that made a mess. Now, they won't get matched, and at worst it just
12 | looks plain.
13 |
14 | That's it.
15 |
--------------------------------------------------------------------------------
/messages/9.0.0.txt:
--------------------------------------------------------------------------------
1 | babel-sublime
2 | -------------
3 |
4 | * JSX indentation fixes.
5 | * Support for https://github.com/styled-components/styled-components
6 | - See https://github.com/babel/babel-sublime/pull/289
7 |
8 | More coming up...
9 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {},
3 | "private": true
4 | }
5 |
--------------------------------------------------------------------------------
/plugin.py:
--------------------------------------------------------------------------------
1 | from .build.build import BuildBabelPackageCommand
2 |
3 |
4 | __all__ = ['BuildBabelPackageCommand']
5 |
--------------------------------------------------------------------------------
/screenshots/compare-builtin-jsx@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babel/babel-sublime/2b3608cd8b555e3e16df5585e11543085658afbd/screenshots/compare-builtin-jsx@2x.png
--------------------------------------------------------------------------------
/support/Comments.tmPreferences:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | scope
5 | source.js, source.jsx, source.ts, source.tsx, meta.jsx meta.tag.name, meta.jsx meta.tag.attributes
6 | settings
7 |
8 | shellVariables
9 |
10 |
11 | name
12 | TM_COMMENT_START
13 | value
14 | //
15 |
16 |
17 | name
18 | TM_COMMENT_START_2
19 | value
20 | /*
21 |
22 |
23 | name
24 | TM_COMMENT_END_2
25 | value
26 | */
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/support/Completion Rules.tmPreferences:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | scope
5 | source.js
6 | settings
7 |
8 | cancelCompletion
9 | ^\s*(\{?\s*(else|return|do)|(function)\s*[a-zA-Z_0-9]+)$
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/support/Indentation Rules.tmPreferences:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | scope
5 | source.js, source.ts, source.jsx, source.tsx
6 | settings
7 |
8 | decreaseIndentPattern
9 | ^(.*\*/)?\s*\}.*$
10 | increaseIndentPattern
11 | ^.*\{[^}"']*$
12 | bracketIndentNextLinePattern
13 | (?x)
14 | ^ \s* \b(if|while|else)\b [^;]* $
15 | | ^ \s* \b(for)\b .* $
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/support/JSX Comments.tmPreferences:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | name
6 | JSX Comments
7 | scope
8 | meta.jsx
9 | settings
10 |
11 | shellVariables
12 |
13 |
14 | name
15 | TM_COMMENT_START
16 | value
17 | {/*
18 |
19 |
20 | name
21 | TM_COMMENT_END
22 | value
23 | */}
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/support/JavaScript (Babel).sublime-settings:
--------------------------------------------------------------------------------
1 | {
2 | "word_separators": "./\\()\"'-:,.;<>~!@#%^&*|+=[]{}`~?",
3 | }
4 |
--------------------------------------------------------------------------------
/support/Regular Expressions (JavaScript).sublime-syntax:
--------------------------------------------------------------------------------
1 | %YAML 1.2
2 | ---
3 | name: Regular Expressions (Javascript)
4 | scope: source.regexp.js
5 | hidden: true
6 | variables:
7 | identifier: '[_$[:alpha:]][_$[:alnum:]]*'
8 | contexts:
9 | main:
10 | - include: anchor
11 | - include: backref
12 | - include: quantifier
13 | - include: operator
14 | - include: group-assertion
15 | - include: group-definition
16 | - include: character-class
17 | - include: character-class-definition
18 |
19 | anchor:
20 | - match: '\\[bB]|\^|\$'
21 | scope: keyword.control.anchor.regexp
22 |
23 | backref:
24 | - match: '\\[1-9][0-9]*'
25 | scope: keyword.other.back-reference.regexp
26 |
27 | - match: (\\k)(<)({{identifier}})(>)
28 | captures:
29 | 1: keyword.other.back-reference.regexp
30 | 2: punctuation.definition.group.named.begin.regexp
31 | 3: variable.other.group.regexp
32 | 4: punctuation.definition.group.named.end.regexp
33 |
34 | character-class:
35 | - match: '\\[wWsSdD]|\.'
36 | scope: constant.other.character-class.escape.backslash.regexp
37 | - match: '(\\[pP])(\{)([[:alpha:]_]+)(?:(=)([[:alpha:]_]+)?)?(\})'
38 | captures:
39 | 1: constant.other.character-class.escape.unicode-property.regexp
40 | 2: punctuation.definition.unicode-property.begin.regexp
41 | 3: support.constant.unicode-property.regexp
42 | 4: punctuation.separator.key-value.unicode-property.regexp
43 | 5: support.constant.unicode-property.regexp
44 | 6: punctuation.definition.unicode-property.end.regexp
45 | - match: '\\([trnvf0\\]|c[A-Z]|x[\da-fA-F]{2}|u[\da-fA-F]{4}|.)'
46 | scope: constant.character.escape.backslash.regexp
47 |
48 | character-class-definition:
49 | - match: '(\[)(\^)?'
50 | captures:
51 | 1: punctuation.definition.character-class.begin.regexp
52 | 2: keyword.operator.negation.regexp
53 | push:
54 | - meta_scope: constant.other.character-class.set.regexp
55 | - match: '\]'
56 | scope: punctuation.definition.character-class.end.regexp
57 | pop: true
58 | - match: |-
59 | (?x)
60 | (?:
61 | (\\[wWsSdD]|\.)|
62 | (\\(?:[trnvf0]|c[A-Z]|x[\da-fA-F]{2}|u[\da-fA-F]{4}|.))|
63 | .
64 | )
65 | (\-)
66 | (?:
67 | (\\[wWsSdD]|\.)|
68 | (\\(?:[trnvf0]|c[A-Z]|x[\da-fA-F]{2}|u[\da-fA-F]{4}|.))|
69 | [^]]
70 | )
71 | scope: constant.other.character-class.range.regexp
72 | captures:
73 | 1: constant.other.character-class.escape.backslash.regexp
74 | 2: constant.character.escape.backslash.regexp
75 | 3: punctuation.definition.range.regexp
76 | 4: constant.other.character-class.escape.backslash.regexp
77 | 5: constant.character.escape.backslash.regexp
78 | - include: character-class
79 |
80 | group-assertion:
81 | - match: (\()((\?=)|(\?!)|(\?<=)|(\?))?
98 | captures:
99 | 1: punctuation.definition.group.begin.regexp
100 | 2: punctuation.definition.group.no-capture.regexp
101 | 3: punctuation.definition.group.begin.regexp
102 | 4: punctuation.definition.group.named.begin.regexp
103 | 5: entity.name.other.group.regexp
104 | 6: punctuation.definition.group.named.end.regexp
105 | push:
106 | - meta_scope: meta.group.regexp
107 | - match: \)
108 | scope: punctuation.definition.group.end.regexp
109 | pop: true
110 | - include: main
111 |
112 | operator:
113 | - match: \|
114 | scope: keyword.operator.or.regexp
115 |
116 | quantifier:
117 | - match: '[?*+]\??'
118 | scope: keyword.operator.quantifier.regexp
119 |
120 | - match: '\{(\d+)(?:(,)(\d+)?)?\}'
121 | scope: keyword.operator.quantifier.regexp
122 | captures:
123 | 1: constant.literal.numeric.regexp
124 | 2: punctuation.separator.comma.regexp
125 | 3: constant.literal.numeric.regexp
126 |
127 | - match: \{(,)(\d+)\}
128 | scope: keyword.operator.quantifier.regexp
129 | captures:
130 | 1: punctuation.separator.comma.regexp
131 | 2: constant.literal.numeric.regexp
132 |
--------------------------------------------------------------------------------
/support/Symbol List - Exports.tmPreferences:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | scope
5 |
6 | meta.export.js meta.binding.name - meta.export.js meta.function meta.binding.name
7 |
8 | settings
9 |
10 | showInIndexedSymbolList
11 | 1
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/support/Symbol List.tmPreferences:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | scope
5 |
6 | entity.name.interface.js
7 |
8 | settings
9 |
10 | showInSymbolList
11 | 1
12 | showInIndexedSymbolList
13 | 1
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/tests/syntax_test_flow.js:
--------------------------------------------------------------------------------
1 | // SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax"
2 | /* Built-in types */
3 |
4 | const x:boolean;
5 | // ^^^^^^^ support.type.primitive.boolean
6 |
7 | const x:number;
8 | // ^^^^^^ support.type.primitive.number
9 |
10 | const x:string;
11 | // ^^^^^^ support.type.primitive.string
12 |
13 | const x:null;
14 | // ^^^^ support.type.primitive.null
15 |
16 | const x:void;
17 | // ^^^^ support.type.primitive.void
18 |
19 | const x:mixed;
20 | // ^^^^^ support.type.mixed
21 |
22 | const x:any;
23 | // ^^^ support.type.any
24 |
25 | const x:*;
26 | // ^ constant.language.type.existential
27 |
28 | const x:$Keys<>;
29 | // ^^^^^ support.type.utility
30 |
31 | /* Literal types */
32 |
33 | const x:true;
34 | // ^^^^^ keyword.declaration
35 | // ^ meta.binding.name variable.other.readwrite
36 | // ^^^^^ meta.flow-type
37 | // ^ punctuation.separator.type
38 | // ^^^^ constant.language.boolean.true
39 |
40 | const x:42;
41 | // ^^^^^ keyword.declaration
42 | // ^ meta.binding.name variable.other.readwrite
43 | // ^^^ meta.flow-type
44 | // ^ punctuation.separator.type
45 | // ^^ meta.number.integer.decimal constant.numeric
46 |
47 | const x:"foo";
48 | // ^^^^^ keyword.declaration
49 | // ^ meta.binding.name variable.other.readwrite
50 | // ^^^^^^ meta.flow-type
51 | // ^ punctuation.separator.type
52 | // ^^^^^ string.quoted.double
53 |
54 | const x:'bar';
55 | // ^^^^^ keyword.declaration
56 | // ^ meta.binding.name variable.other.readwrite
57 | // ^^^^^^ meta.flow-type
58 | // ^ punctuation.separator.type
59 | // ^^^^^ string.quoted.single
60 |
61 | /* Utility types */
62 |
63 | /* Named types */
64 |
65 | const x:foo;
66 | // ^^^ variable.other.class
67 |
68 | /* Modifiers */
69 |
70 | const x: ?number;
71 | // ^^^^^^^^^ meta.flow-type
72 | // ^ storage.modifier.maybe
73 | // ^^^^^^ support.type.primitive.number
74 |
75 | const x: number[];
76 | // ^^^^^^^^^^ meta.flow-type
77 | // ^^^^^^ support.type.primitive.number
78 | // ^^ storage.modifier.array
79 |
80 | const x: Array ;
81 | // ^^^^^^^^^^^^^^^^ meta.flow-type
82 | // ^^^^^ variable.other.class
83 | // ^ punctuation.definition.generic.begin
84 | // ^^^^^^ support.type.primitive.number
85 | // ^ punctuation.definition.generic.end
86 |
87 | const x: number | string;
88 | // ^^^^^^^^^^^^^^^^^ meta.flow-type
89 | // ^^^^^^ support.type.primitive.number
90 | // ^ keyword.operator.type.union
91 | // ^^^^^^ support.type.primitive.string
92 |
93 | const x: number & string;
94 | // ^^^^^^^^^^^^^^^^^ meta.flow-type
95 | // ^^^^^^ support.type.primitive.number
96 | // ^ keyword.operator.type.intersection
97 | // ^^^^^^ support.type.primitive.string
98 |
99 | const x: typeof 42;
100 | // ^^^^^^^^^^^ meta.flow-type
101 | // ^^^^^^ keyword.operator
102 | // ^^ meta.number.integer.decimal constant.numeric
103 |
104 | const x: number %checks;
105 | // ^^^^^^^^^^^^^^^^ meta.flow-type
106 | // ^^^^^^ support.type.primitive.number
107 | // ^^^^^^^ storage.modifier.checks
108 |
109 |
110 | /* Object types */
111 |
112 | const x: { foo: number };
113 | // ^^^^^^^^^^^^^^^^^ meta.flow-type
114 | // ^^^^^^^^^^^^^^^ meta.type.object
115 | // ^^^ meta.object-literal.key
116 | // ^ punctuation.separator.key-value
117 | // ^^^^^^ support.type.primitive.number
118 |
119 | const x: {
120 |
121 | foo : number,
122 | // ^^^ meta.object-literal.key
123 | // ^ punctuation.separator.key-value
124 | // ^^^^^^ support.type.primitive.number
125 | // ^ punctuation.separator.comma
126 |
127 | bar ?: number,
128 | // ^^^ meta.object-literal.key
129 | // ^ storage.modifier.optional
130 | // ^ punctuation.separator.key-value
131 | // ^^^^^^ support.type.primitive.number
132 | // ^ punctuation.separator.comma
133 |
134 | [baz : string] : number,
135 | // ^ punctuation.section.brackets.begin
136 | // ^^^ meta.object-literal.key
137 | // ^ punctuation.separator.key-value
138 | // ^^^^^^ support.type.primitive.string
139 | // ^ punctuation.section.brackets.end
140 | // ^ punctuation.separator.key-value
141 | // ^^^^^^ support.type.primitive.number
142 | // ^ punctuation.separator.comma
143 | };
144 |
145 | const x: {| foo: number |};
146 | // ^^^^^^^^^^^^^^^^^^^ meta.flow-type
147 | // ^^^^^^^^^^^^^^^^^ meta.type.object.exact
148 | // ^^^ meta.object-literal.key
149 | // ^ punctuation.separator.key-value
150 | // ^^^^^^ support.type.primitive.number
151 |
152 | const x: {|
153 |
154 | foo : number,
155 | // ^^^ meta.object-literal.key
156 | // ^ punctuation.separator.key-value
157 | // ^^^^^^ support.type.primitive.number
158 | // ^ punctuation.separator.comma
159 |
160 | bar ?: number,
161 | // ^^^ meta.object-literal.key
162 | // ^ storage.modifier.optional
163 | // ^ punctuation.separator.key-value
164 | // ^^^^^^ support.type.primitive.number
165 | // ^ punctuation.separator.comma
166 |
167 | [baz : string] : number,
168 | // ^ punctuation.section.brackets.begin
169 | // ^^^ meta.object-literal.key
170 | // ^ punctuation.separator.key-value
171 | // ^^^^^^ support.type.primitive.string
172 | // ^ punctuation.section.brackets.end
173 | // ^ punctuation.separator.key-value
174 | // ^^^^^^ support.type.primitive.number
175 | // ^ punctuation.separator.comma
176 | |};
177 |
178 | /* Tuple types */
179 |
180 | const x : [ number, boolean, string ];
181 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.flow-type meta.sequence
182 | // ^ punctuation.section.brackets.begin
183 | // ^^^^^^ support.type.primitive.number
184 | // ^ punctuation.separator.comma
185 | // ^^^^^^^ support.type.primitive.boolean
186 | // ^ punctuation.separator.comma
187 | // ^^^^^^ support.type.primitive.string
188 | // ^ punctuation.section.brackets.end
189 |
190 | /* Variables */
191 |
192 | var x : number;
193 | // ^^^ keyword.declaration
194 | // ^ meta.binding.name variable.other.readwrite
195 | // ^^^^^^^^ meta.flow-type
196 | // ^ punctuation.separator.type
197 | // ^^^^^^ support.type.primitive.number
198 | // ^ punctuation.terminator.statement
199 |
200 | let x : number;
201 | // ^^^ keyword.declaration
202 | // ^ meta.binding.name variable.other.readwrite
203 | // ^^^^^^^^ meta.flow-type
204 | // ^ punctuation.separator.type
205 | // ^^^^^^ support.type.primitive.number
206 | // ^ punctuation.terminator.statement
207 |
208 | const x : number;
209 | // ^^^^^ keyword.declaration
210 | // ^ meta.binding.name variable.other.readwrite
211 | // ^^^^^^^^ meta.flow-type
212 | // ^ punctuation.separator.type
213 | // ^^^^^^ support.type.primitive.number
214 | // ^ punctuation.terminator.statement
215 |
216 | const x: typeof 42, y: number;
217 | // ^^^^^^^^^^^ meta.flow-type
218 | // ^ punctuation.separator.comma - meta.flow-type
219 | // ^^^^^^^^ meta.flow-type
220 |
221 | /* Functions */
222 |
223 | function f() : number {}
224 | // ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function
225 | // ^ entity.name.function
226 | // ^^^^^^^^ meta.flow-type
227 | // ^^ meta.block
228 |
229 | function f() : number {}
230 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function
231 | // ^ entity.name.function
232 | // ^^^^^^ meta.generic.declaration
233 | // ^ punctuation.definition.generic.begin
234 | // ^ variable.parameter.type
235 | // ^ punctuation.separator.comma
236 | // ^ variable.parameter.type
237 | // ^ punctuation.definition.generic.end
238 | // ^^^^^^^^ meta.flow-type
239 | // ^^ meta.block
240 |
241 | function f(
242 | a : number,
243 | // ^ meta.binding.name variable.parameter.function
244 | // ^^^^^^^^ meta.flow-type
245 | // ^ punctuation.separator.type
246 | // ^^^^^^ support.type.primitive.number
247 |
248 | b ?: number,
249 | // ^ meta.binding.name variable.parameter.function
250 | // ^ storage.modifier.optional
251 | // ^^^^^^^^ meta.flow-type
252 | // ^ punctuation.separator.type
253 | // ^^^^^^ support.type.primitive.number
254 |
255 | ...c : Array
256 | // ^^^^^^^^^^^^^^^ meta.flow-type
257 | ) {}
258 |
259 | /* Classes */
260 |
261 | class MyClass {
262 | foo() : number {}
263 | // ^^^^^^^^^^^^^^^^^ meta.function
264 | // ^^^^^^^^ meta.flow-type
265 | // ^ punctuation.separator.type
266 | // ^^^^^^ support.type.primitive.number
267 |
268 | foo(
269 | a : number,
270 | // ^ meta.binding.name variable.parameter.function
271 | // ^^^^^^^^ meta.flow-type
272 | // ^ punctuation.separator.type
273 | // ^^^^^^ support.type.primitive.number
274 |
275 | b ?: number,
276 | // ^ meta.binding.name variable.parameter.function
277 | // ^ storage.modifier.optional
278 | // ^^^^^^^^ meta.flow-type
279 | // ^ punctuation.separator.type
280 | // ^^^^^^ support.type.primitive.number
281 |
282 | ...c : Array
283 | // ^^^^^^^^^^^^^^^ meta.flow-type
284 | ) {}
285 |
286 | bar: number;
287 | // ^^^^^^^^ meta.flow-type
288 | // ^ punctuation.separator.type
289 | // ^^^^^^ support.type.primitive.number
290 |
291 | bar: number = 42;
292 | // ^^^^^^^^ meta.flow-type
293 | // ^ punctuation.separator.type
294 | // ^^^^^^ support.type.primitive.number
295 | // ^ keyword.operator.assignment
296 | // ^^ meta.number.integer.decimal constant.numeric
297 | }
298 |
299 | class MyClass {}
300 | // ^^^^^^^^^^^^^^^^^^^^^^^ meta.class
301 | // ^^^^^ keyword.declaration.class
302 | // ^^^^^^^ entity.name.class
303 | // ^^^^^^ meta.generic.declaration
304 | // ^ punctuation.definition.generic.begin
305 | // ^ variable.parameter.type
306 | // ^ punctuation.separator.comma
307 | // ^ variable.parameter.type
308 | // ^ punctuation.definition.generic.end
309 |
310 | class MyClass extends Parent {}
311 | // ^^^^^^^ storage.modifier.extends
312 | // ^^^^^^ entity.other.inherited-class
313 | // ^^^^^^ meta.generic
314 |
315 | /* Type aliases */
316 |
317 | type MyType = number;
318 | // ^^^^^^^^^^^^^^^^^^^^ meta.declaration.type - meta.declaration.type meta.declaration.type
319 | // ^^^^ keyword.declaration
320 | // ^^^^^^ entity.name.type
321 | // ^ keyword.operator.assignment
322 | // ^^^^^^ support.type.primitive.number
323 |
324 | type MyType = number;
325 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.type
326 | // ^^^^ keyword.declaration
327 | // ^^^^^^ entity.name.type
328 | // ^^^^^^ meta.generic.declaration
329 | // ^ punctuation.definition.generic.begin
330 | // ^ variable.parameter.type
331 | // ^ punctuation.separator.comma
332 | // ^ variable.parameter.type
333 | // ^ punctuation.definition.generic.end
334 | // ^ keyword.operator.assignment
335 | // ^^^^^^ support.type.primitive.number
336 |
337 | type;
338 | // ^^^^ variable.other.readwrite - storage
339 |
340 | type = function() {};
341 | // ^^^^ entity.name.function variable.other.readwrite - storage
342 | // ^^^^^^^^^^^^^ meta.function
343 |
344 | type
345 | // ^^^^ keyword.declaration
346 | /foo/g;
347 | // ^ keyword.operator.arithmetic - string
348 |
349 | type
350 | // ^^^^ keyword.declaration
351 | foo;
352 | // ^^^ meta.declaration.type entity.name.type
353 |
354 | type /**/ foo;
355 | // ^^^ meta.declaration.type entity.name.type
356 |
357 | /* Type casting expressions */
358 |
359 | (42 : number);
360 | // ^^^^^^^^^^^^^ meta.group
361 | // ^ punctuation.section.group
362 | // ^^ meta.number.integer.decimal constant.numeric
363 | // ^^^^^^^^ meta.flow-type
364 | // ^ punctuation.separator.type
365 | // ^^^^^^ support.type.primitive.number
366 | // ^ punctuation.section.group
367 |
368 | // Opaque aliases
369 | // Interface types
370 | // Arrow functions
371 | // Module Types
372 | // Special comments
373 |
374 | /* Imports/exports */
375 |
376 | import { type Foo } from 'bar';
377 | // ^^^^ keyword.declaration
378 | // ^^^ variable.other.readwrite
379 |
380 | import type Foo from 'bar';
381 | // ^^^^ keyword.declaration
382 | // ^^^ variable.other.readwrite
383 |
384 | export type { Foo };
385 | // ^^^^ keyword.declaration
386 | // ^^^ variable.other.readwrite
387 |
388 | export type Foo = bar;
389 | // ^^^^ keyword.declaration
390 | // ^^^ entity.name.type
391 |
392 | import typeof React from 'React';
393 | // ^^^^^^ keyword.operator
394 | // ^^^^^ variable.other.readwrite
395 | // ^^^^ keyword.control.import-export
396 |
397 | import {typeof useState} from 'React';
398 | // ^^^^^^ keyword.operator
399 | // ^^^^^^^^ variable.other.readwrite
400 | // ^^^^ keyword.control.import-export
401 |
402 | import typeof {useState} from 'React';
403 | // ^^^^^^ keyword.operator
404 | // ^^^^^^^^ variable.other.readwrite
405 | // ^^^^ keyword.control.import-export
406 |
407 | import {typeof useState as UseState} from 'React';
408 | // ^^^^^^ keyword.operator
409 | // ^^^^^^^^ variable.other.readwrite
410 | // ^^ keyword.control.import-export
411 |
412 | import typeof {useState as UseState} from 'React';
413 | // ^^^^^^ keyword.operator
414 | // ^^^^^^^^ variable.other.readwrite
415 | // ^^ keyword.control.import-export
416 |
417 | /* Generics */
418 |
419 | foo();
420 | // ^^^ variable.function
421 | // ^^^ meta.generic
422 | // ^ punctuation.definition.generic.begin
423 | // ^ variable.other.class
424 | // ^ punctuation.definition.generic.end
425 | // ^^ meta.group
426 | // ^ punctuation.section.group.begin
427 | // ^ punctuation.section.group.end
428 | // ^ punctuation.terminator.statement
429 |
430 | foo>();
431 | // ^^^ variable.function
432 | // ^^^^^^^^^ meta.generic
433 | // ^ punctuation.definition.generic.begin
434 | // ^ variable.other.class
435 | // ^ punctuation.separator.comma
436 | // ^ variable.other.class
437 | // ^^^ meta.generic
438 | // ^ punctuation.definition.generic.begin
439 | // ^ variable.other.class
440 | // ^ punctuation.definition.generic.end
441 | // ^ punctuation.definition.generic.end
442 | // ^^ meta.group
443 | // ^ punctuation.section.group.begin
444 | // ^ punctuation.section.group.end
445 | // ^ punctuation.terminator.statement
446 |
447 | const C = (props: any): React.Node => {};
448 | // ^^ keyword.declaration.function
449 |
450 | () => {};
451 | // ^^^^^^^^^^^^ meta.function
452 | // ^^^^ meta.generic.declaration
453 | // ^ punctuation.definition.generic.begin
454 | // ^ variable.parameter.type
455 | // ^ punctuation.separator.comma
456 | // ^ punctuation.definition.generic.end
457 | // ^^ keyword.declaration.function
458 |
459 | (a < b && c <= d);
460 | // ^ keyword.operator.comparison
461 | // ^^ keyword.operator.comparison
462 |
--------------------------------------------------------------------------------
/tests/syntax_test_js_bindings.js:
--------------------------------------------------------------------------------
1 | // SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax"
2 |
3 |
4 | // Variable declarations
5 |
6 | const x = value;
7 | // ^ meta.binding.name variable.other.readwrite
8 |
9 |
10 | const [ x, y, ...z, ] = value;
11 | // ^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence
12 | // ^ meta.binding.name variable.other.readwrite
13 | // ^ punctuation.separator.comma
14 | // ^ meta.binding.name variable.other.readwrite
15 | // ^ punctuation.separator.comma
16 | // ^^^ keyword.operator.spread
17 | // ^ meta.binding.name variable.other.readwrite
18 | // ^ punctuation.separator.comma
19 |
20 | const [ x, [a, b], z] = value;
21 | // ^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence
22 | // ^^^^^^ meta.binding.destructuring.sequence meta.binding.destructuring.sequence
23 | // ^ meta.binding.name variable.other.readwrite
24 | // ^ meta.binding.name variable.other.readwrite
25 |
26 | const [ x = 42, y = [a, b, c] ] = value;
27 | // ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence
28 | // ^ keyword.operator.assignment
29 | // ^^ meta.binding.destructuring.sequence.js meta.number.integer.decimal.js constant.numeric.value.js
30 | // ^ keyword.operator.assignment
31 | // ^^^^^^^^^ meta.sequence
32 | // ^ variable.other.readwrite - meta.binding.name
33 |
34 | const { a, b: c, ...d } = value;
35 | // ^^^^^^^^^^^^^^^^^ meta.binding.destructuring.mapping
36 | // ^ meta.mapping.key meta.binding.name variable.other.readwrite
37 | // ^ punctuation.separator.comma
38 | // ^ meta.mapping.key - variable
39 | // ^ punctuation.separator.key-value
40 | // ^^^ keyword.operator.spread
41 | // ^ meta.binding.name variable.other.readwrite
42 |
43 | const { 'a': x, "b": y, [c]: z } = value;
44 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring.mapping
45 | // ^^^ meta.mapping.key string.quoted.single
46 | // ^ punctuation.separator.key-value
47 | // ^ meta.binding.name variable.other.readwrite
48 | // ^^^ meta.mapping.key string.quoted.double
49 | // ^ punctuation.separator.key-value
50 | // ^ meta.binding.name variable.other.readwrite
51 | // ^^^ meta.mapping.key
52 | // ^ variable.other.readwrite
53 | // ^ punctuation.separator.key-value
54 | // ^ meta.binding.name variable.other.readwrite
55 |
56 | const x;
57 | // ^ meta.binding.name variable.other.readwrite
58 |
59 | let
60 | // <- keyword.declaration
61 | w
62 | // <- meta.binding.name variable.other.readwrite
63 | ,
64 | // <- punctuation.separator.comma
65 | x
66 | // <- meta.binding.name variable.other.readwrite
67 | y
68 | // <- variable.other.readwrite - meta.binding.name
69 | ,
70 | // <- keyword.operator.comma
71 | z
72 | // <- variable.other.readwrite - meta.binding.name
73 |
74 | // `let` is only reserved in strict mode, and we can't distinguish that yet.
75 |
76 | let let;
77 | // ^^^ meta.binding.name variable.other.readwrite
78 |
79 | let
80 | let;
81 | // <- meta.binding.name variable.other.readwrite
82 |
83 | const
84 | const x = 0;
85 | // <- keyword.declaration
86 |
87 | // Function parameters
88 |
89 | function f ([ x, y, ...z, ]) {}
90 | // ^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence
91 | // ^ meta.binding.name variable.parameter.function
92 | // ^ punctuation.separator.parameter
93 | // ^ meta.binding.name variable.parameter.function
94 | // ^ punctuation.separator.parameter
95 | // ^^^ keyword.operator.spread
96 | // ^ meta.binding.name variable.parameter.function
97 | // ^ punctuation.separator.parameter
98 |
99 | function f ([ x, [a, b], z]) {}
100 | // ^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence
101 | // ^^^^^^ meta.binding.destructuring.sequence meta.binding.destructuring.sequence
102 | // ^ meta.binding.name variable.parameter.function
103 | // ^ meta.binding.name variable.parameter.function
104 |
105 | function f ([ $x, [$a, $b], $z]) {}
106 | // ^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence
107 | // ^ meta.binding.name variable.parameter.function punctuation.dollar
108 | // ^ meta.binding.name variable.parameter.function - punctuation.dollar
109 | // ^^^^^^^^ meta.binding.destructuring.sequence meta.binding.destructuring.sequence
110 | // ^ meta.binding.name variable.parameter.function punctuation.dollar
111 | // ^ meta.binding.name variable.parameter.function - punctuation.dollar
112 | // ^ meta.binding.name variable.parameter.function punctuation.dollar
113 | // ^ meta.binding.name variable.parameter.function - punctuation.dollar
114 | // ^ meta.binding.name variable.parameter.function punctuation.dollar
115 | // ^ meta.binding.name variable.parameter.function - punctuation.dollar
116 |
117 | function f ([ x = 42, y = [a, b, c] ]) {}
118 | // ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence
119 | // ^ keyword.operator.assignment
120 | // ^^ meta.function meta.binding.destructuring.sequence meta.number.integer.decimal constant.numeric.value
121 | // ^ keyword.operator.assignment
122 | // ^^^^^^^^^ meta.sequence
123 | // ^ variable.other.readwrite - meta.binding.name
124 |
125 | function f ({ a, b: c, ...d }) {}
126 | // ^^^^^^^^^^^^^^^^^ meta.binding.destructuring.mapping
127 | // ^ meta.mapping.key meta.binding.name variable.parameter.function
128 | // ^ punctuation.separator.parameter
129 | // ^ meta.mapping.key - variable
130 | // ^ punctuation.separator.key-value
131 | // ^^^ keyword.operator.spread
132 | // ^ meta.binding.name variable.parameter.function
133 |
134 | function f ({ 'a': x, "b": y, [c]: z }) = value;
135 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring.mapping
136 | // ^^^ meta.mapping.key string.quoted.single
137 | // ^ punctuation.separator.key-value
138 | // ^ meta.binding.name variable.parameter.function
139 | // ^^^ meta.mapping.key string.quoted.double
140 | // ^ punctuation.separator.key-value
141 | // ^ meta.binding.name variable.parameter.function
142 | // ^^^ meta.mapping.key
143 | // ^ variable.other.readwrite
144 | // ^ punctuation.separator.key-value
145 | // ^ meta.binding.name variable.parameter.function
146 |
147 | function f (a, ...rest) {}
148 | // ^ meta.binding.name variable.parameter.function
149 | // ^^^ keyword.operator.spread
150 | // ^^^^ variable.parameter.function
151 |
152 | function f ($a, ...$rest) {}
153 | // ^ meta.binding.name variable.parameter.function punctuation.dollar
154 | // ^ meta.binding.name variable.parameter.function - punctuation.dollar
155 | // ^^^ keyword.operator.spread
156 | // ^ meta.binding.name variable.parameter.function punctuation.dollar
157 | // ^^^^ meta.binding.name variable.parameter.function - punctuation.dollar
158 |
159 | function f (new) {}
160 | // ^^^^^^^^^^^^^^^^ meta.function
161 | // ^^^ invalid.illegal.identifier meta.binding.name variable.parameter.function
162 |
163 | let f = ([ x, y, ...z, ]) => {};
164 | // ^^^^^^^^^^^^^^^^^^^^^^^ meta.function
165 | // ^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence
166 | // ^ meta.binding.name variable.parameter.function
167 | // ^ punctuation.separator.parameter
168 | // ^ meta.binding.name variable.parameter.function
169 | // ^ punctuation.separator.parameter
170 | // ^^^ keyword.operator.spread
171 | // ^ meta.binding.name variable.parameter.function
172 | // ^ punctuation.separator.parameter
173 |
174 | let f = ([ x, [a, b], z]) => {};
175 | // ^ entity.name.function variable.other.readwrite
176 | // ^^^^^^^^^^^^^^^^^^^^^^^ meta.function
177 | // ^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence
178 | // ^^^^^^ meta.binding.destructuring.sequence meta.binding.destructuring.sequence
179 | // ^ meta.binding.name variable.parameter.function
180 | // ^ meta.binding.name variable.parameter.function
181 |
182 | let f = ([ x = 42, y = [a, b, c] ]) => {};
183 | // ^ entity.name.function variable.other.readwrite
184 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function
185 | // ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence
186 | // ^ keyword.operator.assignment
187 | // ^^ meta.binding.destructuring.sequence.js meta.number.integer.decimal.js constant.numeric.value.js
188 | // ^ keyword.operator.assignment
189 | // ^^^^^^^^^ meta.sequence
190 | // ^ variable.other.readwrite - meta.binding.name
191 |
192 | let f = ({ a, b: c, ...d }) => {};
193 | // ^ entity.name.function variable.other.readwrite
194 | // ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function
195 | // ^^^^^^^^^^^^^^^^^ meta.binding.destructuring.mapping
196 | // ^ meta.mapping.key meta.binding.name variable.parameter.function
197 | // ^ punctuation.separator.parameter
198 | // ^ meta.mapping.key - variable
199 | // ^ punctuation.separator.key-value
200 | // ^^^ keyword.operator.spread
201 | // ^ meta.binding.name variable.parameter.function
202 |
203 | let f = ({ 'a': x, "b": y, [c]: z }) => {};
204 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring.mapping
205 | // ^^^ meta.mapping.key string.quoted.single
206 | // ^ punctuation.separator.key-value
207 | // ^ meta.binding.name variable.parameter.function
208 | // ^^^ meta.mapping.key string.quoted.double
209 | // ^ punctuation.separator.key-value
210 | // ^ meta.binding.name variable.parameter.function
211 | // ^^^ meta.mapping.key
212 | // ^ variable.other.readwrite
213 | // ^ punctuation.separator.key-value
214 | // ^ meta.binding.name variable.parameter.function
215 |
216 | let f = (a, ...rest) => {};
217 | // ^ entity.name.function variable.other.readwrite
218 | // ^^^^^^^^^^^^^^^^^^ meta.function
219 | // ^ meta.binding.name variable.parameter.function
220 | // ^^^ keyword.operator.spread
221 | // ^^^^ meta.binding.name variable.parameter.function
222 |
223 | let f = (new) => {};
224 | // ^^^^^^^^^^^ meta.function
225 | // ^^^ invalid.illegal.identifier meta.binding.name variable.parameter.function
226 |
--------------------------------------------------------------------------------
/tests/syntax_test_js_class.js:
--------------------------------------------------------------------------------
1 | // SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax"
2 |
3 | class MyClass extends TheirClass {
4 | // <- keyword.declaration.class
5 | // ^^^^^^^ entity.name.class
6 | // ^^^^^^^ storage.modifier.extends
7 | // ^^^^^^^^^^ entity.other.inherited-class
8 | // ^ meta.block punctuation.section.block.begin
9 |
10 | x = 42;
11 | // ^ variable.other.readwrite
12 | // ^ keyword.operator.assignment
13 | // ^^ constant.numeric
14 |
15 | 'y' = 42;
16 | // ^^^ meta.string string.quoted.single
17 | // ^ variable.other.readwrite
18 | // ^ keyword.operator.assignment
19 | // ^^ constant.numeric
20 |
21 | "z" = 42;
22 | // ^^^ meta.string string.quoted.double
23 | // ^ variable.other.readwrite
24 | // ^ keyword.operator.assignment
25 | // ^^ constant.numeric
26 |
27 | [w] = 42;
28 | // ^ punctuation.section.brackets.begin
29 | // ^ variable.other.readwrite
30 | // ^ punctuation.section.brackets.end
31 | // ^ keyword.operator.assignment
32 | // ^^ constant.numeric
33 |
34 | [w]
35 | get other() {}
36 | // ^^^ storage.type.accessor.js
37 |
38 | #v = 42;
39 | // ^ punctuation.definition.variable
40 | // ^ variable.other.readwrite
41 | // ^ keyword.operator.assignment
42 | // ^^ constant.numeric
43 |
44 | #u
45 | get other() {}
46 | // ^^^ storage.type.accessor.js
47 |
48 | f = a => b;
49 | // ^ entity.name.function variable.other.readwrite
50 | // ^^^^^^ meta.function
51 | // ^ variable.parameter.function
52 |
53 | g = function() {};
54 | // ^ entity.name.function variable.other.readwrite
55 | // ^^^^^^^^^^^^^ meta.function
56 |
57 | #h = function() {};
58 | // ^ punctuation.definition.variable
59 | // ^ entity.name.function variable.other.readwrite
60 | // ^^^^^^^^^^^^^ meta.function
61 |
62 | class = null;
63 | // ^^^^^ variable.other.readwrite
64 |
65 | static x = 42;
66 | // ^^^^^^ storage.modifier.js
67 | // ^ variable.other.readwrite
68 | // ^ keyword.operator.assignment
69 | // ^^ constant.numeric
70 |
71 | static 'y' = 42;
72 | // ^^^^^^ storage.modifier.js
73 | // ^^^ meta.string string.quoted.single
74 | // ^ variable.other.readwrite
75 | // ^ keyword.operator.assignment
76 | // ^^ constant.numeric
77 |
78 | static "z" = 42;
79 | // ^^^^^^ storage.modifier.js
80 | // ^^^ meta.string string.quoted.double
81 | // ^ variable.other.readwrite
82 | // ^ keyword.operator.assignment
83 | // ^^ constant.numeric
84 |
85 | static [w] = 42;
86 | // ^^^^^^ storage.modifier.js
87 | // ^ punctuation.section.brackets.begin
88 | // ^ variable.other.readwrite
89 | // ^ punctuation.section.brackets.end
90 | // ^ keyword.operator.assignment
91 | // ^^ constant.numeric
92 |
93 | static #v = 42;
94 | // ^ punctuation.definition.variable
95 | // ^ variable.other.readwrite
96 | // ^ keyword.operator.assignment
97 | // ^^ constant.numeric
98 |
99 | static f = a => b;
100 | // ^ entity.name.function variable.other.readwrite
101 | // ^^^^^^ meta.function
102 | // ^ variable.parameter.function
103 |
104 | static g = function() {};
105 | // ^ entity.name.function variable.other.readwrite
106 | // ^^^^^^^^^^^^^ meta.function
107 |
108 | static {
109 | // ^^^^^^ storage.modifier
110 | // ^ meta.block punctuation.section.block.begin
111 | this.#foo = 42;
112 | // ^^^^ variable.language.this
113 | // ^ punctuation.accessor
114 | // ^ punctuation.definition.variable
115 | // ^^^ meta.property.object
116 | // ^ keyword.operator.assignment
117 | // ^^ meta.number.integer.decimal constant.numeric.value
118 | }
119 | // ^ meta.block punctuation.section.block.end
120 |
121 | static = 42;
122 | // ^^^^^^ variable.other.readwrite
123 |
124 | static() {}
125 | // ^^^^^^^^^^^ meta.function
126 | // ^^^^^^ entity.name.function
127 |
128 | accessor foo;
129 | // ^^^^^^^^ storage.modifier
130 | // ^^^ variable.other.readwrite
131 |
132 | foo // You thought I was a field...
133 | () { return '...but was a method all along!'; }
134 | // ^^ meta.class meta.block meta.function
135 |
136 | someMethod() {
137 | return #e * 2;
138 | // ^ punctuation.definition.variable
139 | // ^ variable.other.readwrite
140 | // ^ keyword.operator.arithmetic
141 |
142 | for (const param of this.#data.get('value')) {}
143 | // ^ punctuation.definition.variable
144 | // ^^^^ meta.property.object
145 | }
146 |
147 | #privateMethod() {}
148 | // ^^^^^^^^^^^^^^^^^^^ meta.function
149 | // ^^^^^^^^^^^^^^ entity.name.function.js
150 | // ^ punctuation.definition.js
151 |
152 | constructor(el)
153 | // ^^^^^^^^^^^^^^^ meta.function
154 | // ^ entity.name.function.constructor
155 | {
156 | // ^ meta.class meta.block meta.function meta.block punctuation.section.block
157 | $.foo = "";
158 | super(el);
159 | }
160 | // ^ meta.class meta.block meta.function meta.block punctuation.section.block
161 |
162 | get foo()
163 | // ^^^^^^^^^ meta.function
164 | // <- storage.type.accessor
165 | // ^ entity.name.function
166 | {
167 | return this._foo;
168 | }
169 |
170 | get *foo()
171 |
172 | static foo(baz) {
173 | // ^^^^^^ storage.modifier
174 | // ^^^^^^^^^^ meta.function
175 | // ^^^ entity.name.function
176 |
177 | }
178 |
179 | qux()
180 | // ^^^^^ meta.function
181 | { }
182 | // ^ meta.class meta.block meta.block punctuation.section.block.begin
183 |
184 | get bar () {
185 | // ^^^^^^^^^^^^ meta.function
186 | // ^ meta.class meta.block meta.block punctuation.section.block.begin
187 | // <- storage.type.accessor
188 | // ^ entity.name.function
189 | return false;
190 | }
191 |
192 | baz() { return null }
193 | // ^^^^^^^^^^^^^^^^^^^^^ meta.function
194 | // <- entity.name.function
195 |
196 | get() { return "foobar"; }
197 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function
198 | // ^^^ entity.name.function.js - storage.type.accessor
199 |
200 | set (value) { return value; }
201 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function
202 | // ^^^^^ variable.parameter.function.js
203 | // ^^^ entity.name.function.js - storage.type.accessor
204 |
205 | set abc(value1, value2) { return value1 + value2; }
206 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function
207 | // ^^^ storage.type.accessor - entity.name.function.js
208 | // ^^^ entity.name.function.js
209 | // ^^^^^^ variable.parameter.function.js
210 | // ^ punctuation.separator.parameter.function.js
211 | // ^^^^^^ variable.parameter.function.js
212 |
213 | static$
214 | // ^^^^^^^ - storage
215 | () {};
216 |
217 | constructor$() {}
218 | // ^^^^^^^^^^^^ entity.name.function - entity.name.function.constructor
219 |
220 | @foo bar() {}
221 | // ^^^^ meta.annotation
222 | // ^ punctuation.definition.annotation
223 | // ^^^ variable.annotation
224 | // ^^^ entity.name.function
225 |
226 | @foo.bar bar() {}
227 | // ^^^^^^^^ meta.annotation
228 | // ^ punctuation.definition.annotation
229 | // ^^^ variable.other.readwrite - variable.annotation
230 | // ^^^ variable.annotation
231 | // ^^^ entity.name.function
232 |
233 | @(whatever) bar() {}
234 | // ^^^^^^^^^^^ meta.annotation
235 | // ^ punctuation.definition.annotation
236 | // ^^^^^^^^^^ meta.group
237 | // ^^^ entity.name.function
238 |
239 | ['foo']() {}
240 | // ^^^^^^^^^^^^ meta.function
241 |
242 | static ['foo']() {}
243 | // ^^^^^^^^^^^^ meta.function
244 |
245 | async foo() {}
246 | // ^^^^^ keyword.declaration.async
247 |
248 | *foo() {}
249 | // ^ keyword.generator.asterisk
250 |
251 | async *foo() {}
252 | // ^^^^^ keyword.declaration.async
253 | // ^ keyword.generator.asterisk
254 |
255 | static *foo() {}
256 | // ^^^^^^ storage.modifier
257 | // ^ keyword.generator.asterisk
258 | // ^^^ entity.name.function
259 |
260 | static async foo() {}
261 | // ^^^^^^ storage.modifier
262 | // ^^^^^ keyword.declaration.async
263 |
264 | async() {}
265 | // ^^^^^^^^^^ meta.function
266 | // ^^^^^ entity.name.function
267 | // ^^ meta.function.parameters
268 | // ^ punctuation.section.group.begin
269 | // ^ punctuation.section.group.end
270 | // ^^ meta.block
271 | // ^ punctuation.section.block.begin
272 | // ^ punctuation.section.block.end
273 |
274 | static async() {}
275 | // ^^^^^^ storage.modifier
276 | // ^^^^^ entity.name.function
277 | }
278 | // <- meta.block punctuation.section.block.end
279 |
280 | class Foo extends React.Component {
281 | // ^^^^^ - entity.other.inherited-class
282 | // ^^^^^^^^^ entity.other.inherited-class
283 | constructor()
284 | {}
285 |
286 | [foo.bar](arg) {
287 | // ^^^ variable.other
288 | // ^^^ meta.property
289 | // ^^^ variable.parameter
290 | return this.a;
291 | }
292 | }
293 |
294 | class Foo extends (Foo).Bar {}
295 | // ^^^ entity.other.inherited-class
296 |
297 | class Foo extends Bar
298 | // ^^^ entity.other.inherited-class
299 | .baz {}
300 | // ^^^^^^^ meta.class
301 | // ^ punctuation.accessor
302 | // ^^^ entity.other.inherited-class
303 |
304 | class Foo extends
305 | // ^^^^^^^ storage.modifier.extends
306 | Bar {}
307 |
308 | class Foo extends getSomeClass() {}
309 | // ^^^^^^^^^^^^ meta.function-call variable.function - entity.other.inherited-class
310 |
311 | (class extends Bar {});
312 | // ^^^^^^^ storage.modifier.extends - entity.name.class
313 |
314 | (class extends class {} {});
315 | // ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class
316 | // ^^^^^^^ storage.modifier.extends
317 | // ^^^^^^^^ meta.class meta.class
318 | // ^^^^^ keyword.declaration.class
319 |
320 | // Better highlighting while typing.
321 | class
322 | class
323 | // <- keyword.declaration.class - entity.name.class
324 |
325 | class{}/**/
326 | // ^ - meta.class
327 |
328 | @foo class Foo {}
329 | // ^^^^ meta.annotation
330 | // ^ punctuation.definition.annotation
331 | // ^^^ variable.annotation
332 | // ^^^^^ keyword.declaration.class
333 |
334 | @foo.bar class Foo {}
335 | // ^^^^^^^^ meta.annotation
336 | // ^ punctuation.definition.annotation
337 | // ^^^ variable.other.readwrite - variable.annotation
338 | // ^^^ variable.annotation
339 | // ^^^^^ keyword.declaration.class
340 |
341 | @(whatever) class Foo {}
342 | // ^^^^^^^^^^^ meta.annotation
343 | // ^ punctuation.definition.annotation
344 | // ^^^^^^^^^^ meta.group
345 | // ^^^^^ keyword.declaration.class
346 |
--------------------------------------------------------------------------------
/tests/syntax_test_js_control.js:
--------------------------------------------------------------------------------
1 | // SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax"
2 |
3 | if ( true ) { } ;
4 | // ^^^^^^^^^^^^^^^ meta.conditional
5 | // ^^ keyword.control.conditional.if
6 | // ^^^^^^^^ meta.group
7 | // ^ punctuation.section.group.begin
8 | // ^^^^ constant.language.boolean.true
9 | // ^ punctuation.section.group.end
10 | // ^^^ meta.block
11 | // ^ punctuation.section.block.begin
12 | // ^ punctuation.section.block.end
13 | // ^ - meta.conditional
14 | // ^ punctuation.terminator.statement.empty
15 |
16 | if ( true ) null ;
17 | // ^^^^^^^^^^^^^^^^^^ meta.conditional
18 | // ^^ keyword.control.conditional.if
19 | // ^^^^^^^^ meta.group
20 | // ^ punctuation.section.group.begin
21 | // ^^^^ constant.language.boolean.true
22 | // ^ punctuation.section.group.end
23 | // ^^^^ constant.language.null
24 | // ^ punctuation.terminator.statement - punctuation.terminator.statement.empty
25 | // ^ - meta.conditional
26 |
27 | if (true) {}/**/
28 | // ^^^^ - meta.conditional
29 |
30 | if (true) ;
31 | // ^^^^^^^^^^ meta.conditional
32 | // ^ punctuation.terminator.statement.empty
33 |
34 | if (true) ;
35 | else { } ;
36 | // ^^^^^^^^ meta.conditional
37 | // ^^^^ keyword.control.conditional.else
38 | // ^^^ meta.block
39 | // ^ punctuation.section.block.begin
40 | // ^ punctuation.section.block.end
41 | // ^ - meta.conditional
42 | // ^ punctuation.terminator.statement.empty
43 |
44 | else if (true) { } ;
45 | // ^^^^^^^^^^^^^^^^^^ meta.conditional
46 | // ^^^^^^^ keyword.control.conditional.elseif
47 | // ^^^^^^ meta.group
48 | // ^ punctuation.section.group.begin
49 | // ^^^^ constant.language.boolean.true
50 | // ^ punctuation.section.group.end
51 | // ^^^ meta.block
52 | // ^ punctuation.section.block.begin
53 | // ^ punctuation.section.block.end
54 | // ^^^ - meta.conditional
55 | // ^ punctuation.terminator.statement.empty
56 |
57 | do { } while ( true ) ;
58 | // ^^^^^^^^^^^^^^^^^^^^^ meta.do-while
59 | // ^^ keyword.control.loop.do-while
60 | // ^^^ meta.block
61 | // ^ punctuation.section.block.begin
62 | // ^ punctuation.section.block.end
63 | // ^^^^^ keyword.control.loop.while
64 | // ^^^^^^^^ meta.group
65 | // ^ punctuation.section.group.begin
66 | // ^^^^ constant.language.boolean.true
67 | // ^ punctuation.section.group.end
68 | // ^ - meta.do-while
69 | // ^ punctuation.terminator.statement.empty
70 |
71 | do 42 ; while ( true ) ;
72 | // ^^^^^^^^^^^^^^^^^^^^^^ meta.do-while
73 | // ^^ keyword.control.loop.do-while
74 | // ^^ meta.number.integer.decimal constant.numeric.value
75 | // ^ punctuation.terminator.statement
76 | // ^^^^^ keyword.control.loop.while
77 | // ^^^^^^^^ meta.group
78 | // ^ punctuation.section.group.begin
79 | // ^^^^ constant.language.boolean.true
80 | // ^ punctuation.section.group.end
81 | // ^ punctuation.terminator.statement.empty
82 |
83 | do {} while (false)/**/
84 | // ^ - meta.do-while
85 |
86 | for (var i = 0; i < 10; i++) { } ;
87 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.for
88 | // ^^^ keyword.control.loop.for
89 | // ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group
90 | // ^ punctuation.section.group
91 | // ^^^ keyword.declaration
92 | // ^ meta.binding.name variable.other.readwrite
93 | // ^ keyword.operator.assignment
94 | // ^ meta.number.integer.decimal constant.numeric.value
95 | // ^ punctuation.separator.expression
96 | // ^ variable.other.readwrite
97 | // ^ keyword.operator.comparison
98 | // ^^ meta.number.integer.decimal constant.numeric.value
99 | // ^ punctuation.separator.expression
100 | // ^ variable.other.readwrite
101 | // ^^ keyword.operator.arithmetic
102 | // ^ punctuation.section.group
103 | // ^^^ meta.block
104 | // ^ punctuation.section.block.begin
105 | // ^ punctuation.section.block.end
106 | // ^ - meta.for
107 | // ^ punctuation.terminator.statement.empty
108 |
109 | for (;;) 42;
110 | // ^^^^^^^^^ meta.for
111 | // ^^^ keyword.control.loop.for
112 | // ^^^^ meta.group
113 | // ^ punctuation.section.group
114 | // ^^ punctuation.separator.expression
115 | // ^ punctuation.section.group
116 | // ^^ meta.number.integer.decimal constant.numeric.value
117 | // ^ punctuation.terminator.statement - punctuation.terminator.statement.empty
118 | // ^ - meta.for
119 |
120 | for (; x in list;) {}
121 | // ^^^^^^^^^^^^^^^^^^^^^ meta.for
122 | // ^^^ keyword.control.loop.for
123 | // ^^^^^^^^^^^^^^ meta.group
124 | // ^ punctuation.separator.expression
125 | // ^^ keyword.operator
126 | // ^ punctuation.separator.expression
127 |
128 | for (a[x in list];;) {}
129 | // ^^^^^^^^^^^^^^^^^^^^^^^ meta.for
130 | // ^^^ keyword.control.loop.for
131 | // ^^^^^^^^^^^^^^^^ meta.group
132 | // ^^^^^^^^^^^ meta.brackets
133 | // ^^ keyword.operator
134 | // ^ punctuation.separator.expression
135 | // ^ punctuation.separator.expression
136 |
137 | for (;function () {}/a/g;) {}
138 | // ^ keyword.operator
139 |
140 | for (const x in list) {}
141 | // ^^^^^^^^^^^^^^^^^^^^^^^^ meta.for
142 | // ^^^ keyword.control.loop.for
143 | // ^^^^^^^^^^^^^^^^^ meta.group
144 | // ^^^^^ keyword.declaration
145 | // ^^ keyword.operator.word
146 |
147 | for (const x of list) {}
148 | // ^^^^^^^^^^^^^^^^^^^^^^^^ meta.for
149 | // ^^^ keyword.control.loop.for
150 | // ^^^^^^^^^^^^^^^^^ meta.group
151 | // ^^^^^ keyword.declaration
152 | // ^^ keyword.operator.word
153 |
154 | for (x in list) {}
155 | // ^^^^^^^^^^^^^^^^^^ meta.for
156 | // ^^^ keyword.control.loop.for
157 | // ^^^^^^^^^^^ meta.group
158 | // ^^ keyword.operator.word
159 |
160 | for (x of list) {}
161 | // ^^^^^^^^^^^^^^^^^^ meta.for
162 | // ^^^ keyword.control.loop.for
163 | // ^^^^^^^^^^^ meta.group
164 | // ^^ keyword.operator.word
165 |
166 | for await (const x of list) {}
167 | // ^^^ keyword.control.loop.for
168 | // ^^^^^ keyword.control.flow.await
169 |
170 | for
171 | 42;
172 | // ^^ constant.numeric - meta.for
173 |
174 | for(;;){}/**/
175 | // ^ - meta.for
176 |
177 | {}/**/
178 | //^ - meta.block
179 |
180 | while (true)
181 | // ^^^^^^^^^ meta.while
182 | // ^^^^ meta.group
183 | {
184 | // <- meta.block
185 | x = yield;
186 | // ^^^^^ keyword.control.flow.yield
187 |
188 | x = yield * 42;
189 | // ^^^^^ keyword.control.flow.yield
190 | // ^ keyword.generator.asterisk
191 |
192 | x = yield
193 | function f() {}
194 | [];
195 | // ^^ meta.sequence - meta.brackets
196 |
197 |
198 | x = yield*
199 | function f() {}
200 | [];
201 | // ^^ meta.brackets - meta.sequence
202 |
203 | y = await 42;
204 | // ^^^^^ keyword.control.flow.await
205 |
206 | y = yield await 42;
207 | // ^^^^^ keyword.control.flow.yield
208 | // ^^^^^ keyword.control.flow.await
209 |
210 | yield (parenthesized_expression);
211 | // ^^^^^ keyword.control.flow.yield
212 |
213 | yield `template`;
214 | // ^^^^^ keyword.control.flow.yield
215 |
216 | break;
217 | // ^^^^^ keyword.control.flow.break
218 |
219 | break foo;
220 | // ^^^^^ keyword.control.flow.break
221 | // ^^^ variable.label
222 |
223 | break
224 | foo;
225 | // ^^^ variable.other.readwrite - variable.label
226 |
227 | break/**/foo;
228 | // ^^^ variable.label - variable.other.readwrite
229 |
230 | break/*
231 | */foo;
232 | // ^^^ variable.other.readwrite - variable.label
233 |
234 | break function;
235 | // ^^^^^^^^ invalid.illegal.identifier variable.label
236 |
237 | continue;
238 | // ^^^^^^^^ keyword.control.flow.continue
239 |
240 | continue foo;
241 | // ^^^^^^^^ keyword.control.flow.continue
242 | // ^^^ variable.label
243 |
244 | continue
245 | foo;
246 | // ^^^ variable.other.readwrite - variable.label
247 |
248 | continue/**/foo;
249 | // ^^^ variable.label - variable.other.readwrite
250 |
251 | continue/*
252 | */ foo;
253 | // ^^^ variable.other.readwrite - variable.label
254 |
255 | goto;
256 | // ^^^^ variable.other.readwrite - keyword
257 | }
258 | // <- meta.block
259 |
260 | while (true) 42 ;
261 | // ^^^^^^^^^^^^^ meta.while
262 | // ^^^^^ keyword.control.loop.while
263 | // ^^^^^^ meta.group
264 | // ^ punctuation.section.group.begin
265 | // ^^^^ constant.language.boolean.true
266 | // ^ punctuation.section.group.end
267 | // ^^ meta.number.integer.decimal constant.numeric.value
268 | // ^ punctuation.terminator.statement - punctuation.terminator.statement.empty
269 |
270 | while // Incomplete statement
271 | 42;
272 | // ^^ constant.numeric - meta.while
273 |
274 | while(false){}/**/
275 | // ^ - meta.while
276 |
277 | with (undefined) {
278 | // <- keyword.control.import.with
279 | //^^^^^^^^^^ meta.with
280 | // ^^^^^^^^^ constant.language.undefined
281 | return;
282 | // ^^^^^^ meta.with.js meta.block.js keyword.control.flow.return
283 | }
284 |
285 | with // Incomplete statement
286 | 42;
287 | // ^^ constant.numeric - meta.while
288 |
289 | with(false){}/**/
290 | // ^ - meta.with
291 |
292 | switch ($foo) {
293 | // <- meta.switch.js keyword.control.conditional.switch
294 | // ^^^^^^^^^^^^ meta.switch
295 | //^^^^ keyword.control.conditional.switch
296 | // ^^^^ meta.group
297 | // ^ meta.block punctuation.section.block.begin
298 | case foo:
299 | // ^ meta.switch meta.block keyword.control.conditional.case
300 | // ^ - punctuation.separator.key-value
301 | qux = 1;
302 | break;
303 | // ^ keyword.control.flow.break
304 | case "baz":
305 | // ^ keyword.control.conditional.case
306 | // ^ - punctuation.separator.key-value string
307 | qux = 2;
308 | break;
309 | // ^ keyword.control.flow.break
310 | default:
311 | // ^ meta.switch meta.block keyword.control.conditional.default
312 | // ^ - punctuation.separator.key-value
313 | qux = 3;
314 |
315 | case$
316 | // ^^^^^ - keyword
317 | ;
318 |
319 | default$
320 | // ^^^^^^^^ - keyword
321 | ;
322 |
323 | case 0: {}
324 | case 1:
325 | // ^^^^ keyword.control.conditional.case
326 | }
327 | // <- meta.block punctuation.section.block.end
328 |
329 | try {
330 | // <- meta.try keyword.control.exception.try
331 | // ^^ meta.try
332 | // ^ meta.block
333 | foobar = qux.bar();
334 | // ^^^^^^^^^^^^^^^^^^^ meta.try meta.block
335 | } catch (e) {
336 | // <- meta.block
337 | //^^^^^^^^^^^^ meta.catch
338 | //^^^^^ keyword.control.exception.catch
339 | // ^^^ meta.group
340 | // ^ meta.binding.name variable.other.readwrite
341 | // ^ meta.block
342 | foobar = 0
343 | // ^^^^^^^^^^ meta.catch meta.block
344 | } finally {
345 | // <- meta.block
346 | //^^^^^^^^^^ meta.finally
347 | //^^^^^^^ keyword.control.exception.finally
348 | // ^ meta.block
349 | foobar += 1
350 | // ^^^^^^^^^^^ meta.finally meta.block
351 | }
352 | // <- meta.block
353 |
354 | switch // Incomplete statement
355 | 42;
356 | // ^^ constant.numeric - meta.switch
357 |
358 | switch(x){}/**/
359 | // ^^ - meta.switch
360 |
361 | try{}/**/
362 | // ^ - meta.try
363 | catch{}/**/
364 | // ^ - meta.catch
365 | finally{}/**/
366 | // ^ - meta.finally
367 |
--------------------------------------------------------------------------------
/tests/syntax_test_js_import_export.js:
--------------------------------------------------------------------------------
1 | // SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax"
2 |
3 | import TheirClass from "./mypath";
4 | //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.js
5 | // ^ keyword.control.import-export
6 | // ^ keyword.control.import-export
7 |
8 | import {identifier, otherIdentifier} from "somewhere";
9 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import
10 | // ^ keyword.control.import-export
11 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block
12 | // ^ punctuation.section.block.begin
13 | // ^ punctuation.section.block.end
14 | // ^ meta.import meta.block variable.other.readwrite
15 |
16 | import thing, {identifier as otherIdentifier}, * as otherName from "otherplace";
17 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import
18 | // ^ keyword.control.import-export
19 | // ^ variable.other.readwrite
20 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block
21 | // ^ variable.other.readwrite
22 | // ^ keyword.control.import-export
23 | // ^ variable.other.readwrite
24 | // ^ constant.other.js
25 | // ^ keyword.control.import-export
26 |
27 | import 'module';
28 | // ^^^^^^^^^^^^^ meta.import
29 |
30 | import foo from 'bar' assert { type: "json" };
31 | //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.js
32 | //^^^^ keyword.control.import-export.js
33 | // ^^^ variable.other.readwrite.js
34 | // ^^^^ keyword.control.import-export.js
35 | // ^^^^^ meta.string.js string.quoted.single.js
36 | // ^ punctuation.definition.string.begin.js
37 | // ^ punctuation.definition.string.end.js
38 | // ^^^^^^ keyword.control.import-export.js
39 | // ^^^^^^^^^^^^^^^^ meta.mapping.js
40 | // ^ punctuation.section.mapping.begin.js
41 | // ^^^^ meta.mapping.key.js
42 | // ^ punctuation.separator.key-value.js
43 | // ^^^^^^ meta.string.js string.quoted.double.js
44 | // ^ punctuation.definition.string.begin.js
45 | // ^ punctuation.definition.string.end.js
46 | // ^ punctuation.section.mapping.end.js
47 | // ^ punctuation.terminator.statement.js
48 |
49 | // Better highlighting while typing.
50 | import
51 | import;
52 | // <- keyword.control.import-export
53 |
54 | import;/**/
55 | // ^ - meta.import
56 |
57 | export { name1, name2 as name3, name4 as '+', name5 as "+" };
58 | //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
59 | //^ keyword.control.import-export
60 | // ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block
61 | // ^ punctuation.separator.comma
62 | // ^^ keyword.control.import-export
63 | // ^^ keyword.control.import-export
64 | // ^^^ meta.string string.quoted.single
65 | // ^^ keyword.control.import-export
66 | // ^^^ meta.string string.quoted.double
67 |
68 | export let name1, name2;
69 | //^^^^^^^^^^^^^^^^^^^^^^ meta.export
70 | //^ keyword.control.import-export
71 | // ^^^ keyword.declaration
72 | // ^ punctuation.separator.comma
73 |
74 | export var name3;
75 | //^^^^^^^^^^^^^^^ meta.export
76 | //^ keyword.control.import-export
77 | // ^^^ keyword.declaration
78 |
79 | export const name1 = 5;
80 | //^^^^^^^^^^^^^^^^^^^^^ meta.export
81 | //^ keyword.control.import-export
82 | // ^^^^^ keyword.declaration
83 | // ^ keyword.operator.assignment
84 |
85 | export let foo = 123 // No semicolon
86 | export function bar() {}
87 | // <- keyword.control.import-export
88 |
89 | export function foo() {};
90 | //^^^^^^^^^^^^^^^^^^^^^^ meta.export
91 | //^^^^ keyword.control.import-export
92 | // ^^^^^^^^^^^^^^^^^ meta.function
93 | // ^ punctuation.terminator.statement.empty
94 |
95 | export function* foo() {};
96 | //^^^^^^^^^^^^^^^^^^^^^^^ meta.export
97 | //^^^^ keyword.control.import-export
98 | // ^^^^^^^^^^^^^^^^^^ meta.function
99 | // ^ punctuation.terminator.statement.empty
100 |
101 | export async function foo() {};
102 | //^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
103 | //^^^^ keyword.control.import-export
104 | // ^^^^^^^^^^^^^^^^^^^^^^^ meta.function
105 | // ^ punctuation.terminator.statement.empty
106 |
107 | export class Foo {};
108 | //^^^^^^^^^^^^^^^^^ meta.export
109 | //^^^^ keyword.control.import-export
110 | // ^^^^^^^^^^^^ meta.class
111 | // ^ punctuation.terminator.statement.empty
112 |
113 | export default expression;
114 | //^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
115 | //^ keyword.control.import-export
116 | // ^ keyword.control.import-export
117 |
118 | export default function (a) { };
119 | //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
120 | //^^^^ keyword.control.import-export
121 | // ^^^^^^^ keyword.control.import-export
122 | // ^^^^^^^^^^^^^^^^ meta.function
123 | // ^ punctuation.terminator.statement.empty - meta.export
124 |
125 | export default function* (a) { };
126 | //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
127 | //^^^^ keyword.control.import-export
128 | // ^^^^^^^ keyword.control.import-export
129 | // ^^^^^^^^^^^^^^^^^ meta.function
130 | // ^ punctuation.terminator.statement.empty - meta.export
131 |
132 | export default function name1(b) { }
133 | //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
134 | //^ keyword.control.import-export
135 | // ^ keyword.control.import-export
136 | // ^^^^^^^^ keyword.declaration.function
137 | // ^ entity.name.function
138 |
139 | export default class Foo {};
140 | //^^^^^^^^^^^^^^^^^ meta.export
141 | //^^^^ keyword.control.import-export
142 | // ^^^^^^^ keyword.control.import-export
143 | // ^^^^^^^^^^^^ meta.class
144 | // ^ punctuation.terminator.statement.empty
145 |
146 | export default +function (a) { };
147 | //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
148 | //^^^^ keyword.control.import-export
149 | // ^^^^^^^ keyword.control.import-export
150 | // ^^^^^^^^^^^^^^^^ meta.function
151 |
152 | export { name1 as default };
153 | //^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
154 | //^ keyword.control.import-export
155 | // ^^^^^^^^^^^^^^^^^^^^ meta.block
156 | // ^ keyword.control.import-export
157 | // ^ keyword.control.import-export
158 |
159 | export * from "./othermod";
160 | //^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
161 | //^ keyword.control.import-export
162 | // ^ constant.other
163 | // ^ keyword.control.import-export
164 |
165 | export { name1, name2 } from "./othermod";
166 | //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
167 | //^ keyword.control.import-export
168 | // ^^^^^^^^^^^^^^^^ meta.block
169 | // ^ punctuation.section.block.begin
170 | // ^ punctuation.section.block.end
171 | // ^ keyword.control.import-export
172 |
173 | export { import1 as name1, import2 as name2, nameN } from "./othermod";
174 | //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
175 | //^ keyword.control.import-export
176 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block
177 | // ^ keyword.control.import-export
178 | // ^ keyword.control.import-export
179 | // ^ keyword.control.import-export
180 |
181 | // Better highlighting while typing.
182 | export
183 | export;
184 | // <- keyword.control.import-export
185 |
186 | export;/**/
187 | // ^ - meta.export
188 |
189 | import * as
190 | alias from "module";
191 | // ^^^^^^^^^^^^^^^^^^^^^ meta.import.js
192 |
193 | import { member as
194 | alias } from "module";
195 | // ^^^^^^^^^^^^^^^^^^^^^^^ meta.import.js
196 |
197 | import { * as
198 | alias } from "module";
199 | // ^^^^^^^^^^^^^^^^^^^^^^^ meta.import.js
200 |
201 | export { member as
202 | alias } from "module";
203 | // ^^^^^^^^^^^^^^^^^^^^^^^ meta.export.js
204 |
205 | export { member as
206 | default } from "module";
207 | // ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export.js
208 |
209 | let from;
210 | // ^^^^ variable.other.readwrite.js
211 |
212 | import from from "./othermod";
213 | // ^^^^ variable.other.readwrite.js
214 |
215 | import { from } from "./othermod";
216 | // ^^^^ variable.other.readwrite.js
217 |
218 | export from from "./othermod";
219 | // ^^^^ variable.other.readwrite.js
220 |
221 | export { from } from "./othermod";
222 | // ^^^^ variable.other.readwrite.js
223 |
224 | export default$
225 | // ^^^^^^^^ - keyword
226 | ;
227 |
228 | let x = import.meta;
229 | // ^^^^^^^^^^^ - meta.import
230 | // ^^^^^^ keyword.import
231 | // ^ punctuation.accessor
232 | // ^^^^ variable.language.import
233 |
234 | import.meta;
235 | // ^^^^^^^^^^^ - meta.import
236 | // ^^^^^^ keyword.import
237 | // ^ punctuation.accessor
238 | // ^^^^ variable.language.import
239 |
240 | import
241 | // ^^^^^^ - meta.import
242 | .meta;
243 | // ^^^^^ - meta.import
244 | // ^ punctuation.accessor
245 | // ^^^^ variable.language.import
246 |
247 | import('foo');
248 | // ^^^^^^ keyword.import
249 | // ^^^^^^^ meta.group
250 |
251 | import
252 | // ^^^^^^ - meta.import
253 | ('foo');
254 | // ^^^^^^^ meta.group
255 |
--------------------------------------------------------------------------------
/tests/syntax_test_js_indent_common.js:
--------------------------------------------------------------------------------
1 | // SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax"
2 |
3 | /**
4 | * This is my first JavaScript program.
5 | * This will print 'Hello World' as the output
6 | **/
7 |
8 | function testIfElseIndentationNoBraces(v)
9 | {
10 | /**
11 | * comment
12 | */
13 | if (v.isNull() == true) return fun(v);
14 |
15 | if (v.isNull() == true)
16 | return false;
17 |
18 | if (v.isNull() == true)
19 | return false;
20 | else
21 | {
22 | if (v.endsWith("("))
23 | return false;
24 | else if (v.endsWith(")"))
25 | return true;
26 | else if (v.endsWith("\""))
27 | return true;
28 | else if (v.endsWith("\\"))
29 | return true;
30 | else if (v.endsWith('('))
31 | return false;
32 | else if (v.endsWith(')'))
33 | return true;
34 | else if (v.endsWith('\''))
35 | return true;
36 | else if (v.endsWith('\\'))
37 | return true;
38 | else
39 | return false;
40 |
41 | if (v.endsWith("baz"))
42 | return false;
43 | return true;
44 | }
45 | }
46 |
47 | function testIfElseIndentationNoBracesWithLineComments(v)
48 | {
49 | /**
50 | * comment
51 | */
52 |
53 | // line comment
54 | if (v.isNull() == true) return fun(v);
55 |
56 | // line comment
57 | if (v.isNull() == true)
58 | // line comment
59 | return false;
60 |
61 | // line comment
62 | if (v.isNull() == true)
63 | // line comment
64 | return false;
65 | // line comment
66 | else
67 | // line comment
68 | {
69 | // line comment
70 | if (v.endsWith("("))
71 | // line comment
72 | return false;
73 | // line comment
74 | else if (v.endsWith(")"))
75 | // line comment
76 | return true;
77 | // line comment
78 | else if (v.endsWith("\""))
79 | // line comment
80 | return true;
81 | // line comment
82 | else if (v.endsWith("\\"))
83 | // line comment
84 | return true;
85 | // line comment
86 | else if (v.endsWith('('))
87 | // line comment
88 | return false;
89 | // line comment
90 | else if (v.endsWith(')'))
91 | // line comment
92 | return true;
93 | // line comment
94 | else if (v.endsWith('\''))
95 | // line comment
96 | return true;
97 | // line comment
98 | else if (v.endsWith('\\'))
99 | // line comment
100 | return true;
101 | // line comment
102 | else
103 | // line comment
104 | return false;
105 |
106 | // line comment
107 | if (v.endsWith("baz"))
108 | // line comment
109 | return false;
110 | // line comment
111 | return true;
112 | }
113 | }
114 |
115 | function testIfElseIndentationNoBracesMultiLine(v)
116 | {
117 | // line comment
118 | if (v.isNull() == true
119 | || v.endsWith(")"))
120 | // line comment
121 | return false;
122 | else if (v.isNull() == true
123 | || v.endsWith("("))
124 | return false;
125 | // line comment
126 | return true;
127 | }
128 |
129 | function testIfElseIndentationNoBracesButComments(v)
130 | {
131 | if (v.isNull() == true) return fun(v); /**/ // ; "comment" ()
132 |
133 | if (v.isNull() == true) /**/ // ; "comment" ()
134 | return false; /**/ // ; "comment" ()
135 |
136 | if (v.isNull() == true) /**/ // ; "comment" ()
137 | return false; /**/ // ; "comment" ()
138 | else /**/ // ; "comment" ()
139 | { /**/ // ; "comment" ()
140 | if (v.endsWith("(")) /**/ // ; "comment" ()
141 | return false; /**/ // ; "comment" ()
142 | else if (v.endsWith(")")) /**/ // ; "comment" ()
143 | return true; /**/ // ; "comment" ()
144 | else if (v.endsWith("\"")) /**/ // ; "comment" ()
145 | return true; /**/ // ; "comment" ()
146 | else if (v.endsWith("\\")) /**/ // ; "comment" ()
147 | return true; /**/ // ; "comment" ()
148 | else if (v.endsWith('(')) /**/ // ; "comment" ()
149 | return false; /**/ // ; "comment" ()
150 | else if (v.endsWith(')')) /**/ // ; "comment" ()
151 | return true; /**/ // ; "comment" ()
152 | else if (v.endsWith('\'')) /**/ // ; "comment" ()
153 | return true; /**/ // ; "comment" ()
154 | else if (v.endsWith('\\')) /**/ // ; "comment" ()
155 | return true; /**/ // ; "comment" ()
156 | else /**/ // ; "comment" ()
157 | return false; /**/ // ; "comment" ()
158 | } /**/ // ; "comment" ()
159 | }
160 |
161 | function testIfElseIndentationNoBracesButBlockCommentsPart1(v)
162 | {
163 | /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ isNull( /*(*/ ) /*(*/ == /*(*/ true /*(*/ ) /*(*/ return /*(*/ fun /*(*/ ( /*(*/ ) /*(*/ ; // ; "comment" ()
164 |
165 | /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ isNull( /*(*/ ) /*(*/ == /*(*/ true /*(*/ ) /*(*/ // ; "comment" ()
166 | return false; /*(*/ // ; "comment" ()
167 |
168 | /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ isNull( /*(*/ ) /*(*/ == /*(*/ true /*(*/ ) /*(*/ // ; "comment" ()
169 | return false; /*(*/ // ; "comment" ()
170 | else /*(*/ // ; "comment" ()
171 | { /*(*/ // ; "comment" ()
172 | /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ endsWith /*(*/ ( /*(*/ "(") /*(*/ ) /*(*/ // ; "comment" ()
173 | return false; /*(*/ // ; "comment" ()
174 | else /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ endsWith /*(*/ ( /*(*/ ")") /*(*/ ) /*(*/ // ; "comment" ()
175 | return true; /*(*/ // ; "comment" ()
176 | else /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ endsWith /*(*/ ( /*(*/ "\"") /*(*/ ) /*(*/ // ; "comment" ()
177 | return true; /*(*/ // ; "comment" ()
178 | else /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ endsWith /*(*/ ( /*(*/ "\\") /*(*/ ) /*(*/ // ; "comment" ()
179 | return true; /*(*/ // ; "comment" ()
180 | else /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ endsWith /*(*/ ( /*(*/ '(') /*(*/ ) /*(*/ // ; "comment" ()
181 | return false; /*(*/ // ; "comment" ()
182 | else /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ endsWith /*(*/ ( /*(*/ ')') /*(*/ ) /*(*/ // ; "comment" ()
183 | return true; /*(*/ // ; "comment" ()
184 | else /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ endsWith /*(*/ ( /*(*/ '\'') /*(*/ ) /*(*/ // ; "comment" ()
185 | return true; /*(*/ // ; "comment" ()
186 | else /*(*/ if /*(*/ ( /*(*/ v /*(*/ . /*(*/ endsWith /*(*/ ( /*(*/ '\\') /*(*/ ) /*(*/ // ; "comment" ()
187 | return true; /*(*/ // ; "comment" ()
188 | else /*(*/ // ; "comment" ()
189 | return false; /*(*/ // ; "comment" ()
190 | } /*(*/ // ; "comment" ()
191 | }
192 |
193 | function testIfElseIndentationNoBracesButBlockCommentsPart2(v)
194 | {
195 | /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ isNull( /*)*/ ) /*)*/ == /*)*/ true /*)*/ ) /*)*/ return /*)*/ fun /*)*/ ( /*)*/ ) /*)*/ ; // ; "comment" ()
196 |
197 | /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ isNull( /*)*/ ) /*)*/ == /*)*/ true /*)*/ ) /*)*/ // ; "comment" ()
198 | return false; /*)*/ // ; "comment" ()
199 |
200 | /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ isNull( /*)*/ ) /*)*/ == /*)*/ true /*)*/ ) /*)*/ // ; "comment" ()
201 | return false; /*)*/ // ; "comment" ()
202 | else /*)*/ // ; "comment" ()
203 | { /*)*/ // ; "comment" ()
204 | /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ endsWith /*)*/ ( /*)*/ "(") /*)*/ ) /*)*/ // ; "comment" ()
205 | return false; /*)*/ // ; "comment" ()
206 | else /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ endsWith /*)*/ ( /*)*/ ")") /*)*/ ) /*)*/ // ; "comment" ()
207 | return true; /*)*/ // ; "comment" ()
208 | else /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ endsWith /*)*/ ( /*)*/ "\"") /*)*/ ) /*)*/ // ; "comment" ()
209 | return true; /*)*/ // ; "comment" ()
210 | else /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ endsWith /*)*/ ( /*)*/ "\\") /*)*/ ) /*)*/ // ; "comment" ()
211 | return true; /*)*/ // ; "comment" ()
212 | else /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ endsWith /*)*/ ( /*)*/ '(') /*)*/ ) /*)*/ // ; "comment" ()
213 | return false; /*)*/ // ; "comment" ()
214 | else /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ endsWith /*)*/ ( /*)*/ ')') /*)*/ ) /*)*/ // ; "comment" ()
215 | return true; /*)*/ // ; "comment" ()
216 | else /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ endsWith /*)*/ ( /*)*/ '\'') /*)*/ ) /*)*/ // ; "comment" ()
217 | return true; /*)*/ // ; "comment" ()
218 | else /*)*/ if /*)*/ ( /*)*/ v /*)*/ . /*)*/ endsWith /*)*/ ( /*)*/ '\\') /*)*/ ) /*)*/ // ; "comment" ()
219 | return true; /*)*/ // ; "comment" ()
220 | else /*)*/ // ; "comment" ()
221 | return false; /*)*/ // ; "comment" ()
222 | } /*)*/ // ; "comment" ()
223 | }
224 |
225 | function testIfElseIndentationWithBraces(v) {
226 |
227 | if (v.isNull() == true) { return fun(v); }
228 |
229 | if (v.isNull() == true) {
230 | return false;
231 | }
232 |
233 | if (v.isNull() == true) {
234 | return false;
235 | } else {
236 | if (v.endsWith("(")) {
237 | return false;
238 | } else if (v.endsWith(")")) {
239 | return true;
240 | } else if (v.endsWith("\"")) {
241 | return true;
242 | } else if (v.endsWith("\\")) {
243 | return true;
244 | } else if (v.endsWith('(')) {
245 | return false;
246 | } else if (v.endsWith(')')) {
247 | return true;
248 | } else if (v.endsWith('\'')) {
249 | return true;
250 | } else if (v.endsWith('\\')) {
251 | return true;
252 | } else {
253 | return false;
254 | }
255 | }
256 |
257 | if (v.isNull() == true)
258 | {
259 | return
260 | }
261 | if (v.isNull() == true)
262 | {
263 | return false
264 | }
265 | if (v.isNull() == true)
266 | {
267 | return false;
268 | }
269 |
270 | if (v.isNull() == true)
271 | {
272 | return false;
273 | }
274 | else
275 | {
276 | if (v.endsWith("("))
277 | {
278 | return false;
279 | }
280 | else if (v.endsWith(")"))
281 | {
282 | return true;
283 | }
284 | else if (v.endsWith("\""))
285 | {
286 | return true;
287 | }
288 | else if (v.endsWith("\\"))
289 | {
290 | return true;
291 | }
292 | else if (v.endsWith('('))
293 | {
294 | return false;
295 | }
296 | else if (v.endsWith(')'))
297 | {
298 | return true;
299 | }
300 | else if (v.endsWith('\''))
301 | {
302 | return true;
303 | }
304 | else if (v.endsWith('\\'))
305 | {
306 | return true;
307 | }
308 | else
309 | {
310 | return false;
311 | }
312 | }
313 | }
314 |
315 | function testIfElseIndentationWithBracesAndLineComments(v) {
316 |
317 | // comment
318 | if (v.isNull() == true) { return fun(v); }
319 |
320 | // comment
321 | if (v.isNull() == true) {
322 | // comment
323 | return false;
324 | }
325 |
326 | // comment
327 | if (v.isNull() == true) {
328 | // comment
329 | return false;
330 | } else {
331 | // comment
332 | if (v.endsWith("(")) {
333 | // comment
334 | return false;
335 | // comment
336 | } else if (v.endsWith(")")) {
337 | // comment
338 | return true;
339 | // comment
340 | } else if (v.endsWith("\"")) {
341 | // comment
342 | return true;
343 | // comment
344 | } else if (v.endsWith("\\")) {
345 | // comment
346 | return true;
347 | // comment
348 | } else if (v.endsWith('(')) {
349 | // comment
350 | return false;
351 | // comment
352 | } else if (v.endsWith(')')) {
353 | // comment
354 | return true;
355 | // comment
356 | } else if (v.endsWith('\'')) {
357 | // comment
358 | return true;
359 | // comment
360 | } else if (v.endsWith('\\')) {
361 | // comment
362 | return true;
363 | // comment
364 | } else {
365 | // comment
366 | return false;
367 | }
368 | }
369 |
370 | // comment
371 | if (v.isNull() == true)
372 | {
373 | // comment
374 | return
375 | }
376 | // comment
377 | if (v.isNull() == true)
378 | {
379 | // comment
380 | return false
381 | }
382 | // comment
383 | if (v.isNull() == true)
384 | {
385 | // comment
386 | return false;
387 | }
388 |
389 | // comment
390 | if (v.isNull() == true)
391 | {
392 | // comment
393 | return false;
394 | }
395 | // comment
396 | else
397 | {
398 | // comment
399 | if (v.endsWith("("))
400 | {
401 | // comment
402 | return false;
403 | }
404 | // comment
405 | else if (v.endsWith(")"))
406 | {
407 | // comment
408 | return true;
409 | }
410 | // comment
411 | else if (v.endsWith("\""))
412 | {
413 | // comment
414 | return true;
415 | }
416 | // comment
417 | else if (v.endsWith("\\"))
418 | {
419 | // comment
420 | return true;
421 | }
422 | // comment
423 | else if (v.endsWith('('))
424 | {
425 | // comment
426 | return false;
427 | }
428 | // comment
429 | else if (v.endsWith(')'))
430 | {
431 | // comment
432 | return true;
433 | }
434 | // comment
435 | else if (v.endsWith('\''))
436 | {
437 | // comment
438 | return true;
439 | }
440 | // comment
441 | else if (v.endsWith('\\'))
442 | {
443 | // comment
444 | return true;
445 | }
446 | // comment
447 | else
448 | {
449 | // comment
450 | return false;
451 | }
452 | }
453 | }
454 |
455 | function testIfElseIndentationWithBracesAndComment(v) {
456 |
457 | if (v.isNull() == true) { return } /**/ // ; "comment" ()
458 |
459 | if (v.isNull() == true) { return fun(v) } /**/ // ; "comment" ()
460 |
461 | if (v.isNull() == true) { return fun(v); } /**/ // ; "comment" ()
462 |
463 | if (v.isNull() == true) { /**/ // ; "comment" ()
464 | return false; /**/ // ; "comment" ()
465 | } /**/ // ; "comment" ()
466 |
467 | if (v.isNull() == true) { /**/ // ; "comment" ()
468 | return false; /**/ // ; "comment" ()
469 | } else { /**/ // ; "comment" ()
470 | if (v.endsWith("(")) { /**/ // ; "comment" ()
471 | return false; /**/ // ; "comment" ()
472 | } else if (v.endsWith(")")) { /**/ // ; "comment" ()
473 | return true; /**/ // ; "comment" ()
474 | } else if (v.endsWith("\"")) { /**/ // ; "comment" ()
475 | return true; /**/ // ; "comment" ()
476 | } else if (v.endsWith("\\")) { /**/ // ; "comment" ()
477 | return true; /**/ // ; "comment" ()
478 | } else if (v.endsWith('(')) { /**/ // ; "comment" ()
479 | return false; /**/ // ; "comment" ()
480 | } else if (v.endsWith(')')) { /**/ // ; "comment" ()
481 | return true; /**/ // ; "comment" ()
482 | } else if (v.endsWith('\'')) { /**/ // ; "comment" ()
483 | return true; /**/ // ; "comment" ()
484 | } else if (v.endsWith('\\')) { /**/ // ; "comment" ()
485 | return true; /**/ // ; "comment" ()
486 | } else { /**/ // ; "comment" ()
487 | return false; /**/ // ; "comment" ()
488 | } /**/ // ; "comment" ()
489 | } /**/ // ; "comment" ()
490 |
491 | if (v.isNull() == true) /**/ // ; "comment" ()
492 | { /**/ // ; "comment" ()
493 | return /**/ // ; "comment" ()
494 | } /**/ // ; "comment" ()
495 | if (v.isNull() == true) /**/ // ; "comment" ()
496 | { /**/ // ; "comment" ()
497 | return false /**/ // ; "comment" ()
498 | } /**/ // ; "comment" ()
499 | if (v.isNull() == true) /**/ // ; "comment" ()
500 | { /**/ // ; "comment" ()
501 | return false; /**/ // ; "comment" ()
502 | } /**/ // ; "comment" ()
503 |
504 | if (v.isNull() == true) /**/ // ; "comment" ()
505 | { /**/ // ; "comment" ()
506 | return false; /**/ // ; "comment" ()
507 | } /**/ // ; "comment" ()
508 | else /**/ // ; "comment" ()
509 | { /**/ // ; "comment" ()
510 | if (v.endsWith("(")) /**/ // ; "comment" ()
511 | { /**/ // ; "comment" ()
512 | return false; /**/ // ; "comment" ()
513 | } /**/ // ; "comment" ()
514 | else if (v.endsWith(")")) /**/ // ; "comment" ()
515 | { /**/ // ; "comment" ()
516 | return true; /**/ // ; "comment" ()
517 | } /**/ // ; "comment" ()
518 | else if (v.endsWith("\"")) /**/ // ; "comment" ()
519 | { /**/ // ; "comment" ()
520 | return true; /**/ // ; "comment" ()
521 | } /**/ // ; "comment" ()
522 | else if (v.endsWith("\\")) /**/ // ; "comment" ()
523 | { /**/ // ; "comment" ()
524 | return true; /**/ // ; "comment" ()
525 | } /**/ // ; "comment" ()
526 | else if (v.endsWith('(')) /**/ // ; "comment" ()
527 | { /**/ // ; "comment" ()
528 | return false; /**/ // ; "comment" ()
529 | } /**/ // ; "comment" ()
530 | else if (v.endsWith(')')) /**/ // ; "comment" ()
531 | { /**/ // ; "comment" ()
532 | return true; /**/ // ; "comment" ()
533 | } /**/ // ; "comment" ()
534 | else if (v.endsWith('\'')) /**/ // ; "comment" ()
535 | { /**/ // ; "comment" ()
536 | return true; /**/ // ; "comment" ()
537 | } /**/ // ; "comment" ()
538 | else if (v.endsWith('\\')) /**/ // ; "comment" ()
539 | { /**/ // ; "comment" ()
540 | return true; /**/ // ; "comment" ()
541 | } /**/ // ; "comment" ()
542 | else /**/ // ; "comment" ()
543 | { /**/ // ; "comment" ()
544 | return false; /**/ // ; "comment" ()
545 | } /**/ // ; "comment" ()
546 | } /**/ // ; "comment" ()
547 | }
548 |
549 | function testSwitchCaseIndentation(v) {
550 | switch (s) {
551 | case
552 | case:
553 | case break
554 | case: break
555 | case "(": break
556 | case ")": break;
557 | case ":": break;
558 | case ";": break;
559 | case
560 | break;
561 | case:
562 | break;
563 | case ":"
564 | break;
565 | case ':':
566 | break;
567 | case NestedIfStatement:
568 | if (s.endsWith() = '(')
569 | return;
570 | break;
571 | case NestedSwitchCase:
572 | switch (v) {
573 | case 0: break;
574 | case 2:
575 | break;
576 | }
577 | break;
578 | case NestedSwitchCaseBlock:
579 | {
580 | switch (v) {
581 | case 0: break;
582 | case 2:
583 | break;
584 | }
585 | break;
586 | }
587 | case NestedSwitchCaseBlock2:
588 | {
589 | switch (v) {
590 | case 0: break;
591 | case 2:
592 | break;
593 | }
594 | }
595 | break;
596 | default:
597 | break;
598 | }
599 | }
600 |
601 | function testSwitchCaseIndentationWithLineComments(v) {
602 | switch (s) { // comments
603 | case // comments
604 | case: // comments
605 | case break // comments
606 | case: break // comments
607 | case "(": break // comments
608 | case ")": break; // comments
609 | case ":": break; // comments
610 | case ";": break; // comments
611 | case // comments
612 | break; // comments
613 | case: // comments
614 | break; // comments
615 | case ":" // comments
616 | break; // comments
617 | case ':': // comments
618 | break; // comments
619 | case NestedIfStatement: // comments
620 | if (s.endsWith() = '(') // comments
621 | return; // comments
622 | break; // comments
623 | case NestedSwitchCase: // comments
624 | switch (v) { // comments
625 | case 0: break; // comments
626 | case 2: // comments
627 | break; // comments
628 | } // comments
629 | break; // comments
630 | case NestedSwitchCaseBlock: // comments
631 | { // comments
632 | switch (v) { // comments
633 | case 0: break; // comments
634 | case 2: // comments
635 | break; // comments
636 | } // comments
637 | break; // comments
638 | } // comments
639 | case NestedSwitchCaseBlock2: // comments
640 | { // comments
641 | switch (v) { // comments
642 | case 0: break; // comments
643 | case 2: // comments
644 | break; // comments
645 | } // comments
646 | } // comments
647 | break; // comments
648 | default: // comments
649 | break; // comments
650 | } // comments
651 | } // comments
652 |
653 | function testForIndentation(v) {
654 |
655 | for (let i = 0; i < 10; i++)
656 | System.out.println("Row " + i);
657 |
658 | for (let i = 0; i < 10; i++) {
659 | System.out.println("Row " + i);
660 | }
661 |
662 | for (let i = 0; i < 10; i++)
663 | {
664 | System.out.println("Row " + i);
665 | }
666 |
667 | for (let i = 0; i < 10; i++) {
668 | for (let j = 0; j < 10; j++)
669 | System.out.println("Row " + i + " Col " + j);
670 | }
671 |
672 | for (let i = 0; i < 10; i++) {
673 | for (let j = 0; j < 10; j++) {
674 | System.out.println("Row " + i + " Col " + j);
675 | }
676 | }
677 |
678 | for (
679 | let i = 0;
680 | i < 10;
681 | i++)
682 | {
683 | let j = 0;
684 | let k = 0;
685 | }
686 | }
687 |
688 | function testWhileIndentationNoBraces(v) {
689 | while () v++;
690 | while (()) v++;
691 | while ((())) v++;
692 | while ((())()) v++;
693 | while ()
694 | v++;
695 | while (v == '(')
696 | v++;
697 | while (v == ')')
698 | v++;
699 | while (v == '\'')
700 | v++;
701 | while (v == '\\')
702 | v++;
703 | while (v == "(")
704 | v++;
705 | while (v == ")")
706 | v++;
707 | while (v == "\"")
708 | v++;
709 | while (v == "\\\"")
710 | v++;
711 | while (v == foo( bar("") + "" ))
712 | v++;
713 | }
714 |
715 | function testWhileIndentationNoBracesButComments(v) {
716 | while () v++; // ; "comment" ()
717 | while (()) v++; // ; "comment" ()
718 | while ((())) v++; // ; "comment" ()
719 | while ((())()) v++; // ; "comment" ()
720 | while () // ; "comment" ()
721 | v++; // ; "comment" ()
722 | while (v == '(') // ; "comment" ()
723 | v++; // ; "comment" ()
724 | while (v == ')') // ; "comment" ()
725 | v++; // ; "comment" ()
726 | while (v == '\'') // ; "comment" ()
727 | v++; // ; "comment" ()
728 | while (v == '\\') // ; "comment" ()
729 | v++; // ; "comment" ()
730 | while (v == "(") // ; "comment" ()
731 | v++; // ; "comment" ()
732 | while (v == ")") // ; "comment" ()
733 | v++; // ; "comment" ()
734 | while (v == "\"") // ; "comment" ()
735 | v++; // ; "comment" ()
736 | while (v == "\\\"") // ; "comment" ()
737 | v++; // ; "comment" ()
738 | while (v == foo( bar("") + "" )) // ; "comment" ()
739 | v++; // ; "comment" ()
740 | while () { } // a hack to make tests succeed
741 | }
742 |
743 | function testWhileIndentationNoBracesButBlockCommentsPart1(v) {
744 | while /*(*/ () v++; /*(*/ // ; "comment" ()
745 | while /*(*/ (()) v++; /*(*/ // ; "comment" ()
746 | while /*(*/ ((())) v++; /*(*/ // ; "comment" ()
747 | while /*(*/ ((()/*(*/)/*(*/()) v++; /*(*/ // ; "comment" ()
748 | while /*(*/ () /*(*/ // ; "comment" ()
749 | v++; /*(*/ // ; "comment" ()
750 | while /*(*/ ( /*(*/ v /*(*/ == /*(*/ '(' /*(*/ ) /*(*/ // ; "comment" ()
751 | v++; /*(*/ // ; "comment" ()
752 | while /*(*/ ( /*(*/ v /*(*/ == /*(*/ ')' /*(*/ ) /*(*/ // ; "comment" ()
753 | v++; /*(*/ // ; "comment" ()
754 | while /*(*/ ( /*(*/ v /*(*/ == /*(*/ '\'' /*(*/ ) /*(*/ // ; "comment" ()
755 | v++; /*(*/ // ; "comment" ()
756 | while /*(*/ ( /*(*/ v /*(*/ == /*(*/ '\\' /*(*/ ) /*(*/ // ; "comment" ()
757 | v++; /*(*/ // ; "comment" ()
758 | while /*(*/ ( /*(*/ v /*(*/ == /*(*/ "(" /*(*/ ) /*(*/ // ; "comment" ()
759 | v++; /*(*/ // ; "comment" ()
760 | while /*(*/ ( /*(*/ v /*(*/ == /*(*/ ")" /*(*/ ) /*(*/ // ; "comment" ()
761 | v++; /*(*/ // ; "comment" ()
762 | while /*(*/ ( /*(*/ v /*(*/ == /*(*/ "\"" /*(*/ ) /*(*/ // ; "comment" ()
763 | v++; /*(*/ // ; "comment" ()
764 | while /*(*/ ( /*(*/ v /*(*/ == /*(*/ "\\\"" /*(*/ ) /*(*/ // ; "comment" ()
765 | v++; /*(*/ // ; "comment" ()
766 | while /*(*/ ( /*(*/ v /*(*/ == /*(*/ foo( /*(*/ bar( /*(*/ "/*(*/" /*(*/ ) /*(*/ + /*(*/ "" /*(*/ ) /*(*/ ) /*(*/ // ; "comment" ()
767 | v++; /*(*/ // ; "comment" ()
768 | while /*(*/ () { } // a hack to make tests succeed
769 | }
770 |
771 | function testWhileIndentationNoBracesButBlockCommentsPart2(v) {
772 | while /*)*/ () v++; /*)*/ // ; "comment" ()
773 | while /*)*/ (()) v++; /*)*/ // ; "comment" ()
774 | while /*)*/ ((())) v++; /*)*/ // ; "comment" ()
775 | while /*)*/ ((()/*)*/)/*)*/()) v++; /*)*/ // ; "comment" ()
776 | while /*)*/ () /*)*/ // ; "comment" ()
777 | v++; /*)*/ // ; "comment" ()
778 | while /*)*/ ( /*)*/ v /*)*/ == /*)*/ '(' /*)*/ ) /*)*/ // ; "comment" ()
779 | v++; /*)*/ // ; "comment" ()
780 | while /*)*/ ( /*)*/ v /*)*/ == /*)*/ ')' /*)*/ ) /*)*/ // ; "comment" ()
781 | v++; /*)*/ // ; "comment" ()
782 | while /*)*/ ( /*)*/ v /*)*/ == /*)*/ '\'' /*)*/ ) /*)*/ // ; "comment" ()
783 | v++; /*)*/ // ; "comment" ()
784 | while /*)*/ ( /*)*/ v /*)*/ == /*)*/ '\\' /*)*/ ) /*)*/ // ; "comment" ()
785 | v++; /*)*/ // ; "comment" ()
786 | while /*)*/ ( /*)*/ v /*)*/ == /*)*/ "(" /*)*/ ) /*)*/ // ; "comment" ()
787 | v++; /*)*/ // ; "comment" ()
788 | while /*)*/ ( /*)*/ v /*)*/ == /*)*/ ")" /*)*/ ) /*)*/ // ; "comment" ()
789 | v++; /*)*/ // ; "comment" ()
790 | while /*)*/ ( /*)*/ v /*)*/ == /*)*/ "\"" /*)*/ ) /*)*/ // ; "comment" ()
791 | v++; /*)*/ // ; "comment" ()
792 | while /*)*/ ( /*)*/ v /*)*/ == /*)*/ "\\\"" /*)*/ ) /*)*/ // ; "comment" ()
793 | v++; /*)*/ // ; "comment" ()
794 | while /*)*/ ( /*)*/ v /*)*/ == /*)*/ foo( /*)*/ bar( /*)*/ "/*)*/" /*)*/ ) /*)*/ + /*)*/ "" /*)*/ ) /*)*/ ) /*)*/ // ; "comment" ()
795 | v++; /*)*/ // ; "comment" ()
796 | while /*)*/ () { } // a hack to make tests succeed
797 | }
798 |
799 | function testWhileIndentationWithBraces(v) {
800 |
801 | while () { v++; }
802 | while (()) { v++; }
803 | while ((())) { v++; }
804 | while ((())()) { v++; }
805 | while () {
806 | v++;
807 | }
808 | while (v == '(') {
809 | v++;
810 | }
811 | while (v == ')') {
812 | v++;
813 | }
814 | while (v == '\'') {
815 | v++;
816 | }
817 | while (v == '\\') {
818 | v++;
819 | }
820 | while (v == "(") {
821 | v++;
822 | }
823 | while (v == ")") {
824 | v++;
825 | }
826 | while (v == "\"") {
827 | v++;
828 | }
829 | while (v == "\\\"") {
830 | v++;
831 | }
832 | while (v == foo( bar("") + "" )) {
833 | v++;
834 | }
835 | while ()
836 | {
837 | v++;
838 | }
839 | while (v == '(')
840 | {
841 | v++;
842 | }
843 | while (v == ')')
844 | {
845 | v++;
846 | }
847 | while (v == '\'')
848 | {
849 | v++;
850 | }
851 | while (v == '\\')
852 | {
853 | v++;
854 | }
855 | while (v == "(")
856 | {
857 | v++;
858 | }
859 | while (v == ")")
860 | {
861 | v++;
862 | }
863 | while (v == "\"")
864 | {
865 | v++;
866 | }
867 | while (v == "\\\"")
868 | {
869 | v++;
870 | }
871 | while (v == foo( bar("") + "" ))
872 | {
873 | v++;
874 | }
875 | while (
876 | v == foo( bar("") + "" )
877 | )
878 | {
879 | v++;
880 | v++;
881 | }
882 | }
883 |
884 | function testWhileIndentationWithBracesAndComments(v) {
885 |
886 | while () { v++ } // ; "comments" ()
887 | while () { v++; } // ; "comments" ()
888 | while (()) { v++ } // ; "comments" ()
889 | while ((())) { v++ } // ; "comments" ()
890 | while ((())()) { v++ } // ; "comments" ()
891 | while () { // ; "comments" ()
892 | v++ // ; "comments" ()
893 | } // ; "comments" ()
894 | while (v == '(') { // ; "comments" ()
895 | v++ // ; "comments" ()
896 | } // ; "comments" ()
897 | while (v == ')') { // ; "comments" ()
898 | v++ // ; "comments" ()
899 | } // ; "comments" ()
900 | while (v == '\'') { // ; "comments" ()
901 | v++ // ; "comments" ()
902 | } // ; "comments" ()
903 | while (v == '\\') { // ; "comments" ()
904 | v++ // ; "comments" ()
905 | } // ; "comments" ()
906 | while (v == "(") { // ; "comments" ()
907 | v++ // ; "comments" ()
908 | } // ; "comments" ()
909 | while (v == ")") { // ; "comments" ()
910 | v++ // ; "comments" ()
911 | } // ; "comments" ()
912 | while (v == "\"") { // ; "comments" ()
913 | v++ // ; "comments" ()
914 | } // ; "comments" ()
915 | while (v == "\\\"") { // ; "comments" ()
916 | v++ // ; "comments" ()
917 | } // ; "comments" ()
918 | while (v == foo( bar("") + "" )) { // ; "comments" ()
919 | v++ // ; "comments" ()
920 | } // ; "comments" ()
921 | while () // ; "comments" ()
922 | { // ; "comments" ()
923 | v++ // ; "comments" ()
924 | } // ; "comments" ()
925 | while (v == '(') // ; "comments" ()
926 | { // ; "comments" ()
927 | v++ // ; "comments" ()
928 | } // ; "comments" ()
929 | while (v == ')') // ; "comments" ()
930 | { // ; "comments" ()
931 | v++ // ; "comments" ()
932 | } // ; "comments" ()
933 | while (v == '\'') // ; "comments" ()
934 | { // ; "comments" ()
935 | v++ // ; "comments" ()
936 | } // ; "comments" ()
937 | while (v == '\\') // ; "comments" ()
938 | { // ; "comments" ()
939 | v++ // ; "comments" ()
940 | } // ; "comments" ()
941 | while (v == "(") // ; "comments" ()
942 | { // ; "comments" ()
943 | v++ // ; "comments" ()
944 | } // ; "comments" ()
945 | while (v == ")") // ; "comments" ()
946 | { // ; "comments" ()
947 | v++ // ; "comments" ()
948 | } // ; "comments" ()
949 | while (v == "\"") // ; "comments" ()
950 | { // ; "comments" ()
951 | v++ // ; "comments" ()
952 | } // ; "comments" ()
953 | while (v == "\\\"") // ; "comments" ()
954 | { // ; "comments" ()
955 | v++ // ; "comments" ()
956 | } // ; "comments" ()
957 | while (v == foo( bar("") + "" )) // ; "comments" ()
958 | { // ; "comments" ()
959 | v++ // ; "comments" ()
960 | } // ; "comments" ()
961 | while ( // ; "comments" ()
962 | v == foo( bar("") + "" ) // ; "comments" ()
963 | ) // ; "comments" ()
964 | { // ; "comments" ()
965 | v++ // ; "comments" ()
966 | v++ // ; "comments" ()
967 | } // ; "comments" ()
968 | while ( // ; "comments" ()
969 | v == foo( bar("") + "" ) ) { // ; "comments" ()
970 | v++ // ; "comments" ()
971 | v++ // ; "comments" ()
972 | } // ; "comments" ()
973 | while ( // ; "comments" ()
974 | v == foo( bar("") + "" ) // ; "comments" ()
975 | ) { // ; "comments" ()
976 | v++ // ; "comments" ()
977 | v++ // ; "comments" ()
978 | } // ; "comments" ()
979 | }
980 |
--------------------------------------------------------------------------------
/tests/syntax_test_js_jsdoc.js:
--------------------------------------------------------------------------------
1 | // SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax"
2 |
3 | /**@a*/
4 | // ^^^ punctuation.definition.comment.begin
5 | // ^^ entity.other.attribute-name.documentation
6 | // ^^ punctuation.definition.comment.end - entity.other.attribute-name.documentation
7 | // ^^^^^^^ comment.block.documentation.js
8 |
9 | /** @a b */
10 | // ^^ entity.other.attribute-name.documentation
11 | // ^ - entity.other.attribute-name.documentation
12 | // ^^ punctuation.definition.comment.end
13 |
14 | /** @a@b */
15 | // ^^ entity.other.attribute-name.documentation
16 | // ^^ - entity.other.attribute-name.documentation
17 |
18 | /**
19 | * @a b
20 | // ^^ entity.other.attribute-name.documentation
21 | // ^ comment.block.documentation
22 | */
23 | // <- punctuation.definition.comment.end
24 |
25 | /**
26 | * First line
27 | * @a @b c */
28 | // ^^ entity.other.attribute-name.documentation
29 | // ^^ - entity.other.attribute-name.documentation
30 | // ^^^^ comment.block.documentation
31 | // ^^^^ - comment.block.documentation comment.block.documentation
32 | // ^^ comment.block.documentation punctuation.definition.comment.end
33 |
34 | /**
35 |
36 | @a */
37 | //^^ - entity.other.attribute-name.documentation
38 | // ^^ punctuation.definition.comment.end
39 |
40 | /*@a */
41 | //^^ - entity.other.attribute-name.documentation
42 | // ^^ punctuation.definition.comment.end
43 |
--------------------------------------------------------------------------------
/tests/syntax_test_js_not_typescript.js:
--------------------------------------------------------------------------------
1 | // SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax"
2 |
3 | ///
4 | // <- comment.line.triple-slash.js punctuation.definition.comment.js
5 | //^^^^^^^^^^^^^^^^^^^ comment.line.triple-slash.js - meta.preprocessor
6 |
--------------------------------------------------------------------------------
/tests/syntax_test_js_regexp.js:
--------------------------------------------------------------------------------
1 | // SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax"
2 |
3 | /* LITERAL */
4 |
5 | //
6 | // ^^ comment - string.regexp
7 |
8 | /abc/;
9 | // ^^^^^ string.regexp
10 | // ^ punctuation.definition.string.begin
11 | // ^ punctuation.definition.string.end
12 |
13 | /ab\/c/;
14 | // ^^^^^^^ string.regexp
15 | // ^^ constant.character.escape.backslash
16 |
17 | /ab\//;
18 | // ^^^^^^ string.regexp - comment
19 | // ^^ constant.character.escape.backslash
20 |
21 | /ab\/*/;
22 | // ^^^^^^^ string.regexp - comment
23 | // ^^ constant.character.escape.backslash
24 | // ^ keyword.operator.quantifier
25 |
26 | /abc/gimuys;
27 | // ^^^^^^^^^^^ string.regexp
28 | // ^^^^^^ keyword.other.js
29 |
30 | /abc/
31 | gimuys;
32 | // ^^^^^^ variable.other.readwrite - string.regexp;
33 |
34 | /abc//*
35 | */gimuys;
36 | // ^^^^^^ variable.other.readwrite - string.regexp;
37 |
38 | /abc//i;
39 | // ^^^^^ string.regexp
40 | // ^^ - string.regexp
41 | // ^ keyword.operator.arithmetic
42 | // ^ variable.other.readwrite
43 |
44 | /abc/*i;
45 | // ^^^^^ string.regexp
46 | // ^^ - string.regexp
47 | // ^ keyword.operator.arithmetic - string.regexp
48 | // ^ variable.other.readwrite
49 |
50 | /abc/**i;
51 | // ^^^^^ string.regexp
52 | // ^^^ - string.regexp
53 | // ^^ keyword.operator.arithmetic - string.regexp
54 | // ^ variable.other.readwrite
55 |
56 |
57 | /a|b/;
58 | // ^ keyword.operator.or
59 |
60 | /* ESCAPES */
61 |
62 | /a.c/;
63 | // ^ constant.other.character-class.escape
64 |
65 | /\d\D\w\W\s\S/;
66 | // ^^^^^^^^^^^^ constant.other.character-class.escape.backslash
67 |
68 | /\t\r\n\v\f\0/;
69 | // ^^^^^^^^^^^^ constant.character.escape.backslash
70 |
71 | /\cAB/;
72 | // ^^^ constant.character.escape.backslash
73 | // ^ - constant.character.escape
74 |
75 | /\x0ff/;
76 | // ^^^^ constant.character.escape.backslash
77 | // ^ - constant.character.escape
78 |
79 | /\x0/;
80 | // ^^ constant.character.escape.backslash
81 | // ^ - constant.character.escape
82 |
83 | /\u12abc/;
84 | // ^^^^^^ constant.character.escape.backslash
85 | // ^ - constant.character.escape
86 |
87 | /\u12a/;
88 | // ^^ constant.character.escape.backslash
89 | // ^^^ - constant.character.escape
90 |
91 | /\b\B^$/;
92 | // ^^^^^^ keyword.control.anchor
93 |
94 | /\p{General_Category=Letter} \P{Letter}/;
95 | // ^^ constant.other.character-class.escape.unicode-property
96 | // ^ punctuation.definition.unicode-property.begin
97 | // ^^^^^^^^^^^^^^^^ support.constant.unicode-property
98 | // ^ punctuation.separator.key-value.unicode-property
99 | // ^^^^^^ support.constant.unicode-property
100 | // ^ punctuation.definition.unicode-property.end
101 | // ^^ constant.other.character-class.escape.unicode-property
102 | // ^ punctuation.definition.unicode-property.begin
103 | // ^^^^^^ support.constant.unicode-property
104 | // ^ punctuation.definition.unicode-property.end
105 |
106 | /* QUANTIFIERS */
107 |
108 | /a*b+c?/;
109 | // ^ keyword.operator.quantifier.regexp
110 | // ^ keyword.operator.quantifier.regexp
111 | // ^ keyword.operator.quantifier.regexp
112 |
113 | /a*?b+?c??/;
114 | // ^^ keyword.operator.quantifier.regexp
115 | // ^^ keyword.operator.quantifier.regexp
116 | // ^^ keyword.operator.quantifier.regexp
117 |
118 | /a{10}b{1,2}c{1,}d{,2}/;
119 | // ^^^^ keyword.operator.quantifier
120 | // ^^^^^ keyword.operator.quantifier
121 | // ^^^^ keyword.operator.quantifier
122 | // ^^^^ keyword.operator.quantifier
123 |
124 |
125 | /a{10}?b{1,2}?c{1,}?d{,2}?/;
126 | // ^^^^^ keyword.operator.quantifier
127 | // ^^^^^^ keyword.operator.quantifier
128 | // ^^^^^ keyword.operator.quantifier
129 | // ^^^^^ keyword.operator.quantifier
130 |
131 | /a{b{}c{,}d{1, 2}/;
132 | // ^^^^^^^^^^^^^^^^ - keyword.operator.quantifier
133 |
134 | /* GROUPING */
135 |
136 | /a(bc)d/;
137 | // ^^^^ meta.group
138 | // ^ punctuation.definition.group
139 | // ^ punctuation.definition.group
140 |
141 | /a(?:bc)d/;
142 | // ^^^^^^ meta.group
143 | // ^^^ punctuation.definition.group
144 | // ^^ punctuation.definition.group.no-capture
145 | // ^ punctuation.definition.group
146 |
147 | /a(b(c)d)e/;
148 | // ^^^^^^^ meta.group
149 | // ^^^ meta.group meta.group
150 | // ^ punctuation.definition.group
151 | // ^ punctuation.definition.group
152 | // ^ punctuation.definition.group
153 | // ^ punctuation.definition.group
154 |
155 | /a(b)c\1/;
156 | // ^^ keyword.other.back-reference
157 |
158 | /a(?bc)d\k/;
159 | // ^^^^^^^^^^ meta.group
160 | // ^^ punctuation.definition.group
161 | // ^ punctuation.definition.group.named.begin
162 | // ^^^ entity.name.other.group
163 | // ^ punctuation.definition.group.named.end
164 | // ^ punctuation.definition.group
165 | // ^^ keyword.other.back-reference
166 | // ^ punctuation.definition.group.named.begin
167 | // ^^^ variable.other.group
168 | // ^ punctuation.definition.group.named.end
169 |
170 | /* ASSERTIONS */
171 |
172 | /(?=foo)/;
173 | // ^^^^^^^ meta.group.assertion
174 | // ^ punctuation.definition.group
175 | // ^^ punctuation.definition.group.assertion meta.assertion.look-ahead
176 | // ^ punctuation.definition.group
177 |
178 | /(?!foo)/;
179 | // ^^^^^^^ meta.group.assertion
180 | // ^ punctuation.definition.group
181 | // ^^ punctuation.definition.group.assertion meta.assertion.negative-look-ahead
182 | // ^ punctuation.definition.group
183 |
184 | /(?<=foo)/;
185 | // ^^^^^^^^ meta.group.assertion
186 | // ^ punctuation.definition.group
187 | // ^^^ punctuation.definition.group.assertion meta.assertion.look-behind
188 | // ^ punctuation.definition.group
189 |
190 | /(?
77 | // <- comment.line.other.js punctuation.definition.comment.js
78 | //^^^^^^^^^^^^^^^^^^^^ comment.line.other.js - meta.preprocessor
79 |
80 | ;
81 | // ^^^^^^^ meta.jsx meta.tag
82 | // ^ punctuation.definition.tag.begin
83 | // ^^^ meta.tag.name entity.name.tag.native
84 | // ^^ punctuation.definition.tag.end
85 |
86 | Hello!;
87 | // ^^^^^^^^^^^^^^^^^ meta.jsx
88 | // ^^^^^ meta.tag
89 | // ^ punctuation.definition.tag.begin
90 | // ^^^ meta.tag.name entity.name.tag.native
91 | // ^ punctuation.definition.tag.end
92 | // ^^^^^^ - meta.tag
93 | // ^^^^^^ meta.tag
94 | // ^^ punctuation.definition.tag.begin
95 | // ^^^ meta.tag.name entity.name.tag.native
96 | // ^ punctuation.definition.tag.end
97 |
98 | Hello!;
99 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.jsx
100 | // ^^^^^^^^^^^^^ meta.tag
101 | // ^^^^^^^^^^^ meta.tag.name - entity.name.tag.native
102 | // ^ punctuation.accessor
103 | // ^ punctuation.accessor
104 | // ^^^ entity.name.tag
105 | // ^^^^^^ - meta.tag
106 | // ^^^^^^^^^^^^^^ meta.tag
107 | // ^^^^^^^^^^^ meta.tag.name - entity.name.tag.native
108 | // ^ punctuation.accessor
109 | // ^ punctuation.accessor
110 | // ^^^ entity.name.tag
111 |
112 | Hello!World!;
113 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.jsx
114 | // ^^^^^ meta.tag
115 | // ^^^^^^ - meta.tag
116 | // ^^^^^^ meta.tag
117 | // ^^^^^^ - meta.tag
118 | // ^^^^^^ meta.tag
119 |
120 |
121 | // ^^^^^^^^^^^ meta.jsx
122 | // ^^^^^ - meta.jsx
123 | // ^ keyword.operator.comparison
124 | // ^^^ variable
125 | // ^ keyword.operator.comparison
126 | 0;
127 |
128 | <>Hello!>;
129 | // ^^^^^^^^^^^ meta.jsx
130 | // ^^ meta.tag
131 | // ^ punctuation.definition.tag.begin
132 | // ^ punctuation.definition.tag.end
133 | // ^^^^^^ - meta.tag
134 | // ^^^ meta.tag
135 | // ^^ punctuation.definition.tag.begin
136 | // ^ punctuation.definition.tag.end
137 |
138 |
139 |
140 | // ^^^^^ - meta.jsx
141 | // ^ keyword.operator.comparison
142 | // ^^^ variable
143 | // ^ keyword.operator.comparison
144 | 0;
145 |
146 | ;
147 | // ^^^^ invalid.illegal.unmatched-tag
148 |
149 | ;
226 | // <- meta.jsx meta.tag punctuation.definition.tag.end
227 |
228 |
229 | // test
230 | // ^^^^^^^^ - comment
231 |
232 | /* test */
233 | // ^^^^^^^^^^ - comment
234 |
235 |   ;
236 | // ^^^^^^ constant.character.escape
237 | // ^ punctuation.definition.entity
238 | // ^ punctuation.definition.entity
239 | // ^^^^^^^ - constant.character.escape
240 |
241 | {xyzzy}
242 | // ^^^^^^^ meta.interpolation
243 | // ^^^^^ source.js.embedded.jsx variable.other.readwrite
244 |
245 | {{ xyzzy:42 }}
246 | // ^^^^^^^^^^^^^^ meta.interpolation
247 | // ^^^^^^^^^^^^ source.js.embedded.jsx
248 | // ^^^^^^^^^^^^ meta.mapping
249 | // ^^^^^ meta.mapping.key
250 | // ^ punctuation.separator.key-value
251 | // ^^ meta.number.integer.decimal.js constant.numeric.value.js
252 | // ^ punctuation.definition.interpolation.end
253 |
254 | {//}
255 | // ^ punctuation.definition.interpolation.begin
256 | // ^^^ comment.line.double-slash
257 | // ^^ punctuation.definition.comment
258 | // ^ - punctuation
259 | }
260 | // ^ punctuation.definition.interpolation.end
261 |
262 | {/* foo */}
263 | // ^^^^^^^^^^^ meta.jsx meta.interpolation comment.block - source.embedded
264 | // ^ punctuation.definition.interpolation.begin
265 | // ^^ punctuation.definition.comment.begin
266 | // ^^ punctuation.definition.comment.end
267 | // ^ punctuation.definition.interpolation.end
268 |
269 | {/* foo */ bar}
270 | // ^^^^^^^^^^^^^^^ meta.jsx meta.interpolation
271 | // ^^^^^^^^^^^^^ source.js.embedded
272 | // ^ punctuation.definition.interpolation.begin - comment
273 | // ^^ punctuation.definition.comment.begin
274 | // ^^ punctuation.definition.comment.end
275 | // ^^^^^ - comment
276 | // ^^^ meta.jsx meta.interpolation variable.other.readwrite
277 | // ^ punctuation.definition.interpolation.end
278 |
279 | ;
280 |
281 | ;
282 | // ^^^^^ entity.name.tag - entity.name.tag.native
283 |
--------------------------------------------------------------------------------
/tests/syntax_test_string_object_keys.js:
--------------------------------------------------------------------------------
1 | // SYNTAX TEST "Packages/babel-sublime/JavaScript (Babel).sublime-syntax"
2 | ({
3 | foo: 42,
4 | // ^^^ meta.group meta.mapping meta.mapping.key string.unquoted
5 |
6 | [bar]: 42,
7 | // ^^^^^ - string
8 | });
9 |
10 | const { x } = 42;
11 | // ^ - string
12 |
13 | const { x: y } = 42;
14 | // ^ string.unquoted
15 |
--------------------------------------------------------------------------------