@arcgis/arcade-languageservice 5.2.0-next.93 → 5.2.0-next.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/arcade-language-service.d.ts +22 -0
- package/dist/index.d.ts +6 -1591
- package/dist/index.js +817 -2721
- package/dist/services/api-context.d.ts +7 -0
- package/dist/services/api-diagnostic.d.ts +62 -0
- package/dist/services/arcade-formatting/arcade-formatting.d.ts +18 -0
- package/dist/services/arcade-formatting/index.d.ts +2 -0
- package/dist/services/arcade-formatting/options.d.ts +28 -0
- package/dist/services/languageKeywords.d.ts +7 -0
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,1931 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
True: "true"
|
|
8
|
-
}, f = {
|
|
9
|
-
Break: "break",
|
|
10
|
-
Continue: "continue",
|
|
11
|
-
Else: "else",
|
|
12
|
-
For: "for",
|
|
13
|
-
Function: "function",
|
|
14
|
-
If: "if",
|
|
15
|
-
Import: "import",
|
|
16
|
-
Export: "export",
|
|
17
|
-
In: "in",
|
|
18
|
-
Return: "return",
|
|
19
|
-
Var: "var",
|
|
20
|
-
While: "while"
|
|
21
|
-
}, te = {
|
|
22
|
-
From: "from",
|
|
23
|
-
Of: "of"
|
|
24
|
-
}, u = {
|
|
25
|
-
AssignmentExpression: "AssignmentExpression",
|
|
26
|
-
ArrayExpression: "ArrayExpression",
|
|
27
|
-
BlockComment: "BlockComment",
|
|
28
|
-
BlockStatement: "BlockStatement",
|
|
29
|
-
BinaryExpression: "BinaryExpression",
|
|
30
|
-
BreakStatement: "BreakStatement",
|
|
31
|
-
CallExpression: "CallExpression",
|
|
32
|
-
ContinueStatement: "ContinueStatement",
|
|
33
|
-
EmptyStatement: "EmptyStatement",
|
|
34
|
-
ExpressionStatement: "ExpressionStatement",
|
|
35
|
-
ExportNamedDeclaration: "ExportNamedDeclaration",
|
|
36
|
-
ForStatement: "ForStatement",
|
|
37
|
-
ForInStatement: "ForInStatement",
|
|
38
|
-
ForOfStatement: "ForOfStatement",
|
|
39
|
-
FunctionDeclaration: "FunctionDeclaration",
|
|
40
|
-
Identifier: "Identifier",
|
|
41
|
-
IfStatement: "IfStatement",
|
|
42
|
-
ImportDeclaration: "ImportDeclaration",
|
|
43
|
-
ImportDefaultSpecifier: "ImportDefaultSpecifier",
|
|
44
|
-
LineComment: "LineComment",
|
|
45
|
-
Literal: "Literal",
|
|
46
|
-
LogicalExpression: "LogicalExpression",
|
|
47
|
-
MemberAccessChainExpression: "MemberAccessChainExpression",
|
|
48
|
-
MemberExpression: "MemberExpression",
|
|
49
|
-
ObjectExpression: "ObjectExpression",
|
|
50
|
-
Program: "Program",
|
|
51
|
-
Property: "Property",
|
|
52
|
-
ReturnStatement: "ReturnStatement",
|
|
53
|
-
SafeMemberExpression: "SafeMemberExpression",
|
|
54
|
-
TemplateElement: "TemplateElement",
|
|
55
|
-
TemplateLiteral: "TemplateLiteral",
|
|
56
|
-
UnaryExpression: "UnaryExpression",
|
|
57
|
-
UpdateExpression: "UpdateExpression",
|
|
58
|
-
VariableDeclaration: "VariableDeclaration",
|
|
59
|
-
VariableDeclarator: "VariableDeclarator",
|
|
60
|
-
WhileStatement: "WhileStatement"
|
|
61
|
-
}, ue = ["++", "--"], Ne = ["-", "+", "!", "~"], Me = ["=", "/=", "*=", "%=", "+=", "-="], Ue = ["||", "&&"], Qe = [
|
|
62
|
-
"|",
|
|
63
|
-
"&",
|
|
64
|
-
">>",
|
|
65
|
-
"<<",
|
|
66
|
-
">>>",
|
|
67
|
-
"^",
|
|
68
|
-
"==",
|
|
69
|
-
"!=",
|
|
70
|
-
"<",
|
|
71
|
-
"<=",
|
|
72
|
-
">",
|
|
73
|
-
">=",
|
|
74
|
-
"+",
|
|
75
|
-
"-",
|
|
76
|
-
"*",
|
|
77
|
-
"/",
|
|
78
|
-
"%"
|
|
79
|
-
], w = "?.", q = {
|
|
80
|
-
"||": 1,
|
|
81
|
-
"&&": 2,
|
|
82
|
-
"|": 3,
|
|
83
|
-
"^": 4,
|
|
84
|
-
"&": 5,
|
|
85
|
-
"==": 6,
|
|
86
|
-
"!=": 6,
|
|
87
|
-
"<": 7,
|
|
88
|
-
">": 7,
|
|
89
|
-
"<=": 7,
|
|
90
|
-
">=": 7,
|
|
91
|
-
"<<": 8,
|
|
92
|
-
">>": 8,
|
|
93
|
-
">>>": 8,
|
|
94
|
-
"+": 9,
|
|
95
|
-
"-": 9,
|
|
96
|
-
"*": 10,
|
|
97
|
-
"/": 10,
|
|
98
|
-
"%": 10
|
|
99
|
-
}, l = {
|
|
100
|
-
BooleanLiteral: 1,
|
|
101
|
-
EOF: 2,
|
|
102
|
-
Identifier: 3,
|
|
103
|
-
Keyword: 4,
|
|
104
|
-
NullLiteral: 5,
|
|
105
|
-
NumericLiteral: 6,
|
|
106
|
-
Punctuator: 7,
|
|
107
|
-
StringLiteral: 8,
|
|
108
|
-
Template: 10
|
|
109
|
-
}, Oe = [
|
|
110
|
-
"Unknown",
|
|
111
|
-
"Boolean",
|
|
112
|
-
"<end>",
|
|
113
|
-
"Identifier",
|
|
114
|
-
"Keyword",
|
|
115
|
-
"Null",
|
|
116
|
-
"Numeric",
|
|
117
|
-
"Punctuator",
|
|
118
|
-
"String",
|
|
119
|
-
"RegularExpression",
|
|
120
|
-
"Template"
|
|
121
|
-
], h = {
|
|
122
|
-
InvalidModuleUri: "InvalidModuleUri",
|
|
123
|
-
ForInOfLoopInitializer: "ForInOfLoopInitializer",
|
|
124
|
-
IdentifierExpected: "IdentifierExpected",
|
|
125
|
-
InvalidEscapedReservedWord: "InvalidEscapedReservedWord",
|
|
126
|
-
InvalidExpression: "InvalidExpression",
|
|
127
|
-
InvalidFunctionIdentifier: "InvalidFunctionIdentifier",
|
|
128
|
-
InvalidHexEscapeSequence: "InvalidHexEscapeSequence",
|
|
129
|
-
InvalidLeftHandSideInAssignment: "InvalidLeftHandSideInAssignment",
|
|
130
|
-
InvalidLeftHandSideInForIn: "InvalidLeftHandSideInForIn",
|
|
131
|
-
InvalidTemplateHead: "InvalidTemplateHead",
|
|
132
|
-
InvalidVariableAssignment: "InvalidVariableAssignment",
|
|
133
|
-
KeyMustBeString: "KeyMustBeString",
|
|
134
|
-
NoFunctionInsideBlock: "NoFunctionInsideBlock",
|
|
135
|
-
NoFunctionInsideFunction: "NoFunctionInsideFunction",
|
|
136
|
-
ModuleExportRootOnly: "ModuleExportRootOnly",
|
|
137
|
-
ModuleImportRootOnly: "ModuleImportRootOnly",
|
|
138
|
-
PunctuatorExpected: "PunctuatorExpected",
|
|
139
|
-
TemplateOctalLiteral: "TemplateOctalLiteral",
|
|
140
|
-
UnexpectedBoolean: "UnexpectedBoolean",
|
|
141
|
-
UnexpectedEndOfScript: "UnexpectedEndOfScript",
|
|
142
|
-
UnexpectedIdentifier: "UnexpectedIdentifier",
|
|
143
|
-
UnexpectedKeyword: "UnexpectedKeyword",
|
|
144
|
-
UnexpectedNull: "UnexpectedNull",
|
|
145
|
-
UnexpectedNumber: "UnexpectedNumber",
|
|
146
|
-
UnexpectedPunctuator: "UnexpectedPunctuator",
|
|
147
|
-
UnexpectedString: "UnexpectedString",
|
|
148
|
-
UnexpectedTemplate: "UnexpectedTemplate",
|
|
149
|
-
UnexpectedToken: "UnexpectedToken"
|
|
150
|
-
}, je = {
|
|
151
|
-
[h.InvalidModuleUri]: "Module uri must be a text literal.",
|
|
152
|
-
[h.ForInOfLoopInitializer]: "for-in loop variable declaration may not have an initializer.",
|
|
153
|
-
[h.IdentifierExpected]: "'${value}' is an invalid identifier.",
|
|
154
|
-
[h.InvalidEscapedReservedWord]: "Keyword cannot contain escaped characters.",
|
|
155
|
-
[h.InvalidExpression]: "Invalid expression.",
|
|
156
|
-
[h.InvalidFunctionIdentifier]: "'${value}' is an invalid function identifier.",
|
|
157
|
-
[h.InvalidHexEscapeSequence]: "Invalid hexadecimal escape sequence.",
|
|
158
|
-
[h.InvalidLeftHandSideInAssignment]: "Invalid left-hand side in assignment.",
|
|
159
|
-
[h.InvalidLeftHandSideInForIn]: "Invalid left-hand side in for-in.",
|
|
160
|
-
[h.InvalidTemplateHead]: "Invalid template structure.",
|
|
161
|
-
[h.InvalidVariableAssignment]: "Invalid variable assignment.",
|
|
162
|
-
[h.KeyMustBeString]: "Object property keys must be a word starting with a letter.",
|
|
163
|
-
[h.NoFunctionInsideBlock]: "Functions cannot be declared inside of code blocks.",
|
|
164
|
-
[h.NoFunctionInsideFunction]: "Functions cannot be declared inside another function.",
|
|
165
|
-
[h.ModuleExportRootOnly]: "Module exports cannot be declared inside of code blocks.",
|
|
166
|
-
[h.ModuleImportRootOnly]: "Module import cannot be declared inside of code blocks.",
|
|
167
|
-
[h.PunctuatorExpected]: "'${value}' expected.",
|
|
168
|
-
[h.TemplateOctalLiteral]: "Octal literals are not allowed in template literals.",
|
|
169
|
-
[h.UnexpectedBoolean]: "Unexpected boolean literal.",
|
|
170
|
-
[h.UnexpectedEndOfScript]: "Unexpected end of Arcade expression.",
|
|
171
|
-
[h.UnexpectedIdentifier]: "Unexpected identifier.",
|
|
172
|
-
[h.UnexpectedKeyword]: "Unexpected keyword.",
|
|
173
|
-
[h.UnexpectedNull]: "Unexpected null literal.",
|
|
174
|
-
[h.UnexpectedNumber]: "Unexpected number.",
|
|
175
|
-
[h.UnexpectedPunctuator]: "Unexpected punctuator.",
|
|
176
|
-
[h.UnexpectedString]: "Unexpected text literal.",
|
|
177
|
-
[h.UnexpectedTemplate]: "Unexpected quasi '${value}'.",
|
|
178
|
-
[h.UnexpectedToken]: "Unexpected token '${value}'."
|
|
179
|
-
};
|
|
180
|
-
class z extends Error {
|
|
181
|
-
/**
|
|
182
|
-
* @public
|
|
183
|
-
* @param diagnosticApi
|
|
184
|
-
*/
|
|
185
|
-
constructor({ code: e, index: t, line: i, column: r, len: s = 0, description: a, data: o }) {
|
|
186
|
-
super(a ?? e), this.declaredRootClass = "esri.arcade.lib.diagnostic", this.name = "ParsingError", this.code = e, this.index = t, this.line = i, this.column = r, this.len = s, this.data = o, this.description = a, this.range = {
|
|
187
|
-
start: { line: i, column: r - 1 },
|
|
188
|
-
end: { line: i, column: r + s }
|
|
189
|
-
}, Error.captureStackTrace?.(
|
|
190
|
-
this,
|
|
191
|
-
z
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
function Ze(n) {
|
|
196
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.Program;
|
|
197
|
-
}
|
|
198
|
-
function b(n) {
|
|
199
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.BlockStatement;
|
|
200
|
-
}
|
|
201
|
-
function Xe(n) {
|
|
202
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.BlockComment;
|
|
203
|
-
}
|
|
204
|
-
function pe(n) {
|
|
205
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.EmptyStatement;
|
|
206
|
-
}
|
|
207
|
-
function Ye(n) {
|
|
208
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.ExpressionStatement;
|
|
209
|
-
}
|
|
210
|
-
function ge(n) {
|
|
211
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.FunctionDeclaration;
|
|
212
|
-
}
|
|
213
|
-
function ae(n) {
|
|
214
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.IfStatement;
|
|
215
|
-
}
|
|
216
|
-
function G(n) {
|
|
217
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.VariableDeclaration;
|
|
218
|
-
}
|
|
219
|
-
function J(n) {
|
|
220
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.ArrayExpression;
|
|
221
|
-
}
|
|
222
|
-
function oe(n) {
|
|
223
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.BinaryExpression;
|
|
224
|
-
}
|
|
225
|
-
function I(n) {
|
|
226
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.Identifier;
|
|
227
|
-
}
|
|
228
|
-
function ze(n) {
|
|
229
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.Literal;
|
|
230
|
-
}
|
|
231
|
-
function ce(n) {
|
|
232
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.LogicalExpression;
|
|
233
|
-
}
|
|
234
|
-
function xe(n) {
|
|
235
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.ObjectExpression;
|
|
236
|
-
}
|
|
237
|
-
function Fe(n) {
|
|
238
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.MemberExpression;
|
|
239
|
-
}
|
|
240
|
-
function et(n) {
|
|
241
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.SafeMemberExpression;
|
|
242
|
-
}
|
|
243
|
-
function tt(n) {
|
|
244
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.MemberAccessChainExpression;
|
|
245
|
-
}
|
|
246
|
-
function it(n) {
|
|
247
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.UnaryExpression;
|
|
248
|
-
}
|
|
249
|
-
function nt(n) {
|
|
250
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.UpdateExpression;
|
|
251
|
-
}
|
|
252
|
-
function Ve(n) {
|
|
253
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.VariableDeclarator;
|
|
254
|
-
}
|
|
255
|
-
function rt(n) {
|
|
256
|
-
return !!n && typeof n == "object" && "type" in n && n.type === u.Property;
|
|
257
|
-
}
|
|
258
|
-
function ie(n, e) {
|
|
259
|
-
return e.loc.end.line === n.loc.start.line && e.loc.end.column <= n.loc.start.column;
|
|
260
|
-
}
|
|
261
|
-
function Ae(n, e) {
|
|
262
|
-
return n.range[0] >= e.range[0] && n.range[1] <= e.range[1];
|
|
263
|
-
}
|
|
264
|
-
class st {
|
|
265
|
-
constructor() {
|
|
266
|
-
this.comments = [], this._nodeStack = [], this._newComments = [];
|
|
267
|
-
}
|
|
268
|
-
insertInnerComments(e) {
|
|
269
|
-
if (!b(e) || e.body.length !== 0)
|
|
270
|
-
return;
|
|
271
|
-
const t = [];
|
|
272
|
-
for (let i = this._newComments.length - 1; i >= 0; i--) {
|
|
273
|
-
const r = this._newComments[i];
|
|
274
|
-
e.range[1] >= r.range[0] && (t.unshift(r), this._newComments.splice(i, 1));
|
|
275
|
-
}
|
|
276
|
-
t.length && (e.innerComments = t);
|
|
277
|
-
}
|
|
278
|
-
attachTrailingComments(e) {
|
|
279
|
-
const t = this._nodeStack.at(-1);
|
|
280
|
-
if (!t)
|
|
281
|
-
return;
|
|
282
|
-
if (b(e) && Ae(t, e))
|
|
283
|
-
for (let r = this._newComments.length - 1; r >= 0; r--) {
|
|
284
|
-
const s = this._newComments[r];
|
|
285
|
-
Ae(s, e) && (t.trailingComments = [...t.trailingComments ?? [], s], this._newComments.splice(r, 1));
|
|
286
|
-
}
|
|
287
|
-
let i = [];
|
|
288
|
-
if (this._newComments.length > 0)
|
|
289
|
-
for (let r = this._newComments.length - 1; r >= 0; r--) {
|
|
290
|
-
const s = this._newComments[r];
|
|
291
|
-
ie(s, t) ? (t.trailingComments = [...t.trailingComments ?? [], s], this._newComments.splice(r, 1)) : ie(s, e) && (i.unshift(s), this._newComments.splice(r, 1));
|
|
292
|
-
}
|
|
293
|
-
if (t.trailingComments) {
|
|
294
|
-
const r = t.trailingComments[0];
|
|
295
|
-
ie(r, e) && (i = [...i, ...t.trailingComments], delete t.trailingComments);
|
|
296
|
-
}
|
|
297
|
-
i.length > 0 && (e.trailingComments = i);
|
|
298
|
-
}
|
|
299
|
-
attachLeadingComments(e) {
|
|
300
|
-
let t;
|
|
301
|
-
for (; this._nodeStack.length > 0; ) {
|
|
302
|
-
const s = this._nodeStack[this._nodeStack.length - 1];
|
|
303
|
-
if (e.range[0] <= s.range[0]) {
|
|
304
|
-
t = s, this._nodeStack.pop();
|
|
305
|
-
continue;
|
|
306
|
-
}
|
|
307
|
-
break;
|
|
308
|
-
}
|
|
309
|
-
const i = [], r = [];
|
|
310
|
-
if (t != null) {
|
|
311
|
-
if (!t.leadingComments)
|
|
312
|
-
return;
|
|
313
|
-
for (let s = t.leadingComments.length - 1; s >= 0; s--) {
|
|
314
|
-
const a = t.leadingComments[s];
|
|
315
|
-
if (e.range[0] >= a.range[1]) {
|
|
316
|
-
i.unshift(a), t.leadingComments.splice(s, 1);
|
|
317
|
-
continue;
|
|
318
|
-
}
|
|
319
|
-
Ve(e) && !Xe(a) && (r.unshift(a), t.leadingComments.splice(s, 1));
|
|
320
|
-
}
|
|
321
|
-
t.leadingComments.length === 0 && delete t.leadingComments, i.length && (e.leadingComments = i), r.length && (e.trailingComments = [...r, ...e.trailingComments ?? []]);
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
for (let s = this._newComments.length - 1; s >= 0; s--) {
|
|
325
|
-
const a = this._newComments[s];
|
|
326
|
-
e.range[0] >= a.range[0] && (i.unshift(a), this._newComments.splice(s, 1));
|
|
327
|
-
}
|
|
328
|
-
i.length && (e.leadingComments = i);
|
|
329
|
-
}
|
|
330
|
-
attachComments(e) {
|
|
331
|
-
if (Ze(e) && e.body.length > 0) {
|
|
332
|
-
const t = this._nodeStack.at(-1);
|
|
333
|
-
if (t) {
|
|
334
|
-
t.trailingComments = [...t.trailingComments ?? [], ...this._newComments], this._newComments.length = 0, this._nodeStack.pop();
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
e.trailingComments = [...this._newComments], this._newComments.length = 0;
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
this.attachTrailingComments(e), this.attachLeadingComments(e), this.insertInnerComments(e), this._nodeStack.push(e);
|
|
341
|
-
}
|
|
342
|
-
collectComment(e) {
|
|
343
|
-
this.comments.push(e), this._newComments.push(e);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
const ut = /\$\{(.*?)\}/gu;
|
|
347
|
-
function he(n, e) {
|
|
348
|
-
const t = je[n];
|
|
349
|
-
return e ? t.replace(ut, (i, r) => e[r]?.toString() ?? "") : t;
|
|
350
|
-
}
|
|
351
|
-
class _e {
|
|
352
|
-
constructor(e = !1) {
|
|
353
|
-
this.tolerant = e, this.errors = [];
|
|
354
|
-
}
|
|
355
|
-
recordError(e) {
|
|
356
|
-
this.errors.push(e);
|
|
357
|
-
}
|
|
358
|
-
tolerate(e) {
|
|
359
|
-
if (this.tolerant)
|
|
360
|
-
this.recordError(e);
|
|
361
|
-
else
|
|
362
|
-
throw e;
|
|
363
|
-
}
|
|
364
|
-
throwError(e) {
|
|
365
|
-
throw e.description ??= he(e.code, e.data), new z(e);
|
|
366
|
-
}
|
|
367
|
-
tolerateError(e) {
|
|
368
|
-
e.description ??= he(e.code, e.data);
|
|
369
|
-
const t = new z(e);
|
|
370
|
-
if (this.tolerant)
|
|
371
|
-
this.recordError(t);
|
|
372
|
-
else
|
|
373
|
-
throw t;
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
function ye(n, e) {
|
|
377
|
-
if (!n)
|
|
378
|
-
throw new Error(`ASSERT: ${e}`);
|
|
379
|
-
}
|
|
380
|
-
const Be = {
|
|
381
|
-
// Unicode v12.1.0 NonAsciiIdentifierStart:
|
|
382
|
-
NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEF\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7C6\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB67\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/u,
|
|
383
|
-
// Unicode v12.1.0 NonAsciiIdentifierPart:
|
|
384
|
-
NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05EF-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u07FD\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D3-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u09FE\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1878\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CD0-\u1CD2\u1CD4-\u1CFA\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEF\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7C6\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB67\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD27\uDD30-\uDD39\uDF00-\uDF1C\uDF27\uDF30-\uDF50\uDFE0-\uDFF6]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD44-\uDD46\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDC9-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3B-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC5E\uDC5F\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB8\uDEC0-\uDEC9\uDF00-\uDF1A\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDC00-\uDC3A\uDCA0-\uDCE9\uDCFF\uDDA0-\uDDA7\uDDAA-\uDDD7\uDDDA-\uDDE1\uDDE3\uDDE4\uDE00-\uDE3E\uDE47\uDE50-\uDE99\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD8E\uDD90\uDD91\uDD93-\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF6]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF4F-\uDF87\uDF8F-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDD00-\uDD2C\uDD30-\uDD3D\uDD40-\uDD49\uDD4E\uDEC0-\uDEF9]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/u
|
|
385
|
-
}, m = {
|
|
386
|
-
fromCodePoint(n) {
|
|
387
|
-
return n < 65536 ? String.fromCharCode(n) : String.fromCharCode(55296 + (n - 65536 >> 10)) + String.fromCharCode(56320 + (n - 65536 & 1023));
|
|
388
|
-
},
|
|
389
|
-
// https://tc39.github.io/ecma262/#sec-white-space
|
|
390
|
-
isWhiteSpace(n) {
|
|
391
|
-
return n === 32 || n === 9 || n === 11 || n === 12 || n === 160 || n >= 5760 && [
|
|
392
|
-
5760,
|
|
393
|
-
8192,
|
|
394
|
-
8193,
|
|
395
|
-
8194,
|
|
396
|
-
8195,
|
|
397
|
-
8196,
|
|
398
|
-
8197,
|
|
399
|
-
8198,
|
|
400
|
-
8199,
|
|
401
|
-
8200,
|
|
402
|
-
8201,
|
|
403
|
-
8202,
|
|
404
|
-
8239,
|
|
405
|
-
8287,
|
|
406
|
-
12288,
|
|
407
|
-
65279
|
|
408
|
-
].includes(n);
|
|
409
|
-
},
|
|
410
|
-
// https://tc39.github.io/ecma262/#sec-line-terminators
|
|
411
|
-
isLineTerminator(n) {
|
|
412
|
-
return n === 10 || n === 13 || n === 8232 || n === 8233;
|
|
413
|
-
},
|
|
414
|
-
// https://tc39.github.io/ecma262/#sec-names-and-keywords
|
|
415
|
-
isIdentifierStart(n) {
|
|
416
|
-
return n === 36 || n === 95 || // $ (dollar) and _ (underscore)
|
|
417
|
-
n >= 65 && n <= 90 || // A..Z
|
|
418
|
-
n >= 97 && n <= 122 || // a..z
|
|
419
|
-
n === 92 || // \ (backslash)
|
|
420
|
-
n >= 128 && Be.NonAsciiIdentifierStart.test(m.fromCodePoint(n));
|
|
421
|
-
},
|
|
422
|
-
isIdentifierPart(n) {
|
|
423
|
-
return n === 36 || n === 95 || // $ (dollar) and _ (underscore)
|
|
424
|
-
n >= 65 && n <= 90 || // A..Z
|
|
425
|
-
n >= 97 && n <= 122 || // a..z
|
|
426
|
-
n >= 48 && n <= 57 || // 0..9
|
|
427
|
-
n === 92 || // \ (backslash)
|
|
428
|
-
n >= 128 && Be.NonAsciiIdentifierPart.test(m.fromCodePoint(n));
|
|
429
|
-
},
|
|
430
|
-
// https://tc39.github.io/ecma262/#sec-literals-numeric-literals
|
|
431
|
-
isDecimalDigit(n) {
|
|
432
|
-
return n >= 48 && n <= 57;
|
|
433
|
-
},
|
|
434
|
-
isHexDigit(n) {
|
|
435
|
-
return n >= 48 && n <= 57 || // 0..9
|
|
436
|
-
n >= 65 && n <= 70 || // A..F
|
|
437
|
-
n >= 97 && n <= 102;
|
|
438
|
-
},
|
|
439
|
-
isOctalDigit(n) {
|
|
440
|
-
return n >= 48 && n <= 55;
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
function Se(n) {
|
|
444
|
-
return "0123456789abcdef".indexOf(n.toLowerCase());
|
|
445
|
-
}
|
|
446
|
-
function ne(n) {
|
|
447
|
-
return "01234567".indexOf(n);
|
|
448
|
-
}
|
|
449
|
-
const N = [[], [], []];
|
|
450
|
-
ue.forEach((n) => N[n.length - 1].push(n));
|
|
451
|
-
Ne.forEach((n) => N[n.length - 1].push(n));
|
|
452
|
-
Ue.forEach((n) => N[n.length - 1].push(n));
|
|
453
|
-
Me.forEach((n) => N[n.length - 1].push(n));
|
|
454
|
-
Qe.forEach((n) => N[n.length - 1].push(n));
|
|
455
|
-
N[w.length - 1].push(w);
|
|
456
|
-
class $e {
|
|
457
|
-
constructor(e, t) {
|
|
458
|
-
this.source = e, this.errorHandler = t, this._length = e.length, this.index = 0, this.lineNumber = 1, this.lineStart = 0, this.curlyStack = [];
|
|
459
|
-
}
|
|
460
|
-
saveState() {
|
|
461
|
-
return {
|
|
462
|
-
index: this.index,
|
|
463
|
-
lineNumber: this.lineNumber,
|
|
464
|
-
lineStart: this.lineStart,
|
|
465
|
-
curlyStack: this.curlyStack.slice()
|
|
466
|
-
};
|
|
467
|
-
}
|
|
468
|
-
restoreState(e) {
|
|
469
|
-
this.index = e.index, this.lineNumber = e.lineNumber, this.lineStart = e.lineStart, this.curlyStack = e.curlyStack;
|
|
470
|
-
}
|
|
471
|
-
eof() {
|
|
472
|
-
return this.index >= this._length;
|
|
473
|
-
}
|
|
474
|
-
throwUnexpectedToken(e = h.UnexpectedToken) {
|
|
475
|
-
this.errorHandler.throwError({
|
|
476
|
-
code: e,
|
|
477
|
-
index: this.index,
|
|
478
|
-
line: this.lineNumber,
|
|
479
|
-
column: this.index - this.lineStart + 1,
|
|
480
|
-
data: { value: this.source.charAt(this.index) }
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
tolerateUnexpectedToken(e = h.UnexpectedToken) {
|
|
484
|
-
this.errorHandler.tolerateError({
|
|
485
|
-
code: e,
|
|
486
|
-
index: this.index,
|
|
487
|
-
line: this.lineNumber,
|
|
488
|
-
column: this.index - this.lineStart + 1
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
skipSingleLineComment(e) {
|
|
492
|
-
const t = [], i = this.index - e, r = {
|
|
493
|
-
start: {
|
|
494
|
-
line: this.lineNumber,
|
|
495
|
-
column: this.index - this.lineStart - e
|
|
496
|
-
},
|
|
497
|
-
end: { line: 0, column: 0 }
|
|
498
|
-
// Fake for now
|
|
499
|
-
};
|
|
500
|
-
for (; !this.eof(); ) {
|
|
501
|
-
const a = this.source.charCodeAt(this.index);
|
|
502
|
-
if (this.index += 1, m.isLineTerminator(a)) {
|
|
503
|
-
r.end = {
|
|
504
|
-
line: this.lineNumber,
|
|
505
|
-
column: this.index - this.lineStart - 1
|
|
506
|
-
};
|
|
507
|
-
const o = {
|
|
508
|
-
multiLine: !1,
|
|
509
|
-
start: i + e,
|
|
510
|
-
end: this.index - 1,
|
|
511
|
-
range: [i, this.index - 1],
|
|
512
|
-
loc: r
|
|
513
|
-
};
|
|
514
|
-
return t.push(o), a === 13 && this.source.charCodeAt(this.index) === 10 && (this.index += 1), this.lineNumber += 1, this.lineStart = this.index, t;
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
r.end = {
|
|
518
|
-
line: this.lineNumber,
|
|
519
|
-
column: this.index - this.lineStart
|
|
520
|
-
};
|
|
521
|
-
const s = {
|
|
522
|
-
multiLine: !1,
|
|
523
|
-
start: i + e,
|
|
524
|
-
end: this.index,
|
|
525
|
-
range: [i, this.index],
|
|
526
|
-
loc: r
|
|
527
|
-
};
|
|
528
|
-
return t.push(s), t;
|
|
529
|
-
}
|
|
530
|
-
skipMultiLineComment() {
|
|
531
|
-
const e = [], t = this.index - 2, i = {
|
|
532
|
-
start: {
|
|
533
|
-
line: this.lineNumber,
|
|
534
|
-
column: this.index - this.lineStart - 2
|
|
535
|
-
},
|
|
536
|
-
end: { line: 0, column: 0 }
|
|
537
|
-
// Fake for now
|
|
538
|
-
};
|
|
539
|
-
for (; !this.eof(); ) {
|
|
540
|
-
const s = this.source.charCodeAt(this.index);
|
|
541
|
-
if (m.isLineTerminator(s))
|
|
542
|
-
s === 13 && this.source.charCodeAt(this.index + 1) === 10 && (this.index += 1), this.lineNumber += 1, this.index += 1, this.lineStart = this.index;
|
|
543
|
-
else if (s === 42) {
|
|
544
|
-
if (this.source.charCodeAt(this.index + 1) === 47) {
|
|
545
|
-
this.index += 2, i.end = {
|
|
546
|
-
line: this.lineNumber,
|
|
547
|
-
column: this.index - this.lineStart
|
|
548
|
-
};
|
|
549
|
-
const a = {
|
|
550
|
-
multiLine: !0,
|
|
551
|
-
start: t + 2,
|
|
552
|
-
end: this.index - 2,
|
|
553
|
-
range: [t, this.index],
|
|
554
|
-
loc: i
|
|
555
|
-
};
|
|
556
|
-
return e.push(a), e;
|
|
557
|
-
}
|
|
558
|
-
this.index += 1;
|
|
559
|
-
} else
|
|
560
|
-
this.index += 1;
|
|
561
|
-
}
|
|
562
|
-
i.end = {
|
|
563
|
-
line: this.lineNumber,
|
|
564
|
-
column: this.index - this.lineStart
|
|
565
|
-
};
|
|
566
|
-
const r = {
|
|
567
|
-
multiLine: !0,
|
|
568
|
-
start: t + 2,
|
|
569
|
-
end: this.index,
|
|
570
|
-
range: [t, this.index],
|
|
571
|
-
loc: i
|
|
572
|
-
};
|
|
573
|
-
return e.push(r), this.tolerateUnexpectedToken(), e;
|
|
574
|
-
}
|
|
575
|
-
scanComments() {
|
|
576
|
-
let e = [];
|
|
577
|
-
for (; !this.eof(); ) {
|
|
578
|
-
let t = this.source.charCodeAt(this.index);
|
|
579
|
-
if (m.isWhiteSpace(t))
|
|
580
|
-
this.index += 1;
|
|
581
|
-
else if (m.isLineTerminator(t))
|
|
582
|
-
this.index += 1, t === 13 && this.source.charCodeAt(this.index) === 10 && (this.index += 1), this.lineNumber += 1, this.lineStart = this.index;
|
|
583
|
-
else if (t === 47)
|
|
584
|
-
if (t = this.source.charCodeAt(this.index + 1), t === 47) {
|
|
585
|
-
this.index += 2;
|
|
586
|
-
const i = this.skipSingleLineComment(2);
|
|
587
|
-
e = [...e, ...i];
|
|
588
|
-
} else if (t === 42) {
|
|
589
|
-
this.index += 2;
|
|
590
|
-
const i = this.skipMultiLineComment();
|
|
591
|
-
e = [...e, ...i];
|
|
592
|
-
} else
|
|
593
|
-
break;
|
|
594
|
-
else
|
|
595
|
-
break;
|
|
596
|
-
}
|
|
597
|
-
return e;
|
|
598
|
-
}
|
|
599
|
-
isKeyword(e) {
|
|
600
|
-
switch (e = e.toLowerCase(), e.length) {
|
|
601
|
-
case 2:
|
|
602
|
-
return e === f.If || e === f.In;
|
|
603
|
-
case 3:
|
|
604
|
-
return e === f.Var || e === f.For;
|
|
605
|
-
case 4:
|
|
606
|
-
return e === f.Else;
|
|
607
|
-
case 5:
|
|
608
|
-
return e === f.Break || e === f.While;
|
|
609
|
-
case 6:
|
|
610
|
-
return e === f.Return || e === f.Import || e === f.Export;
|
|
611
|
-
case 8:
|
|
612
|
-
return e === f.Function || e === f.Continue;
|
|
613
|
-
default:
|
|
614
|
-
return !1;
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
codePointAt(e) {
|
|
618
|
-
let t = this.source.charCodeAt(e);
|
|
619
|
-
if (t >= 55296 && t <= 56319) {
|
|
620
|
-
const i = this.source.charCodeAt(e + 1);
|
|
621
|
-
i >= 56320 && i <= 57343 && (t = (t - 55296) * 1024 + i - 56320 + 65536);
|
|
622
|
-
}
|
|
623
|
-
return t;
|
|
624
|
-
}
|
|
625
|
-
scanHexEscape(e) {
|
|
626
|
-
const t = e === "u" ? 4 : 2;
|
|
627
|
-
let i = 0;
|
|
628
|
-
for (let r = 0; r < t; r++)
|
|
629
|
-
if (!this.eof() && m.isHexDigit(this.source.charCodeAt(this.index)))
|
|
630
|
-
i = i * 16 + Se(this.source[this.index] ?? ""), this.index += 1;
|
|
631
|
-
else
|
|
632
|
-
return null;
|
|
633
|
-
return String.fromCharCode(i);
|
|
634
|
-
}
|
|
635
|
-
scanUnicodeCodePointEscape() {
|
|
636
|
-
let e = this.source[this.index], t = 0;
|
|
637
|
-
for (e === "}" && this.throwUnexpectedToken(); !this.eof() && (e = this.source[this.index] ?? "", this.index += 1, !!m.isHexDigit(e.charCodeAt(0))); )
|
|
638
|
-
t = t * 16 + Se(e);
|
|
639
|
-
return (t > 1114111 || e !== "}") && this.throwUnexpectedToken(), m.fromCodePoint(t);
|
|
640
|
-
}
|
|
641
|
-
getIdentifier() {
|
|
642
|
-
const e = this.index;
|
|
643
|
-
for (this.index += 1; !this.eof(); ) {
|
|
644
|
-
const t = this.source.charCodeAt(this.index);
|
|
645
|
-
if (t === 92)
|
|
646
|
-
return this.index = e, this.getComplexIdentifier();
|
|
647
|
-
if (t >= 55296 && t < 57343)
|
|
648
|
-
return this.index = e, this.getComplexIdentifier();
|
|
649
|
-
if (m.isIdentifierPart(t))
|
|
650
|
-
this.index += 1;
|
|
651
|
-
else
|
|
652
|
-
break;
|
|
653
|
-
}
|
|
654
|
-
return this.source.slice(e, this.index);
|
|
655
|
-
}
|
|
656
|
-
getComplexIdentifier() {
|
|
657
|
-
let e = this.codePointAt(this.index), t = m.fromCodePoint(e);
|
|
658
|
-
this.index += t.length;
|
|
659
|
-
let i;
|
|
660
|
-
for (e === 92 && (this.source.charCodeAt(this.index) !== 117 && this.throwUnexpectedToken(), this.index += 1, this.source[this.index] === "{" ? (this.index += 1, i = this.scanUnicodeCodePointEscape()) : (i = this.scanHexEscape("u"), (i === null || i === "\\" || !m.isIdentifierStart(i.charCodeAt(0))) && this.throwUnexpectedToken()), t = i); !this.eof() && (e = this.codePointAt(this.index), !!m.isIdentifierPart(e)); )
|
|
661
|
-
i = m.fromCodePoint(e), t += i, this.index += i.length, e === 92 && (t = t.substring(0, t.length - 1), this.source.charCodeAt(this.index) !== 117 && this.throwUnexpectedToken(), this.index += 1, this.source[this.index] === "{" ? (this.index += 1, i = this.scanUnicodeCodePointEscape()) : (i = this.scanHexEscape("u"), (i === null || i === "\\" || !m.isIdentifierPart(i.charCodeAt(0))) && this.throwUnexpectedToken()), t += i);
|
|
662
|
-
return t;
|
|
663
|
-
}
|
|
664
|
-
octalToDecimal(e) {
|
|
665
|
-
let t = e !== "0", i = ne(e);
|
|
666
|
-
return !this.eof() && m.isOctalDigit(this.source.charCodeAt(this.index)) && (t = !0, i = i * 8 + ne(this.source[this.index] ?? ""), this.index += 1, "0123".includes(e) && !this.eof() && m.isOctalDigit(this.source.charCodeAt(this.index)) && (i = i * 8 + ne(this.source[this.index] ?? ""), this.index += 1)), { code: i, octal: t };
|
|
667
|
-
}
|
|
668
|
-
// https://tc39.github.io/ecma262/#sec-names-and-keywords
|
|
669
|
-
scanIdentifier() {
|
|
670
|
-
let e;
|
|
671
|
-
const t = this.index, i = this.source.charCodeAt(t) === 92 ? this.getComplexIdentifier() : this.getIdentifier();
|
|
672
|
-
if (i.length === 1 ? e = l.Identifier : this.isKeyword(i) ? e = l.Keyword : i.toLowerCase() === V.Null ? e = l.NullLiteral : i.toLowerCase() === V.True || i.toLowerCase() === V.False ? e = l.BooleanLiteral : e = l.Identifier, e !== l.Identifier && t + i.length !== this.index) {
|
|
673
|
-
const r = this.index;
|
|
674
|
-
this.index = t, this.tolerateUnexpectedToken(h.InvalidEscapedReservedWord), this.index = r;
|
|
675
|
-
}
|
|
676
|
-
return {
|
|
677
|
-
type: e,
|
|
678
|
-
value: i,
|
|
679
|
-
lineNumber: this.lineNumber,
|
|
680
|
-
lineStart: this.lineStart,
|
|
681
|
-
start: t,
|
|
682
|
-
end: this.index
|
|
683
|
-
};
|
|
684
|
-
}
|
|
685
|
-
// https://tc39.github.io/ecma262/#sec-punctuators
|
|
686
|
-
scanPunctuator() {
|
|
687
|
-
const e = this.index;
|
|
688
|
-
let t = this.source[this.index] ?? "";
|
|
689
|
-
switch (t) {
|
|
690
|
-
case "(":
|
|
691
|
-
case "{":
|
|
692
|
-
t === "{" && this.curlyStack.push("{"), this.index += 1;
|
|
693
|
-
break;
|
|
694
|
-
case ".":
|
|
695
|
-
this.index += 1;
|
|
696
|
-
break;
|
|
697
|
-
case "}":
|
|
698
|
-
this.index += 1, this.curlyStack.pop();
|
|
699
|
-
break;
|
|
700
|
-
case ")":
|
|
701
|
-
case ";":
|
|
702
|
-
case ",":
|
|
703
|
-
case "[":
|
|
704
|
-
case "]":
|
|
705
|
-
case ":":
|
|
706
|
-
case "~":
|
|
707
|
-
this.index += 1;
|
|
708
|
-
break;
|
|
709
|
-
default:
|
|
710
|
-
for (let i = N.length; i > 0; i--)
|
|
711
|
-
if (t = this.source.substring(this.index, this.index + i), N[i - 1]?.includes(t)) {
|
|
712
|
-
this.index += i;
|
|
713
|
-
break;
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
return this.index === e && this.throwUnexpectedToken(), {
|
|
717
|
-
type: l.Punctuator,
|
|
718
|
-
value: t,
|
|
719
|
-
lineNumber: this.lineNumber,
|
|
720
|
-
lineStart: this.lineStart,
|
|
721
|
-
start: e,
|
|
722
|
-
end: this.index
|
|
723
|
-
};
|
|
724
|
-
}
|
|
725
|
-
// https://tc39.github.io/ecma262/#sec-literals-numeric-literals
|
|
726
|
-
scanHexLiteral(e) {
|
|
727
|
-
let t = "";
|
|
728
|
-
for (; !this.eof() && m.isHexDigit(this.source.charCodeAt(this.index)); )
|
|
729
|
-
t += this.source[this.index], this.index += 1;
|
|
730
|
-
return t.length === 0 && this.throwUnexpectedToken(), m.isIdentifierStart(this.source.charCodeAt(this.index)) && this.throwUnexpectedToken(), {
|
|
731
|
-
type: l.NumericLiteral,
|
|
732
|
-
value: Number.parseInt(`0x${t}`, 16),
|
|
733
|
-
lineNumber: this.lineNumber,
|
|
734
|
-
lineStart: this.lineStart,
|
|
735
|
-
start: e,
|
|
736
|
-
end: this.index
|
|
737
|
-
};
|
|
738
|
-
}
|
|
739
|
-
scanBinaryLiteral(e) {
|
|
740
|
-
let t = "";
|
|
741
|
-
for (; !this.eof(); ) {
|
|
742
|
-
const i = this.source[this.index];
|
|
743
|
-
if (i !== "0" && i !== "1")
|
|
744
|
-
break;
|
|
745
|
-
t += this.source[this.index], this.index += 1;
|
|
746
|
-
}
|
|
747
|
-
if (t.length === 0 && this.throwUnexpectedToken(), !this.eof()) {
|
|
748
|
-
const i = this.source.charCodeAt(this.index);
|
|
749
|
-
(m.isIdentifierStart(i) || m.isDecimalDigit(i)) && this.throwUnexpectedToken();
|
|
750
|
-
}
|
|
751
|
-
return {
|
|
752
|
-
type: l.NumericLiteral,
|
|
753
|
-
value: Number.parseInt(t, 2),
|
|
754
|
-
lineNumber: this.lineNumber,
|
|
755
|
-
lineStart: this.lineStart,
|
|
756
|
-
start: e,
|
|
757
|
-
end: this.index
|
|
758
|
-
};
|
|
759
|
-
}
|
|
760
|
-
scanOctalLiteral(e, t) {
|
|
761
|
-
let i = "", r = !1;
|
|
762
|
-
for (m.isOctalDigit(e.charCodeAt(0)) && (r = !0, i = `0${this.source[this.index]}`), this.index += 1; !this.eof() && m.isOctalDigit(this.source.charCodeAt(this.index)); )
|
|
763
|
-
i += this.source[this.index], this.index += 1;
|
|
764
|
-
return !r && i.length === 0 && this.throwUnexpectedToken(), (m.isIdentifierStart(this.source.charCodeAt(this.index)) || m.isDecimalDigit(this.source.charCodeAt(this.index))) && this.throwUnexpectedToken(), {
|
|
765
|
-
type: l.NumericLiteral,
|
|
766
|
-
value: Number.parseInt(i, 8),
|
|
767
|
-
lineNumber: this.lineNumber,
|
|
768
|
-
lineStart: this.lineStart,
|
|
769
|
-
start: t,
|
|
770
|
-
end: this.index
|
|
771
|
-
};
|
|
772
|
-
}
|
|
773
|
-
scanNumericLiteral() {
|
|
774
|
-
const e = this.index;
|
|
775
|
-
let t = this.source[e] ?? "";
|
|
776
|
-
ye(
|
|
777
|
-
m.isDecimalDigit(t.charCodeAt(0)) || t === ".",
|
|
778
|
-
"Numeric literal must start with a decimal digit or a decimal point"
|
|
779
|
-
);
|
|
780
|
-
let i = "";
|
|
781
|
-
if (t !== ".") {
|
|
782
|
-
if (i = this.source[this.index] ?? "", this.index += 1, t = this.source[this.index] ?? "", i === "0") {
|
|
783
|
-
if (t === "x" || t === "X")
|
|
784
|
-
return this.index += 1, this.scanHexLiteral(e);
|
|
785
|
-
if (t === "b" || t === "B")
|
|
786
|
-
return this.index += 1, this.scanBinaryLiteral(e);
|
|
787
|
-
if (t === "o" || t === "O")
|
|
788
|
-
return this.scanOctalLiteral(t, e);
|
|
789
|
-
}
|
|
790
|
-
for (; m.isDecimalDigit(this.source.charCodeAt(this.index)); )
|
|
791
|
-
i += this.source[this.index], this.index += 1;
|
|
792
|
-
t = this.source[this.index] ?? "";
|
|
793
|
-
}
|
|
794
|
-
if (t === ".") {
|
|
795
|
-
for (i += this.source[this.index], this.index += 1; m.isDecimalDigit(this.source.charCodeAt(this.index)); )
|
|
796
|
-
i += this.source[this.index], this.index += 1;
|
|
797
|
-
t = this.source[this.index] ?? "";
|
|
798
|
-
}
|
|
799
|
-
if (t === "e" || t === "E")
|
|
800
|
-
if (i += this.source[this.index], this.index += 1, t = this.source[this.index] ?? "", (t === "+" || t === "-") && (i += this.source[this.index], this.index += 1), m.isDecimalDigit(this.source.charCodeAt(this.index)))
|
|
801
|
-
for (; m.isDecimalDigit(this.source.charCodeAt(this.index)); )
|
|
802
|
-
i += this.source[this.index], this.index += 1;
|
|
803
|
-
else
|
|
804
|
-
this.throwUnexpectedToken();
|
|
805
|
-
return m.isIdentifierStart(this.source.charCodeAt(this.index)) && this.throwUnexpectedToken(), {
|
|
806
|
-
type: l.NumericLiteral,
|
|
807
|
-
value: Number.parseFloat(i),
|
|
808
|
-
lineNumber: this.lineNumber,
|
|
809
|
-
lineStart: this.lineStart,
|
|
810
|
-
start: e,
|
|
811
|
-
end: this.index
|
|
812
|
-
};
|
|
813
|
-
}
|
|
814
|
-
scanStringLiteral() {
|
|
815
|
-
const e = this.index;
|
|
816
|
-
let t = this.source[e];
|
|
817
|
-
ye(t === "'" || t === '"', "String literal must starts with a quote"), this.index += 1;
|
|
818
|
-
let i = !1, r = "";
|
|
819
|
-
for (; !this.eof(); ) {
|
|
820
|
-
let s = this.source[this.index] ?? "";
|
|
821
|
-
if (this.index += 1, s === t) {
|
|
822
|
-
t = "";
|
|
823
|
-
break;
|
|
824
|
-
}
|
|
825
|
-
if (s === "\\")
|
|
826
|
-
if (s = this.source[this.index] ?? "", this.index += 1, !s || !m.isLineTerminator(s.charCodeAt(0)))
|
|
827
|
-
switch (s) {
|
|
828
|
-
case "u":
|
|
829
|
-
if (this.source[this.index] === "{")
|
|
830
|
-
this.index += 1, r += this.scanUnicodeCodePointEscape();
|
|
831
|
-
else {
|
|
832
|
-
const a = this.scanHexEscape(s);
|
|
833
|
-
a === null && this.throwUnexpectedToken(), r += a;
|
|
834
|
-
}
|
|
835
|
-
break;
|
|
836
|
-
case "x": {
|
|
837
|
-
const a = this.scanHexEscape(s);
|
|
838
|
-
a === null && this.throwUnexpectedToken(h.InvalidHexEscapeSequence), r += a;
|
|
839
|
-
break;
|
|
840
|
-
}
|
|
841
|
-
case "n":
|
|
842
|
-
r += `
|
|
843
|
-
`;
|
|
844
|
-
break;
|
|
845
|
-
case "r":
|
|
846
|
-
r += "\r";
|
|
847
|
-
break;
|
|
848
|
-
case "t":
|
|
849
|
-
r += " ";
|
|
850
|
-
break;
|
|
851
|
-
case "b":
|
|
852
|
-
r += "\b";
|
|
853
|
-
break;
|
|
854
|
-
case "f":
|
|
855
|
-
r += "\f";
|
|
856
|
-
break;
|
|
857
|
-
case "v":
|
|
858
|
-
r += "\v";
|
|
859
|
-
break;
|
|
860
|
-
case "8":
|
|
861
|
-
case "9":
|
|
862
|
-
r += s, this.tolerateUnexpectedToken();
|
|
863
|
-
break;
|
|
864
|
-
default:
|
|
865
|
-
if (s && m.isOctalDigit(s.charCodeAt(0))) {
|
|
866
|
-
const a = this.octalToDecimal(s);
|
|
867
|
-
i = a.octal || i, r += String.fromCharCode(a.code);
|
|
868
|
-
} else
|
|
869
|
-
r += s;
|
|
870
|
-
break;
|
|
871
|
-
}
|
|
872
|
-
else
|
|
873
|
-
this.lineNumber += 1, s === "\r" && this.source[this.index] === `
|
|
874
|
-
` && (this.index += 1), this.lineStart = this.index;
|
|
875
|
-
else {
|
|
876
|
-
if (m.isLineTerminator(s.charCodeAt(0)))
|
|
877
|
-
break;
|
|
878
|
-
r += s;
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
return t !== "" && (this.index = e, this.throwUnexpectedToken()), {
|
|
882
|
-
type: l.StringLiteral,
|
|
883
|
-
value: r,
|
|
884
|
-
lineNumber: this.lineNumber,
|
|
885
|
-
lineStart: this.lineStart,
|
|
886
|
-
start: e,
|
|
887
|
-
end: this.index
|
|
888
|
-
};
|
|
889
|
-
}
|
|
890
|
-
scanTemplate() {
|
|
891
|
-
let e = "", t = !1;
|
|
892
|
-
const i = this.index, r = this.source[i] === "`";
|
|
893
|
-
let s = !1, a = 2;
|
|
894
|
-
for (this.index += 1; !this.eof(); ) {
|
|
895
|
-
let o = this.source[this.index] ?? "";
|
|
896
|
-
if (this.index += 1, o === "`") {
|
|
897
|
-
a = 1, s = !0, t = !0;
|
|
898
|
-
break;
|
|
899
|
-
}
|
|
900
|
-
if (o === "$") {
|
|
901
|
-
if (this.source[this.index] === "{") {
|
|
902
|
-
this.curlyStack.push("${"), this.index += 1, t = !0;
|
|
903
|
-
break;
|
|
904
|
-
}
|
|
905
|
-
e += o;
|
|
906
|
-
continue;
|
|
907
|
-
}
|
|
908
|
-
if (o === "\\") {
|
|
909
|
-
if (o = this.source[this.index] ?? "", this.index += 1, m.isLineTerminator(o.charCodeAt(0)))
|
|
910
|
-
this.lineNumber += 1, o === "\r" && this.source[this.index] === `
|
|
911
|
-
` && (this.index += 1), this.lineStart = this.index;
|
|
912
|
-
else
|
|
913
|
-
switch (o) {
|
|
914
|
-
case "n":
|
|
915
|
-
e += `
|
|
916
|
-
`;
|
|
917
|
-
break;
|
|
918
|
-
case "r":
|
|
919
|
-
e += "\r";
|
|
920
|
-
break;
|
|
921
|
-
case "t":
|
|
922
|
-
e += " ";
|
|
923
|
-
break;
|
|
924
|
-
case "u":
|
|
925
|
-
if (this.source[this.index] === "{")
|
|
926
|
-
this.index += 1, e += this.scanUnicodeCodePointEscape();
|
|
927
|
-
else {
|
|
928
|
-
const c = this.index, d = this.scanHexEscape(o);
|
|
929
|
-
d !== null ? e += d : (this.index = c, e += o);
|
|
930
|
-
}
|
|
931
|
-
break;
|
|
932
|
-
case "x": {
|
|
933
|
-
const c = this.scanHexEscape(o);
|
|
934
|
-
c === null && this.throwUnexpectedToken(h.InvalidHexEscapeSequence), e += c;
|
|
935
|
-
break;
|
|
936
|
-
}
|
|
937
|
-
case "b":
|
|
938
|
-
e += "\b";
|
|
939
|
-
break;
|
|
940
|
-
case "f":
|
|
941
|
-
e += "\f";
|
|
942
|
-
break;
|
|
943
|
-
case "v":
|
|
944
|
-
e += "\v";
|
|
945
|
-
break;
|
|
946
|
-
default:
|
|
947
|
-
o === "0" ? (m.isDecimalDigit(this.source.charCodeAt(this.index)) && this.throwUnexpectedToken(h.TemplateOctalLiteral), e += "\0") : m.isOctalDigit(o.charCodeAt(0)) ? this.throwUnexpectedToken(h.TemplateOctalLiteral) : e += o;
|
|
948
|
-
break;
|
|
949
|
-
}
|
|
950
|
-
continue;
|
|
951
|
-
}
|
|
952
|
-
if (m.isLineTerminator(o.charCodeAt(0))) {
|
|
953
|
-
this.lineNumber += 1, o === "\r" && this.source[this.index] === `
|
|
954
|
-
` && (this.index += 1), this.lineStart = this.index, e += `
|
|
955
|
-
`;
|
|
956
|
-
continue;
|
|
957
|
-
}
|
|
958
|
-
e += o;
|
|
959
|
-
}
|
|
960
|
-
return t || this.throwUnexpectedToken(), r || this.curlyStack.pop(), {
|
|
961
|
-
type: l.Template,
|
|
962
|
-
value: this.source.slice(i + 1, this.index - a),
|
|
963
|
-
cooked: e,
|
|
964
|
-
head: r,
|
|
965
|
-
tail: s,
|
|
966
|
-
lineNumber: this.lineNumber,
|
|
967
|
-
lineStart: this.lineStart,
|
|
968
|
-
start: i,
|
|
969
|
-
end: this.index
|
|
970
|
-
};
|
|
971
|
-
}
|
|
972
|
-
lex() {
|
|
973
|
-
if (this.eof())
|
|
974
|
-
return {
|
|
975
|
-
type: l.EOF,
|
|
976
|
-
value: "",
|
|
977
|
-
lineNumber: this.lineNumber,
|
|
978
|
-
lineStart: this.lineStart,
|
|
979
|
-
start: this.index,
|
|
980
|
-
end: this.index
|
|
981
|
-
};
|
|
982
|
-
const e = this.source.charCodeAt(this.index);
|
|
983
|
-
return m.isIdentifierStart(e) ? this.scanIdentifier() : e === 40 || e === 41 || e === 59 ? this.scanPunctuator() : e === 39 || e === 34 ? this.scanStringLiteral() : e === 46 ? m.isDecimalDigit(this.source.charCodeAt(this.index + 1)) ? this.scanNumericLiteral() : this.scanPunctuator() : m.isDecimalDigit(e) ? this.scanNumericLiteral() : e === 96 || e === 125 && this.curlyStack[this.curlyStack.length - 1] === "${" ? this.scanTemplate() : e >= 55296 && e < 57343 && m.isIdentifierStart(this.codePointAt(this.index)) ? this.scanIdentifier() : this.scanPunctuator();
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
const y = {
|
|
987
|
-
None: 0,
|
|
988
|
-
Function: 1,
|
|
989
|
-
IfClause: 2,
|
|
990
|
-
ForLoop: 4,
|
|
991
|
-
ForOfLoop: 8,
|
|
992
|
-
WhileLoop: 16
|
|
993
|
-
}, re = {
|
|
994
|
-
AsObject: 0,
|
|
995
|
-
Automatic: 1
|
|
996
|
-
};
|
|
997
|
-
function Ie(n, e = 0) {
|
|
998
|
-
let t = n.start - n.lineStart, i = n.lineNumber;
|
|
999
|
-
return t < 0 && (t += e, i -= 1), { index: n.start, line: i, column: t };
|
|
1000
|
-
}
|
|
1001
|
-
function be(n) {
|
|
1002
|
-
return [
|
|
1003
|
-
{ index: n.range[0], ...n.loc.start },
|
|
1004
|
-
{ index: n.range[1], ...n.loc.end }
|
|
1005
|
-
];
|
|
1006
|
-
}
|
|
1007
|
-
function we(n) {
|
|
1008
|
-
return n in q ? q[n] : 0;
|
|
1009
|
-
}
|
|
1010
|
-
class at {
|
|
1011
|
-
constructor(e, t = {}, i) {
|
|
1012
|
-
this.delegate = i, this.hasLineTerminator = !1, this.options = {
|
|
1013
|
-
tokens: typeof t.tokens == "boolean" && t.tokens,
|
|
1014
|
-
comments: typeof t.comments == "boolean" && t.comments,
|
|
1015
|
-
tolerant: typeof t.tolerant == "boolean" && t.tolerant
|
|
1016
|
-
}, this.options.comments && (this.commentHandler = new st()), this.errorHandler = new _e(this.options.tolerant), this.scanner = new $e(e, this.errorHandler), this.context = {
|
|
1017
|
-
isAssignmentTarget: !1,
|
|
1018
|
-
blockContext: y.None,
|
|
1019
|
-
curlyParsingType: re.AsObject
|
|
1020
|
-
}, this.rawToken = {
|
|
1021
|
-
type: l.EOF,
|
|
1022
|
-
value: "",
|
|
1023
|
-
lineNumber: this.scanner.lineNumber,
|
|
1024
|
-
lineStart: 0,
|
|
1025
|
-
start: 0,
|
|
1026
|
-
end: 0
|
|
1027
|
-
}, this.tokens = [], this.startMarker = {
|
|
1028
|
-
index: 0,
|
|
1029
|
-
line: this.scanner.lineNumber,
|
|
1030
|
-
column: 0
|
|
1031
|
-
}, this.endMarker = {
|
|
1032
|
-
index: 0,
|
|
1033
|
-
line: this.scanner.lineNumber,
|
|
1034
|
-
column: 0
|
|
1035
|
-
}, this.readNextRawToken(), this.endMarker = {
|
|
1036
|
-
index: this.scanner.index,
|
|
1037
|
-
line: this.scanner.lineNumber,
|
|
1038
|
-
column: this.scanner.index - this.scanner.lineStart
|
|
1039
|
-
};
|
|
1040
|
-
}
|
|
1041
|
-
throwIfInvalidType(e, t, {
|
|
1042
|
-
validTypes: i,
|
|
1043
|
-
invalidTypes: r
|
|
1044
|
-
}) {
|
|
1045
|
-
i?.some((s) => e.type === s) || r?.some((s) => e.type === s) && this.throwError(h.InvalidExpression, t);
|
|
1046
|
-
}
|
|
1047
|
-
throwError(e, t, i = this.endMarker) {
|
|
1048
|
-
const { index: r, line: s, column: a } = t, o = i.index - r - 1;
|
|
1049
|
-
this.errorHandler.throwError({ code: e, index: r, line: s, column: a + 1, len: o });
|
|
1050
|
-
}
|
|
1051
|
-
tolerateError(e, t) {
|
|
1052
|
-
throw new Error("######################################### !!!");
|
|
1053
|
-
}
|
|
1054
|
-
// Throw an exception because of the token.
|
|
1055
|
-
unexpectedTokenError(e = {}) {
|
|
1056
|
-
const { rawToken: t } = e;
|
|
1057
|
-
let { code: i, data: r } = e, s;
|
|
1058
|
-
if (t) {
|
|
1059
|
-
if (!i)
|
|
1060
|
-
switch (t.type) {
|
|
1061
|
-
case l.EOF:
|
|
1062
|
-
i = h.UnexpectedEndOfScript;
|
|
1063
|
-
break;
|
|
1064
|
-
case l.Identifier:
|
|
1065
|
-
i = h.UnexpectedIdentifier;
|
|
1066
|
-
break;
|
|
1067
|
-
case l.NumericLiteral:
|
|
1068
|
-
i = h.UnexpectedNumber;
|
|
1069
|
-
break;
|
|
1070
|
-
case l.StringLiteral:
|
|
1071
|
-
i = h.UnexpectedString;
|
|
1072
|
-
break;
|
|
1073
|
-
case l.Template:
|
|
1074
|
-
i = h.UnexpectedTemplate;
|
|
1075
|
-
break;
|
|
1076
|
-
}
|
|
1077
|
-
s = t.value.toString();
|
|
1078
|
-
} else
|
|
1079
|
-
s = "ILLEGAL";
|
|
1080
|
-
i ??= h.UnexpectedToken, r ??= { value: s };
|
|
1081
|
-
const a = he(i, r);
|
|
1082
|
-
if (t) {
|
|
1083
|
-
const d = t.start, E = t.lineNumber, F = t.start - t.lineStart + 1;
|
|
1084
|
-
return new z({
|
|
1085
|
-
code: i,
|
|
1086
|
-
index: d,
|
|
1087
|
-
line: E,
|
|
1088
|
-
column: F,
|
|
1089
|
-
len: t.end - t.start - 1,
|
|
1090
|
-
data: r,
|
|
1091
|
-
description: a
|
|
1092
|
-
});
|
|
1093
|
-
}
|
|
1094
|
-
const { index: o, line: c } = this.endMarker;
|
|
1095
|
-
return new z({ code: i, index: o, line: c, column: this.endMarker.column + 1, data: r, description: a });
|
|
1096
|
-
}
|
|
1097
|
-
throwUnexpectedToken(e = {}) {
|
|
1098
|
-
throw e.rawToken ??= this.rawToken, this.unexpectedTokenError(e);
|
|
1099
|
-
}
|
|
1100
|
-
collectComments(e) {
|
|
1101
|
-
const { commentHandler: t } = this;
|
|
1102
|
-
!t || !e.length || e.forEach((i) => {
|
|
1103
|
-
const r = {
|
|
1104
|
-
type: i.multiLine ? u.BlockComment : u.LineComment,
|
|
1105
|
-
value: this.getSourceValue(i),
|
|
1106
|
-
range: i.range,
|
|
1107
|
-
loc: i.loc
|
|
1108
|
-
};
|
|
1109
|
-
t.collectComment(r);
|
|
1110
|
-
});
|
|
1111
|
-
}
|
|
1112
|
-
peekAhead(e) {
|
|
1113
|
-
const t = () => (this.scanner.scanComments(), this.scanner.lex()), i = this.scanner.saveState(), r = e.call(this, t);
|
|
1114
|
-
return this.scanner.restoreState(i), r;
|
|
1115
|
-
}
|
|
1116
|
-
getSourceValue(e) {
|
|
1117
|
-
return this.scanner.source.slice(e.start, e.end);
|
|
1118
|
-
}
|
|
1119
|
-
convertToToken(e) {
|
|
1120
|
-
return {
|
|
1121
|
-
type: Oe[e.type],
|
|
1122
|
-
value: this.getSourceValue(e),
|
|
1123
|
-
range: [e.start, e.end],
|
|
1124
|
-
loc: {
|
|
1125
|
-
start: {
|
|
1126
|
-
line: this.startMarker.line,
|
|
1127
|
-
column: this.startMarker.column
|
|
1128
|
-
},
|
|
1129
|
-
end: {
|
|
1130
|
-
line: this.scanner.lineNumber,
|
|
1131
|
-
column: this.scanner.index - this.scanner.lineStart
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
};
|
|
1135
|
-
}
|
|
1136
|
-
readNextRawToken() {
|
|
1137
|
-
this.endMarker.index = this.scanner.index, this.endMarker.line = this.scanner.lineNumber, this.endMarker.column = this.scanner.index - this.scanner.lineStart;
|
|
1138
|
-
const e = this.rawToken;
|
|
1139
|
-
this.collectComments(this.scanner.scanComments()), this.scanner.index !== this.startMarker.index && (this.startMarker.index = this.scanner.index, this.startMarker.line = this.scanner.lineNumber, this.startMarker.column = this.scanner.index - this.scanner.lineStart), this.rawToken = this.scanner.lex(), this.hasLineTerminator = e.lineNumber !== this.rawToken.lineNumber, this.options.tokens && this.rawToken.type !== l.EOF && this.tokens.push(this.convertToToken(this.rawToken));
|
|
1140
|
-
}
|
|
1141
|
-
captureStartMarker() {
|
|
1142
|
-
return {
|
|
1143
|
-
index: this.startMarker.index,
|
|
1144
|
-
line: this.startMarker.line,
|
|
1145
|
-
column: this.startMarker.column
|
|
1146
|
-
};
|
|
1147
|
-
}
|
|
1148
|
-
getItemLocation(e) {
|
|
1149
|
-
return {
|
|
1150
|
-
range: [e.index, this.endMarker.index],
|
|
1151
|
-
loc: {
|
|
1152
|
-
start: {
|
|
1153
|
-
line: e.line,
|
|
1154
|
-
column: e.column
|
|
1155
|
-
},
|
|
1156
|
-
end: {
|
|
1157
|
-
line: this.endMarker.line,
|
|
1158
|
-
column: this.endMarker.column
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
};
|
|
1162
|
-
}
|
|
1163
|
-
finalize(e) {
|
|
1164
|
-
return (this.delegate ?? this.commentHandler) && (this.commentHandler?.attachComments(e), this.delegate?.(e)), e;
|
|
1165
|
-
}
|
|
1166
|
-
expectPunctuator(e) {
|
|
1167
|
-
const t = this.rawToken;
|
|
1168
|
-
if (this.matchPunctuator(e)) {
|
|
1169
|
-
this.readNextRawToken();
|
|
1170
|
-
return;
|
|
1171
|
-
}
|
|
1172
|
-
this.throwUnexpectedToken({ rawToken: t, code: h.PunctuatorExpected, data: { value: e } });
|
|
1173
|
-
}
|
|
1174
|
-
expectKeyword(e) {
|
|
1175
|
-
if (this.rawToken.type === l.Keyword && this.rawToken.value.toLowerCase() === e.toString()) {
|
|
1176
|
-
this.readNextRawToken();
|
|
1177
|
-
return;
|
|
1178
|
-
}
|
|
1179
|
-
this.throwUnexpectedToken({ rawToken: this.rawToken });
|
|
1180
|
-
}
|
|
1181
|
-
expectContextualKeyword(e) {
|
|
1182
|
-
if (this.rawToken.type === l.Identifier && this.rawToken.value.toLowerCase() === e) {
|
|
1183
|
-
this.readNextRawToken();
|
|
1184
|
-
return;
|
|
1185
|
-
}
|
|
1186
|
-
this.throwUnexpectedToken({ rawToken: this.rawToken });
|
|
1187
|
-
}
|
|
1188
|
-
matchKeyword(e) {
|
|
1189
|
-
return this.rawToken.type === l.Keyword && this.rawToken.value.toLowerCase() === e;
|
|
1190
|
-
}
|
|
1191
|
-
matchContextualKeyword(e) {
|
|
1192
|
-
return this.rawToken.type === l.Identifier && this.rawToken.value === e;
|
|
1193
|
-
}
|
|
1194
|
-
matchPunctuator(e) {
|
|
1195
|
-
return this.rawToken.type === l.Punctuator && this.rawToken.value === e;
|
|
1196
|
-
}
|
|
1197
|
-
getMatchingPunctuator(e) {
|
|
1198
|
-
if (typeof e == "string" && (e = e.split("")), !(this.rawToken.type !== l.Punctuator || !e.length))
|
|
1199
|
-
return e.find(this.matchPunctuator.bind(this));
|
|
1200
|
-
}
|
|
1201
|
-
// Cover grammar support.
|
|
1202
|
-
//
|
|
1203
|
-
// When an assignment expression position starts with an left parenthesis, the determination of the type
|
|
1204
|
-
// of the syntax is to be deferred arbitrarily long until the end of the parentheses pair (plus a lookahead)
|
|
1205
|
-
// or the first comma. This situation also defers the determination of all the expressions nested in the pair.
|
|
1206
|
-
//
|
|
1207
|
-
// There are two productions that can be parsed in a parentheses pair that needs to be determined
|
|
1208
|
-
// after the outermost pair is closed. They are:
|
|
1209
|
-
//
|
|
1210
|
-
// 1. AssignmentExpression
|
|
1211
|
-
// 2. AssignmentTargets
|
|
1212
|
-
//
|
|
1213
|
-
// In order to avoid exponential backtracking, we use two flags to denote if the production can be
|
|
1214
|
-
// assignment target.
|
|
1215
|
-
//
|
|
1216
|
-
// The two productions have the relationship:
|
|
1217
|
-
//
|
|
1218
|
-
// AssignmentTargets ⊆ AssignmentExpression
|
|
1219
|
-
//
|
|
1220
|
-
// with a single exception that CoverInitializedName when used directly in an Expression, generates
|
|
1221
|
-
// an early error.
|
|
1222
|
-
//
|
|
1223
|
-
// isolateCoverGrammar function runs the given parser function with a new cover grammar context, and it does not
|
|
1224
|
-
// effect the current flags. This means the production the parser parses is only used as an expression. Therefore
|
|
1225
|
-
// the CoverInitializedName check is conducted.
|
|
1226
|
-
//
|
|
1227
|
-
// inheritCoverGrammar function runs the given parse function with a new cover grammar context, and it propagates
|
|
1228
|
-
// the flags outside of the parser. This means the production the parser parses is used as a part of a potential
|
|
1229
|
-
// pattern. The CoverInitializedName check is deferred.
|
|
1230
|
-
isolateCoverGrammar(e) {
|
|
1231
|
-
const t = this.context.isAssignmentTarget;
|
|
1232
|
-
this.context.isAssignmentTarget = !0;
|
|
1233
|
-
const i = e.call(this);
|
|
1234
|
-
return this.context.isAssignmentTarget = t, i;
|
|
1235
|
-
}
|
|
1236
|
-
inheritCoverGrammar(e) {
|
|
1237
|
-
const t = this.context.isAssignmentTarget;
|
|
1238
|
-
this.context.isAssignmentTarget = !0;
|
|
1239
|
-
const i = e.call(this);
|
|
1240
|
-
return this.context.isAssignmentTarget &&= t, i;
|
|
1241
|
-
}
|
|
1242
|
-
withBlockContext(e, t) {
|
|
1243
|
-
const i = this.context.blockContext;
|
|
1244
|
-
this.context.blockContext |= e;
|
|
1245
|
-
const r = this.context.curlyParsingType;
|
|
1246
|
-
this.context.curlyParsingType = re.Automatic;
|
|
1247
|
-
const s = t.call(this);
|
|
1248
|
-
return this.context.blockContext = i, this.context.curlyParsingType = r, s;
|
|
1249
|
-
}
|
|
1250
|
-
consumeSemicolon() {
|
|
1251
|
-
if (this.matchPunctuator(";")) {
|
|
1252
|
-
this.readNextRawToken();
|
|
1253
|
-
return;
|
|
1254
|
-
}
|
|
1255
|
-
if (!this.hasLineTerminator) {
|
|
1256
|
-
if (this.rawToken.type === l.EOF || this.matchPunctuator("}")) {
|
|
1257
|
-
this.endMarker.index = this.startMarker.index, this.endMarker.line = this.startMarker.line, this.endMarker.column = this.startMarker.column;
|
|
1258
|
-
return;
|
|
1259
|
-
}
|
|
1260
|
-
this.throwUnexpectedToken({ rawToken: this.rawToken });
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
parsePrimaryExpression() {
|
|
1264
|
-
const e = this.captureStartMarker(), t = this.rawToken;
|
|
1265
|
-
switch (t.type) {
|
|
1266
|
-
case l.Identifier:
|
|
1267
|
-
return this.readNextRawToken(), this.finalize({
|
|
1268
|
-
type: u.Identifier,
|
|
1269
|
-
name: t.value,
|
|
1270
|
-
...this.getItemLocation(e)
|
|
1271
|
-
});
|
|
1272
|
-
case l.NumericLiteral:
|
|
1273
|
-
case l.StringLiteral:
|
|
1274
|
-
return this.context.isAssignmentTarget = !1, this.readNextRawToken(), this.finalize({
|
|
1275
|
-
type: u.Literal,
|
|
1276
|
-
value: t.value,
|
|
1277
|
-
raw: this.getSourceValue(t),
|
|
1278
|
-
isString: typeof t.value == "string",
|
|
1279
|
-
...this.getItemLocation(e)
|
|
1280
|
-
});
|
|
1281
|
-
case l.BooleanLiteral:
|
|
1282
|
-
return this.context.isAssignmentTarget = !1, this.readNextRawToken(), this.finalize({
|
|
1283
|
-
type: u.Literal,
|
|
1284
|
-
value: t.value.toLowerCase() === V.True,
|
|
1285
|
-
raw: this.getSourceValue(t),
|
|
1286
|
-
isString: !1,
|
|
1287
|
-
...this.getItemLocation(e)
|
|
1288
|
-
});
|
|
1289
|
-
case l.NullLiteral:
|
|
1290
|
-
return this.context.isAssignmentTarget = !1, this.readNextRawToken(), this.finalize({
|
|
1291
|
-
type: u.Literal,
|
|
1292
|
-
value: null,
|
|
1293
|
-
raw: this.getSourceValue(t),
|
|
1294
|
-
isString: !1,
|
|
1295
|
-
...this.getItemLocation(e)
|
|
1296
|
-
});
|
|
1297
|
-
case l.Template:
|
|
1298
|
-
return this.parseTemplateLiteral();
|
|
1299
|
-
case l.Punctuator:
|
|
1300
|
-
switch (t.value) {
|
|
1301
|
-
case "(":
|
|
1302
|
-
return this.inheritCoverGrammar(this.parseGroupExpression.bind(this));
|
|
1303
|
-
case "[":
|
|
1304
|
-
return this.inheritCoverGrammar(this.parseArrayInitializer.bind(this));
|
|
1305
|
-
case "{":
|
|
1306
|
-
return this.inheritCoverGrammar(this.parseObjectExpression.bind(this));
|
|
1307
|
-
default:
|
|
1308
|
-
return this.throwUnexpectedToken({ rawToken: this.rawToken });
|
|
1309
|
-
}
|
|
1310
|
-
case l.Keyword:
|
|
1311
|
-
return this.context.isAssignmentTarget = !1, this.throwUnexpectedToken({ rawToken: this.rawToken });
|
|
1312
|
-
default:
|
|
1313
|
-
return this.throwUnexpectedToken({ rawToken: this.rawToken });
|
|
1314
|
-
}
|
|
1315
|
-
}
|
|
1316
|
-
parseArrayInitializer() {
|
|
1317
|
-
const e = this.captureStartMarker();
|
|
1318
|
-
this.expectPunctuator("[");
|
|
1319
|
-
const t = [];
|
|
1320
|
-
for (; !this.matchPunctuator("]"); ) {
|
|
1321
|
-
const i = this.captureStartMarker();
|
|
1322
|
-
this.matchPunctuator(",") ? (this.readNextRawToken(), this.throwError(h.InvalidExpression, i)) : (t.push(this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this))), this.matchPunctuator("]") || this.expectPunctuator(","));
|
|
1323
|
-
}
|
|
1324
|
-
return this.expectPunctuator("]"), this.finalize({ type: u.ArrayExpression, elements: t, ...this.getItemLocation(e) });
|
|
1325
|
-
}
|
|
1326
|
-
parseObjectPropertyKey() {
|
|
1327
|
-
const e = this.captureStartMarker(), t = this.rawToken;
|
|
1328
|
-
switch (t.type) {
|
|
1329
|
-
case l.StringLiteral:
|
|
1330
|
-
return this.readNextRawToken(), this.finalize({
|
|
1331
|
-
type: u.Literal,
|
|
1332
|
-
value: t.value,
|
|
1333
|
-
raw: this.getSourceValue(t),
|
|
1334
|
-
isString: !0,
|
|
1335
|
-
...this.getItemLocation(e)
|
|
1336
|
-
});
|
|
1337
|
-
case l.Identifier:
|
|
1338
|
-
case l.BooleanLiteral:
|
|
1339
|
-
case l.NullLiteral:
|
|
1340
|
-
case l.Keyword:
|
|
1341
|
-
return this.readNextRawToken(), this.finalize({
|
|
1342
|
-
type: u.Identifier,
|
|
1343
|
-
name: t.value,
|
|
1344
|
-
...this.getItemLocation(e)
|
|
1345
|
-
});
|
|
1346
|
-
default:
|
|
1347
|
-
this.throwError(h.KeyMustBeString, e);
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
parseObjectProperty() {
|
|
1351
|
-
const e = this.rawToken, t = this.captureStartMarker(), i = this.parseObjectPropertyKey();
|
|
1352
|
-
let r = !1, s = null;
|
|
1353
|
-
return this.matchPunctuator(":") ? (this.readNextRawToken(), s = this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this))) : e.type === l.Identifier ? (r = !0, s = this.finalize({
|
|
1354
|
-
type: u.Identifier,
|
|
1355
|
-
name: e.value,
|
|
1356
|
-
...this.getItemLocation(t)
|
|
1357
|
-
})) : this.throwUnexpectedToken({ rawToken: this.rawToken }), this.finalize({
|
|
1358
|
-
type: u.Property,
|
|
1359
|
-
kind: "init",
|
|
1360
|
-
key: i,
|
|
1361
|
-
value: s,
|
|
1362
|
-
shorthand: r,
|
|
1363
|
-
...this.getItemLocation(t)
|
|
1364
|
-
});
|
|
1365
|
-
}
|
|
1366
|
-
parseObjectExpression() {
|
|
1367
|
-
const e = this.captureStartMarker();
|
|
1368
|
-
this.expectPunctuator("{");
|
|
1369
|
-
const t = [];
|
|
1370
|
-
for (; !this.matchPunctuator("}"); )
|
|
1371
|
-
t.push(this.parseObjectProperty()), this.matchPunctuator("}") || this.expectPunctuator(",");
|
|
1372
|
-
return this.expectPunctuator("}"), this.finalize({ type: u.ObjectExpression, properties: t, ...this.getItemLocation(e) });
|
|
1373
|
-
}
|
|
1374
|
-
parseTemplateElement(e = !1) {
|
|
1375
|
-
const t = this.rawToken;
|
|
1376
|
-
t.type !== l.Template && this.throwUnexpectedToken({ rawToken: t }), e && !t.head && this.throwUnexpectedToken({ code: h.InvalidTemplateHead, rawToken: t });
|
|
1377
|
-
const i = this.captureStartMarker();
|
|
1378
|
-
this.readNextRawToken();
|
|
1379
|
-
const { value: r, cooked: s, tail: a } = t, o = this.finalize({
|
|
1380
|
-
type: u.TemplateElement,
|
|
1381
|
-
value: { raw: r, cooked: s },
|
|
1382
|
-
tail: a,
|
|
1383
|
-
...this.getItemLocation(i)
|
|
1384
|
-
});
|
|
1385
|
-
return o.loc.start.column += 1, o.loc.end.column -= a ? 1 : 2, o;
|
|
1386
|
-
}
|
|
1387
|
-
parseTemplateLiteral() {
|
|
1388
|
-
const e = this.captureStartMarker(), t = [], i = [];
|
|
1389
|
-
let r = this.parseTemplateElement(!0);
|
|
1390
|
-
for (i.push(r); !r.tail; )
|
|
1391
|
-
t.push(this.parseExpression()), r = this.parseTemplateElement(), i.push(r);
|
|
1392
|
-
return this.finalize({
|
|
1393
|
-
type: u.TemplateLiteral,
|
|
1394
|
-
quasis: i,
|
|
1395
|
-
expressions: t,
|
|
1396
|
-
...this.getItemLocation(e)
|
|
1397
|
-
});
|
|
1398
|
-
}
|
|
1399
|
-
parseGroupExpression() {
|
|
1400
|
-
this.expectPunctuator("(");
|
|
1401
|
-
const e = this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this));
|
|
1402
|
-
return this.expectPunctuator(")"), e;
|
|
1403
|
-
}
|
|
1404
|
-
parseArguments() {
|
|
1405
|
-
this.expectPunctuator("(");
|
|
1406
|
-
const e = [];
|
|
1407
|
-
if (!this.matchPunctuator(")"))
|
|
1408
|
-
for (; ; ) {
|
|
1409
|
-
const t = this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this));
|
|
1410
|
-
if (e.push(t), this.matchPunctuator(")") || (this.expectPunctuator(","), this.matchPunctuator(")")))
|
|
1411
|
-
break;
|
|
1412
|
-
}
|
|
1413
|
-
return this.expectPunctuator(")"), e;
|
|
1414
|
-
}
|
|
1415
|
-
parseMemberName() {
|
|
1416
|
-
const e = this.rawToken, t = this.captureStartMarker();
|
|
1417
|
-
return this.readNextRawToken(), e.type !== l.NullLiteral && e.type !== l.Identifier && e.type !== l.Keyword && e.type !== l.BooleanLiteral && this.throwUnexpectedToken({ rawToken: e }), this.finalize({
|
|
1418
|
-
type: u.Identifier,
|
|
1419
|
-
name: e.value,
|
|
1420
|
-
...this.getItemLocation(t)
|
|
1421
|
-
});
|
|
1422
|
-
}
|
|
1423
|
-
parseLeftHandSideExpression() {
|
|
1424
|
-
const e = this.captureStartMarker();
|
|
1425
|
-
let t = this.inheritCoverGrammar(this.parsePrimaryExpression.bind(this)), i = !1, r;
|
|
1426
|
-
for (; r = this.getMatchingPunctuator(["(", "[", ".", w]); ) {
|
|
1427
|
-
let s = !1;
|
|
1428
|
-
switch (r === w && (i = !0, s = !0, this.expectPunctuator(w), this.getMatchingPunctuator("[") ? r = "[" : r = "."), r) {
|
|
1429
|
-
case "(": {
|
|
1430
|
-
this.context.isAssignmentTarget = !1;
|
|
1431
|
-
const a = this.parseArguments();
|
|
1432
|
-
t = this.finalize({
|
|
1433
|
-
type: u.CallExpression,
|
|
1434
|
-
callee: t,
|
|
1435
|
-
arguments: a,
|
|
1436
|
-
...this.getItemLocation(e)
|
|
1437
|
-
});
|
|
1438
|
-
continue;
|
|
1439
|
-
}
|
|
1440
|
-
case "[": {
|
|
1441
|
-
this.context.isAssignmentTarget = !s, this.expectPunctuator("[");
|
|
1442
|
-
const a = this.isolateCoverGrammar(() => this.parseExpression());
|
|
1443
|
-
this.expectPunctuator("]"), t = this.finalize({
|
|
1444
|
-
type: s ? u.SafeMemberExpression : u.MemberExpression,
|
|
1445
|
-
computed: !0,
|
|
1446
|
-
object: t,
|
|
1447
|
-
property: a,
|
|
1448
|
-
...this.getItemLocation(e)
|
|
1449
|
-
});
|
|
1450
|
-
continue;
|
|
1451
|
-
}
|
|
1452
|
-
case ".": {
|
|
1453
|
-
this.context.isAssignmentTarget = !s, s || this.expectPunctuator(".");
|
|
1454
|
-
const a = this.parseMemberName();
|
|
1455
|
-
t = this.finalize({
|
|
1456
|
-
type: s ? u.SafeMemberExpression : u.MemberExpression,
|
|
1457
|
-
computed: !1,
|
|
1458
|
-
object: t,
|
|
1459
|
-
property: a,
|
|
1460
|
-
...this.getItemLocation(e)
|
|
1461
|
-
});
|
|
1462
|
-
continue;
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
return i ? this.finalize({
|
|
1467
|
-
type: u.MemberAccessChainExpression,
|
|
1468
|
-
expression: t,
|
|
1469
|
-
...this.getItemLocation(e)
|
|
1470
|
-
}) : t;
|
|
1471
|
-
}
|
|
1472
|
-
parseUpdateExpression() {
|
|
1473
|
-
const e = this.captureStartMarker();
|
|
1474
|
-
let t = this.getMatchingPunctuator(ue);
|
|
1475
|
-
if (t) {
|
|
1476
|
-
this.readNextRawToken();
|
|
1477
|
-
const a = this.captureStartMarker(), o = this.inheritCoverGrammar(this.parseUnaryExpression.bind(this));
|
|
1478
|
-
return o.type !== u.Identifier && o.type !== u.MemberExpression && o.type !== u.CallExpression && this.throwError(h.InvalidExpression, a), this.context.isAssignmentTarget || this.tolerateError(h.InvalidLeftHandSideInAssignment, e), this.context.isAssignmentTarget = !1, this.finalize({
|
|
1479
|
-
type: u.UpdateExpression,
|
|
1480
|
-
operator: t,
|
|
1481
|
-
argument: o,
|
|
1482
|
-
prefix: !0,
|
|
1483
|
-
...this.getItemLocation(e)
|
|
1484
|
-
});
|
|
1485
|
-
}
|
|
1486
|
-
const i = this.captureStartMarker(), r = this.inheritCoverGrammar(this.parseLeftHandSideExpression.bind(this)), s = this.captureStartMarker();
|
|
1487
|
-
return this.hasLineTerminator || (t = this.getMatchingPunctuator(ue), !t) ? r : (r.type !== u.Identifier && r.type !== u.MemberExpression && this.throwError(h.InvalidExpression, i, s), this.context.isAssignmentTarget || this.tolerateError(h.InvalidLeftHandSideInAssignment, e), this.readNextRawToken(), this.context.isAssignmentTarget = !1, this.finalize({
|
|
1488
|
-
type: u.UpdateExpression,
|
|
1489
|
-
operator: t,
|
|
1490
|
-
argument: r,
|
|
1491
|
-
prefix: !1,
|
|
1492
|
-
...this.getItemLocation(e)
|
|
1493
|
-
}));
|
|
1494
|
-
}
|
|
1495
|
-
parseUnaryExpression() {
|
|
1496
|
-
const e = this.getMatchingPunctuator(Ne);
|
|
1497
|
-
if (e) {
|
|
1498
|
-
const t = this.captureStartMarker();
|
|
1499
|
-
this.readNextRawToken();
|
|
1500
|
-
const i = this.inheritCoverGrammar(this.parseUnaryExpression.bind(this));
|
|
1501
|
-
return this.context.isAssignmentTarget = !1, this.finalize({
|
|
1502
|
-
type: u.UnaryExpression,
|
|
1503
|
-
operator: e,
|
|
1504
|
-
argument: i,
|
|
1505
|
-
prefix: !0,
|
|
1506
|
-
...this.getItemLocation(t)
|
|
1507
|
-
});
|
|
1508
|
-
}
|
|
1509
|
-
return this.parseUpdateExpression();
|
|
1510
|
-
}
|
|
1511
|
-
parseBinaryExpression() {
|
|
1512
|
-
const e = this.rawToken;
|
|
1513
|
-
let t = this.inheritCoverGrammar(this.parseUnaryExpression.bind(this));
|
|
1514
|
-
if (this.rawToken.type !== l.Punctuator)
|
|
1515
|
-
return t;
|
|
1516
|
-
const i = this.rawToken.value;
|
|
1517
|
-
let r = we(i);
|
|
1518
|
-
if (r === 0)
|
|
1519
|
-
return t;
|
|
1520
|
-
this.readNextRawToken(), this.context.isAssignmentTarget = !1;
|
|
1521
|
-
const s = [e, this.rawToken];
|
|
1522
|
-
let a = t, o = this.inheritCoverGrammar(
|
|
1523
|
-
this.parseUnaryExpression.bind(this)
|
|
1524
|
-
);
|
|
1525
|
-
const c = [a, i, o], d = [r];
|
|
1526
|
-
for (; this.rawToken.type === l.Punctuator && (r = we(this.rawToken.value)) > 0; ) {
|
|
1527
|
-
for (; c.length > 2 && r <= d[d.length - 1]; ) {
|
|
1528
|
-
o = c.pop();
|
|
1529
|
-
const k = c.pop();
|
|
1530
|
-
d.pop(), a = c.pop(), s.pop();
|
|
1531
|
-
const R = s[s.length - 1], ee = Ie(R, R.lineStart);
|
|
1532
|
-
c.push(this.finalize(this.createBinaryOrLogicalExpression(ee, k, a, o)));
|
|
1533
|
-
}
|
|
1534
|
-
c.push(this.rawToken.value), d.push(r), s.push(this.rawToken), this.readNextRawToken(), c.push(this.inheritCoverGrammar(this.parseUnaryExpression.bind(this)));
|
|
1535
|
-
}
|
|
1536
|
-
let E = c.length - 1;
|
|
1537
|
-
t = c[E];
|
|
1538
|
-
let F = s.pop();
|
|
1539
|
-
for (; E > 1; ) {
|
|
1540
|
-
const k = s.pop();
|
|
1541
|
-
if (!k)
|
|
1542
|
-
break;
|
|
1543
|
-
const R = F?.lineStart, ee = Ie(k, R), qe = c[E - 1];
|
|
1544
|
-
t = this.finalize(
|
|
1545
|
-
this.createBinaryOrLogicalExpression(ee, qe, c[E - 2], t)
|
|
1546
|
-
), E -= 2, F = k;
|
|
1547
|
-
}
|
|
1548
|
-
return t;
|
|
1549
|
-
}
|
|
1550
|
-
createBinaryOrLogicalExpression(e, t, i, r) {
|
|
1551
|
-
return Ue.includes(t) ? ((i.type === u.AssignmentExpression || i.type === u.UpdateExpression) && this.throwError(h.InvalidExpression, ...be(i)), (r.type === u.AssignmentExpression || r.type === u.UpdateExpression) && this.throwError(h.InvalidExpression, ...be(i)), {
|
|
1552
|
-
type: u.LogicalExpression,
|
|
1553
|
-
operator: t,
|
|
1554
|
-
left: i,
|
|
1555
|
-
right: r,
|
|
1556
|
-
...this.getItemLocation(e)
|
|
1557
|
-
}) : {
|
|
1558
|
-
type: u.BinaryExpression,
|
|
1559
|
-
operator: t,
|
|
1560
|
-
left: i,
|
|
1561
|
-
right: r,
|
|
1562
|
-
...this.getItemLocation(e)
|
|
1563
|
-
};
|
|
1564
|
-
}
|
|
1565
|
-
parseAssignmentExpression() {
|
|
1566
|
-
const e = this.captureStartMarker(), t = this.inheritCoverGrammar(this.parseBinaryExpression.bind(this)), i = this.captureStartMarker(), r = this.getMatchingPunctuator(Me);
|
|
1567
|
-
if (!r)
|
|
1568
|
-
return t;
|
|
1569
|
-
t.type !== u.Identifier && t.type !== u.MemberExpression && this.throwError(h.InvalidExpression, e, i), this.context.isAssignmentTarget || this.tolerateError(h.InvalidLeftHandSideInAssignment, e), this.matchPunctuator("=") || (this.context.isAssignmentTarget = !1), this.readNextRawToken();
|
|
1570
|
-
const s = this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this));
|
|
1571
|
-
return this.finalize({
|
|
1572
|
-
type: u.AssignmentExpression,
|
|
1573
|
-
left: t,
|
|
1574
|
-
operator: r,
|
|
1575
|
-
right: s,
|
|
1576
|
-
...this.getItemLocation(e)
|
|
1577
|
-
});
|
|
1578
|
-
}
|
|
1579
|
-
parseExpression() {
|
|
1580
|
-
return this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this));
|
|
1581
|
-
}
|
|
1582
|
-
parseStatements(e) {
|
|
1583
|
-
const t = [];
|
|
1584
|
-
for (; this.rawToken.type !== l.EOF && !this.matchPunctuator(e); ) {
|
|
1585
|
-
const i = this.parseStatementListItem();
|
|
1586
|
-
pe(i) || t.push(i);
|
|
1587
|
-
}
|
|
1588
|
-
return t;
|
|
1589
|
-
}
|
|
1590
|
-
parseStatementListItem() {
|
|
1591
|
-
return this.context.isAssignmentTarget = !0, this.matchKeyword(f.Function) ? this.parseFunctionDeclaration() : this.matchKeyword(f.Export) ? this.parseExportDeclaration() : this.matchKeyword(f.Import) ? this.parseImportDeclaration() : this.parseStatement();
|
|
1592
|
-
}
|
|
1593
|
-
parseBlock() {
|
|
1594
|
-
const e = this.captureStartMarker();
|
|
1595
|
-
this.expectPunctuator("{");
|
|
1596
|
-
const t = this.parseStatements("}");
|
|
1597
|
-
return this.expectPunctuator("}"), this.finalize({ type: u.BlockStatement, body: t, ...this.getItemLocation(e) });
|
|
1598
|
-
}
|
|
1599
|
-
parseObjectStatement() {
|
|
1600
|
-
const e = this.captureStartMarker(), t = this.parseObjectExpression();
|
|
1601
|
-
return this.finalize({
|
|
1602
|
-
type: u.ExpressionStatement,
|
|
1603
|
-
expression: t,
|
|
1604
|
-
...this.getItemLocation(e)
|
|
1605
|
-
});
|
|
1606
|
-
}
|
|
1607
|
-
parseBlockOrObjectStatement() {
|
|
1608
|
-
return this.context.curlyParsingType === re.AsObject ? this.parseObjectStatement() : this.peekAhead((e) => {
|
|
1609
|
-
let t = e();
|
|
1610
|
-
return !(t.type !== l.Identifier && t.type !== l.StringLiteral || (t = e(), t.type !== l.Punctuator || t.value !== ":"));
|
|
1611
|
-
}) ? this.parseObjectStatement() : this.parseBlock();
|
|
1612
|
-
}
|
|
1613
|
-
parseIdentifier() {
|
|
1614
|
-
const e = this.rawToken;
|
|
1615
|
-
if (e.type !== l.Identifier)
|
|
1616
|
-
return null;
|
|
1617
|
-
const t = this.captureStartMarker();
|
|
1618
|
-
return this.readNextRawToken(), this.finalize({
|
|
1619
|
-
type: u.Identifier,
|
|
1620
|
-
name: e.value,
|
|
1621
|
-
...this.getItemLocation(t)
|
|
1622
|
-
});
|
|
1623
|
-
}
|
|
1624
|
-
parseVariableDeclarator() {
|
|
1625
|
-
const e = this.captureStartMarker(), t = this.parseIdentifier();
|
|
1626
|
-
t || this.throwUnexpectedToken({ code: h.IdentifierExpected });
|
|
1627
|
-
let i = null;
|
|
1628
|
-
if (this.matchPunctuator("=")) {
|
|
1629
|
-
this.readNextRawToken();
|
|
1630
|
-
const r = this.rawToken;
|
|
1631
|
-
try {
|
|
1632
|
-
i = this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this));
|
|
1633
|
-
} catch {
|
|
1634
|
-
this.throwUnexpectedToken({ rawToken: r, code: h.InvalidVariableAssignment });
|
|
1635
|
-
}
|
|
1636
|
-
}
|
|
1637
|
-
return this.finalize({ type: u.VariableDeclarator, id: t, init: i, ...this.getItemLocation(e) });
|
|
1638
|
-
}
|
|
1639
|
-
parseVariableDeclarators() {
|
|
1640
|
-
const e = [this.parseVariableDeclarator()];
|
|
1641
|
-
for (; this.matchPunctuator(","); )
|
|
1642
|
-
this.readNextRawToken(), e.push(this.parseVariableDeclarator());
|
|
1643
|
-
return e;
|
|
1644
|
-
}
|
|
1645
|
-
parseVariableDeclaration() {
|
|
1646
|
-
const e = this.captureStartMarker();
|
|
1647
|
-
this.expectKeyword(f.Var);
|
|
1648
|
-
const t = this.parseVariableDeclarators();
|
|
1649
|
-
return this.consumeSemicolon(), this.finalize({
|
|
1650
|
-
type: u.VariableDeclaration,
|
|
1651
|
-
declarations: t,
|
|
1652
|
-
kind: "var",
|
|
1653
|
-
...this.getItemLocation(e)
|
|
1654
|
-
});
|
|
1655
|
-
}
|
|
1656
|
-
parseEmptyStatement() {
|
|
1657
|
-
const e = this.captureStartMarker();
|
|
1658
|
-
return this.expectPunctuator(";"), this.finalize({ type: u.EmptyStatement, ...this.getItemLocation(e) });
|
|
1659
|
-
}
|
|
1660
|
-
parseExpressionStatement() {
|
|
1661
|
-
const e = this.captureStartMarker(), t = this.parseExpression();
|
|
1662
|
-
return this.consumeSemicolon(), this.finalize({
|
|
1663
|
-
type: u.ExpressionStatement,
|
|
1664
|
-
expression: t,
|
|
1665
|
-
...this.getItemLocation(e)
|
|
1666
|
-
});
|
|
1667
|
-
}
|
|
1668
|
-
parseIfClause() {
|
|
1669
|
-
return this.withBlockContext(y.IfClause, this.parseStatement.bind(this));
|
|
1670
|
-
}
|
|
1671
|
-
parseIfStatement() {
|
|
1672
|
-
const e = this.captureStartMarker();
|
|
1673
|
-
this.expectKeyword(f.If), this.expectPunctuator("(");
|
|
1674
|
-
const t = this.captureStartMarker(), i = this.parseExpression(), r = this.captureStartMarker();
|
|
1675
|
-
this.expectPunctuator(")"), (i.type === u.AssignmentExpression || i.type === u.UpdateExpression) && this.throwError(h.InvalidExpression, t, r);
|
|
1676
|
-
const s = this.parseIfClause();
|
|
1677
|
-
let a = null;
|
|
1678
|
-
return this.matchKeyword(f.Else) && (this.readNextRawToken(), a = this.parseIfClause()), this.finalize({
|
|
1679
|
-
type: u.IfStatement,
|
|
1680
|
-
test: i,
|
|
1681
|
-
consequent: s,
|
|
1682
|
-
alternate: a,
|
|
1683
|
-
...this.getItemLocation(e)
|
|
1684
|
-
});
|
|
1685
|
-
}
|
|
1686
|
-
parseWhileStatement() {
|
|
1687
|
-
const e = this.captureStartMarker();
|
|
1688
|
-
this.expectKeyword(f.While), this.expectPunctuator("(");
|
|
1689
|
-
const t = this.captureStartMarker(), i = this.parseExpression(), r = this.captureStartMarker();
|
|
1690
|
-
this.expectPunctuator(")"), (i.type === u.AssignmentExpression || i.type === u.UpdateExpression) && this.throwError(h.InvalidExpression, t, r);
|
|
1691
|
-
const s = this.withBlockContext(y.WhileLoop, this.parseStatement.bind(this));
|
|
1692
|
-
return this.finalize({
|
|
1693
|
-
type: u.WhileStatement,
|
|
1694
|
-
test: i,
|
|
1695
|
-
body: s,
|
|
1696
|
-
...this.getItemLocation(e)
|
|
1697
|
-
});
|
|
1698
|
-
}
|
|
1699
|
-
parseForStatement() {
|
|
1700
|
-
let e = u.ForStatement, t = null, i = null, r = null, s = null, a = null;
|
|
1701
|
-
const o = this.captureStartMarker();
|
|
1702
|
-
if (this.expectKeyword(f.For), this.expectPunctuator("("), this.matchKeyword(f.Var)) {
|
|
1703
|
-
const d = this.captureStartMarker();
|
|
1704
|
-
this.readNextRawToken();
|
|
1705
|
-
const E = this.parseVariableDeclarators();
|
|
1706
|
-
t = this.finalize({
|
|
1707
|
-
type: u.VariableDeclaration,
|
|
1708
|
-
declarations: E,
|
|
1709
|
-
kind: "var",
|
|
1710
|
-
...this.getItemLocation(d)
|
|
1711
|
-
});
|
|
1712
|
-
const F = this.matchKeyword(f.In), k = this.matchContextualKeyword(te.Of);
|
|
1713
|
-
E.length === 1 && (F || k) && (E[0].init && this.throwError(h.ForInOfLoopInitializer, d), e = F ? u.ForInStatement : u.ForOfStatement, s = t);
|
|
1714
|
-
} else if (!this.matchPunctuator(";")) {
|
|
1715
|
-
const d = this.context.isAssignmentTarget, E = this.captureStartMarker();
|
|
1716
|
-
t = this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this));
|
|
1717
|
-
const F = this.matchKeyword(f.In), k = this.matchContextualKeyword(te.Of);
|
|
1718
|
-
F || k ? (this.context.isAssignmentTarget || this.tolerateError(h.InvalidLeftHandSideInForIn, E), t.type !== u.Identifier && this.throwError(h.InvalidLeftHandSideInForIn, E), e = F ? u.ForInStatement : u.ForOfStatement, s = t) : this.context.isAssignmentTarget = d;
|
|
1719
|
-
}
|
|
1720
|
-
e === u.ForStatement ? (this.expectPunctuator(";"), i = this.matchPunctuator(";") ? null : this.isolateCoverGrammar(this.parseExpression.bind(this)), this.expectPunctuator(";"), r = this.matchPunctuator(")") ? null : this.isolateCoverGrammar(this.parseExpression.bind(this))) : (this.readNextRawToken(), a = this.parseExpression()), this.expectPunctuator(")");
|
|
1721
|
-
const c = this.withBlockContext(
|
|
1722
|
-
e === u.ForOfStatement ? y.ForOfLoop : y.ForLoop,
|
|
1723
|
-
() => this.isolateCoverGrammar(this.parseStatement.bind(this))
|
|
1724
|
-
);
|
|
1725
|
-
return e === u.ForInStatement || e === u.ForOfStatement ? this.finalize({
|
|
1726
|
-
type: e,
|
|
1727
|
-
left: s,
|
|
1728
|
-
right: a,
|
|
1729
|
-
body: c,
|
|
1730
|
-
...this.getItemLocation(o)
|
|
1731
|
-
}) : this.finalize({
|
|
1732
|
-
type: e,
|
|
1733
|
-
init: t,
|
|
1734
|
-
test: i,
|
|
1735
|
-
update: r,
|
|
1736
|
-
body: c,
|
|
1737
|
-
...this.getItemLocation(o)
|
|
1738
|
-
});
|
|
1739
|
-
}
|
|
1740
|
-
parseContinueStatement() {
|
|
1741
|
-
const e = this.captureStartMarker();
|
|
1742
|
-
return this.expectKeyword(f.Continue), this.consumeSemicolon(), this.finalize({ type: u.ContinueStatement, ...this.getItemLocation(e) });
|
|
1743
|
-
}
|
|
1744
|
-
parseBreakStatement() {
|
|
1745
|
-
const e = this.captureStartMarker();
|
|
1746
|
-
return this.expectKeyword(f.Break), this.consumeSemicolon(), this.finalize({ type: u.BreakStatement, ...this.getItemLocation(e) });
|
|
1747
|
-
}
|
|
1748
|
-
parseReturnStatement() {
|
|
1749
|
-
const e = this.captureStartMarker();
|
|
1750
|
-
this.expectKeyword(f.Return);
|
|
1751
|
-
const t = !this.matchPunctuator(";") && !this.matchPunctuator("}") && !this.hasLineTerminator && this.rawToken.type !== l.EOF || this.rawToken.type === l.StringLiteral || this.rawToken.type === l.Template ? this.parseExpression() : null;
|
|
1752
|
-
return this.consumeSemicolon(), this.finalize({ type: u.ReturnStatement, argument: t, ...this.getItemLocation(e) });
|
|
1753
|
-
}
|
|
1754
|
-
parseStatement() {
|
|
1755
|
-
switch (this.rawToken.type) {
|
|
1756
|
-
case l.BooleanLiteral:
|
|
1757
|
-
case l.NullLiteral:
|
|
1758
|
-
case l.NumericLiteral:
|
|
1759
|
-
case l.StringLiteral:
|
|
1760
|
-
case l.Template:
|
|
1761
|
-
case l.Identifier:
|
|
1762
|
-
return this.parseExpressionStatement();
|
|
1763
|
-
case l.Punctuator:
|
|
1764
|
-
return this.rawToken.value === "{" ? this.parseBlockOrObjectStatement() : this.rawToken.value === "(" ? this.parseExpressionStatement() : this.rawToken.value === ";" ? this.parseEmptyStatement() : this.parseExpressionStatement();
|
|
1765
|
-
case l.Keyword:
|
|
1766
|
-
switch (this.rawToken.value.toLowerCase()) {
|
|
1767
|
-
case f.Break:
|
|
1768
|
-
return this.parseBreakStatement();
|
|
1769
|
-
case f.Continue:
|
|
1770
|
-
return this.parseContinueStatement();
|
|
1771
|
-
case f.For:
|
|
1772
|
-
return this.parseForStatement();
|
|
1773
|
-
case f.Function:
|
|
1774
|
-
return this.parseFunctionDeclaration();
|
|
1775
|
-
case f.If:
|
|
1776
|
-
return this.parseIfStatement();
|
|
1777
|
-
case f.Return:
|
|
1778
|
-
return this.parseReturnStatement();
|
|
1779
|
-
case f.Var:
|
|
1780
|
-
return this.parseVariableDeclaration();
|
|
1781
|
-
case f.While:
|
|
1782
|
-
return this.parseWhileStatement();
|
|
1783
|
-
default:
|
|
1784
|
-
return this.parseExpressionStatement();
|
|
1785
|
-
}
|
|
1786
|
-
default:
|
|
1787
|
-
return this.throwUnexpectedToken({ rawToken: this.rawToken });
|
|
1788
|
-
}
|
|
1789
|
-
}
|
|
1790
|
-
parseFormalParameters() {
|
|
1791
|
-
const e = [];
|
|
1792
|
-
if (this.expectPunctuator("("), !this.matchPunctuator(")"))
|
|
1793
|
-
for (; this.rawToken.type !== l.EOF; ) {
|
|
1794
|
-
const t = this.parseIdentifier();
|
|
1795
|
-
if (t || this.throwUnexpectedToken({ rawToken: this.rawToken, code: h.IdentifierExpected }), e.push(t), this.matchPunctuator(")") || (this.expectPunctuator(","), this.matchPunctuator(")")))
|
|
1796
|
-
break;
|
|
1797
|
-
}
|
|
1798
|
-
return this.expectPunctuator(")"), e;
|
|
1799
|
-
}
|
|
1800
|
-
parseFunctionDeclaration() {
|
|
1801
|
-
(this.context.blockContext & y.Function) === y.Function && this.throwUnexpectedToken({ code: h.NoFunctionInsideFunction }), ((this.context.blockContext & y.WhileLoop) === y.WhileLoop || (this.context.blockContext & y.ForOfLoop) === y.ForOfLoop || (this.context.blockContext & y.IfClause) === y.IfClause) && this.throwUnexpectedToken({ code: h.NoFunctionInsideBlock });
|
|
1802
|
-
const e = this.captureStartMarker();
|
|
1803
|
-
this.expectKeyword(f.Function);
|
|
1804
|
-
const t = this.parseIdentifier();
|
|
1805
|
-
t || this.throwUnexpectedToken({ code: h.InvalidFunctionIdentifier });
|
|
1806
|
-
const i = this.parseFormalParameters(), r = this.context.blockContext;
|
|
1807
|
-
this.context.blockContext |= y.Function;
|
|
1808
|
-
const s = this.parseBlock();
|
|
1809
|
-
return this.context.blockContext = r, this.finalize({
|
|
1810
|
-
type: u.FunctionDeclaration,
|
|
1811
|
-
id: t,
|
|
1812
|
-
params: i,
|
|
1813
|
-
body: s,
|
|
1814
|
-
...this.getItemLocation(e)
|
|
1815
|
-
});
|
|
1816
|
-
}
|
|
1817
|
-
parseScript() {
|
|
1818
|
-
const e = this.captureStartMarker(), t = this.parseStatements(), i = this.finalize({
|
|
1819
|
-
type: u.Program,
|
|
1820
|
-
body: t,
|
|
1821
|
-
...this.getItemLocation(e)
|
|
1822
|
-
});
|
|
1823
|
-
return this.options.tokens && (i.tokens = this.tokens), this.options.tolerant && (i.errors = this.errorHandler.errors), i;
|
|
1824
|
-
}
|
|
1825
|
-
parseExportDeclaration() {
|
|
1826
|
-
this.context.blockContext !== y.None && this.throwUnexpectedToken({ code: h.ModuleExportRootOnly });
|
|
1827
|
-
let e = null;
|
|
1828
|
-
const t = this.captureStartMarker();
|
|
1829
|
-
return this.expectKeyword(f.Export), this.matchKeyword(f.Var) ? e = this.parseVariableDeclaration() : this.matchKeyword("function") ? e = this.parseFunctionDeclaration() : this.throwUnexpectedToken({ code: h.InvalidExpression }), this.finalize({
|
|
1830
|
-
type: u.ExportNamedDeclaration,
|
|
1831
|
-
declaration: e,
|
|
1832
|
-
specifiers: [],
|
|
1833
|
-
source: null,
|
|
1834
|
-
...this.getItemLocation(t)
|
|
1835
|
-
});
|
|
1836
|
-
}
|
|
1837
|
-
// The module specified part of a import XX from 'MODULESPECIFIER'
|
|
1838
|
-
parseModuleSpecifier() {
|
|
1839
|
-
const e = this.captureStartMarker(), t = this.rawToken;
|
|
1840
|
-
if (t.type === l.StringLiteral)
|
|
1841
|
-
return this.readNextRawToken(), this.finalize({
|
|
1842
|
-
type: u.Literal,
|
|
1843
|
-
value: t.value,
|
|
1844
|
-
raw: this.getSourceValue(t),
|
|
1845
|
-
isString: !0,
|
|
1846
|
-
...this.getItemLocation(e)
|
|
1847
|
-
});
|
|
1848
|
-
this.throwError(h.InvalidModuleUri, e);
|
|
1849
|
-
}
|
|
1850
|
-
parseDefaultSpecifier() {
|
|
1851
|
-
const e = this.captureStartMarker(), t = this.parseIdentifier();
|
|
1852
|
-
return t || this.throwUnexpectedToken({ code: h.IdentifierExpected }), this.finalize({
|
|
1853
|
-
type: u.ImportDefaultSpecifier,
|
|
1854
|
-
local: t,
|
|
1855
|
-
...this.getItemLocation(e)
|
|
1856
|
-
});
|
|
1857
|
-
}
|
|
1858
|
-
parseImportDeclaration() {
|
|
1859
|
-
this.context.blockContext !== y.None && this.throwUnexpectedToken({ code: h.ModuleImportRootOnly });
|
|
1860
|
-
const e = this.captureStartMarker();
|
|
1861
|
-
this.expectKeyword(f.Import);
|
|
1862
|
-
const t = this.parseDefaultSpecifier();
|
|
1863
|
-
this.expectContextualKeyword(te.From);
|
|
1864
|
-
const i = this.parseModuleSpecifier();
|
|
1865
|
-
return this.finalize({
|
|
1866
|
-
type: u.ImportDeclaration,
|
|
1867
|
-
specifiers: [t],
|
|
1868
|
-
source: i,
|
|
1869
|
-
...this.getItemLocation(e)
|
|
1870
|
-
});
|
|
1871
|
-
}
|
|
1872
|
-
}
|
|
1873
|
-
class ot {
|
|
1874
|
-
constructor(e, t) {
|
|
1875
|
-
this.errorHandler = new _e(), this.errorHandler.tolerant = t ? typeof t.tolerant == "boolean" && t.tolerant : !1, this.scanner = new $e(e, this.errorHandler), this.trackComments = t ? typeof t.comment == "boolean" && t.comment : !1, this.buffer = [];
|
|
1876
|
-
}
|
|
1877
|
-
errors() {
|
|
1878
|
-
return this.errorHandler.errors;
|
|
1879
|
-
}
|
|
1880
|
-
/**
|
|
1881
|
-
* Used by the exposed method 'tokenize'
|
|
1882
|
-
*/
|
|
1883
|
-
getNextToken() {
|
|
1884
|
-
if (this.buffer.length === 0) {
|
|
1885
|
-
const e = this.scanner.scanComments();
|
|
1886
|
-
if (this.trackComments && e.forEach((t) => {
|
|
1887
|
-
const i = this.scanner.source.slice(t.start, t.end), r = {
|
|
1888
|
-
type: t.multiLine ? u.BlockComment : u.LineComment,
|
|
1889
|
-
value: i,
|
|
1890
|
-
range: t.range,
|
|
1891
|
-
loc: t.loc
|
|
1892
|
-
};
|
|
1893
|
-
this.buffer.push(r);
|
|
1894
|
-
}), !this.scanner.eof()) {
|
|
1895
|
-
const t = {
|
|
1896
|
-
line: this.scanner.lineNumber,
|
|
1897
|
-
column: this.scanner.index - this.scanner.lineStart
|
|
1898
|
-
}, i = this.scanner.lex(), r = {
|
|
1899
|
-
line: this.scanner.lineNumber,
|
|
1900
|
-
column: this.scanner.index - this.scanner.lineStart
|
|
1901
|
-
}, s = {
|
|
1902
|
-
type: Oe[i.type],
|
|
1903
|
-
value: this.scanner.source.slice(i.start, i.end),
|
|
1904
|
-
range: [i.start, i.end],
|
|
1905
|
-
loc: { start: t, end: r }
|
|
1906
|
-
};
|
|
1907
|
-
this.buffer.push(s);
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1910
|
-
return this.buffer.shift();
|
|
1911
|
-
}
|
|
1912
|
-
}
|
|
1913
|
-
function Re(n, e, t) {
|
|
1914
|
-
return new at(n, e, t).parseScript();
|
|
1915
|
-
}
|
|
1916
|
-
function ct(n, e, t) {
|
|
1917
|
-
const i = new ot(n, e), r = [];
|
|
1918
|
-
let s;
|
|
1919
|
-
try {
|
|
1920
|
-
let a;
|
|
1921
|
-
for (; a = i.getNextToken(); )
|
|
1922
|
-
t && (a = t(a)), r.push(a);
|
|
1923
|
-
} catch (a) {
|
|
1924
|
-
a instanceof Error && i.errorHandler.tolerate(a);
|
|
1925
|
-
}
|
|
1926
|
-
return i.errorHandler.tolerant && (s = i.errors()), { tokens: r, errors: s };
|
|
1927
|
-
}
|
|
1928
|
-
const p = {
|
|
1
|
+
import * as a from "@arcgis/arcade-parser";
|
|
2
|
+
import { Keywords as ee, Literals as te } from "@arcgis/arcade-parser";
|
|
3
|
+
import { CompletionItemKind as m, InsertTextFormat as x, InsertTextMode as L, DiagnosticSeverity as g } from "vscode-languageserver-types";
|
|
4
|
+
import { DiagnosticSeverity as ht } from "vscode-languageserver-types";
|
|
5
|
+
import { isDictionaryVariable as ie, isValueVariable as R, ApiService as ne } from "@arcgis/languages-api-utils";
|
|
6
|
+
const h = {
|
|
1929
7
|
AlreadyDefined: "AlreadyDefined",
|
|
1930
8
|
ApiConflict: "ApiConflict",
|
|
1931
9
|
AssignedNeverUsed: "AssignedNeverUsed",
|
|
@@ -1947,61 +25,61 @@ const p = {
|
|
|
1947
25
|
UnexpectedEmptyFunction: "UnexpectedEmptyFunction",
|
|
1948
26
|
UnexpectedPropertyIdentifier: "UnexpectedPropertyIdentifier",
|
|
1949
27
|
UnknownPropertyIdentifier: "UnknownPropertyIdentifier"
|
|
1950
|
-
},
|
|
1951
|
-
[
|
|
1952
|
-
[
|
|
1953
|
-
[
|
|
1954
|
-
[
|
|
1955
|
-
[
|
|
1956
|
-
[
|
|
1957
|
-
[
|
|
1958
|
-
[
|
|
1959
|
-
[
|
|
1960
|
-
[
|
|
1961
|
-
[
|
|
1962
|
-
[
|
|
1963
|
-
[
|
|
1964
|
-
[
|
|
1965
|
-
[
|
|
1966
|
-
[
|
|
1967
|
-
[
|
|
1968
|
-
[
|
|
1969
|
-
[
|
|
1970
|
-
[
|
|
1971
|
-
[
|
|
1972
|
-
...
|
|
28
|
+
}, se = {
|
|
29
|
+
[h.AlreadyDefined]: "'${identifier}' is already defined.",
|
|
30
|
+
[h.ApiConflict]: "'${identifier}' is already defined as an Arcade constant or function.",
|
|
31
|
+
[h.AssignedNeverUsed]: "'${identifier}' is assigned but never used.",
|
|
32
|
+
[h.DefinedNeverAssigned]: "'${identifier}' is defined but never assigned.",
|
|
33
|
+
[h.DefinedNeverUsed]: "'${identifier}' is defined but never used.",
|
|
34
|
+
[h.EmptyBlockStatement]: "Empty block statement.",
|
|
35
|
+
[h.ExecutionError]: "Execution Error: '${stack}'",
|
|
36
|
+
[h.InvalidApiFunctionUsage]: "Arcade function '${identifier}' not used in a call expression.",
|
|
37
|
+
[h.InvalidConstantIdentifier]: "Invalid constant identifier, expecting ${list}.",
|
|
38
|
+
[h.InvalidPropertyIdentifier]: "Invalid property identifier, expecting ${list}.",
|
|
39
|
+
[h.NoArgumentExpected]: "Expecting no argument.",
|
|
40
|
+
[h.NotADictionary]: "'${identifier}' doesn't have properties.",
|
|
41
|
+
[h.NotDefined]: "'${identifier}' is not defined.",
|
|
42
|
+
[h.NotEnoughArguments]: "Expecting at least ${min} argument(s).",
|
|
43
|
+
[h.ProfileVariablesAreImmutable]: "Profile variables cannot be modified.",
|
|
44
|
+
[h.ProfileVariablesConflict]: "'${identifier}' is already defined as a profile variable.",
|
|
45
|
+
[h.ReservedKeyword]: "'${identifier}' is a reserved keyword.",
|
|
46
|
+
[h.TooManyArguments]: "Too many arguments, expecting ${max}.",
|
|
47
|
+
[h.UnexpectedEmptyFunction]: "Unexpected empty function '${identifier}'.",
|
|
48
|
+
[h.UnexpectedPropertyIdentifier]: "Unexpected property identifier.",
|
|
49
|
+
[h.UnknownPropertyIdentifier]: "Unknown property identifier '${identifier}'.",
|
|
50
|
+
...a.DiagnosticMessages
|
|
1973
51
|
};
|
|
1974
|
-
function
|
|
52
|
+
function B(n, e) {
|
|
1975
53
|
return n.line - e.line || n.column - e.column;
|
|
1976
54
|
}
|
|
1977
|
-
function
|
|
55
|
+
function re(n, e) {
|
|
1978
56
|
const t = {
|
|
1979
57
|
start: n.loc.start,
|
|
1980
58
|
end: n.loc.end
|
|
1981
|
-
}, i = (
|
|
1982
|
-
return
|
|
59
|
+
}, i = (s) => ae(t, s.loc);
|
|
60
|
+
return B(t.start, t.end) < 0 && (t.start = { ...t.start }, e.skipSpaces(t.start), B(t.start, t.end) < 0 && (t.end = { ...t.end }, e.skipSpaces(t.end, !0))), n.leadingComments?.forEach(i), n.trailingComments?.forEach(i), t;
|
|
1983
61
|
}
|
|
1984
|
-
function
|
|
1985
|
-
|
|
62
|
+
function ae(n, e) {
|
|
63
|
+
B(e.start, n.start) < 0 && (n.start = e.start), B(n.end, e.end) < 0 && (n.end = e.end);
|
|
1986
64
|
}
|
|
1987
|
-
const
|
|
1988
|
-
function
|
|
1989
|
-
return !
|
|
65
|
+
const oe = /\S/u;
|
|
66
|
+
function D(n = "") {
|
|
67
|
+
return !oe.test(n);
|
|
1990
68
|
}
|
|
1991
|
-
const
|
|
69
|
+
const V = {
|
|
1992
70
|
indentWidth: 2,
|
|
1993
71
|
wrapColumn: 80,
|
|
1994
72
|
quote: null
|
|
1995
73
|
};
|
|
1996
|
-
function
|
|
74
|
+
function O(n) {
|
|
1997
75
|
return {
|
|
1998
|
-
indentWidth: n?.indentWidth ??
|
|
1999
|
-
wrapColumn: n?.wrapColumn ??
|
|
2000
|
-
quote: n?.quote ??
|
|
76
|
+
indentWidth: n?.indentWidth ?? V.indentWidth,
|
|
77
|
+
wrapColumn: n?.wrapColumn ?? V.wrapColumn,
|
|
78
|
+
quote: n?.quote ?? V.quote
|
|
2001
79
|
};
|
|
2002
80
|
}
|
|
2003
|
-
const
|
|
2004
|
-
class
|
|
81
|
+
const ce = /^\s*/u, le = /\u000D\u000A|\u000D(?!\u000A)|\u000A|\u2028|\u2029/u;
|
|
82
|
+
class M {
|
|
2005
83
|
// private cachedIndentWidth: number | void = void 0;
|
|
2006
84
|
constructor(e) {
|
|
2007
85
|
this.lineRecords = e, this.length = e.length;
|
|
@@ -2011,16 +89,16 @@ class Z {
|
|
|
2011
89
|
if (typeof e != "string")
|
|
2012
90
|
return e;
|
|
2013
91
|
const i = t?.indentWidth;
|
|
2014
|
-
return new
|
|
2015
|
-
e.split(
|
|
2016
|
-
const
|
|
92
|
+
return new M(
|
|
93
|
+
e.split(le).map((r) => {
|
|
94
|
+
const o = ce.exec(r)?.[0] ?? "";
|
|
2017
95
|
return {
|
|
2018
|
-
line:
|
|
2019
|
-
indentation:
|
|
96
|
+
line: r,
|
|
97
|
+
indentation: ue(o, i),
|
|
2020
98
|
// Boolean indicating whether this line can be re-indented.
|
|
2021
99
|
locked: !1,
|
|
2022
|
-
sliceStart:
|
|
2023
|
-
sliceEnd:
|
|
100
|
+
sliceStart: o.length,
|
|
101
|
+
sliceEnd: r.length
|
|
2024
102
|
};
|
|
2025
103
|
})
|
|
2026
104
|
);
|
|
@@ -2029,15 +107,15 @@ class Z {
|
|
|
2029
107
|
return this.sliceString(this.firstPos(), this.lastPos());
|
|
2030
108
|
}
|
|
2031
109
|
charAt(e) {
|
|
2032
|
-
const { line: t, column: i } = e,
|
|
2033
|
-
if (typeof
|
|
110
|
+
const { line: t, column: i } = e, s = this.lineRecords[t - 1];
|
|
111
|
+
if (typeof s > "u" || i < 0)
|
|
2034
112
|
return "";
|
|
2035
|
-
const
|
|
2036
|
-
if (i <
|
|
113
|
+
const r = this.getIndentationAt(t);
|
|
114
|
+
if (i < r)
|
|
2037
115
|
return " ";
|
|
2038
|
-
const
|
|
2039
|
-
return
|
|
2040
|
-
` :
|
|
116
|
+
const o = i + s.sliceStart - r;
|
|
117
|
+
return o === s.sliceEnd && t < this.length ? `
|
|
118
|
+
` : o >= s.sliceEnd ? "" : s.line.charAt(o);
|
|
2041
119
|
}
|
|
2042
120
|
getIndentationAt(e) {
|
|
2043
121
|
return Math.max(this.lineRecords[e - 1].indentation, 0);
|
|
@@ -2048,14 +126,14 @@ class Z {
|
|
|
2048
126
|
}
|
|
2049
127
|
getStatementLineSeparators(e) {
|
|
2050
128
|
const t = this.slice(e, this.skipSpaces({ ...e }) ?? this.lastPos());
|
|
2051
|
-
return t.length === 1 || !
|
|
129
|
+
return t.length === 1 || !D(t.lineRecords[1].line) ? [`
|
|
2052
130
|
`] : [`
|
|
2053
131
|
`, `
|
|
2054
132
|
`];
|
|
2055
133
|
}
|
|
2056
134
|
getLeadingCommentSeparators(e) {
|
|
2057
135
|
const t = this.slice(e, this.skipSpaces({ ...e }) ?? this.lastPos());
|
|
2058
|
-
return t.length === 1 ? [" "] :
|
|
136
|
+
return t.length === 1 ? [" "] : D(t.lineRecords[1].line) ? [`
|
|
2059
137
|
`, `
|
|
2060
138
|
`] : [`
|
|
2061
139
|
`];
|
|
@@ -2065,14 +143,14 @@ class Z {
|
|
|
2065
143
|
return Math.max(e.column, 0) < this.getLineLength(i) ? (e.column += 1, t ? !!this.skipSpaces(e) : !0) : i < this.length ? (e.line += 1, e.column = 0, t ? !!this.skipSpaces(e) : !0) : !1;
|
|
2066
144
|
}
|
|
2067
145
|
prevPos(e, t = !1) {
|
|
2068
|
-
let i = e.line,
|
|
2069
|
-
if (
|
|
146
|
+
let i = e.line, s = e.column;
|
|
147
|
+
if (s < 1) {
|
|
2070
148
|
if (i -= 1, i < 1)
|
|
2071
149
|
return !1;
|
|
2072
|
-
|
|
150
|
+
s = this.getLineLength(i);
|
|
2073
151
|
} else
|
|
2074
|
-
|
|
2075
|
-
return e.line = i, e.column =
|
|
152
|
+
s = Math.min(s - 1, this.getLineLength(i));
|
|
153
|
+
return e.line = i, e.column = s, t ? !!this.skipSpaces(e, !0) : !0;
|
|
2076
154
|
}
|
|
2077
155
|
firstPos() {
|
|
2078
156
|
return { line: 1, column: 0 };
|
|
@@ -2086,11 +164,11 @@ class Z {
|
|
|
2086
164
|
skipSpaces(e, t = !1) {
|
|
2087
165
|
if (t) {
|
|
2088
166
|
for (; this.prevPos(e); )
|
|
2089
|
-
if (!
|
|
167
|
+
if (!D(this.charAt(e)) && this.nextPos(e))
|
|
2090
168
|
return e;
|
|
2091
169
|
return null;
|
|
2092
170
|
} else {
|
|
2093
|
-
for (;
|
|
171
|
+
for (; D(this.charAt(e)); )
|
|
2094
172
|
if (!this.nextPos(e))
|
|
2095
173
|
return null;
|
|
2096
174
|
return e;
|
|
@@ -2102,29 +180,29 @@ class Z {
|
|
|
2102
180
|
if (t ??= this.lastPos(), !e)
|
|
2103
181
|
throw new Error("cannot slice with end but not start");
|
|
2104
182
|
const i = this.lineRecords.slice(e.line - 1, t.line);
|
|
2105
|
-
return e.line === t.line ? i[0] =
|
|
183
|
+
return e.line === t.line ? i[0] = N(i[0], e.column, t.column) : (i[0] = N(i[0], e.column), i.push(N(i.pop() ?? i[0], 0, t.column))), new M(i);
|
|
2106
184
|
}
|
|
2107
185
|
sliceString(e = this.firstPos(), t = this.lastPos()) {
|
|
2108
186
|
const i = [];
|
|
2109
|
-
for (let
|
|
2110
|
-
let
|
|
2111
|
-
|
|
2112
|
-
let
|
|
2113
|
-
const
|
|
2114
|
-
|
|
187
|
+
for (let s = e.line; s <= t.line; s++) {
|
|
188
|
+
let r = this.lineRecords[s - 1];
|
|
189
|
+
s === e.line ? s === t.line ? r = N(r, e.column, t.column) : r = N(r, e.column) : s === t.line && (r = N(r, 0, t.column));
|
|
190
|
+
let o = "";
|
|
191
|
+
const c = Math.max(r.indentation, 0);
|
|
192
|
+
c > 0 && (o += new Array(c + 1).join(" ")), o += r.line.slice(r.sliceStart, r.sliceEnd), i.push(o);
|
|
2115
193
|
}
|
|
2116
194
|
return i.join(`
|
|
2117
195
|
`);
|
|
2118
196
|
}
|
|
2119
197
|
}
|
|
2120
|
-
function
|
|
198
|
+
function ue(n, e = 2) {
|
|
2121
199
|
let t = 0;
|
|
2122
200
|
const i = n.length;
|
|
2123
|
-
for (let
|
|
2124
|
-
switch (n.charCodeAt(
|
|
201
|
+
for (let s = 0; s < i; s++)
|
|
202
|
+
switch (n.charCodeAt(s)) {
|
|
2125
203
|
case 9: {
|
|
2126
|
-
const
|
|
2127
|
-
|
|
204
|
+
const r = Math.ceil(t / e) * e;
|
|
205
|
+
r === t ? t += e : t = r;
|
|
2128
206
|
break;
|
|
2129
207
|
}
|
|
2130
208
|
case 11:
|
|
@@ -2142,26 +220,26 @@ function ft(n, e = 2) {
|
|
|
2142
220
|
}
|
|
2143
221
|
return t;
|
|
2144
222
|
}
|
|
2145
|
-
function
|
|
2146
|
-
let i = n.sliceStart,
|
|
2147
|
-
const
|
|
2148
|
-
return t ??=
|
|
223
|
+
function N(n, e, t) {
|
|
224
|
+
let i = n.sliceStart, s = n.sliceEnd, r = Math.max(n.indentation, 0);
|
|
225
|
+
const o = r + s - i;
|
|
226
|
+
return t ??= o, e = Math.max(e, 0), t = Math.min(t, o), t = Math.max(t, e), t < r ? (r = t, s = i) : s -= o - t, e < r ? r -= e : (e -= r, r = 0, i += e), n.indentation === r && n.sliceStart === i && n.sliceEnd === s ? n : {
|
|
2149
227
|
line: n.line,
|
|
2150
|
-
indentation:
|
|
228
|
+
indentation: r,
|
|
2151
229
|
sliceStart: i,
|
|
2152
|
-
sliceEnd:
|
|
230
|
+
sliceEnd: s
|
|
2153
231
|
};
|
|
2154
232
|
}
|
|
2155
|
-
function
|
|
233
|
+
function K(n, e, t) {
|
|
2156
234
|
return !n && !t ? "" : n ? t ? `${n}${e}${t}` : n : t;
|
|
2157
235
|
}
|
|
2158
|
-
const
|
|
2159
|
-
class
|
|
236
|
+
const he = /\u000D\u000A|\u000D(?!\u000A)|\u000A|\u2028|\u2029/u;
|
|
237
|
+
class u {
|
|
2160
238
|
constructor(e = []) {
|
|
2161
239
|
this.lines = e;
|
|
2162
240
|
}
|
|
2163
241
|
static fromString(e) {
|
|
2164
|
-
return new
|
|
242
|
+
return new u(e.split(he));
|
|
2165
243
|
}
|
|
2166
244
|
/**
|
|
2167
245
|
* Append the elements lines together into a new FormattedLines.
|
|
@@ -2170,7 +248,7 @@ class D {
|
|
|
2170
248
|
* @returns
|
|
2171
249
|
*/
|
|
2172
250
|
static appendLines(e = []) {
|
|
2173
|
-
const t = new
|
|
251
|
+
const t = new u();
|
|
2174
252
|
return e.forEach((i) => {
|
|
2175
253
|
i != null && (typeof i == "string" ? t.lines.push(i) : t.lines.push(...i.lines));
|
|
2176
254
|
}), t;
|
|
@@ -2184,12 +262,12 @@ class D {
|
|
|
2184
262
|
* @returns
|
|
2185
263
|
*/
|
|
2186
264
|
static joinLines(e = [], t = "") {
|
|
2187
|
-
const i = new
|
|
2188
|
-
return e.forEach((
|
|
2189
|
-
if (
|
|
265
|
+
const i = new u();
|
|
266
|
+
return e.forEach((s) => {
|
|
267
|
+
if (s == null)
|
|
2190
268
|
return;
|
|
2191
|
-
const
|
|
2192
|
-
typeof
|
|
269
|
+
const r = i.lines.pop() ?? "";
|
|
270
|
+
typeof s == "string" ? i.lines.push(K(r, t, s)) : (i.lines.push(K(r, t, s.lines.slice(0)[0])), i.lines.push(...s.lines.slice(1)));
|
|
2193
271
|
}), i;
|
|
2194
272
|
}
|
|
2195
273
|
/**
|
|
@@ -2203,16 +281,16 @@ class D {
|
|
|
2203
281
|
* @param indentation
|
|
2204
282
|
* @returns
|
|
2205
283
|
*/
|
|
2206
|
-
static aggregateLines(e, t, i,
|
|
284
|
+
static aggregateLines(e, t, i, s, r) {
|
|
2207
285
|
if (i.isEmpty)
|
|
2208
286
|
return e;
|
|
2209
287
|
if (!t || e.isEmpty)
|
|
2210
|
-
return i.indentFirstLine(
|
|
2211
|
-
const
|
|
2212
|
-
if (
|
|
2213
|
-
return
|
|
2214
|
-
const
|
|
2215
|
-
return
|
|
288
|
+
return i.indentFirstLine(r);
|
|
289
|
+
const o = s.start.line - t.end.line;
|
|
290
|
+
if (o === 0)
|
|
291
|
+
return u.joinLines([e, " ", i]);
|
|
292
|
+
const c = o === 1 ? void 0 : "";
|
|
293
|
+
return u.appendLines([e, c, i.indentFirstLine(r)]);
|
|
2216
294
|
}
|
|
2217
295
|
get isEmpty() {
|
|
2218
296
|
return this.lines.length === 0 || this.lines.length === 1 && this.lines[0].length === 0;
|
|
@@ -2227,7 +305,7 @@ class D {
|
|
|
2227
305
|
return (this.lines[this.lines.length - 1] ?? "").length;
|
|
2228
306
|
}
|
|
2229
307
|
surroundWith(e = "", t = "") {
|
|
2230
|
-
return !e && !t ? this : this.isEmpty ? new
|
|
308
|
+
return !e && !t ? this : this.isEmpty ? new u([e + t]) : this.lines.length === 1 ? new u([e + this.lines[0] + t]) : u.joinLines([e, this, t]);
|
|
2231
309
|
}
|
|
2232
310
|
indentFirstLine(e = "") {
|
|
2233
311
|
return this.isEmpty ? this : (this.lines[0] = e + this.lines[0], this);
|
|
@@ -2240,53 +318,53 @@ class D {
|
|
|
2240
318
|
return this.lines.join(e);
|
|
2241
319
|
}
|
|
2242
320
|
}
|
|
2243
|
-
function
|
|
321
|
+
function W(n, e) {
|
|
2244
322
|
return n * (e.indentWidth ?? 2);
|
|
2245
323
|
}
|
|
2246
|
-
function
|
|
2247
|
-
const { indentWidth: t = 2 } =
|
|
324
|
+
function w(n = 0, e) {
|
|
325
|
+
const { indentWidth: t = 2 } = O(e);
|
|
2248
326
|
return new Array(n * t + 1).join(" ");
|
|
2249
327
|
}
|
|
2250
|
-
function
|
|
328
|
+
function F(n) {
|
|
2251
329
|
return n.replace(/['"]/gu, (e) => e === '"' ? "'" : '"');
|
|
2252
330
|
}
|
|
2253
|
-
function
|
|
331
|
+
function pe(n, e) {
|
|
2254
332
|
switch (n.type) {
|
|
2255
|
-
case
|
|
2256
|
-
return (
|
|
2257
|
-
case
|
|
2258
|
-
case
|
|
333
|
+
case a.NodeTypes.UnaryExpression:
|
|
334
|
+
return (a.isMemberExpression(e) || a.isSafeMemberExpression(e)) && e.object === n;
|
|
335
|
+
case a.NodeTypes.BinaryExpression:
|
|
336
|
+
case a.NodeTypes.LogicalExpression:
|
|
2259
337
|
switch (e.type) {
|
|
2260
|
-
case
|
|
338
|
+
case a.NodeTypes.UnaryExpression:
|
|
2261
339
|
return !0;
|
|
2262
|
-
case
|
|
2263
|
-
case
|
|
340
|
+
case a.NodeTypes.MemberExpression:
|
|
341
|
+
case a.NodeTypes.SafeMemberExpression:
|
|
2264
342
|
return e.object === n;
|
|
2265
|
-
case
|
|
2266
|
-
case
|
|
2267
|
-
return
|
|
343
|
+
case a.NodeTypes.BinaryExpression:
|
|
344
|
+
case a.NodeTypes.LogicalExpression:
|
|
345
|
+
return a.OperatorPrecedence[e.operator] > a.OperatorPrecedence[n.operator];
|
|
2268
346
|
default:
|
|
2269
347
|
return !1;
|
|
2270
348
|
}
|
|
2271
|
-
case
|
|
2272
|
-
return
|
|
2273
|
-
case
|
|
349
|
+
case a.NodeTypes.Literal:
|
|
350
|
+
return a.isMemberExpression(e) && typeof n.value == "number" && e.object === n;
|
|
351
|
+
case a.NodeTypes.AssignmentExpression:
|
|
2274
352
|
switch (e.type) {
|
|
2275
|
-
case
|
|
2276
|
-
case
|
|
2277
|
-
case
|
|
2278
|
-
case
|
|
353
|
+
case a.NodeTypes.UnaryExpression:
|
|
354
|
+
case a.NodeTypes.BinaryExpression:
|
|
355
|
+
case a.NodeTypes.LogicalExpression:
|
|
356
|
+
case a.NodeTypes.ReturnStatement:
|
|
2279
357
|
return !0;
|
|
2280
|
-
case
|
|
2281
|
-
case
|
|
358
|
+
case a.NodeTypes.MemberExpression:
|
|
359
|
+
case a.NodeTypes.SafeMemberExpression:
|
|
2282
360
|
return e.object === n;
|
|
2283
361
|
default:
|
|
2284
362
|
return !1;
|
|
2285
363
|
}
|
|
2286
|
-
case
|
|
364
|
+
case a.NodeTypes.MemberAccessChainExpression:
|
|
2287
365
|
switch (e.type) {
|
|
2288
|
-
case
|
|
2289
|
-
case
|
|
366
|
+
case a.NodeTypes.MemberExpression:
|
|
367
|
+
case a.NodeTypes.SafeMemberExpression:
|
|
2290
368
|
return e.object === n;
|
|
2291
369
|
default:
|
|
2292
370
|
return !1;
|
|
@@ -2295,101 +373,101 @@ function Et(n, e) {
|
|
|
2295
373
|
return !1;
|
|
2296
374
|
}
|
|
2297
375
|
}
|
|
2298
|
-
function
|
|
376
|
+
function f(n, e, t) {
|
|
2299
377
|
switch (n?.type) {
|
|
2300
|
-
case
|
|
2301
|
-
case
|
|
2302
|
-
return
|
|
2303
|
-
case
|
|
2304
|
-
return new
|
|
2305
|
-
case
|
|
2306
|
-
case
|
|
2307
|
-
return new
|
|
2308
|
-
case
|
|
2309
|
-
return new
|
|
2310
|
-
case
|
|
2311
|
-
return new
|
|
2312
|
-
case
|
|
2313
|
-
return
|
|
2314
|
-
case
|
|
2315
|
-
return
|
|
2316
|
-
case
|
|
2317
|
-
return new
|
|
2318
|
-
case
|
|
2319
|
-
case
|
|
2320
|
-
case
|
|
2321
|
-
return new
|
|
2322
|
-
case
|
|
2323
|
-
return new
|
|
2324
|
-
case
|
|
2325
|
-
return new
|
|
378
|
+
case a.NodeTypes.BinaryExpression:
|
|
379
|
+
case a.NodeTypes.LogicalExpression:
|
|
380
|
+
return fe(n, e, t);
|
|
381
|
+
case a.NodeTypes.AssignmentExpression:
|
|
382
|
+
return new U(n, e, t);
|
|
383
|
+
case a.NodeTypes.MemberExpression:
|
|
384
|
+
case a.NodeTypes.SafeMemberExpression:
|
|
385
|
+
return new ge(n, e, t);
|
|
386
|
+
case a.NodeTypes.Identifier:
|
|
387
|
+
return new z(n, e, t);
|
|
388
|
+
case a.NodeTypes.CallExpression:
|
|
389
|
+
return new me(n, e, t);
|
|
390
|
+
case a.NodeTypes.ObjectExpression:
|
|
391
|
+
return T(n, e, t);
|
|
392
|
+
case a.NodeTypes.ArrayExpression:
|
|
393
|
+
return T(n, e, t);
|
|
394
|
+
case a.NodeTypes.Literal:
|
|
395
|
+
return new z(n, e, t);
|
|
396
|
+
case a.NodeTypes.UpdateExpression:
|
|
397
|
+
case a.NodeTypes.UnaryExpression:
|
|
398
|
+
case a.NodeTypes.MemberAccessChainExpression:
|
|
399
|
+
return new G(n, e, t);
|
|
400
|
+
case a.NodeTypes.TemplateLiteral:
|
|
401
|
+
return new xe(n, e, t);
|
|
402
|
+
case a.NodeTypes.VariableDeclaration:
|
|
403
|
+
return new _(n, e, t);
|
|
2326
404
|
default:
|
|
2327
405
|
throw new Error(`unknown type: ${JSON.stringify(n)}`);
|
|
2328
406
|
}
|
|
2329
407
|
}
|
|
2330
|
-
function
|
|
2331
|
-
const i = new
|
|
408
|
+
function T(n, e, t) {
|
|
409
|
+
const i = new j(n, e, t);
|
|
2332
410
|
switch (n.type) {
|
|
2333
|
-
case
|
|
411
|
+
case a.NodeTypes.ArrayExpression:
|
|
2334
412
|
return i.setupCollection(
|
|
2335
|
-
n.elements.map((
|
|
413
|
+
n.elements.map((s) => f(s, n, t)),
|
|
2336
414
|
"SquareBrackets"
|
|
2337
415
|
), i;
|
|
2338
|
-
case
|
|
416
|
+
case a.NodeTypes.ObjectExpression:
|
|
2339
417
|
return i.setupCollection(
|
|
2340
|
-
n.properties.map((
|
|
418
|
+
n.properties.map((s) => new ye(s, n, t)),
|
|
2341
419
|
"CurlyBrackets"
|
|
2342
420
|
), i;
|
|
2343
|
-
case
|
|
421
|
+
case a.NodeTypes.VariableDeclaration:
|
|
2344
422
|
return i.prefix = "var ", i.setupCollection(
|
|
2345
|
-
n.declarations.map((
|
|
423
|
+
n.declarations.map((s) => Y(s, n, t)),
|
|
2346
424
|
"None"
|
|
2347
425
|
), i;
|
|
2348
|
-
case
|
|
426
|
+
case a.NodeTypes.FunctionDeclaration:
|
|
2349
427
|
return i.prefix = `function ${n.id.name}`, i.setupCollection(
|
|
2350
|
-
n.params.map((
|
|
428
|
+
n.params.map((s) => f(s, n, t)),
|
|
2351
429
|
"Parentheses"
|
|
2352
430
|
), i;
|
|
2353
|
-
case
|
|
431
|
+
case a.NodeTypes.ForStatement:
|
|
2354
432
|
return i.prefix = "for ", i.setupCollection(
|
|
2355
433
|
[
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
434
|
+
f(n.init, n, t),
|
|
435
|
+
f(n.test, n, t),
|
|
436
|
+
f(n.update, n, t)
|
|
2359
437
|
],
|
|
2360
438
|
"Parentheses",
|
|
2361
439
|
";"
|
|
2362
440
|
), i;
|
|
2363
|
-
case
|
|
2364
|
-
case
|
|
2365
|
-
return i.prefix = "for ", i.setupCollection([new
|
|
2366
|
-
case
|
|
2367
|
-
return i.prefix = "if ", i.setupCollection([
|
|
2368
|
-
case
|
|
2369
|
-
return i.prefix = "while ", i.setupCollection([
|
|
441
|
+
case a.NodeTypes.ForInStatement:
|
|
442
|
+
case a.NodeTypes.ForOfStatement:
|
|
443
|
+
return i.prefix = "for ", i.setupCollection([new U(n, e, t)], "Parentheses", ""), i;
|
|
444
|
+
case a.NodeTypes.IfStatement:
|
|
445
|
+
return i.prefix = "if ", i.setupCollection([f(n.test, n, t)], "Parentheses", ""), i;
|
|
446
|
+
case a.NodeTypes.WhileStatement:
|
|
447
|
+
return i.prefix = "while ", i.setupCollection([f(n.test, n, t)], "Parentheses", ""), i;
|
|
2370
448
|
default:
|
|
2371
449
|
return i;
|
|
2372
450
|
}
|
|
2373
451
|
}
|
|
2374
|
-
function
|
|
2375
|
-
return n.init ? new
|
|
452
|
+
function Y(n, e, t) {
|
|
453
|
+
return n.init ? new U(n, e, t) : new z(n.id, e, t);
|
|
2376
454
|
}
|
|
2377
|
-
function
|
|
2378
|
-
const
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
].map((
|
|
2382
|
-
return
|
|
455
|
+
function fe(n, e, t) {
|
|
456
|
+
const s = [
|
|
457
|
+
...$(n.left, n.operator),
|
|
458
|
+
...$(n.right, n.operator)
|
|
459
|
+
].map((o) => f(o, n, t)), r = new j(n, e, t);
|
|
460
|
+
return r.setupCollection(s, "None", ` ${n.operator}`), r;
|
|
2383
461
|
}
|
|
2384
|
-
function
|
|
2385
|
-
return n.type !==
|
|
2386
|
-
|
|
2387
|
-
|
|
462
|
+
function $(n, e) {
|
|
463
|
+
return n.type !== a.NodeTypes.BinaryExpression && n.type !== a.NodeTypes.LogicalExpression ? [n] : n.operator !== e ? [n] : [
|
|
464
|
+
...$(n.left, e),
|
|
465
|
+
...$(n.right, e)
|
|
2388
466
|
];
|
|
2389
467
|
}
|
|
2390
|
-
class
|
|
468
|
+
class E {
|
|
2391
469
|
constructor(e, t, i) {
|
|
2392
|
-
this.node = e, this.parent = t, this.options = i, this.prefix = "", this.suffix = "", this.groupingParentheses = !1, this.groupingParentheses =
|
|
470
|
+
this.node = e, this.parent = t, this.options = i, this.prefix = "", this.suffix = "", this.groupingParentheses = !1, this.groupingParentheses = pe(e, t);
|
|
2393
471
|
}
|
|
2394
472
|
get openingParenthesis() {
|
|
2395
473
|
return this.groupingParentheses ? "(" : "";
|
|
@@ -2404,10 +482,10 @@ class L {
|
|
|
2404
482
|
return [this.closingParenthesis, this.suffix].join("");
|
|
2405
483
|
}
|
|
2406
484
|
finalize(e) {
|
|
2407
|
-
return typeof e == "string" && (e =
|
|
485
|
+
return typeof e == "string" && (e = u.fromString(e)), e.surroundWith(this.leadingString, this.trailingString);
|
|
2408
486
|
}
|
|
2409
487
|
}
|
|
2410
|
-
class
|
|
488
|
+
class j extends E {
|
|
2411
489
|
constructor(e, t, i) {
|
|
2412
490
|
super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "CollectionPrinter", this.bracketsType = "None", this.separator = ",", this.printers = [];
|
|
2413
491
|
}
|
|
@@ -2443,251 +521,251 @@ class Y extends L {
|
|
|
2443
521
|
}
|
|
2444
522
|
}
|
|
2445
523
|
getLinesLevel(e = 0) {
|
|
2446
|
-
return this.bracketsType !== "None" ||
|
|
524
|
+
return this.bracketsType !== "None" || a.isExpressionStatement(this.parent) || a.isVariableDeclarator(this.parent) || (a.isLogicalExpression(this.node) || a.isBinaryExpression(this.node)) && (a.isLogicalExpression(this.parent) || a.isBinaryExpression(this.parent)) ? e + 1 : e;
|
|
2447
525
|
}
|
|
2448
526
|
finalize(e, t = "singleLine", i = 0) {
|
|
2449
527
|
if (this.bracketsType === "None")
|
|
2450
528
|
return super.finalize(e);
|
|
2451
|
-
const
|
|
529
|
+
const s = this.getOpeningBracket(e.isEmpty, t), r = this.getClosingBracket(e.isEmpty, t);
|
|
2452
530
|
if (t === "singleLine")
|
|
2453
|
-
return super.finalize(e.surroundWith(
|
|
2454
|
-
const
|
|
2455
|
-
return super.finalize(
|
|
531
|
+
return super.finalize(e.surroundWith(s, r));
|
|
532
|
+
const o = w(i, this.options);
|
|
533
|
+
return super.finalize(u.appendLines([s, e, o + r]));
|
|
2456
534
|
}
|
|
2457
535
|
singleLineFormat(e = 0) {
|
|
2458
536
|
const t = this.printers.length - 1;
|
|
2459
|
-
return
|
|
537
|
+
return u.joinLines(
|
|
2460
538
|
this.printers.map(
|
|
2461
|
-
(i,
|
|
539
|
+
(i, s) => i.format("singleLine", e).suffixWith(s < t ? this.separator : "")
|
|
2462
540
|
),
|
|
2463
541
|
" "
|
|
2464
542
|
);
|
|
2465
543
|
}
|
|
2466
544
|
optimizedPrinterFormat(e, t, i = 0) {
|
|
2467
|
-
const
|
|
2468
|
-
return
|
|
545
|
+
const s = this.getLinesLevel(i), r = w(s, this.options), o = this.bracketsType === "None" && t === 0 ? "" : r, c = t < this.printers.length - 1 ? this.separator : "", l = e.format("singleLine", s).suffixWith(c);
|
|
546
|
+
return l.maxLineLength + r.length <= this.options.wrapColumn ? l.indentFirstLine(o) : e.format("multiline", s).suffixWith(c).indentFirstLine(o);
|
|
2469
547
|
}
|
|
2470
548
|
multilineFormat(e = 0) {
|
|
2471
|
-
return
|
|
549
|
+
return u.appendLines(
|
|
2472
550
|
this.printers.map((t, i) => this.optimizedPrinterFormat(t, i, e))
|
|
2473
551
|
);
|
|
2474
552
|
}
|
|
2475
553
|
format(e = "singleLine", t = 0) {
|
|
2476
554
|
if (this.printers.length === 0) {
|
|
2477
|
-
const
|
|
2478
|
-
return super.finalize(
|
|
555
|
+
const s = this.getOpeningBracket(!0, e), r = this.getClosingBracket(!0, e);
|
|
556
|
+
return super.finalize(u.fromString(s + r));
|
|
2479
557
|
}
|
|
2480
558
|
if (e === "singleLine") {
|
|
2481
|
-
const
|
|
2482
|
-
return this.finalize(
|
|
559
|
+
const s = this.singleLineFormat(t);
|
|
560
|
+
return this.finalize(s, e, t);
|
|
2483
561
|
}
|
|
2484
562
|
const i = this.multilineFormat(t);
|
|
2485
563
|
return this.finalize(i, e, t);
|
|
2486
564
|
}
|
|
2487
565
|
}
|
|
2488
|
-
const
|
|
2489
|
-
class
|
|
566
|
+
const de = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/u;
|
|
567
|
+
class z extends E {
|
|
2490
568
|
constructor(e, t, i) {
|
|
2491
569
|
super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "StringPrinter";
|
|
2492
570
|
}
|
|
2493
571
|
format() {
|
|
2494
|
-
if (
|
|
572
|
+
if (a.isIdentifier(this.node))
|
|
2495
573
|
return this.finalize(this.node.name);
|
|
2496
574
|
if (typeof this.node.value != "string")
|
|
2497
575
|
return this.finalize(this.node.raw);
|
|
2498
|
-
if (
|
|
576
|
+
if (a.isProperty(this.parent) && this.parent.key === this.node && a.isLiteral(this.node) && typeof this.node.value == "string" && de.test(this.node.value))
|
|
2499
577
|
return this.finalize(this.node.value);
|
|
2500
578
|
switch (this.options.quote) {
|
|
2501
579
|
case "auto": {
|
|
2502
|
-
const e = JSON.stringify(this.node.value), t =
|
|
580
|
+
const e = JSON.stringify(this.node.value), t = F(JSON.stringify(F(this.node.value)));
|
|
2503
581
|
return this.finalize(e.length > t.length ? t : e);
|
|
2504
582
|
}
|
|
2505
583
|
case "single":
|
|
2506
|
-
return this.finalize(
|
|
584
|
+
return this.finalize(F(JSON.stringify(F(this.node.value))));
|
|
2507
585
|
default:
|
|
2508
586
|
return this.finalize(JSON.stringify(this.node.value));
|
|
2509
587
|
}
|
|
2510
588
|
}
|
|
2511
589
|
}
|
|
2512
|
-
class
|
|
590
|
+
class G extends E {
|
|
2513
591
|
constructor(e, t, i) {
|
|
2514
592
|
super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "SingleExpressionPrinter";
|
|
2515
|
-
const
|
|
2516
|
-
if (
|
|
2517
|
-
this.prefix =
|
|
593
|
+
const s = a.isUnaryExpression(e), r = a.isUpdateExpression(e);
|
|
594
|
+
if (s || r) {
|
|
595
|
+
this.prefix = s ? e.operator : "", this.suffix = r && !e.prefix ? e.operator : "", this.printer = f(e.argument, e, this.options);
|
|
2518
596
|
return;
|
|
2519
597
|
}
|
|
2520
|
-
if (
|
|
2521
|
-
this.printer =
|
|
598
|
+
if (a.isMemberAccessChainExpression(e)) {
|
|
599
|
+
this.printer = f(e.expression, e, this.options);
|
|
2522
600
|
return;
|
|
2523
601
|
}
|
|
2524
|
-
this.printer =
|
|
602
|
+
this.printer = f(e, t, this.options);
|
|
2525
603
|
}
|
|
2526
604
|
format(e = "singleLine", t = 0) {
|
|
2527
605
|
return this.finalize(this.printer.format(e, t));
|
|
2528
606
|
}
|
|
2529
607
|
}
|
|
2530
|
-
class
|
|
608
|
+
class _ extends E {
|
|
2531
609
|
constructor(e, t, i) {
|
|
2532
|
-
super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "VariableDeclaratorsPrinter", e.declarations.length === 1 ? (this.printer =
|
|
610
|
+
super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "VariableDeclaratorsPrinter", e.declarations.length === 1 ? (this.printer = Y(e.declarations[0], e, this.options), this.printer.prefix = "var ") : this.printer = T(e, t, this.options);
|
|
2533
611
|
}
|
|
2534
612
|
format(e = "singleLine", t = 0) {
|
|
2535
613
|
return this.finalize(this.printer.format(e, t));
|
|
2536
614
|
}
|
|
2537
615
|
}
|
|
2538
|
-
class
|
|
616
|
+
class me extends E {
|
|
2539
617
|
constructor(e, t, i) {
|
|
2540
|
-
super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "CallExpressionPrinter", this.argumentsPrinter = new
|
|
2541
|
-
e.arguments.map((
|
|
618
|
+
super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "CallExpressionPrinter", this.argumentsPrinter = new j(e, t, i), this.argumentsPrinter.setupCollection(
|
|
619
|
+
e.arguments.map((s) => f(s, e, i)),
|
|
2542
620
|
"Parentheses"
|
|
2543
|
-
),
|
|
621
|
+
), a.isIdentifier(e.callee) ? this.argumentsPrinter.prefix = e.callee.name : this.calleePrinter = f(e.callee, t, i);
|
|
2544
622
|
}
|
|
2545
623
|
format(e = "singleLine", t = 0) {
|
|
2546
624
|
if (!this.calleePrinter)
|
|
2547
625
|
return this.finalize(this.argumentsPrinter.format(e, t));
|
|
2548
|
-
let i = this.calleePrinter.format("singleLine", t),
|
|
626
|
+
let i = this.calleePrinter.format("singleLine", t), s = this.argumentsPrinter.format("singleLine", t);
|
|
2549
627
|
if (e === "singleLine")
|
|
2550
|
-
return this.finalize(
|
|
2551
|
-
let
|
|
2552
|
-
return
|
|
628
|
+
return this.finalize(u.joinLines([i, s]));
|
|
629
|
+
let r = W(t, this.options) + this.leadingString.length + i.firstLineLength;
|
|
630
|
+
return r + 1 < this.options.wrapColumn ? (s = this.argumentsPrinter.format("multiline", t), this.finalize(u.joinLines([i, s]))) : (i = this.calleePrinter.format("multiline", t), r = i.lastLineLength, r + s.maxLineLength > this.options.wrapColumn && (s = this.argumentsPrinter.format("multiline", t + 1)), this.finalize(u.joinLines([i, s])));
|
|
2553
631
|
}
|
|
2554
632
|
}
|
|
2555
|
-
class
|
|
633
|
+
class ge extends E {
|
|
2556
634
|
constructor(e, t, i) {
|
|
2557
|
-
if (super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "MemberExpressionPrinter", this.objectPrinter =
|
|
2558
|
-
const
|
|
2559
|
-
|
|
635
|
+
if (super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "MemberExpressionPrinter", this.objectPrinter = f(e.object, e, this.options), e.computed) {
|
|
636
|
+
const s = new j(e.property, e, this.options);
|
|
637
|
+
s.setupCollection([f(e.property, e, this.options)], "SquareBrackets"), s.prefix = e.type === "SafeMemberExpression" ? a.SafeAccessOperator : "", this.propertyPrinter = s;
|
|
2560
638
|
} else {
|
|
2561
|
-
const
|
|
2562
|
-
|
|
639
|
+
const s = new G(e.property, e, this.options);
|
|
640
|
+
s.prefix = e.type === "SafeMemberExpression" ? a.SafeAccessOperator : ".", this.propertyPrinter = s;
|
|
2563
641
|
}
|
|
2564
642
|
}
|
|
2565
643
|
format(e = "singleLine", t = 0) {
|
|
2566
|
-
let i = this.objectPrinter.format("singleLine", t),
|
|
644
|
+
let i = this.objectPrinter.format("singleLine", t), s = this.propertyPrinter.format("singleLine", t);
|
|
2567
645
|
if (e === "singleLine")
|
|
2568
|
-
return this.finalize(
|
|
2569
|
-
let
|
|
2570
|
-
|
|
2571
|
-
let
|
|
2572
|
-
if (
|
|
2573
|
-
return this.finalize(
|
|
646
|
+
return this.finalize(u.joinLines([i, s]));
|
|
647
|
+
let r = W(t, this.options) + this.leadingString.length + i.firstLineLength;
|
|
648
|
+
r > this.options.wrapColumn && (i = this.objectPrinter.format("multiline", t), r = i.lastLineLength);
|
|
649
|
+
let o = s.firstLineLength + this.trailingString.length;
|
|
650
|
+
if (r + o < this.options.wrapColumn)
|
|
651
|
+
return this.finalize(u.joinLines([i, s]));
|
|
2574
652
|
if (this.node.computed)
|
|
2575
|
-
return this.finalize(
|
|
2576
|
-
const
|
|
2577
|
-
return
|
|
653
|
+
return this.finalize(u.joinLines([i, this.propertyPrinter.format("multiline", t)]));
|
|
654
|
+
const c = t + 1, l = w(c, this.options);
|
|
655
|
+
return s = this.propertyPrinter.format("singleLine", t), o = l.length + s.lastLineLength + this.trailingString.length, o > this.options.wrapColumn && (s = this.propertyPrinter.format("multiline", c)), this.finalize(u.appendLines([i, s.indentFirstLine(l)]));
|
|
2578
656
|
}
|
|
2579
657
|
}
|
|
2580
|
-
class
|
|
658
|
+
class ye extends E {
|
|
2581
659
|
constructor(e, t, i) {
|
|
2582
|
-
super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "PropertyPrinter", this.key =
|
|
660
|
+
super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "PropertyPrinter", this.key = f(e.key, e, this.options), e.shorthand || (this.key.suffix = ":", this.value = f(e.value, e, this.options));
|
|
2583
661
|
}
|
|
2584
662
|
format(e = "singleLine", t = 0) {
|
|
2585
663
|
if (this.node.shorthand || !this.value)
|
|
2586
664
|
return this.finalize(this.key.format(e, t));
|
|
2587
665
|
const i = this.key.format("singleLine", t);
|
|
2588
666
|
if (e === "singleLine") {
|
|
2589
|
-
const
|
|
2590
|
-
return this.finalize(
|
|
667
|
+
const c = this.value.format("singleLine", t);
|
|
668
|
+
return this.finalize(u.joinLines([i, c], " "));
|
|
2591
669
|
}
|
|
2592
|
-
if (
|
|
2593
|
-
const
|
|
2594
|
-
return this.finalize(
|
|
670
|
+
if (a.isArrayExpression(this.node.value) || a.isArrayExpression(this.node.value)) {
|
|
671
|
+
const c = this.value.format("multiline", t);
|
|
672
|
+
return this.finalize(u.joinLines([i, c], " "));
|
|
2595
673
|
}
|
|
2596
|
-
const
|
|
2597
|
-
let
|
|
2598
|
-
return
|
|
674
|
+
const s = w(t + 1, this.options);
|
|
675
|
+
let r = this.value.format("singleLine", t + 1).indentFirstLine(s);
|
|
676
|
+
return r.maxLineLength + this.trailingString.length + 1 <= this.options.wrapColumn ? this.finalize(u.appendLines([i, r])) : (r = this.value.format("multiline", t + 1).indentFirstLine(s), this.finalize(u.appendLines([i, r])));
|
|
2599
677
|
}
|
|
2600
678
|
}
|
|
2601
|
-
class
|
|
679
|
+
class U extends E {
|
|
2602
680
|
constructor(e, t, i) {
|
|
2603
681
|
switch (super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "OperationPrinter", this.operator = "", this.noNewLineWrapping = !1, e.type) {
|
|
2604
|
-
case
|
|
2605
|
-
this.leftPrinter =
|
|
682
|
+
case a.NodeTypes.AssignmentExpression:
|
|
683
|
+
this.leftPrinter = f(e.left, e, this.options), this.operator = ` ${e.operator}`, this.rightPrinter = f(e.right, e, this.options), this.noNewLineWrapping = (a.isIdentifier(e.left) || a.isLiteral(e.left)) && (a.isArrayExpression(e.right) || a.isObjectExpression(e.right));
|
|
2606
684
|
return;
|
|
2607
|
-
case
|
|
2608
|
-
this.leftPrinter =
|
|
685
|
+
case a.NodeTypes.VariableDeclarator:
|
|
686
|
+
this.leftPrinter = f(e.id, e, this.options), e.init && (this.operator = " =", this.rightPrinter = f(e.init, e, this.options)), this.noNewLineWrapping = a.isArrayExpression(e.init) || a.isObjectExpression(e.init);
|
|
2609
687
|
return;
|
|
2610
|
-
case
|
|
2611
|
-
case
|
|
2612
|
-
this.leftPrinter =
|
|
688
|
+
case a.NodeTypes.ForInStatement:
|
|
689
|
+
case a.NodeTypes.ForOfStatement:
|
|
690
|
+
this.leftPrinter = f(e.left, e, this.options), this.operator = e.type === "ForInStatement" ? " in" : " of", this.rightPrinter = f(e.right, e, this.options);
|
|
2613
691
|
return;
|
|
2614
|
-
case
|
|
2615
|
-
case
|
|
2616
|
-
this.leftPrinter =
|
|
692
|
+
case a.NodeTypes.BinaryExpression:
|
|
693
|
+
case a.NodeTypes.LogicalExpression:
|
|
694
|
+
this.leftPrinter = f(e.left, e, this.options), this.operator = ` ${e.operator}`, this.rightPrinter = f(e.right, e, this.options);
|
|
2617
695
|
return;
|
|
2618
696
|
}
|
|
2619
697
|
}
|
|
2620
698
|
format(e = "singleLine", t = 0) {
|
|
2621
699
|
if (!this.rightPrinter)
|
|
2622
700
|
return this.finalize(this.leftPrinter.format(e, t));
|
|
2623
|
-
let i = this.leftPrinter.format("singleLine", t).suffixWith(this.operator),
|
|
701
|
+
let i = this.leftPrinter.format("singleLine", t).suffixWith(this.operator), s = this.rightPrinter.format("singleLine", t);
|
|
2624
702
|
if (e === "singleLine")
|
|
2625
|
-
return this.finalize(
|
|
2626
|
-
let
|
|
2627
|
-
|
|
2628
|
-
const
|
|
2629
|
-
if (
|
|
2630
|
-
return this.finalize(
|
|
2631
|
-
const
|
|
2632
|
-
return
|
|
703
|
+
return this.finalize(u.joinLines([i, s], " "));
|
|
704
|
+
let r = W(t, this.options) + this.leadingString.length + i.maxLineLength + 1;
|
|
705
|
+
r > this.options.wrapColumn && (i = this.leftPrinter.format("multiline", t).suffixWith(this.operator), r = i.lastLineLength + 1);
|
|
706
|
+
const o = s.firstLineLength + this.trailingString.length + 1;
|
|
707
|
+
if (r + o < this.options.wrapColumn)
|
|
708
|
+
return this.finalize(u.joinLines([i, s], " "));
|
|
709
|
+
const c = this.rightPrinter.format("multiline", t);
|
|
710
|
+
return c.firstLineLength + this.trailingString.length + 1 + r < this.options.wrapColumn || this.noNewLineWrapping ? this.finalize(u.joinLines([i, c], " ")) : (o > this.options.wrapColumn && (s = this.rightPrinter.format("multiline", t + 1)), s = s.indentFirstLine(w(t + 1)), this.finalize(u.appendLines([i, s])));
|
|
2633
711
|
}
|
|
2634
712
|
}
|
|
2635
|
-
class
|
|
713
|
+
class xe extends E {
|
|
2636
714
|
constructor(e, t, i) {
|
|
2637
715
|
super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "TemplateLiteralPrinter", this.parts = [];
|
|
2638
|
-
const
|
|
2639
|
-
(
|
|
716
|
+
const s = e.expressions.map(
|
|
717
|
+
(r) => f(r, e, this.options)
|
|
2640
718
|
);
|
|
2641
|
-
this.parts.push("`"), e.quasis.forEach((
|
|
2642
|
-
this.parts.push(
|
|
719
|
+
this.parts.push("`"), e.quasis.forEach((r, o) => {
|
|
720
|
+
this.parts.push(r.value.raw), o < s.length && (this.parts.push("${"), this.parts.push(s[o]), this.parts.push("}"));
|
|
2643
721
|
}), this.parts.push("`");
|
|
2644
722
|
}
|
|
2645
723
|
format(e = "singleLine", t = 0) {
|
|
2646
724
|
return this.finalize(
|
|
2647
|
-
|
|
725
|
+
u.joinLines(this.parts.map((i) => typeof i == "string" ? i : i.format(e, t)))
|
|
2648
726
|
);
|
|
2649
727
|
}
|
|
2650
728
|
}
|
|
2651
|
-
function
|
|
729
|
+
function Le(n) {
|
|
2652
730
|
const e = { ...n.leadingComments?.slice(0, 1)[0]?.loc.start ?? n.loc.start }, t = { ...n.trailingComments?.slice(-1)[0]?.loc.end ?? n.loc.end };
|
|
2653
731
|
return { start: e, end: t };
|
|
2654
732
|
}
|
|
2655
|
-
function
|
|
2656
|
-
return n.trailingComments?.slice(-1)[0]?.type ===
|
|
733
|
+
function Ee(n) {
|
|
734
|
+
return n.trailingComments?.slice(-1)[0]?.type === a.NodeTypes.LineComment;
|
|
2657
735
|
}
|
|
2658
|
-
class
|
|
736
|
+
class I {
|
|
2659
737
|
constructor(e, t, i) {
|
|
2660
|
-
this.node = e, this.parent = t, this.options = i, this.indentStatementFirstLine = !0, this.externalOffset = 0, this.options =
|
|
738
|
+
this.node = e, this.parent = t, this.options = i, this.indentStatementFirstLine = !0, this.externalOffset = 0, this.options = O(this.options);
|
|
2661
739
|
}
|
|
2662
740
|
createStatementPrinter(e) {
|
|
2663
741
|
switch (e.type) {
|
|
2664
|
-
case
|
|
2665
|
-
return new
|
|
2666
|
-
case
|
|
2667
|
-
return new
|
|
2668
|
-
case
|
|
2669
|
-
return new
|
|
2670
|
-
case
|
|
742
|
+
case a.NodeTypes.Program:
|
|
743
|
+
return new A(e, this.node, this.options);
|
|
744
|
+
case a.NodeTypes.ImportDeclaration:
|
|
745
|
+
return new Ne(e, this.node, this.options);
|
|
746
|
+
case a.NodeTypes.ExpressionStatement:
|
|
747
|
+
return new we(e, this.node, this.options);
|
|
748
|
+
case a.NodeTypes.FunctionDeclaration:
|
|
749
|
+
return new Q(e, this.node, this.options);
|
|
750
|
+
case a.NodeTypes.ExportNamedDeclaration:
|
|
751
|
+
return a.isVariableDeclaration(e) ? new J(e, this.node, this.options) : new Q(e, this.node, this.options);
|
|
752
|
+
case a.NodeTypes.BlockStatement:
|
|
753
|
+
return new A(e, this.node, this.options);
|
|
754
|
+
case a.NodeTypes.ReturnStatement:
|
|
2671
755
|
return new Te(e, this.node, this.options);
|
|
2672
|
-
case
|
|
2673
|
-
return
|
|
2674
|
-
case
|
|
2675
|
-
return new
|
|
2676
|
-
case
|
|
2677
|
-
|
|
2678
|
-
case
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
case
|
|
2683
|
-
case
|
|
2684
|
-
|
|
2685
|
-
case u.WhileStatement:
|
|
2686
|
-
return new kt(e, this.node, this.options);
|
|
2687
|
-
case u.EmptyStatement:
|
|
2688
|
-
case u.BreakStatement:
|
|
2689
|
-
case u.ContinueStatement:
|
|
2690
|
-
return new bt(e, this.node, this.options);
|
|
756
|
+
case a.NodeTypes.VariableDeclaration:
|
|
757
|
+
return new J(e, this.node, this.options);
|
|
758
|
+
case a.NodeTypes.IfStatement:
|
|
759
|
+
return new Se(e, this.node, this.options);
|
|
760
|
+
case a.NodeTypes.ForStatement:
|
|
761
|
+
case a.NodeTypes.ForInStatement:
|
|
762
|
+
case a.NodeTypes.ForOfStatement:
|
|
763
|
+
case a.NodeTypes.WhileStatement:
|
|
764
|
+
return new be(e, this.node, this.options);
|
|
765
|
+
case a.NodeTypes.EmptyStatement:
|
|
766
|
+
case a.NodeTypes.BreakStatement:
|
|
767
|
+
case a.NodeTypes.ContinueStatement:
|
|
768
|
+
return new Ie(e, this.node, this.options);
|
|
2691
769
|
default:
|
|
2692
770
|
throw new Error(`unknown type: ${JSON.stringify(e)}`);
|
|
2693
771
|
}
|
|
@@ -2706,7 +784,7 @@ class T {
|
|
|
2706
784
|
return this.cachedBody = { body: i, level: t }, i;
|
|
2707
785
|
}
|
|
2708
786
|
getStatementIndentation(e = 0) {
|
|
2709
|
-
return this.indentStatementFirstLine ?
|
|
787
|
+
return this.indentStatementFirstLine ? w(e, this.options) : "";
|
|
2710
788
|
}
|
|
2711
789
|
getStatementIndentationLength(e = 0) {
|
|
2712
790
|
return this.indentStatementFirstLine ? e * this.options.indentWidth : 0;
|
|
@@ -2717,7 +795,7 @@ class T {
|
|
|
2717
795
|
* @returns
|
|
2718
796
|
*/
|
|
2719
797
|
getIndentation(e = 0) {
|
|
2720
|
-
return
|
|
798
|
+
return w(e, this.options);
|
|
2721
799
|
}
|
|
2722
800
|
/**
|
|
2723
801
|
* Once the statement has been formatted, we need to wrap the leading and the
|
|
@@ -2730,68 +808,68 @@ class T {
|
|
|
2730
808
|
const i = this.getStatementIndentation(t);
|
|
2731
809
|
if (!this.node.leadingComments?.length && !this.node.trailingComments?.length)
|
|
2732
810
|
return e.indentFirstLine(i);
|
|
2733
|
-
const
|
|
2734
|
-
(
|
|
2735
|
-
const
|
|
811
|
+
const s = (this.node.leadingComments ?? []).reduce(
|
|
812
|
+
(c, l) => {
|
|
813
|
+
const p = this.formatComment(l);
|
|
2736
814
|
return {
|
|
2737
|
-
formattedLines:
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
815
|
+
formattedLines: u.aggregateLines(
|
|
816
|
+
c.formattedLines,
|
|
817
|
+
c.location,
|
|
818
|
+
p,
|
|
819
|
+
l.loc,
|
|
2742
820
|
i
|
|
2743
821
|
),
|
|
2744
|
-
location:
|
|
822
|
+
location: l.loc
|
|
2745
823
|
};
|
|
2746
824
|
},
|
|
2747
|
-
{ formattedLines: new
|
|
2748
|
-
),
|
|
2749
|
-
|
|
2750
|
-
|
|
825
|
+
{ formattedLines: new u() }
|
|
826
|
+
), r = u.aggregateLines(
|
|
827
|
+
s.formattedLines,
|
|
828
|
+
s.location,
|
|
2751
829
|
e,
|
|
2752
830
|
this.node.loc,
|
|
2753
831
|
i
|
|
2754
832
|
);
|
|
2755
833
|
return (this.node.trailingComments?.reduce(
|
|
2756
|
-
(
|
|
2757
|
-
const
|
|
834
|
+
(c, l) => {
|
|
835
|
+
const p = this.formatComment(l);
|
|
2758
836
|
return {
|
|
2759
|
-
formattedLines:
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
837
|
+
formattedLines: u.aggregateLines(
|
|
838
|
+
c.formattedLines,
|
|
839
|
+
c.location,
|
|
840
|
+
p,
|
|
841
|
+
l.loc,
|
|
2764
842
|
i
|
|
2765
843
|
),
|
|
2766
|
-
location:
|
|
844
|
+
location: l.loc
|
|
2767
845
|
};
|
|
2768
846
|
},
|
|
2769
|
-
{ formattedLines:
|
|
2770
|
-
) ?? { formattedLines:
|
|
847
|
+
{ formattedLines: r, location: this.node.loc }
|
|
848
|
+
) ?? { formattedLines: r }).formattedLines;
|
|
2771
849
|
}
|
|
2772
850
|
formatInnerComments(e = 0) {
|
|
2773
|
-
if (!
|
|
2774
|
-
return new
|
|
851
|
+
if (!a.isBlockStatement(this.node) || !Array.isArray(this.node.innerComments) || !this.node.innerComments.length)
|
|
852
|
+
return new u();
|
|
2775
853
|
const t = this.getIndentation(e);
|
|
2776
854
|
return this.node.innerComments.reduce(
|
|
2777
|
-
(
|
|
2778
|
-
const
|
|
855
|
+
(s, r) => {
|
|
856
|
+
const o = this.formatComment(r);
|
|
2779
857
|
return {
|
|
2780
|
-
formattedLines:
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
858
|
+
formattedLines: u.aggregateLines(
|
|
859
|
+
s.formattedLines,
|
|
860
|
+
s.location,
|
|
861
|
+
o,
|
|
862
|
+
r.loc,
|
|
2785
863
|
t
|
|
2786
864
|
),
|
|
2787
|
-
location:
|
|
865
|
+
location: r.loc
|
|
2788
866
|
};
|
|
2789
867
|
},
|
|
2790
|
-
{ formattedLines: new
|
|
868
|
+
{ formattedLines: new u() }
|
|
2791
869
|
).formattedLines;
|
|
2792
870
|
}
|
|
2793
871
|
formatComment(e) {
|
|
2794
|
-
return e.type ===
|
|
872
|
+
return e.type === a.NodeTypes.BlockComment ? u.fromString(e.value).surroundWith("/*", "*/") : u.fromString(e.value.trimEnd()).surroundWith("//");
|
|
2795
873
|
}
|
|
2796
874
|
/**
|
|
2797
875
|
* Invoked for a single line format. Measure is the length of the statement would fit
|
|
@@ -2805,38 +883,38 @@ class T {
|
|
|
2805
883
|
return this.externalOffset + i + this.getStatementIndentationLength(t) + e.lastLineLength <= this.options.wrapColumn;
|
|
2806
884
|
}
|
|
2807
885
|
}
|
|
2808
|
-
class
|
|
886
|
+
class A extends I {
|
|
2809
887
|
constructor(e, t, i) {
|
|
2810
|
-
super(e, t, i), this.node = e, this.printers = [], this.printers = e.body.map((
|
|
888
|
+
super(e, t, i), this.node = e, this.printers = [], this.printers = e.body.map((s) => this.createStatementPrinter(s));
|
|
2811
889
|
}
|
|
2812
890
|
format(e = 0) {
|
|
2813
891
|
if (this.printers.length === 0)
|
|
2814
892
|
return this.formatEmptyBlock(e);
|
|
2815
|
-
const t = [], i =
|
|
893
|
+
const t = [], i = a.isBlockStatement(this.node);
|
|
2816
894
|
i && t.push("{");
|
|
2817
|
-
const
|
|
2818
|
-
let
|
|
2819
|
-
return this.printers.forEach((
|
|
2820
|
-
if (
|
|
895
|
+
const s = i ? e + 1 : e;
|
|
896
|
+
let r;
|
|
897
|
+
return this.printers.forEach((o) => {
|
|
898
|
+
if (a.isEmptyStatement(o.node))
|
|
2821
899
|
return;
|
|
2822
|
-
const
|
|
2823
|
-
|
|
2824
|
-
}), i && t.push(`${this.getIndentation(e)}}`), this.addComments(
|
|
900
|
+
const c = Le(o.node);
|
|
901
|
+
r && c.start.line - r.end.line > 1 && t.push(""), r = c, t.push(o.format(s));
|
|
902
|
+
}), i && t.push(`${this.getIndentation(e)}}`), this.addComments(u.appendLines(t), e);
|
|
2825
903
|
}
|
|
2826
904
|
formatEmptyBlock(e = 0) {
|
|
2827
|
-
if (!
|
|
2828
|
-
return this.addComments(
|
|
2829
|
-
const t = this.formatInnerComments(e + 1), i = "{",
|
|
2830
|
-
return t.isEmpty ?
|
|
905
|
+
if (!a.isBlockStatement(this.node))
|
|
906
|
+
return this.addComments(u.fromString(""), e);
|
|
907
|
+
const t = this.formatInnerComments(e + 1), i = "{", s = `${this.getIndentation(e)}}`;
|
|
908
|
+
return t.isEmpty ? a.isIfStatement(this.parent) ? this.addComments(u.appendLines([i, s]), e) : this.addComments(u.fromString("{}"), e) : this.addComments(u.appendLines([i, t, s]), e);
|
|
2831
909
|
}
|
|
2832
910
|
}
|
|
2833
|
-
class
|
|
911
|
+
class Ie extends I {
|
|
2834
912
|
constructor(e, t, i) {
|
|
2835
913
|
switch (super(e, t, i), this.node = e, this.keyword = "", this.node.type) {
|
|
2836
|
-
case
|
|
914
|
+
case a.NodeTypes.ContinueStatement:
|
|
2837
915
|
this.keyword = "continue;";
|
|
2838
916
|
break;
|
|
2839
|
-
case
|
|
917
|
+
case a.NodeTypes.BreakStatement:
|
|
2840
918
|
this.keyword = "break;";
|
|
2841
919
|
break;
|
|
2842
920
|
default:
|
|
@@ -2844,15 +922,15 @@ class bt extends T {
|
|
|
2844
922
|
}
|
|
2845
923
|
}
|
|
2846
924
|
format(e = 0) {
|
|
2847
|
-
return this.addComments(
|
|
925
|
+
return this.addComments(u.fromString(this.keyword), e);
|
|
2848
926
|
}
|
|
2849
927
|
}
|
|
2850
|
-
class
|
|
928
|
+
class J extends I {
|
|
2851
929
|
constructor(e, t, i) {
|
|
2852
|
-
if (super(e, t, i), this.node = e,
|
|
2853
|
-
this.printer = new
|
|
2854
|
-
else if (
|
|
2855
|
-
this.printer = new
|
|
930
|
+
if (super(e, t, i), this.node = e, a.isVariableDeclaration(e))
|
|
931
|
+
this.printer = new _(e, t, i);
|
|
932
|
+
else if (a.isVariableDeclaration(e.declaration))
|
|
933
|
+
this.printer = new _(e.declaration, t, i), this.printer.prefix = "export ";
|
|
2856
934
|
else
|
|
2857
935
|
throw new Error(`invalid type: ${JSON.stringify(e)}`);
|
|
2858
936
|
}
|
|
@@ -2865,12 +943,12 @@ class Le extends T {
|
|
|
2865
943
|
return this.addComments(this.printer.format("multiline", e).suffixWith(";"), e);
|
|
2866
944
|
}
|
|
2867
945
|
}
|
|
2868
|
-
class
|
|
946
|
+
class Q extends I {
|
|
2869
947
|
constructor(e, t, i) {
|
|
2870
|
-
if (super(e, t, i), this.node = e,
|
|
2871
|
-
this.header =
|
|
2872
|
-
else if (
|
|
2873
|
-
this.header =
|
|
948
|
+
if (super(e, t, i), this.node = e, a.isFunctionDeclaration(e))
|
|
949
|
+
this.header = T(e, t, i), this.body = new A(e.body, e, i);
|
|
950
|
+
else if (a.isFunctionDeclaration(e.declaration))
|
|
951
|
+
this.header = T(e.declaration, t, i), this.header.prefix = "export ", this.body = new A(e.declaration.body, e, i);
|
|
2874
952
|
else
|
|
2875
953
|
throw new Error(`invalid type: ${JSON.stringify(e)}`);
|
|
2876
954
|
}
|
|
@@ -2878,70 +956,70 @@ class Te extends T {
|
|
|
2878
956
|
this.body.indentStatementFirstLine = !1;
|
|
2879
957
|
const i = this.getFormattedBody(this.body, e);
|
|
2880
958
|
if (t === "singleLine" || t === "optimized") {
|
|
2881
|
-
const
|
|
2882
|
-
if (t === "singleLine" || this.canFitSingleLine(
|
|
2883
|
-
return this.addComments(
|
|
959
|
+
const r = this.header.format("singleLine", e);
|
|
960
|
+
if (t === "singleLine" || this.canFitSingleLine(r, e, i.firstLineLength + 1))
|
|
961
|
+
return this.addComments(u.joinLines([r, i], " "), e);
|
|
2884
962
|
}
|
|
2885
|
-
const
|
|
2886
|
-
return this.addComments(
|
|
963
|
+
const s = this.header.format("multiline", e);
|
|
964
|
+
return this.addComments(u.joinLines([s, i], " "), e);
|
|
2887
965
|
}
|
|
2888
966
|
}
|
|
2889
|
-
class
|
|
967
|
+
class Se extends I {
|
|
2890
968
|
constructor(e, t, i) {
|
|
2891
|
-
super(e, t, i), this.node = e, this.header =
|
|
969
|
+
super(e, t, i), this.node = e, this.header = T(e, t, i), this.consequent = this.createStatementPrinter(e.consequent), this.consequent.indentStatementFirstLine = !1, e.alternate && (this.alternate = this.createStatementPrinter(e.alternate), this.alternate.indentStatementFirstLine = !1);
|
|
2892
970
|
}
|
|
2893
971
|
format(e = 0, t = "optimized") {
|
|
2894
|
-
let i = !1,
|
|
972
|
+
let i = !1, s;
|
|
2895
973
|
if (t === "singleLine" || t === "optimized") {
|
|
2896
|
-
const
|
|
2897
|
-
(t === "singleLine" || this.canFitSingleLine(
|
|
2898
|
-
}
|
|
2899
|
-
|
|
2900
|
-
let
|
|
2901
|
-
if (
|
|
2902
|
-
const
|
|
2903
|
-
|
|
2904
|
-
} else if (i ||
|
|
974
|
+
const l = this.header.format("singleLine", e), p = a.isBlockStatement(this.node.consequent) ? 2 : 0;
|
|
975
|
+
(t === "singleLine" || this.canFitSingleLine(l, e, p)) && (s = l);
|
|
976
|
+
}
|
|
977
|
+
s || (i = !0, s = this.header.format("multiline", e));
|
|
978
|
+
let r;
|
|
979
|
+
if (a.isBlockStatement(this.node.consequent)) {
|
|
980
|
+
const l = this.consequent.format(e, "optimized");
|
|
981
|
+
r = u.joinLines([s, " ", l]);
|
|
982
|
+
} else if (i || a.isIfStatement(this.node.consequent)) {
|
|
2905
983
|
this.consequent.indentStatementFirstLine = !0;
|
|
2906
|
-
let
|
|
2907
|
-
this.canFitSingleLine(
|
|
984
|
+
let l = this.consequent.format(e + 1, "singleLine");
|
|
985
|
+
this.canFitSingleLine(l, e + 1) || (l = this.consequent.format(e + 1, "multiline")), r = u.appendLines([s, l]);
|
|
2908
986
|
} else {
|
|
2909
987
|
this.consequent.indentStatementFirstLine = !1;
|
|
2910
|
-
let
|
|
2911
|
-
this.canFitSingleLine(
|
|
988
|
+
let l = this.consequent.format(e, "singleLine");
|
|
989
|
+
this.canFitSingleLine(l, 0, s.lastLineLength + 1) ? r = u.joinLines([s, " ", l]) : (this.consequent.indentStatementFirstLine = !0, l = this.consequent.format(e + 1, "optimized"), r = u.appendLines([s, l]));
|
|
2912
990
|
}
|
|
2913
991
|
if (!this.alternate)
|
|
2914
|
-
return this.addComments(
|
|
2915
|
-
const
|
|
2916
|
-
let
|
|
2917
|
-
if (this.alternate.externalOffset = 0,
|
|
2918
|
-
this.alternate.indentStatementFirstLine = !1, this.alternate.externalOffset =
|
|
992
|
+
return this.addComments(r, e);
|
|
993
|
+
const o = Ee(this.node.consequent) || !a.isBlockStatement(this.node.consequent);
|
|
994
|
+
let c;
|
|
995
|
+
if (this.alternate.externalOffset = 0, a.isBlockStatement(this.node.alternate) || a.isIfStatement(this.node.alternate))
|
|
996
|
+
this.alternate.indentStatementFirstLine = !1, this.alternate.externalOffset = o ? 5 : r.lastLineLength + 6, c = this.alternate.format(e, "optimized"), c = u.joinLines(["else ", c]);
|
|
2919
997
|
else {
|
|
2920
|
-
const
|
|
2921
|
-
this.alternate.indentStatementFirstLine = !1,
|
|
998
|
+
const l = o ? 4 : r.lastLineLength + 4;
|
|
999
|
+
this.alternate.indentStatementFirstLine = !1, c = this.alternate.format(e, "singleLine"), this.canFitSingleLine(c, e, l + 1) ? c = u.joinLines(["else ", c]) : (this.alternate.indentStatementFirstLine = !0, c = this.alternate.format(e + 1, "optimized"), c = u.appendLines(["else", c]));
|
|
2922
1000
|
}
|
|
2923
|
-
return
|
|
1001
|
+
return o ? r = u.appendLines([r, c.indentFirstLine(this.getIndentation(e))]) : r = u.joinLines([r, c], " "), this.addComments(r, e);
|
|
2924
1002
|
}
|
|
2925
1003
|
}
|
|
2926
|
-
class
|
|
1004
|
+
class be extends I {
|
|
2927
1005
|
constructor(e, t, i) {
|
|
2928
|
-
super(e, t, i), this.node = e, this.header =
|
|
1006
|
+
super(e, t, i), this.node = e, this.header = T(e, t, i), this.body = this.createStatementPrinter(e.body);
|
|
2929
1007
|
}
|
|
2930
1008
|
format(e = 0, t = "optimized") {
|
|
2931
1009
|
this.body.indentStatementFirstLine = !1;
|
|
2932
1010
|
const i = this.getFormattedBody(this.body, e);
|
|
2933
1011
|
if (t === "singleLine" || t === "optimized") {
|
|
2934
|
-
const
|
|
2935
|
-
if (t === "singleLine" || this.canFitSingleLine(
|
|
2936
|
-
return this.addComments(
|
|
1012
|
+
const r = this.header.format("singleLine", e);
|
|
1013
|
+
if (t === "singleLine" || this.canFitSingleLine(r, e, i.firstLineLength + 1))
|
|
1014
|
+
return this.addComments(u.joinLines([r, i], " "), e);
|
|
2937
1015
|
}
|
|
2938
|
-
const
|
|
2939
|
-
return this.addComments(
|
|
1016
|
+
const s = this.header.format("multiline", e);
|
|
1017
|
+
return this.addComments(u.joinLines([s, i], " "), e);
|
|
2940
1018
|
}
|
|
2941
1019
|
}
|
|
2942
|
-
class
|
|
1020
|
+
class we extends I {
|
|
2943
1021
|
constructor(e, t, i) {
|
|
2944
|
-
super(e, t, i), this.node = e, this.expression =
|
|
1022
|
+
super(e, t, i), this.node = e, this.expression = f(e.expression, e, i);
|
|
2945
1023
|
}
|
|
2946
1024
|
format(e = 0, t = "optimized") {
|
|
2947
1025
|
if (t === "singleLine" || t === "optimized") {
|
|
@@ -2952,31 +1030,31 @@ class Lt extends T {
|
|
|
2952
1030
|
return this.addComments(this.expression.format("multiline", e).suffixWith(";"), e);
|
|
2953
1031
|
}
|
|
2954
1032
|
}
|
|
2955
|
-
class
|
|
1033
|
+
class Te extends I {
|
|
2956
1034
|
constructor(e, t, i) {
|
|
2957
|
-
super(e, t, i), this.node = e, this.argument =
|
|
1035
|
+
super(e, t, i), this.node = e, this.argument = f(e.argument, e, i);
|
|
2958
1036
|
}
|
|
2959
1037
|
format(e = 0, t = "optimized") {
|
|
2960
1038
|
if (t === "singleLine" || t === "optimized") {
|
|
2961
|
-
const
|
|
2962
|
-
if (t === "singleLine" || this.canFitSingleLine(
|
|
2963
|
-
return this.addComments(
|
|
1039
|
+
const o = this.argument.format("singleLine", e).surroundWith("return ", ";");
|
|
1040
|
+
if (t === "singleLine" || this.canFitSingleLine(o, e))
|
|
1041
|
+
return this.addComments(o, e);
|
|
2964
1042
|
}
|
|
2965
|
-
if (!
|
|
2966
|
-
const
|
|
2967
|
-
return this.addComments(
|
|
1043
|
+
if (!a.isLogicalExpression(this.node.argument) && !a.isBinaryExpression(this.node.argument)) {
|
|
1044
|
+
const o = this.argument.format("multiline", e).surroundWith("return ", ";");
|
|
1045
|
+
return this.addComments(o, e);
|
|
2968
1046
|
}
|
|
2969
|
-
const i = this.getIndentation(e + 1),
|
|
2970
|
-
return this.addComments(
|
|
1047
|
+
const i = this.getIndentation(e + 1), s = this.argument.format("multiline", e + 1).indentFirstLine(i), r = this.getIndentation(e);
|
|
1048
|
+
return this.addComments(u.appendLines(["return (", s, `${r});`]), e);
|
|
2971
1049
|
}
|
|
2972
1050
|
}
|
|
2973
|
-
class
|
|
1051
|
+
class Ne extends I {
|
|
2974
1052
|
constructor(e, t, i) {
|
|
2975
|
-
super(e, t, i), this.node = e, this.libraryNamePrinter =
|
|
1053
|
+
super(e, t, i), this.node = e, this.libraryNamePrinter = f(e.specifiers[0].local, e, i), this.librarySourcePrinter = f(e.source, e, i);
|
|
2976
1054
|
}
|
|
2977
1055
|
format(e = 0) {
|
|
2978
1056
|
return this.addComments(
|
|
2979
|
-
|
|
1057
|
+
u.joinLines([
|
|
2980
1058
|
"import",
|
|
2981
1059
|
" ",
|
|
2982
1060
|
this.libraryNamePrinter.format("singleLine", e),
|
|
@@ -2987,147 +1065,147 @@ class vt extends T {
|
|
|
2987
1065
|
);
|
|
2988
1066
|
}
|
|
2989
1067
|
}
|
|
2990
|
-
const
|
|
2991
|
-
function
|
|
1068
|
+
const Pe = { quote: "auto" };
|
|
1069
|
+
function ot(n, e = {}) {
|
|
2992
1070
|
try {
|
|
2993
|
-
const t = n.getText(), i = n.positionAt(t.length),
|
|
2994
|
-
return [{ range:
|
|
1071
|
+
const t = n.getText(), i = n.positionAt(t.length), s = { start: { line: 0, character: 0 }, end: i }, r = { ...Pe, ...e.formattingOptions ?? {} }, o = Ce(t, r);
|
|
1072
|
+
return [{ range: s, newText: o }];
|
|
2995
1073
|
} catch (t) {
|
|
2996
1074
|
return console.error("Arcade Formatting Error:", t), [];
|
|
2997
1075
|
}
|
|
2998
1076
|
}
|
|
2999
|
-
function
|
|
1077
|
+
function Ce(n, e) {
|
|
3000
1078
|
if (!n)
|
|
3001
1079
|
return "";
|
|
3002
|
-
const t =
|
|
1080
|
+
const t = O(e), i = M.fromString(n, t), s = i.toString(), r = a.parse(s, {
|
|
3003
1081
|
tolerant: !0,
|
|
3004
1082
|
comments: !0
|
|
3005
|
-
}),
|
|
3006
|
-
return
|
|
1083
|
+
}), o = re(r, i);
|
|
1084
|
+
return r.loc.start = o.start, r.loc.end = o.end, new A(r, null, t).format().toString();
|
|
3007
1085
|
}
|
|
3008
|
-
const
|
|
1086
|
+
const ve = Object.values(ee), Ae = Object.values(te), De = ["case", "catch", "debugger", "switch", "try"], Fe = Ae.map((n) => ({ label: n, kind: m.Constant })), ke = ve.map((n) => ({ label: n, kind: m.Keyword })), Be = [
|
|
3009
1087
|
{
|
|
3010
1088
|
label: "exportfunction",
|
|
3011
|
-
kind:
|
|
1089
|
+
kind: m.Snippet,
|
|
3012
1090
|
detail: "Export Function Statement",
|
|
3013
1091
|
insertText: `export function \${1:functionName} ($2) {
|
|
3014
1092
|
$0
|
|
3015
1093
|
}`,
|
|
3016
|
-
insertTextMode:
|
|
3017
|
-
insertTextFormat:
|
|
1094
|
+
insertTextMode: L.adjustIndentation,
|
|
1095
|
+
insertTextFormat: x.Snippet
|
|
3018
1096
|
},
|
|
3019
1097
|
{
|
|
3020
1098
|
label: "exportvar",
|
|
3021
|
-
kind:
|
|
1099
|
+
kind: m.Snippet,
|
|
3022
1100
|
detail: "Export Variable Statement",
|
|
3023
1101
|
insertText: "export var ${0:variableName}\n",
|
|
3024
|
-
insertTextMode:
|
|
3025
|
-
insertTextFormat:
|
|
1102
|
+
insertTextMode: L.adjustIndentation,
|
|
1103
|
+
insertTextFormat: x.Snippet
|
|
3026
1104
|
},
|
|
3027
1105
|
{
|
|
3028
1106
|
label: "for",
|
|
3029
|
-
kind:
|
|
1107
|
+
kind: m.Snippet,
|
|
3030
1108
|
detail: "For Loop Statement",
|
|
3031
1109
|
insertText: "for (var ${1:i} = 0; ${1:i} < ${2:Count(arr)}; ${1:i}++) {\n $0\n}",
|
|
3032
|
-
insertTextMode:
|
|
3033
|
-
insertTextFormat:
|
|
1110
|
+
insertTextMode: L.adjustIndentation,
|
|
1111
|
+
insertTextFormat: x.Snippet
|
|
3034
1112
|
},
|
|
3035
1113
|
{
|
|
3036
1114
|
label: "forin",
|
|
3037
|
-
kind:
|
|
1115
|
+
kind: m.Snippet,
|
|
3038
1116
|
detail: "For-In Loop Statement",
|
|
3039
1117
|
insertText: "for (var ${1:i} in ${2:arrayOrObject}) {\n $0\n}",
|
|
3040
|
-
insertTextMode:
|
|
3041
|
-
insertTextFormat:
|
|
1118
|
+
insertTextMode: L.adjustIndentation,
|
|
1119
|
+
insertTextFormat: x.Snippet
|
|
3042
1120
|
},
|
|
3043
1121
|
{
|
|
3044
1122
|
label: "forof",
|
|
3045
|
-
kind:
|
|
1123
|
+
kind: m.Snippet,
|
|
3046
1124
|
detail: "For-Of Loop Statement",
|
|
3047
1125
|
insertText: "for (var ${1:i} of ${2:arrayOrObject}) {\n $0\n}",
|
|
3048
|
-
insertTextMode:
|
|
3049
|
-
insertTextFormat:
|
|
1126
|
+
insertTextMode: L.adjustIndentation,
|
|
1127
|
+
insertTextFormat: x.Snippet
|
|
3050
1128
|
},
|
|
3051
1129
|
{
|
|
3052
1130
|
label: "function",
|
|
3053
|
-
kind:
|
|
1131
|
+
kind: m.Snippet,
|
|
3054
1132
|
detail: "Function Statement",
|
|
3055
1133
|
insertText: `function \${1:functionName} ($2) {
|
|
3056
1134
|
$0
|
|
3057
1135
|
}`,
|
|
3058
|
-
insertTextMode:
|
|
3059
|
-
insertTextFormat:
|
|
1136
|
+
insertTextMode: L.adjustIndentation,
|
|
1137
|
+
insertTextFormat: x.Snippet
|
|
3060
1138
|
},
|
|
3061
1139
|
{
|
|
3062
1140
|
label: "if",
|
|
3063
|
-
kind:
|
|
1141
|
+
kind: m.Snippet,
|
|
3064
1142
|
detail: "If Statement",
|
|
3065
1143
|
insertText: `if (\${1:1==1}) {
|
|
3066
1144
|
$0
|
|
3067
1145
|
}`,
|
|
3068
|
-
insertTextMode:
|
|
3069
|
-
insertTextFormat:
|
|
1146
|
+
insertTextMode: L.adjustIndentation,
|
|
1147
|
+
insertTextFormat: x.Snippet
|
|
3070
1148
|
},
|
|
3071
1149
|
{
|
|
3072
1150
|
label: "ifelse",
|
|
3073
|
-
kind:
|
|
1151
|
+
kind: m.Snippet,
|
|
3074
1152
|
detail: "If-Else Statement",
|
|
3075
1153
|
insertText: `if (\${1:1==1}) {
|
|
3076
1154
|
$0
|
|
3077
1155
|
} else {
|
|
3078
1156
|
|
|
3079
1157
|
}`,
|
|
3080
|
-
insertTextMode:
|
|
3081
|
-
insertTextFormat:
|
|
1158
|
+
insertTextMode: L.adjustIndentation,
|
|
1159
|
+
insertTextFormat: x.Snippet
|
|
3082
1160
|
},
|
|
3083
1161
|
{
|
|
3084
1162
|
label: "else",
|
|
3085
|
-
kind:
|
|
1163
|
+
kind: m.Snippet,
|
|
3086
1164
|
detail: "Else Statement",
|
|
3087
1165
|
insertText: `else {
|
|
3088
1166
|
$0
|
|
3089
1167
|
}`,
|
|
3090
|
-
insertTextMode:
|
|
3091
|
-
insertTextFormat:
|
|
1168
|
+
insertTextMode: L.adjustIndentation,
|
|
1169
|
+
insertTextFormat: x.Snippet
|
|
3092
1170
|
},
|
|
3093
1171
|
{
|
|
3094
1172
|
label: "import",
|
|
3095
|
-
kind:
|
|
1173
|
+
kind: m.Snippet,
|
|
3096
1174
|
detail: "Import Statement",
|
|
3097
1175
|
insertText: 'import ${1:namespace} from "${0:uri}"',
|
|
3098
|
-
insertTextMode:
|
|
3099
|
-
insertTextFormat:
|
|
1176
|
+
insertTextMode: L.adjustIndentation,
|
|
1177
|
+
insertTextFormat: x.Snippet
|
|
3100
1178
|
},
|
|
3101
1179
|
{
|
|
3102
1180
|
label: "while",
|
|
3103
|
-
kind:
|
|
1181
|
+
kind: m.Snippet,
|
|
3104
1182
|
detail: "While Loop Statement",
|
|
3105
1183
|
insertText: `while (\${1:false}) {
|
|
3106
1184
|
$0
|
|
3107
1185
|
}`,
|
|
3108
|
-
insertTextMode:
|
|
3109
|
-
insertTextFormat:
|
|
1186
|
+
insertTextMode: L.adjustIndentation,
|
|
1187
|
+
insertTextFormat: x.Snippet
|
|
3110
1188
|
}
|
|
3111
|
-
],
|
|
3112
|
-
function
|
|
3113
|
-
return e ? n.replace(
|
|
1189
|
+
], Me = /\$\{(.*?)\}/gu;
|
|
1190
|
+
function v(n, e) {
|
|
1191
|
+
return e ? n.replace(Me, (t, i) => e[i].toString()) : n;
|
|
3114
1192
|
}
|
|
3115
|
-
const
|
|
3116
|
-
function $
|
|
1193
|
+
const q = /[-[\]/{}()*+?.\\^$|]/gu;
|
|
1194
|
+
function $e(n, e) {
|
|
3117
1195
|
return n.line > e.end.line;
|
|
3118
1196
|
}
|
|
3119
|
-
function
|
|
1197
|
+
function je(n, e) {
|
|
3120
1198
|
return n.line < e.start.line;
|
|
3121
1199
|
}
|
|
3122
|
-
function
|
|
3123
|
-
return !(
|
|
1200
|
+
function X(n, e) {
|
|
1201
|
+
return !(je(n, e) || $e(n, e) || n.line === e.start.line && n.column < e.start.column || n.line === e.end.line && n.column > e.end.column);
|
|
3124
1202
|
}
|
|
3125
|
-
const
|
|
1203
|
+
const d = {
|
|
3126
1204
|
None: 0,
|
|
3127
1205
|
Keywords: 1,
|
|
3128
1206
|
All: 255,
|
|
3129
1207
|
NoKeywords: 254
|
|
3130
|
-
},
|
|
1208
|
+
}, S = {
|
|
3131
1209
|
identifiers: "a",
|
|
3132
1210
|
profileVariables: "aa",
|
|
3133
1211
|
constants: "ab",
|
|
@@ -3136,63 +1214,63 @@ const g = {
|
|
|
3136
1214
|
snippets: "b",
|
|
3137
1215
|
keywords: "c"
|
|
3138
1216
|
};
|
|
3139
|
-
function
|
|
3140
|
-
const
|
|
3141
|
-
if (
|
|
1217
|
+
function Ve(n, e, t, i = {}) {
|
|
1218
|
+
const s = n.getText({ start: { line: 0, character: 0 }, end: e }), { tokens: r, errors: o = [] } = a.tokenize(s, { loc: !0, tolerant: !0 });
|
|
1219
|
+
if (o.length)
|
|
3142
1220
|
return { isIncomplete: !1, items: [] };
|
|
3143
|
-
let
|
|
3144
|
-
const
|
|
3145
|
-
|
|
3146
|
-
const
|
|
1221
|
+
let c = r.at(r.length - 1), l = "";
|
|
1222
|
+
const p = Ye(e);
|
|
1223
|
+
c?.type === "Identifier" && X(p, c.loc) && (l = c.value, r.pop(), c = r[r.length - 1]);
|
|
1224
|
+
const y = {
|
|
3147
1225
|
variables: i.profile?.variables ?? [],
|
|
3148
|
-
additionalCompletionItems: (i.snippets ?? []).map((
|
|
3149
|
-
kind:
|
|
3150
|
-
insertTextMode:
|
|
3151
|
-
insertTextFormat:
|
|
3152
|
-
...
|
|
1226
|
+
additionalCompletionItems: (i.snippets ?? []).map((C) => ({
|
|
1227
|
+
kind: m.Snippet,
|
|
1228
|
+
insertTextMode: L.adjustIndentation,
|
|
1229
|
+
insertTextFormat: x.Snippet,
|
|
1230
|
+
...C
|
|
3153
1231
|
})),
|
|
3154
1232
|
apiDatabase: t
|
|
3155
1233
|
};
|
|
3156
|
-
return
|
|
1234
|
+
return c?.type === "Punctuator" && (c.value === "." || c.value === a.SafeAccessOperator) ? _e(r, l, y) : ze(r, l, p, y);
|
|
3157
1235
|
}
|
|
3158
|
-
function
|
|
3159
|
-
const
|
|
3160
|
-
if (
|
|
1236
|
+
function ze(n, e, t, i) {
|
|
1237
|
+
const s = Ue(n, t);
|
|
1238
|
+
if (s === d.None)
|
|
3161
1239
|
return { isIncomplete: !1, items: [] };
|
|
3162
|
-
const
|
|
3163
|
-
return
|
|
3164
|
-
|
|
3165
|
-
}), i.variables.forEach((
|
|
3166
|
-
|
|
3167
|
-
}),
|
|
3168
|
-
|
|
3169
|
-
}), i.additionalCompletionItems.forEach((
|
|
3170
|
-
|
|
3171
|
-
}),
|
|
3172
|
-
|
|
3173
|
-
}),
|
|
3174
|
-
|
|
3175
|
-
}), i.apiDatabase.constantDefinitions.forEach((
|
|
3176
|
-
|
|
3177
|
-
}), i.apiDatabase.functionDefinitions.forEach((
|
|
3178
|
-
|
|
3179
|
-
|
|
1240
|
+
const r = Ke(n), o = [], c = new RegExp(e.replaceAll(q, "\\$&"), "i");
|
|
1241
|
+
return r.forEach((l, p) => {
|
|
1242
|
+
c.test(p) && o.push({ ...l, sortText: S.identifiers });
|
|
1243
|
+
}), i.variables.forEach((l) => {
|
|
1244
|
+
c.test(l.name) && l.completion && o.push({ ...l.completion, sortText: S.profileVariables });
|
|
1245
|
+
}), H(s) && Be.forEach((l) => {
|
|
1246
|
+
l.label.startsWith(e) && o.push({ ...l, sortText: S.snippets });
|
|
1247
|
+
}), i.additionalCompletionItems.forEach((l) => {
|
|
1248
|
+
c.test(l.label) && o.push({ ...l, sortText: S.snippets });
|
|
1249
|
+
}), H(s) && ke.forEach((l) => {
|
|
1250
|
+
c.test(l.label) && o.push({ ...l, sortText: S.keywords });
|
|
1251
|
+
}), Fe.forEach((l) => {
|
|
1252
|
+
c.test(l.label) && o.push({ ...l, sortText: S.literals });
|
|
1253
|
+
}), i.apiDatabase.constantDefinitions.forEach((l, p) => {
|
|
1254
|
+
l.type === "constant" && l.disableDocumentation === !0 || !c.test(p) || o.push({ ...l.completion, sortText: S.constants });
|
|
1255
|
+
}), i.apiDatabase.functionDefinitions.forEach((l, p) => {
|
|
1256
|
+
c.test(p) && l.overloads.forEach((y) => {
|
|
1257
|
+
y.disableDocumentation || o.push({ ...y.completion, sortText: S.functions });
|
|
3180
1258
|
});
|
|
3181
|
-
}), { isIncomplete: !1, items:
|
|
1259
|
+
}), { isIncomplete: !1, items: o };
|
|
3182
1260
|
}
|
|
3183
|
-
function
|
|
1261
|
+
function _e(n, e, t) {
|
|
3184
1262
|
const i = [...n];
|
|
3185
|
-
let
|
|
3186
|
-
const
|
|
3187
|
-
let
|
|
3188
|
-
for (;
|
|
3189
|
-
|
|
3190
|
-
if (
|
|
1263
|
+
let s = i.pop();
|
|
1264
|
+
const r = s;
|
|
1265
|
+
let o = [];
|
|
1266
|
+
for (; s && !(s.type !== "Punctuator" || s.value !== "." && s.value !== a.SafeAccessOperator || (s = i.pop(), s?.type !== "Identifier")); )
|
|
1267
|
+
o = [s.value.toLowerCase(), ...o], s = i.pop();
|
|
1268
|
+
if (o.length === 0 || !r)
|
|
3191
1269
|
return { isIncomplete: !1, items: [] };
|
|
3192
|
-
let
|
|
3193
|
-
return
|
|
1270
|
+
let c = Oe(o, e, t);
|
|
1271
|
+
return c || (c = We(o, e, r, t), c) ? c : { isIncomplete: !1, items: [] };
|
|
3194
1272
|
}
|
|
3195
|
-
function
|
|
1273
|
+
function Oe(n, e, t) {
|
|
3196
1274
|
if (n.length > 1)
|
|
3197
1275
|
return null;
|
|
3198
1276
|
const i = t.apiDatabase.constantDefinitions.get(n[0]);
|
|
@@ -3200,61 +1278,61 @@ function qt(n, e, t) {
|
|
|
3200
1278
|
return null;
|
|
3201
1279
|
if (i.type !== "namespace")
|
|
3202
1280
|
return { isIncomplete: !1, items: [] };
|
|
3203
|
-
const
|
|
3204
|
-
return i.members.forEach((
|
|
3205
|
-
|
|
3206
|
-
}), { isIncomplete: !1, items:
|
|
1281
|
+
const s = [], r = new RegExp(e.replaceAll(q, "\\$&"), "i");
|
|
1282
|
+
return i.members.forEach((o) => {
|
|
1283
|
+
o.disableDocumentation === !0 || !r.test(o.name) || s.push(o.completion);
|
|
1284
|
+
}), { isIncomplete: !1, items: s };
|
|
3207
1285
|
}
|
|
3208
|
-
function
|
|
1286
|
+
function We(n, e, t, i) {
|
|
3209
1287
|
if (!i.variables.length || !n.length)
|
|
3210
1288
|
return null;
|
|
3211
|
-
let
|
|
3212
|
-
for (;
|
|
3213
|
-
const
|
|
3214
|
-
if (!
|
|
1289
|
+
let s = n.shift(), r = i.variables;
|
|
1290
|
+
for (; s; ) {
|
|
1291
|
+
const p = r.find((y) => y.name.toLowerCase() === s);
|
|
1292
|
+
if (!ie(p))
|
|
3215
1293
|
return null;
|
|
3216
|
-
|
|
1294
|
+
r = p.properties ?? [], s = n.shift();
|
|
3217
1295
|
}
|
|
3218
|
-
const
|
|
3219
|
-
return
|
|
3220
|
-
|
|
3221
|
-
}), { isIncomplete: !1, items:
|
|
1296
|
+
const o = [], c = new RegExp(e.replaceAll(q, "\\$&"), "i"), l = Ge(t.loc.start);
|
|
1297
|
+
return r.forEach((p) => {
|
|
1298
|
+
c.test(p.name) && p.completion && (t.value === "." ? o.push(Ze(l, p.completion)) : o.push(p.completion));
|
|
1299
|
+
}), { isIncomplete: !1, items: o };
|
|
3222
1300
|
}
|
|
3223
|
-
function
|
|
3224
|
-
return (n &
|
|
1301
|
+
function H(n) {
|
|
1302
|
+
return (n & d.Keywords) === d.Keywords;
|
|
3225
1303
|
}
|
|
3226
|
-
function
|
|
1304
|
+
function Ue(n, e) {
|
|
3227
1305
|
if (!n.length)
|
|
3228
|
-
return
|
|
1306
|
+
return d.All;
|
|
3229
1307
|
const t = n[n.length - 1];
|
|
3230
1308
|
switch (t.type) {
|
|
3231
1309
|
case "Identifier":
|
|
3232
|
-
return
|
|
1310
|
+
return d.All;
|
|
3233
1311
|
case "Keyword":
|
|
3234
|
-
return ["return", "in", "else"].includes(t.value) ?
|
|
1312
|
+
return ["return", "in", "else"].includes(t.value) ? d.NoKeywords : d.None;
|
|
3235
1313
|
case "Punctuator":
|
|
3236
|
-
return
|
|
1314
|
+
return qe(n);
|
|
3237
1315
|
case "Template":
|
|
3238
|
-
return t.value.endsWith("${") ?
|
|
1316
|
+
return t.value.endsWith("${") ? d.NoKeywords : d.All;
|
|
3239
1317
|
default:
|
|
3240
|
-
return
|
|
1318
|
+
return X(e, t.loc) ? d.None : d.All;
|
|
3241
1319
|
}
|
|
3242
1320
|
}
|
|
3243
|
-
function
|
|
1321
|
+
function qe(n) {
|
|
3244
1322
|
const e = [...n];
|
|
3245
1323
|
let t = e.pop();
|
|
3246
1324
|
if (!t)
|
|
3247
|
-
return
|
|
1325
|
+
return d.All;
|
|
3248
1326
|
if (t.type !== "Punctuator")
|
|
3249
|
-
return
|
|
1327
|
+
return d.None;
|
|
3250
1328
|
if (t.value !== "(" && t.value !== ",")
|
|
3251
|
-
return
|
|
1329
|
+
return d.All;
|
|
3252
1330
|
if (t.value === "(")
|
|
3253
|
-
return
|
|
1331
|
+
return Z(e);
|
|
3254
1332
|
let i = 0;
|
|
3255
1333
|
for (t = e.pop(); t; ) {
|
|
3256
1334
|
if (t.type === "Keyword")
|
|
3257
|
-
return
|
|
1335
|
+
return d.None;
|
|
3258
1336
|
if (t.type !== "Punctuator") {
|
|
3259
1337
|
t = e.pop();
|
|
3260
1338
|
continue;
|
|
@@ -3265,26 +1343,26 @@ function Qt(n) {
|
|
|
3265
1343
|
}
|
|
3266
1344
|
if (t.value === "[") {
|
|
3267
1345
|
if (i === 0)
|
|
3268
|
-
return
|
|
1346
|
+
return d.NoKeywords;
|
|
3269
1347
|
i += 1, t = e.pop();
|
|
3270
1348
|
continue;
|
|
3271
1349
|
}
|
|
3272
1350
|
if (t.value === "(") {
|
|
3273
1351
|
if (i === 0)
|
|
3274
|
-
return
|
|
1352
|
+
return Z(e);
|
|
3275
1353
|
i += 1, t = e.pop();
|
|
3276
1354
|
continue;
|
|
3277
1355
|
}
|
|
3278
1356
|
t = e.pop();
|
|
3279
1357
|
}
|
|
3280
|
-
return
|
|
1358
|
+
return d.None;
|
|
3281
1359
|
}
|
|
3282
|
-
function
|
|
1360
|
+
function Z(n) {
|
|
3283
1361
|
const e = [...n];
|
|
3284
1362
|
let t = e.pop();
|
|
3285
|
-
return t ? t.type === "Keyword" ? t.value.toLowerCase() === "for" ?
|
|
1363
|
+
return t ? t.type === "Keyword" ? t.value.toLowerCase() === "for" ? d.All : d.NoKeywords : t.type !== "Identifier" ? d.All : (t = e.pop(), t?.type === "Keyword" && t.value.toLowerCase() === "function" ? d.None : d.NoKeywords) : d.All;
|
|
3286
1364
|
}
|
|
3287
|
-
class
|
|
1365
|
+
class Re {
|
|
3288
1366
|
constructor(e) {
|
|
3289
1367
|
this.tokens = e, this.currentIndex = 0;
|
|
3290
1368
|
}
|
|
@@ -3302,24 +1380,24 @@ class Zt {
|
|
|
3302
1380
|
return this.tokens[this.currentIndex];
|
|
3303
1381
|
}
|
|
3304
1382
|
}
|
|
3305
|
-
const
|
|
1383
|
+
const k = {
|
|
3306
1384
|
parameterFormat: "(parameter) ${name}",
|
|
3307
1385
|
variableFormat: "var ${name}",
|
|
3308
1386
|
functionFormat: "function ${name} (${paramsDetail})"
|
|
3309
1387
|
};
|
|
3310
|
-
function
|
|
1388
|
+
function Ke(n) {
|
|
3311
1389
|
const e = /* @__PURE__ */ new Map();
|
|
3312
1390
|
if (!n.length)
|
|
3313
1391
|
return e;
|
|
3314
|
-
const t = new
|
|
1392
|
+
const t = new Re(n);
|
|
3315
1393
|
for (; t.current; ) {
|
|
3316
1394
|
if (t.current.type === "Keyword") {
|
|
3317
1395
|
if (t.current.value.toLowerCase() === "var") {
|
|
3318
|
-
t.increment(),
|
|
1396
|
+
t.increment(), Je(t, e);
|
|
3319
1397
|
continue;
|
|
3320
1398
|
}
|
|
3321
1399
|
if (t.current.value.toLowerCase() === "function") {
|
|
3322
|
-
t.increment(),
|
|
1400
|
+
t.increment(), Qe(t, e);
|
|
3323
1401
|
continue;
|
|
3324
1402
|
}
|
|
3325
1403
|
}
|
|
@@ -3327,84 +1405,84 @@ function Xt(n) {
|
|
|
3327
1405
|
}
|
|
3328
1406
|
return e;
|
|
3329
1407
|
}
|
|
3330
|
-
function
|
|
1408
|
+
function Je(n, e) {
|
|
3331
1409
|
for (; n.current; ) {
|
|
3332
1410
|
if (n.current.type !== "Identifier")
|
|
3333
1411
|
return;
|
|
3334
1412
|
const t = n.current.value, i = t.toLowerCase();
|
|
3335
1413
|
e.set(i, {
|
|
3336
1414
|
label: t,
|
|
3337
|
-
kind:
|
|
3338
|
-
detail:
|
|
1415
|
+
kind: m.Variable,
|
|
1416
|
+
detail: v(k.variableFormat, { name: t })
|
|
3339
1417
|
});
|
|
3340
|
-
const
|
|
3341
|
-
if (
|
|
1418
|
+
const s = n.increment();
|
|
1419
|
+
if (s?.type !== "Punctuator")
|
|
3342
1420
|
return;
|
|
3343
|
-
if (
|
|
1421
|
+
if (s.value === ",") {
|
|
3344
1422
|
n.increment();
|
|
3345
1423
|
continue;
|
|
3346
1424
|
}
|
|
3347
|
-
if (
|
|
3348
|
-
n.increment(),
|
|
1425
|
+
if (s.value === "=") {
|
|
1426
|
+
n.increment(), He(n);
|
|
3349
1427
|
continue;
|
|
3350
1428
|
}
|
|
3351
1429
|
}
|
|
3352
1430
|
}
|
|
3353
|
-
function
|
|
1431
|
+
function Qe(n, e) {
|
|
3354
1432
|
for (; n.current; ) {
|
|
3355
1433
|
if (n.current.type !== "Identifier")
|
|
3356
1434
|
return;
|
|
3357
|
-
const t = n.current.value, i = t.toLowerCase(),
|
|
1435
|
+
const t = n.current.value, i = t.toLowerCase(), s = {
|
|
3358
1436
|
label: t,
|
|
3359
|
-
kind:
|
|
3360
|
-
detail:
|
|
1437
|
+
kind: m.Function,
|
|
1438
|
+
detail: v(k.functionFormat, { name: t, paramsDetail: "" }),
|
|
3361
1439
|
insertText: `${t}()`,
|
|
3362
|
-
insertTextMode:
|
|
3363
|
-
insertTextFormat:
|
|
1440
|
+
insertTextMode: L.adjustIndentation,
|
|
1441
|
+
insertTextFormat: x.Snippet
|
|
3364
1442
|
};
|
|
3365
|
-
e.set(i,
|
|
3366
|
-
let
|
|
3367
|
-
if (!
|
|
1443
|
+
e.set(i, s);
|
|
1444
|
+
let r = n.increment();
|
|
1445
|
+
if (!b(r, "("))
|
|
3368
1446
|
return;
|
|
3369
|
-
|
|
3370
|
-
const
|
|
3371
|
-
for (;
|
|
3372
|
-
|
|
3373
|
-
if (
|
|
3374
|
-
|
|
3375
|
-
name:
|
|
3376
|
-
paramsDetail:
|
|
1447
|
+
r = n.increment();
|
|
1448
|
+
const o = [];
|
|
1449
|
+
for (; r && !(r.type !== "Identifier" || (o.push(r.value), r = n.increment(), !b(r, ","))); )
|
|
1450
|
+
r = n.increment();
|
|
1451
|
+
if (o.length) {
|
|
1452
|
+
s.detail = v(k.functionFormat, {
|
|
1453
|
+
name: s.label,
|
|
1454
|
+
paramsDetail: o.join(", ")
|
|
3377
1455
|
});
|
|
3378
|
-
const
|
|
3379
|
-
|
|
1456
|
+
const p = o.map((y, C) => `\${${C + 1}:${y}}`).join(", ");
|
|
1457
|
+
s.insertText = `${s.label}(${p})`;
|
|
3380
1458
|
}
|
|
3381
|
-
if (!
|
|
1459
|
+
if (!b(r, ")") || (r = n.increment(), !b(r, "{")))
|
|
3382
1460
|
return;
|
|
3383
|
-
|
|
3384
|
-
const
|
|
3385
|
-
let
|
|
3386
|
-
for (;
|
|
3387
|
-
|
|
3388
|
-
if (
|
|
1461
|
+
r = n.increment();
|
|
1462
|
+
const c = n.currentIndex;
|
|
1463
|
+
let l = 1;
|
|
1464
|
+
for (; r && l > 0; )
|
|
1465
|
+
b(r, "{") ? l += 1 : b(r, "}") && (l -= 1), r = n.increment();
|
|
1466
|
+
if (l === 0)
|
|
3389
1467
|
return;
|
|
3390
|
-
n.currentIndex =
|
|
3391
|
-
const
|
|
3392
|
-
e.set(
|
|
3393
|
-
label:
|
|
3394
|
-
kind:
|
|
3395
|
-
detail:
|
|
1468
|
+
n.currentIndex = c, o.forEach((p) => {
|
|
1469
|
+
const y = p.toLowerCase();
|
|
1470
|
+
e.set(y, {
|
|
1471
|
+
label: p,
|
|
1472
|
+
kind: m.Variable,
|
|
1473
|
+
detail: v(k.parameterFormat, { name: p })
|
|
3396
1474
|
});
|
|
3397
1475
|
});
|
|
3398
1476
|
}
|
|
3399
1477
|
}
|
|
3400
|
-
function
|
|
1478
|
+
function b(n, e) {
|
|
3401
1479
|
return n?.type === "Punctuator" && n.value === e;
|
|
3402
1480
|
}
|
|
3403
|
-
function
|
|
1481
|
+
function He(n) {
|
|
3404
1482
|
let e = 0;
|
|
3405
1483
|
for (; n.current; ) {
|
|
3406
1484
|
if (n.current.type === "Keyword") {
|
|
3407
|
-
if (
|
|
1485
|
+
if (b(n.previous, ".") || b(n.previous, a.SafeAccessOperator)) {
|
|
3408
1486
|
n.increment();
|
|
3409
1487
|
continue;
|
|
3410
1488
|
}
|
|
@@ -3435,7 +1513,7 @@ function ti(n) {
|
|
|
3435
1513
|
n.increment();
|
|
3436
1514
|
}
|
|
3437
1515
|
}
|
|
3438
|
-
function
|
|
1516
|
+
function Ze(n, e) {
|
|
3439
1517
|
return e.insertText?.startsWith("[") && (e.additionalTextEdits = [
|
|
3440
1518
|
{
|
|
3441
1519
|
newText: "",
|
|
@@ -3449,105 +1527,105 @@ function ii(n, e) {
|
|
|
3449
1527
|
}
|
|
3450
1528
|
]), e;
|
|
3451
1529
|
}
|
|
3452
|
-
function
|
|
1530
|
+
function Ye(n) {
|
|
3453
1531
|
return { line: n.line + 1, column: n.character };
|
|
3454
1532
|
}
|
|
3455
|
-
function
|
|
1533
|
+
function Ge(n) {
|
|
3456
1534
|
return { line: n.line - 1, character: n.column };
|
|
3457
1535
|
}
|
|
3458
|
-
class
|
|
1536
|
+
class Xe {
|
|
3459
1537
|
constructor(e, t = []) {
|
|
3460
1538
|
this._apiDatabase = e, this._profileVariables = t, this._isInBlock = !1, this._isInCallExpression = !1, this._identifierBeingAssigned = void 0, this._assignmentValidationMode = "disabled", this._scriptScopeIdentifiers = /* @__PURE__ */ new Map(), this._diagnostics = [], this._undeclaredIdentifiersInFunctions = /* @__PURE__ */ new Map(), this.handleException = (i) => {
|
|
3461
|
-
if (
|
|
3462
|
-
const { range:
|
|
3463
|
-
this.logDiagnostic(
|
|
1539
|
+
if (et(i)) {
|
|
1540
|
+
const { range: s, code: r, data: o } = i;
|
|
1541
|
+
this.logDiagnostic(s, { code: r, data: o });
|
|
3464
1542
|
} else
|
|
3465
1543
|
this.logDiagnostic(
|
|
3466
1544
|
{ start: { line: 1, column: 0 }, end: { line: 1, column: 0 } },
|
|
3467
|
-
{ code:
|
|
1545
|
+
{ code: h.ExecutionError, data: { stack: i.stack ?? "" } }
|
|
3468
1546
|
);
|
|
3469
1547
|
}, this.validateStatement = (i) => {
|
|
3470
1548
|
if (i)
|
|
3471
1549
|
switch (i.type) {
|
|
3472
|
-
case
|
|
1550
|
+
case a.NodeTypes.BlockStatement:
|
|
3473
1551
|
i.body.forEach(this.validateStatement);
|
|
3474
1552
|
return;
|
|
3475
|
-
case
|
|
3476
|
-
i.declarations.forEach((
|
|
1553
|
+
case a.NodeTypes.VariableDeclaration:
|
|
1554
|
+
i.declarations.forEach((s) => this.validateVariableDeclarator(s));
|
|
3477
1555
|
return;
|
|
3478
|
-
case
|
|
1556
|
+
case a.NodeTypes.FunctionDeclaration:
|
|
3479
1557
|
this.validateFunctionDeclaration(i);
|
|
3480
1558
|
return;
|
|
3481
|
-
case
|
|
1559
|
+
case a.NodeTypes.ExportNamedDeclaration:
|
|
3482
1560
|
this.validateExportDeclaration(i);
|
|
3483
1561
|
return;
|
|
3484
|
-
case
|
|
1562
|
+
case a.NodeTypes.ImportDeclaration:
|
|
3485
1563
|
this.validateImportDeclaration(i);
|
|
3486
1564
|
return;
|
|
3487
|
-
case
|
|
1565
|
+
case a.NodeTypes.WhileStatement:
|
|
3488
1566
|
this.validateWhileStatement(i);
|
|
3489
1567
|
return;
|
|
3490
|
-
case
|
|
1568
|
+
case a.NodeTypes.ForStatement:
|
|
3491
1569
|
this.validateForStatement(i);
|
|
3492
1570
|
return;
|
|
3493
|
-
case
|
|
3494
|
-
case
|
|
1571
|
+
case a.NodeTypes.ForInStatement:
|
|
1572
|
+
case a.NodeTypes.ForOfStatement:
|
|
3495
1573
|
this.validateForInOfStatement(i);
|
|
3496
1574
|
return;
|
|
3497
|
-
case
|
|
1575
|
+
case a.NodeTypes.IfStatement:
|
|
3498
1576
|
this.validateIfStatement(i);
|
|
3499
1577
|
return;
|
|
3500
|
-
case
|
|
1578
|
+
case a.NodeTypes.ReturnStatement:
|
|
3501
1579
|
this.validateExpression(i.argument);
|
|
3502
1580
|
return;
|
|
3503
|
-
case
|
|
1581
|
+
case a.NodeTypes.ExpressionStatement:
|
|
3504
1582
|
this.validateExpression(i.expression);
|
|
3505
1583
|
return;
|
|
3506
1584
|
// No issue statement
|
|
3507
|
-
case
|
|
3508
|
-
case
|
|
3509
|
-
case
|
|
1585
|
+
case a.NodeTypes.BreakStatement:
|
|
1586
|
+
case a.NodeTypes.ContinueStatement:
|
|
1587
|
+
case a.NodeTypes.EmptyStatement:
|
|
3510
1588
|
return;
|
|
3511
1589
|
}
|
|
3512
1590
|
}, this.validateExpression = (i) => {
|
|
3513
1591
|
if (i)
|
|
3514
1592
|
switch (i.type) {
|
|
3515
|
-
case
|
|
1593
|
+
case a.NodeTypes.AssignmentExpression:
|
|
3516
1594
|
this.validateAssignmentExpression(i);
|
|
3517
1595
|
return;
|
|
3518
|
-
case
|
|
1596
|
+
case a.NodeTypes.CallExpression:
|
|
3519
1597
|
this.validateCallExpression(i);
|
|
3520
1598
|
return;
|
|
3521
|
-
case
|
|
1599
|
+
case a.NodeTypes.Identifier:
|
|
3522
1600
|
this.validateIdentifier(i);
|
|
3523
1601
|
return;
|
|
3524
|
-
case
|
|
1602
|
+
case a.NodeTypes.Literal:
|
|
3525
1603
|
this.validateLiteral(i);
|
|
3526
1604
|
return;
|
|
3527
|
-
case
|
|
1605
|
+
case a.NodeTypes.ArrayExpression:
|
|
3528
1606
|
i.elements.forEach(this.validateExpression);
|
|
3529
1607
|
return;
|
|
3530
|
-
case
|
|
1608
|
+
case a.NodeTypes.ObjectExpression:
|
|
3531
1609
|
this.validateObjectExpression(i);
|
|
3532
1610
|
return;
|
|
3533
|
-
case
|
|
1611
|
+
case a.NodeTypes.MemberAccessChainExpression:
|
|
3534
1612
|
this.validateMemberAccessChainExpression(i);
|
|
3535
1613
|
return;
|
|
3536
|
-
case
|
|
1614
|
+
case a.NodeTypes.UnaryExpression:
|
|
3537
1615
|
this.validateUnaryExpression(i);
|
|
3538
1616
|
return;
|
|
3539
|
-
case
|
|
1617
|
+
case a.NodeTypes.UpdateExpression:
|
|
3540
1618
|
this.validateUpdateExpression(i);
|
|
3541
1619
|
return;
|
|
3542
|
-
case
|
|
3543
|
-
case
|
|
1620
|
+
case a.NodeTypes.BinaryExpression:
|
|
1621
|
+
case a.NodeTypes.LogicalExpression:
|
|
3544
1622
|
this.validateBinaryAndLogicalExpression(i);
|
|
3545
1623
|
return;
|
|
3546
|
-
case
|
|
3547
|
-
case
|
|
1624
|
+
case a.NodeTypes.SafeMemberExpression:
|
|
1625
|
+
case a.NodeTypes.MemberExpression:
|
|
3548
1626
|
this.validateMemberExpression(i);
|
|
3549
1627
|
return;
|
|
3550
|
-
case
|
|
1628
|
+
case a.NodeTypes.TemplateLiteral:
|
|
3551
1629
|
i.expressions.forEach(this.validateExpression);
|
|
3552
1630
|
return;
|
|
3553
1631
|
default:
|
|
@@ -3561,11 +1639,11 @@ class si {
|
|
|
3561
1639
|
this._isInBlock = !1, this._identifierBeingAssigned = void 0, this._assignmentValidationMode = "disabled", this._diagnostics = [], this._scriptScopeIdentifiers.clear(), this._undeclaredIdentifiersInFunctions.clear(), this._functionScopeIdentifiers = void 0;
|
|
3562
1640
|
let t = null;
|
|
3563
1641
|
try {
|
|
3564
|
-
t =
|
|
3565
|
-
for (const
|
|
3566
|
-
this.logDiagnostic(
|
|
3567
|
-
code:
|
|
3568
|
-
data: { identifier:
|
|
1642
|
+
t = a.parse(e, { tolerant: !0 }), this.handleErrors(t.errors), t.body.forEach(this.validateStatement), this.diagnoseIdentifiers(), this._undeclaredIdentifiersInFunctions.size > 0 && this._undeclaredIdentifiersInFunctions.forEach((i) => {
|
|
1643
|
+
for (const s of i)
|
|
1644
|
+
this.logDiagnostic(s.node.loc, {
|
|
1645
|
+
code: h.NotDefined,
|
|
1646
|
+
data: { identifier: s.node.name }
|
|
3569
1647
|
});
|
|
3570
1648
|
});
|
|
3571
1649
|
} catch (i) {
|
|
@@ -3589,9 +1667,9 @@ class si {
|
|
|
3589
1667
|
}
|
|
3590
1668
|
logDiagnostic(e, t) {
|
|
3591
1669
|
const i = {
|
|
3592
|
-
severity:
|
|
1670
|
+
severity: g.Error,
|
|
3593
1671
|
...t,
|
|
3594
|
-
message:
|
|
1672
|
+
message: v(se[t.code], t.data),
|
|
3595
1673
|
range: {
|
|
3596
1674
|
start: { line: e.start.line - 1, character: e.start.column },
|
|
3597
1675
|
end: { line: e.end.line - 1, character: e.end.column }
|
|
@@ -3629,10 +1707,10 @@ class si {
|
|
|
3629
1707
|
}
|
|
3630
1708
|
validateFunctionDeclaration(e) {
|
|
3631
1709
|
this.recordFunctionIdentifier(e), this.inFunctionScope(() => {
|
|
3632
|
-
e.params.forEach((t) => this.recordParamAsIdentifier(t)),
|
|
3633
|
-
code:
|
|
1710
|
+
e.params.forEach((t) => this.recordParamAsIdentifier(t)), P(e.body) && this.logDiagnostic(e.body.loc, {
|
|
1711
|
+
code: h.UnexpectedEmptyFunction,
|
|
3634
1712
|
data: { identifier: e.id.name },
|
|
3635
|
-
severity:
|
|
1713
|
+
severity: g.Warning
|
|
3636
1714
|
}), this.validateStatement(e.body);
|
|
3637
1715
|
});
|
|
3638
1716
|
}
|
|
@@ -3643,48 +1721,48 @@ class si {
|
|
|
3643
1721
|
this.recordImportIdentifier(e);
|
|
3644
1722
|
}
|
|
3645
1723
|
validateForStatement(e) {
|
|
3646
|
-
|
|
3647
|
-
code:
|
|
3648
|
-
severity:
|
|
1724
|
+
a.isVariableDeclaration(e.init) ? this.inBlock(this.validateStatement, e.init) : this.validateExpression(e.init), this.validateExpression(e.update), this.validateExpression(e.test), P(e.body) && this.logDiagnostic(e.body.loc, {
|
|
1725
|
+
code: h.EmptyBlockStatement,
|
|
1726
|
+
severity: g.Warning
|
|
3649
1727
|
}), this.inBlock(this.validateStatement, e.body);
|
|
3650
1728
|
}
|
|
3651
1729
|
validateWhileStatement(e) {
|
|
3652
|
-
this.validateExpression(e.test),
|
|
3653
|
-
code:
|
|
3654
|
-
severity:
|
|
1730
|
+
this.validateExpression(e.test), P(e.body) && this.logDiagnostic(e.body.loc, {
|
|
1731
|
+
code: h.EmptyBlockStatement,
|
|
1732
|
+
severity: g.Warning
|
|
3655
1733
|
}), this.inBlock(this.validateStatement, e.body);
|
|
3656
1734
|
}
|
|
3657
1735
|
validateForInOfStatement(e) {
|
|
3658
|
-
if (
|
|
1736
|
+
if (a.isIdentifier(e.left)) {
|
|
3659
1737
|
const t = this._assignmentValidationMode;
|
|
3660
1738
|
this._assignmentValidationMode = "left", this._identifierBeingAssigned = e.left.name.toLowerCase(), this.validateExpression(e.left), this._assignmentValidationMode = t;
|
|
3661
1739
|
} else
|
|
3662
1740
|
this.recordVariableIdentifier(e.left.declarations[0].id, { initialized: !0, inBlock: !0 });
|
|
3663
|
-
this.validateExpression(e.right),
|
|
3664
|
-
code:
|
|
3665
|
-
severity:
|
|
1741
|
+
this.validateExpression(e.right), P(e.body) && this.logDiagnostic(e.body.loc, {
|
|
1742
|
+
code: h.EmptyBlockStatement,
|
|
1743
|
+
severity: g.Warning
|
|
3666
1744
|
}), this.validateStatement(e.body);
|
|
3667
1745
|
}
|
|
3668
1746
|
validateIfStatement(e) {
|
|
3669
|
-
this.validateExpression(e.test),
|
|
3670
|
-
code:
|
|
3671
|
-
severity:
|
|
3672
|
-
}), e.alternate &&
|
|
3673
|
-
code:
|
|
3674
|
-
severity:
|
|
1747
|
+
this.validateExpression(e.test), P(e.consequent) && this.logDiagnostic(e.consequent.loc, {
|
|
1748
|
+
code: h.EmptyBlockStatement,
|
|
1749
|
+
severity: g.Warning
|
|
1750
|
+
}), e.alternate && P(e.alternate) && this.logDiagnostic(e.alternate.loc, {
|
|
1751
|
+
code: h.EmptyBlockStatement,
|
|
1752
|
+
severity: g.Warning
|
|
3675
1753
|
}), this.inBlock(this.validateStatement, e.consequent), this.inBlock(this.validateStatement, e.alternate);
|
|
3676
1754
|
}
|
|
3677
1755
|
validateAssignmentExpression(e) {
|
|
3678
1756
|
const t = this._identifierBeingAssigned, i = this._assignmentValidationMode;
|
|
3679
|
-
|
|
1757
|
+
a.isIdentifier(e.left) && (this._identifierBeingAssigned = e.left.name.toLowerCase(), this._assignmentValidationMode = "left"), this.validateExpression(e.left), a.isIdentifier(e.left) && (this._assignmentValidationMode = "right"), this.validateExpression(e.right), this._identifierBeingAssigned = t, this._assignmentValidationMode = i;
|
|
3680
1758
|
}
|
|
3681
1759
|
validateCallExpression(e) {
|
|
3682
1760
|
const t = this._isInCallExpression;
|
|
3683
|
-
if (this._isInCallExpression = !0, this.validateExpression(e.callee),
|
|
3684
|
-
const i = e.callee.name.toLowerCase(),
|
|
3685
|
-
if (!
|
|
3686
|
-
const
|
|
3687
|
-
|
|
1761
|
+
if (this._isInCallExpression = !0, this.validateExpression(e.callee), a.isIdentifier(e.callee)) {
|
|
1762
|
+
const i = e.callee.name.toLowerCase(), s = this.getIdentifierInfo(i), r = this._apiDatabase?.functionDefinitions.get(i);
|
|
1763
|
+
if (!s && r) {
|
|
1764
|
+
const o = tt(r, e.arguments.length);
|
|
1765
|
+
o && this.logDiagnostic(e.loc, o);
|
|
3688
1766
|
}
|
|
3689
1767
|
}
|
|
3690
1768
|
e.arguments.forEach(this.validateExpression), this._isInCallExpression = t;
|
|
@@ -3706,30 +1784,30 @@ class si {
|
|
|
3706
1784
|
if (this._isInCallExpression)
|
|
3707
1785
|
return;
|
|
3708
1786
|
this.logDiagnostic(e.loc, {
|
|
3709
|
-
code:
|
|
1787
|
+
code: h.InvalidApiFunctionUsage,
|
|
3710
1788
|
data: { identifier: e.name }
|
|
3711
1789
|
});
|
|
3712
1790
|
return;
|
|
3713
1791
|
}
|
|
3714
1792
|
if (this._isInFunctionScope) {
|
|
3715
|
-
let
|
|
3716
|
-
|
|
1793
|
+
let s = this._undeclaredIdentifiersInFunctions.get(t);
|
|
1794
|
+
s || (s = [], this._undeclaredIdentifiersInFunctions.set(t, s)), s.push({ node: e, identifier: t });
|
|
3717
1795
|
return;
|
|
3718
1796
|
}
|
|
3719
|
-
this.logDiagnostic(e.loc, { code:
|
|
1797
|
+
this.logDiagnostic(e.loc, { code: h.NotDefined, data: { identifier: e.name } });
|
|
3720
1798
|
}
|
|
3721
1799
|
}
|
|
3722
1800
|
validateLiteral(e) {
|
|
3723
|
-
|
|
1801
|
+
nt(e.raw).forEach((t) => {
|
|
3724
1802
|
const i = this.getIdentifierInfo(t.toLowerCase());
|
|
3725
1803
|
i && (i.used = !0);
|
|
3726
1804
|
});
|
|
3727
1805
|
}
|
|
3728
1806
|
logProfileOrApiConflict(e) {
|
|
3729
|
-
const t = e.name.toLowerCase(), i = this.isProfileVariable(t),
|
|
3730
|
-
!i && !
|
|
3731
|
-
code: i ?
|
|
3732
|
-
severity:
|
|
1807
|
+
const t = e.name.toLowerCase(), i = this.isProfileVariable(t), s = this.isApiItem(t);
|
|
1808
|
+
!i && !s || this.logDiagnostic(e.loc, {
|
|
1809
|
+
code: i ? h.ProfileVariablesConflict : h.ApiConflict,
|
|
1810
|
+
severity: g.Warning,
|
|
3733
1811
|
data: {
|
|
3734
1812
|
identifier: e.name
|
|
3735
1813
|
}
|
|
@@ -3737,9 +1815,9 @@ class si {
|
|
|
3737
1815
|
}
|
|
3738
1816
|
logReservedKeywordsConflict(e) {
|
|
3739
1817
|
const t = e.name.toLowerCase();
|
|
3740
|
-
|
|
3741
|
-
code:
|
|
3742
|
-
severity:
|
|
1818
|
+
De.includes(t) && this.logDiagnostic(e.loc, {
|
|
1819
|
+
code: h.ReservedKeyword,
|
|
1820
|
+
severity: g.Warning,
|
|
3743
1821
|
data: {
|
|
3744
1822
|
identifier: e.name
|
|
3745
1823
|
}
|
|
@@ -3764,155 +1842,155 @@ class si {
|
|
|
3764
1842
|
}
|
|
3765
1843
|
validateMemberExpression(e) {
|
|
3766
1844
|
const t = this.flattenMemberExpressionAndValidate(e), i = t[0].object;
|
|
3767
|
-
this.disableRecordIdentifierAssignment(this.validateExpression, i),
|
|
1845
|
+
this.disableRecordIdentifierAssignment(this.validateExpression, i), a.isIdentifier(i) && (this.getIdentifierInfo(i.name.toLowerCase()) || this.validateMemberExpressionWithProfile(t) || this.validateConstantMemberExpression(t));
|
|
3768
1846
|
}
|
|
3769
1847
|
flattenMemberExpressionAndValidate(e) {
|
|
3770
1848
|
switch (e.type) {
|
|
3771
|
-
case
|
|
3772
|
-
case
|
|
3773
|
-
return (!
|
|
1849
|
+
case a.NodeTypes.SafeMemberExpression:
|
|
1850
|
+
case a.NodeTypes.MemberExpression:
|
|
1851
|
+
return (!a.isIdentifier(e.property) || e.computed) && this.validateExpression(e.property), [...this.flattenMemberExpressionAndValidate(e.object), e];
|
|
3774
1852
|
default:
|
|
3775
1853
|
return [];
|
|
3776
1854
|
}
|
|
3777
1855
|
}
|
|
3778
1856
|
extractAndValidatePropertyName(e) {
|
|
3779
1857
|
switch (e.type) {
|
|
3780
|
-
case
|
|
1858
|
+
case a.NodeTypes.Identifier:
|
|
3781
1859
|
return e.name.toLowerCase();
|
|
3782
|
-
case
|
|
3783
|
-
return typeof e.value != "string" ? (this.logDiagnostic(e.loc, { code:
|
|
1860
|
+
case a.NodeTypes.Literal:
|
|
1861
|
+
return typeof e.value != "string" ? (this.logDiagnostic(e.loc, { code: h.UnexpectedPropertyIdentifier }), null) : e.value.toLowerCase();
|
|
3784
1862
|
default:
|
|
3785
|
-
return this.logDiagnostic(e.loc, { code:
|
|
1863
|
+
return this.logDiagnostic(e.loc, { code: h.UnexpectedPropertyIdentifier }), null;
|
|
3786
1864
|
}
|
|
3787
1865
|
}
|
|
3788
1866
|
validateConstantMemberExpression(e) {
|
|
3789
1867
|
const t = e[0];
|
|
3790
|
-
if (!
|
|
1868
|
+
if (!a.isIdentifier(t.object))
|
|
3791
1869
|
return !1;
|
|
3792
|
-
const i = t.object.name.toLowerCase(),
|
|
3793
|
-
if (!
|
|
1870
|
+
const i = t.object.name.toLowerCase(), s = this._apiDatabase?.constantDefinitions.get(i);
|
|
1871
|
+
if (!s)
|
|
3794
1872
|
return !1;
|
|
3795
|
-
if (
|
|
1873
|
+
if (s.type !== "namespace")
|
|
3796
1874
|
return this.logDiagnostic(t.property.loc, {
|
|
3797
|
-
code:
|
|
1875
|
+
code: h.NotADictionary,
|
|
3798
1876
|
data: { identifier: i }
|
|
3799
1877
|
}), !0;
|
|
3800
|
-
const
|
|
3801
|
-
if (!
|
|
1878
|
+
const r = this.extractAndValidatePropertyName(t.property);
|
|
1879
|
+
if (!r)
|
|
3802
1880
|
return !0;
|
|
3803
|
-
if (!
|
|
3804
|
-
const
|
|
3805
|
-
(
|
|
1881
|
+
if (!s.members.some((o) => o.name.toLowerCase() === r)) {
|
|
1882
|
+
const o = s.members.reduce(
|
|
1883
|
+
(c, l) => `${c}${c ? " | " : ""}${l.completion.label.split(".").pop()}`,
|
|
3806
1884
|
""
|
|
3807
1885
|
);
|
|
3808
1886
|
this.logDiagnostic(t.property.loc, {
|
|
3809
|
-
code:
|
|
3810
|
-
data: { list:
|
|
1887
|
+
code: h.InvalidConstantIdentifier,
|
|
1888
|
+
data: { list: o }
|
|
3811
1889
|
});
|
|
3812
1890
|
}
|
|
3813
|
-
return e.length > 1 && this.logDiagnostic(e[1].property.loc, { code:
|
|
1891
|
+
return e.length > 1 && this.logDiagnostic(e[1].property.loc, { code: h.UnexpectedPropertyIdentifier }), !0;
|
|
3814
1892
|
}
|
|
3815
1893
|
validateMemberExpressionWithProfile(e) {
|
|
3816
1894
|
const t = e[0];
|
|
3817
|
-
if (t.object.type !==
|
|
1895
|
+
if (t.object.type !== a.NodeTypes.Identifier)
|
|
3818
1896
|
return !1;
|
|
3819
|
-
const i = t.object.name.toLowerCase(),
|
|
3820
|
-
if (!
|
|
1897
|
+
const i = t.object.name.toLowerCase(), s = this._profileVariables.find((o) => o.name.toLowerCase() === i);
|
|
1898
|
+
if (!s)
|
|
3821
1899
|
return !1;
|
|
3822
|
-
if (
|
|
1900
|
+
if (R(s))
|
|
3823
1901
|
return this.logDiagnostic(t.object.loc, {
|
|
3824
|
-
code:
|
|
3825
|
-
data: { identifier:
|
|
1902
|
+
code: h.NotADictionary,
|
|
1903
|
+
data: { identifier: s.name }
|
|
3826
1904
|
}), !0;
|
|
3827
1905
|
if (this._identifierBeingAssigned === i)
|
|
3828
|
-
return this.logDiagnostic(t.loc, { code:
|
|
3829
|
-
let
|
|
3830
|
-
for (let
|
|
3831
|
-
if (e[
|
|
1906
|
+
return this.logDiagnostic(t.loc, { code: h.ProfileVariablesAreImmutable }), !0;
|
|
1907
|
+
let r = s;
|
|
1908
|
+
for (let o = 0; o < e.length; o++) {
|
|
1909
|
+
if (e[o].computed)
|
|
3832
1910
|
return !0;
|
|
3833
|
-
if (
|
|
3834
|
-
return this.logDiagnostic(e[
|
|
3835
|
-
code:
|
|
3836
|
-
data: { identifier:
|
|
1911
|
+
if (R(r))
|
|
1912
|
+
return this.logDiagnostic(e[o - 1]?.property.loc ?? e[o].object.loc, {
|
|
1913
|
+
code: h.NotADictionary,
|
|
1914
|
+
data: { identifier: r.name }
|
|
3837
1915
|
}), !0;
|
|
3838
|
-
const
|
|
3839
|
-
if (!
|
|
1916
|
+
const c = this.extractAndValidatePropertyName(e[o].property);
|
|
1917
|
+
if (!c)
|
|
3840
1918
|
return !0;
|
|
3841
|
-
if (!
|
|
3842
|
-
return this.logDiagnostic(e[
|
|
3843
|
-
code:
|
|
3844
|
-
data: { identifier:
|
|
3845
|
-
severity:
|
|
1919
|
+
if (!r.properties || r.properties.length === 0)
|
|
1920
|
+
return this.logDiagnostic(e[o].property.loc, {
|
|
1921
|
+
code: h.UnknownPropertyIdentifier,
|
|
1922
|
+
data: { identifier: c },
|
|
1923
|
+
severity: g.Warning
|
|
3846
1924
|
}), !0;
|
|
3847
|
-
const
|
|
3848
|
-
(
|
|
1925
|
+
const l = r.properties.find(
|
|
1926
|
+
(p) => p.name.toLowerCase() === c
|
|
3849
1927
|
);
|
|
3850
|
-
if (!
|
|
3851
|
-
const
|
|
3852
|
-
(
|
|
1928
|
+
if (!l) {
|
|
1929
|
+
const p = r.properties.reduce(
|
|
1930
|
+
(y, C) => `${y}${y ? " | " : ""}${C.name.split(".").pop()}`,
|
|
3853
1931
|
""
|
|
3854
1932
|
);
|
|
3855
|
-
return this.logDiagnostic(e[
|
|
3856
|
-
code:
|
|
3857
|
-
data: { list:
|
|
1933
|
+
return this.logDiagnostic(e[o].property.loc, {
|
|
1934
|
+
code: h.InvalidPropertyIdentifier,
|
|
1935
|
+
data: { list: p }
|
|
3858
1936
|
}), !0;
|
|
3859
1937
|
}
|
|
3860
|
-
|
|
1938
|
+
r = l;
|
|
3861
1939
|
}
|
|
3862
1940
|
return !0;
|
|
3863
1941
|
}
|
|
3864
1942
|
recordVariableIdentifier(e, t) {
|
|
3865
1943
|
this.logReservedKeywordsConflict(e), this.logProfileOrApiConflict(e);
|
|
3866
1944
|
const i = e.name.toLowerCase();
|
|
3867
|
-
let
|
|
3868
|
-
const
|
|
3869
|
-
(
|
|
3870
|
-
code:
|
|
1945
|
+
let s = this.getIdentifierInfo(i);
|
|
1946
|
+
const r = this._isInFunctionScope && s?.scope === "function", o = !this._isInFunctionScope && s?.scope === "script";
|
|
1947
|
+
(r || o) && this.logDiagnostic(e.loc, {
|
|
1948
|
+
code: h.AlreadyDefined,
|
|
3871
1949
|
data: { identifier: e.name },
|
|
3872
|
-
severity:
|
|
1950
|
+
severity: g.Warning
|
|
3873
1951
|
});
|
|
3874
|
-
const
|
|
3875
|
-
if (!
|
|
3876
|
-
const
|
|
3877
|
-
|
|
1952
|
+
const c = t.inBlock ?? this._isInBlock, { initialized: l } = t;
|
|
1953
|
+
if (!s || this._isInFunctionScope && s.scope !== "function") {
|
|
1954
|
+
const p = this._isInFunctionScope ? "function" : c ? "block" : "script";
|
|
1955
|
+
s = {
|
|
3878
1956
|
node: e,
|
|
3879
1957
|
used: !1,
|
|
3880
|
-
initialized:
|
|
3881
|
-
scope:
|
|
1958
|
+
initialized: l,
|
|
1959
|
+
scope: p
|
|
3882
1960
|
};
|
|
3883
1961
|
} else
|
|
3884
|
-
|
|
3885
|
-
return
|
|
3886
|
-
code:
|
|
1962
|
+
s.node = e, s.used = !1, s.initialized = l;
|
|
1963
|
+
return s.scope === "block" && !c && (s.scope = "script", this.logDiagnostic(e.loc, {
|
|
1964
|
+
code: h.AlreadyDefined,
|
|
3887
1965
|
data: { identifier: e.name },
|
|
3888
|
-
severity:
|
|
3889
|
-
})), this.setIdentifierInfo(i,
|
|
1966
|
+
severity: g.Warning
|
|
1967
|
+
})), this.setIdentifierInfo(i, s), !1;
|
|
3890
1968
|
}
|
|
3891
1969
|
recordImportIdentifier(e) {
|
|
3892
1970
|
const t = e.specifiers[0].local;
|
|
3893
1971
|
this.logProfileOrApiConflict(t);
|
|
3894
1972
|
const i = t.name.toLowerCase();
|
|
3895
|
-
let
|
|
3896
|
-
|
|
3897
|
-
code:
|
|
1973
|
+
let s = this.getIdentifierInfo(i);
|
|
1974
|
+
s?.scope && this.logDiagnostic(e.specifiers[0].local.loc, {
|
|
1975
|
+
code: h.AlreadyDefined,
|
|
3898
1976
|
data: { identifier: e.specifiers[0].local.name },
|
|
3899
|
-
severity:
|
|
3900
|
-
}),
|
|
1977
|
+
severity: g.Warning
|
|
1978
|
+
}), s = {
|
|
3901
1979
|
node: e.specifiers[0].local,
|
|
3902
1980
|
used: !1,
|
|
3903
|
-
...
|
|
1981
|
+
...s,
|
|
3904
1982
|
scope: "script",
|
|
3905
1983
|
initialized: !0
|
|
3906
|
-
}, this.setIdentifierInfo(i,
|
|
1984
|
+
}, this.setIdentifierInfo(i, s);
|
|
3907
1985
|
}
|
|
3908
1986
|
recordFunctionIdentifier(e) {
|
|
3909
1987
|
this.logProfileOrApiConflict(e.id);
|
|
3910
1988
|
const t = e.id.name.toLowerCase();
|
|
3911
1989
|
let i = this.getIdentifierInfo(t);
|
|
3912
1990
|
i?.scope && this.logDiagnostic(e.id.loc, {
|
|
3913
|
-
code:
|
|
1991
|
+
code: h.AlreadyDefined,
|
|
3914
1992
|
data: { identifier: e.id.name },
|
|
3915
|
-
severity:
|
|
1993
|
+
severity: g.Warning
|
|
3916
1994
|
}), i = {
|
|
3917
1995
|
node: e.id,
|
|
3918
1996
|
used: !1,
|
|
@@ -3927,62 +2005,80 @@ class si {
|
|
|
3927
2005
|
diagnoseIdentifiers() {
|
|
3928
2006
|
(this._functionScopeIdentifiers ?? this._scriptScopeIdentifiers).forEach((e) => {
|
|
3929
2007
|
e.used ? e.initialized || this.logDiagnostic(e.node.loc, {
|
|
3930
|
-
code:
|
|
2008
|
+
code: h.DefinedNeverAssigned,
|
|
3931
2009
|
data: { identifier: e.node.name },
|
|
3932
|
-
severity:
|
|
2010
|
+
severity: g.Warning
|
|
3933
2011
|
}) : this.logDiagnostic(e.node.loc, {
|
|
3934
|
-
code: e.initialized ?
|
|
2012
|
+
code: e.initialized ? h.AssignedNeverUsed : h.DefinedNeverUsed,
|
|
3935
2013
|
data: { identifier: e.node.name },
|
|
3936
|
-
severity:
|
|
2014
|
+
severity: g.Warning
|
|
3937
2015
|
});
|
|
3938
2016
|
});
|
|
3939
2017
|
}
|
|
3940
2018
|
}
|
|
3941
|
-
function
|
|
2019
|
+
function et(n) {
|
|
3942
2020
|
return !!n && n.name === "ParsingError";
|
|
3943
2021
|
}
|
|
3944
|
-
function
|
|
3945
|
-
return
|
|
2022
|
+
function P(n) {
|
|
2023
|
+
return a.isEmptyStatement(n) || a.isBlockStatement(n) && !n.body.length;
|
|
3946
2024
|
}
|
|
3947
|
-
function
|
|
2025
|
+
function tt(n, e) {
|
|
3948
2026
|
const { min: t, max: i } = n.overloads.reduce(
|
|
3949
|
-
(
|
|
3950
|
-
const { min:
|
|
3951
|
-
return
|
|
2027
|
+
(s, r) => {
|
|
2028
|
+
const { min: o, max: c } = r.parametersInfo;
|
|
2029
|
+
return s.min >= 0 && (s.min = Math.min(o, s.min)), s.max >= 0 && (s.max = c < 0 ? c : Math.max(c, s.max)), s;
|
|
3952
2030
|
},
|
|
3953
2031
|
{ min: Number.POSITIVE_INFINITY, max: 0 }
|
|
3954
2032
|
);
|
|
3955
|
-
return e < t ? t > 0 ? { code:
|
|
2033
|
+
return e < t ? t > 0 ? { code: h.NotEnoughArguments, data: { min: t } } : { code: h.NoArgumentExpected } : i >= 0 && e > i ? { code: h.TooManyArguments, data: { max: i } } : null;
|
|
3956
2034
|
}
|
|
3957
|
-
const
|
|
3958
|
-
function
|
|
3959
|
-
return Array.from(n.matchAll(
|
|
2035
|
+
const it = /\B@\w+/gu;
|
|
2036
|
+
function nt(n = "") {
|
|
2037
|
+
return Array.from(n.matchAll(it), (e) => e[0].slice(1));
|
|
3960
2038
|
}
|
|
3961
|
-
class
|
|
2039
|
+
class ct {
|
|
2040
|
+
/** @public */
|
|
2041
|
+
constructor() {
|
|
2042
|
+
}
|
|
2043
|
+
/**
|
|
2044
|
+
* @public
|
|
2045
|
+
* @param settings
|
|
2046
|
+
*/
|
|
3962
2047
|
configure(e) {
|
|
3963
|
-
this.apiService = new
|
|
2048
|
+
this.apiService = new ne(e);
|
|
3964
2049
|
}
|
|
2050
|
+
/**
|
|
2051
|
+
* @public
|
|
2052
|
+
* @param document
|
|
2053
|
+
* @param context
|
|
2054
|
+
*/
|
|
3965
2055
|
async doValidation(e, t) {
|
|
3966
2056
|
if (!this.apiService)
|
|
3967
2057
|
return [];
|
|
3968
|
-
const i = await this.apiService.getApiDatabase(t), { profile: { variables:
|
|
3969
|
-
return
|
|
2058
|
+
const i = await this.apiService.getApiDatabase(t), { profile: { variables: s = [] } = {} } = t, { diagnostics: r } = new Xe(i, s).validateScript(e.getText());
|
|
2059
|
+
return r;
|
|
3970
2060
|
}
|
|
2061
|
+
/**
|
|
2062
|
+
* @public
|
|
2063
|
+
* @param document
|
|
2064
|
+
* @param position
|
|
2065
|
+
* @param context
|
|
2066
|
+
*/
|
|
3971
2067
|
async doComplete(e, t, i) {
|
|
3972
2068
|
if (!this.apiService)
|
|
3973
2069
|
return { isIncomplete: !1, items: [] };
|
|
3974
|
-
const
|
|
3975
|
-
return
|
|
2070
|
+
const s = await this.apiService.getApiDatabase(i);
|
|
2071
|
+
return Ve(e, t, s, i);
|
|
3976
2072
|
}
|
|
3977
2073
|
}
|
|
3978
2074
|
export {
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
2075
|
+
ve as ArcadeKeywords,
|
|
2076
|
+
ct as ArcadeLanguageService,
|
|
2077
|
+
Ae as ArcadeLiterals,
|
|
2078
|
+
De as ArcadeReservedKeywords,
|
|
2079
|
+
se as DiagnosticMessages,
|
|
2080
|
+
ht as DiagnosticSeverity,
|
|
2081
|
+
h as ValidationDiagnosticCodes,
|
|
2082
|
+
ot as arcadeFormat,
|
|
2083
|
+
Ce as format
|
|
3988
2084
|
};
|