Skip to content

Commit eb9a845

Browse files
author
thom
committed
[JavaScript] More fixes and improved tests.
1 parent 78cc4bd commit eb9a845

File tree

2 files changed

+37
-60
lines changed

2 files changed

+37
-60
lines changed

JavaScript/JavaScript.sublime-syntax

+3-6
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ contexts:
106106
import-export:
107107
- match: import{{identifier_break}}
108108
scope: keyword.control.import-export.js
109-
push:
109+
set:
110110
- import-meta
111111
- expect-semicolon
112112
- import-string-or-items
113113

114114
- match: export{{identifier_break}}
115115
scope: keyword.control.import-export.js
116-
push:
116+
set:
117117
- export-meta
118118
- export-extended
119119

@@ -245,9 +245,6 @@ contexts:
245245
scope: invalid.illegal.stray-bracket-end.js
246246
pop: true
247247

248-
- match: \;
249-
scope: punctuation.terminator.statement.js
250-
251248
- match: (?=\S)
252249
push: statement
253250

@@ -285,7 +282,7 @@ contexts:
285282

286283
expect-semicolon:
287284
- match: \;
288-
scope: punctuation.terminator.statement.empty.js
285+
scope: punctuation.terminator.statement.js
289286
pop: true
290287
- include: else-pop
291288

JavaScript/tests/syntax_test_js.js

+34-54
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {identifier, otherIdentifier} from "somewhere";
1010
// ^ meta.import meta.block variable.other.readwrite
1111

1212
import thing, {identifier as otherIdentifier}, * as otherName from "otherplace";
13-
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import
13+
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import
1414
// ^ keyword.control.import-export
1515
// ^ variable.other.readwrite
1616
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block
@@ -20,8 +20,8 @@ import thing, {identifier as otherIdentifier}, * as otherName from "otherplace";
2020
// ^ constant.other.js
2121
// ^ keyword.control.import-export
2222

23-
import 'module'
24-
// ^^^^^^^^^^^^ meta.import
23+
import 'module';
24+
// ^^^^^^^^^^^^^ meta.import
2525

2626
export { name1, name2 as name3 };
2727
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
@@ -31,18 +31,18 @@ export { name1, name2 as name3 };
3131
// ^^ keyword.control.import-export
3232

3333
export let name1, name2;
34-
//^^^^^^^^^^^^^^^^^^^^^ meta.export
34+
//^^^^^^^^^^^^^^^^^^^^^^ meta.export
3535
//^ keyword.control.import-export
3636
// ^^^ storage.type
3737
// ^ punctuation.separator.comma
3838

3939
export var name3;
40-
//^^^^^^^^^^^^^^ meta.export
40+
//^^^^^^^^^^^^^^^ meta.export
4141
//^ keyword.control.import-export
4242
// ^^^ storage.type
4343

4444
export const name1 = 5;
45-
//^^^^^^^^^^^^^^^^^^^^ meta.export
45+
//^^^^^^^^^^^^^^^^^^^^^ meta.export
4646
//^ keyword.control.import-export
4747
// ^^^^^ storage.type
4848
// ^ keyword.operator.assignment
@@ -51,62 +51,48 @@ export let foo = 123 // No semicolon
5151
export function bar() {}
5252
// <- keyword.control.import-export
5353

54-
export function foo() {}
54+
export function foo() {};
5555
//^^^^^^^^^^^^^^^^^^^^^^ meta.export
5656
//^^^^ keyword.control.import-export
5757
// ^^^^^^^^^^^^^^ meta.function.declaration
58+
// ^ punctuation.terminator.statement.empty
5859

59-
[];
60-
// <- meta.sequence
61-
62-
export function* foo() {}
63-
//^^^^^^^^^^^^^^^^^^^^^^ meta.export
60+
export function* foo() {};
61+
//^^^^^^^^^^^^^^^^^^^^^^^ meta.export
6462
//^^^^ keyword.control.import-export
6563
// ^^^^^^^^^^^^^^^ meta.function.declaration
64+
// ^ punctuation.terminator.statement.empty
6665

67-
[];
68-
// <- meta.sequence
69-
70-
export async function foo() {}
71-
//^^^^^^^^^^^^^^^^^^^^^^ meta.export
66+
export async function foo() {};
67+
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
7268
//^^^^ keyword.control.import-export
7369
// ^^^^^^^^^^^^^^^^^^^^ meta.function.declaration
70+
// ^ punctuation.terminator.statement.empty
7471

75-
[];
76-
// <- meta.sequence
77-
78-
export class Foo {}
72+
export class Foo {};
7973
//^^^^^^^^^^^^^^^^^ meta.export
8074
//^^^^ keyword.control.import-export
8175
// ^^^^^^^^^^^^ meta.class
82-
83-
[];
84-
// <- meta.sequence
76+
// ^ punctuation.terminator.statement.empty
8577

8678
export default expression;
87-
//^^^^^^^^^^^^^^^^^^^^^^^ meta.export
79+
//^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
8880
//^ keyword.control.import-export
8981
// ^ keyword.control.import-export
9082

91-
export default function (a) { }
83+
export default function (a) { };
9284
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
9385
//^^^^ keyword.control.import-export
9486
// ^^^^^^^ keyword.control.import-export
9587
// ^^^^^^^^^^^^ meta.function.declaration.js
96-
// ^ - meta.export
97-
98-
[];
99-
// <- meta.sequence
88+
// ^ punctuation.terminator.statement.empty - meta.export
10089

101-
export default function* (a) { }
90+
export default function* (a) { };
10291
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
10392
//^^^^ keyword.control.import-export
10493
// ^^^^^^^ keyword.control.import-export
10594
// ^^^^^^^^^^^^^ meta.function.declaration.js
106-
// ^ - meta.export
107-
108-
[];
109-
// <- meta.sequence
95+
// ^ punctuation.terminator.statement.empty - meta.export
11096

11197
export default function name1(b) { }
11298
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
@@ -115,46 +101,40 @@ export default function name1(b) { }
115101
// ^ storage.type
116102
// ^ entity.name.function
117103

118-
export default class Foo {}
104+
export default class Foo {};
119105
//^^^^^^^^^^^^^^^^^ meta.export
120106
//^^^^ keyword.control.import-export
121107
// ^^^^^^^ keyword.control.import-export
122108
// ^^^^^^^^^^^^ meta.class
109+
// ^ punctuation.terminator.statement.empty
123110

124-
[];
125-
// <- meta.sequence
126-
127-
export default +function (a) { }
128-
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
111+
export default +function (a) { };
112+
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
129113
//^^^^ keyword.control.import-export
130114
// ^^^^^^^ keyword.control.import-export
131115
// ^^^^^^^^^^^^ meta.function.declaration.js
132116

133-
[];
134-
// <- meta.export
135-
// <- meta.brackets
136-
137117
export { name1 as default };
138-
//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
118+
//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
139119
//^ keyword.control.import-export
140120
// ^^^^^^^^^^^^^^^^^^^^ meta.block
141121
// ^ keyword.control.import-export
142122
// ^ keyword.control.import-export
143123

144124
export * from "./othermod";
145-
//^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
125+
//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
146126
//^ keyword.control.import-export
147127
// ^ constant.other
148128
// ^ keyword.control.import-export
149129

150130
export { name1, name2 } from "./othermod";
151-
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
131+
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
152132
//^ keyword.control.import-export
153133
// ^^^^^^^^^^^^^^^^ meta.block
154134
// ^ keyword.control.import-export
155135

156136
export { import1 as name1, import2 as name2, nameN } from "./othermod";
157-
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
137+
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export
158138
//^ keyword.control.import-export
159139
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block
160140
// ^ keyword.control.import-export
@@ -163,23 +143,23 @@ export { import1 as name1, import2 as name2, nameN } from "./othermod";
163143

164144
import * as
165145
alias from "module";
166-
// ^^^^^^^^^^^^^^^^^^^^ meta.import.js
146+
// ^^^^^^^^^^^^^^^^^^^^^ meta.import.js
167147

168148
import { member as
169149
alias } from "module";
170-
// ^^^^^^^^^^^^^^^^^^^^^^ meta.import.js
150+
// ^^^^^^^^^^^^^^^^^^^^^^^ meta.import.js
171151

172152
import { * as
173153
alias } from "module";
174-
// ^^^^^^^^^^^^^^^^^^^^^^ meta.import.js
154+
// ^^^^^^^^^^^^^^^^^^^^^^^ meta.import.js
175155

176156
export { member as
177157
alias } from "module";
178-
// ^^^^^^^^^^^^^^^^^^^^^^ meta.export.js
158+
// ^^^^^^^^^^^^^^^^^^^^^^^ meta.export.js
179159

180160
export { member as
181161
default } from "module";
182-
// ^^^^^^^^^^^^^^^^^^^^^^^^ meta.export.js
162+
// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.export.js
183163

184164
let from;
185165
// ^^^^ variable.other.readwrite.js

0 commit comments

Comments
 (0)