@tslite/parser 1.16.0 → 1.17.0

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.
@@ -1,31 +0,0 @@
1
- // Modificado de microsoft/TypeScript v3.9.10, src/compiler/corePublic.ts: o namespace virou módulo ES, com os imports explícitos.
2
- import { createMapShim, } from "./_namespaces/ts.js";
3
- // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
4
- // If changing the text in this section, be sure to test `configurePrerelease` too.
5
- export const versionMajorMinor = "3.9";
6
- /** The version of the TypeScript compiler release */
7
- export const version = "3.9.10";
8
- /**
9
- * Returns the native Map implementation if it is available and compatible (i.e. supports iteration).
10
- */
11
- export function tryGetNativeMap() {
12
- // O `Map` global, com o tipo da declaração acima. No outFile, o `Map` livre era o global; no módulo, o
13
- // `export const Map` de baixo faz sombra a ele, e o global se lê pelo `globalThis` — cujo tipo de `Map`
14
- // é o da lib, e não o que a declaração afirma.
15
- const NativeMap = globalThis.Map;
16
- // eslint-disable-next-line no-in-operator
17
- return typeof NativeMap !== "undefined" && "entries" in NativeMap.prototype ? NativeMap : undefined;
18
- }
19
- export const Map = tryGetNativeMap() || (() => {
20
- // NOTE: createMapShim will be defined for typescriptServices.js but not for tsc.js, so we must test for it.
21
- if (typeof createMapShim === "function") {
22
- return createMapShim();
23
- }
24
- throw new Error("TypeScript requires an environment that provides a compatible native Map implementation.");
25
- })();
26
- export var Comparison;
27
- (function (Comparison) {
28
- Comparison[Comparison["LessThan"] = -1] = "LessThan";
29
- Comparison[Comparison["EqualTo"] = 0] = "EqualTo";
30
- Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan";
31
- })(Comparison || (Comparison = {}));
package/dist/debug.js DELETED
@@ -1,326 +0,0 @@
1
- // Modificado de microsoft/TypeScript v3.9.10, src/compiler/debug.ts: o namespace virou módulo ES, com os imports explícitos.
2
- import * as ts from "./_namespaces/ts.js";
3
- import { compareValues, every, getEmitFlags, getModifierFlagsNoCache, getOwnKeys, getParseTreeNode, getSourceFileOfNode, getSourceTextOfNodeFromSourceFile, hasProperty, isParseTreeNode, map, nodeIsSynthesized, noop, objectAllocator, stableSort, unescapeLeadingUnderscores, } from "./_namespaces/ts.js";
4
- export var Debug;
5
- (function (Debug) {
6
- let currentAssertionLevel = 0 /* AssertionLevel.None */;
7
- // eslint-disable-next-line prefer-const
8
- Debug.isDebugging = false;
9
- const assertionCache = {};
10
- function getAssertionLevel() {
11
- return currentAssertionLevel;
12
- }
13
- Debug.getAssertionLevel = getAssertionLevel;
14
- function setAssertionLevel(level) {
15
- const prevAssertionLevel = currentAssertionLevel;
16
- currentAssertionLevel = level;
17
- if (level > prevAssertionLevel) {
18
- // restore assertion functions for the current assertion level (see `shouldAssertFunction`).
19
- for (const key of getOwnKeys(assertionCache)) {
20
- const cachedFunc = assertionCache[key];
21
- if (cachedFunc !== undefined && Debug[key] !== cachedFunc.assertion && level >= cachedFunc.level) {
22
- Debug[key] = cachedFunc;
23
- assertionCache[key] = undefined;
24
- }
25
- }
26
- }
27
- }
28
- Debug.setAssertionLevel = setAssertionLevel;
29
- function shouldAssert(level) {
30
- return currentAssertionLevel >= level;
31
- }
32
- Debug.shouldAssert = shouldAssert;
33
- /**
34
- * Tests whether an assertion function should be executed. If it shouldn't, it is cached and replaced with `ts.noop`.
35
- * Replaced assertion functions are restored when `Debug.setAssertionLevel` is set to a high enough level.
36
- * @param level The minimum assertion level required.
37
- * @param name The name of the current assertion function.
38
- */
39
- function shouldAssertFunction(level, name) {
40
- if (!shouldAssert(level)) {
41
- assertionCache[name] = { level, assertion: Debug[name] };
42
- Debug[name] = noop;
43
- return false;
44
- }
45
- return true;
46
- }
47
- function fail(message, stackCrawlMark) {
48
- debugger;
49
- const e = new Error(message ? `Debug Failure. ${message}` : "Debug Failure.");
50
- if (Error.captureStackTrace) {
51
- Error.captureStackTrace(e, stackCrawlMark || fail);
52
- }
53
- throw e;
54
- }
55
- Debug.fail = fail;
56
- function failBadSyntaxKind(node, message, stackCrawlMark) {
57
- return fail(`${message || "Unexpected node."}\r\nNode ${formatSyntaxKind(node.kind)} was unexpected.`, stackCrawlMark || failBadSyntaxKind);
58
- }
59
- Debug.failBadSyntaxKind = failBadSyntaxKind;
60
- function assert(expression, message, verboseDebugInfo, stackCrawlMark) {
61
- if (!expression) {
62
- message = message ? `False expression: ${message}` : "False expression.";
63
- if (verboseDebugInfo) {
64
- message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo());
65
- }
66
- fail(message, stackCrawlMark || assert);
67
- }
68
- }
69
- Debug.assert = assert;
70
- function assertEqual(a, b, msg, msg2, stackCrawlMark) {
71
- if (a !== b) {
72
- const message = msg ? msg2 ? `${msg} ${msg2}` : msg : "";
73
- fail(`Expected ${a} === ${b}. ${message}`, stackCrawlMark || assertEqual);
74
- }
75
- }
76
- Debug.assertEqual = assertEqual;
77
- function assertLessThan(a, b, msg, stackCrawlMark) {
78
- if (a >= b) {
79
- fail(`Expected ${a} < ${b}. ${msg || ""}`, stackCrawlMark || assertLessThan);
80
- }
81
- }
82
- Debug.assertLessThan = assertLessThan;
83
- function assertLessThanOrEqual(a, b, stackCrawlMark) {
84
- if (a > b) {
85
- fail(`Expected ${a} <= ${b}`, stackCrawlMark || assertLessThanOrEqual);
86
- }
87
- }
88
- Debug.assertLessThanOrEqual = assertLessThanOrEqual;
89
- function assertGreaterThanOrEqual(a, b, stackCrawlMark) {
90
- if (a < b) {
91
- fail(`Expected ${a} >= ${b}`, stackCrawlMark || assertGreaterThanOrEqual);
92
- }
93
- }
94
- Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual;
95
- function assertIsDefined(value, message, stackCrawlMark) {
96
- // eslint-disable-next-line no-null/no-null
97
- if (value === undefined || value === null) {
98
- fail(message, stackCrawlMark || assertIsDefined);
99
- }
100
- }
101
- Debug.assertIsDefined = assertIsDefined;
102
- function checkDefined(value, message, stackCrawlMark) {
103
- assertIsDefined(value, message, stackCrawlMark || checkDefined);
104
- return value;
105
- }
106
- Debug.checkDefined = checkDefined;
107
- /**
108
- * @deprecated Use `checkDefined` to check whether a value is defined inline. Use `assertIsDefined` to check whether
109
- * a value is defined at the statement level.
110
- */
111
- Debug.assertDefined = checkDefined;
112
- function assertEachIsDefined(value, message, stackCrawlMark) {
113
- for (const v of value) {
114
- assertIsDefined(v, message, stackCrawlMark || assertEachIsDefined);
115
- }
116
- }
117
- Debug.assertEachIsDefined = assertEachIsDefined;
118
- function checkEachDefined(value, message, stackCrawlMark) {
119
- assertEachIsDefined(value, message, stackCrawlMark || checkEachDefined);
120
- return value;
121
- }
122
- Debug.checkEachDefined = checkEachDefined;
123
- /**
124
- * @deprecated Use `checkEachDefined` to check whether the elements of an array are defined inline. Use `assertEachIsDefined` to check whether
125
- * the elements of an array are defined at the statement level.
126
- */
127
- Debug.assertEachDefined = checkEachDefined;
128
- function assertNever(member, message = "Illegal value:", stackCrawlMark) {
129
- const detail = typeof member === "object" && hasProperty(member, "kind") && hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
130
- return fail(`${message} ${detail}`, stackCrawlMark || assertNever);
131
- }
132
- Debug.assertNever = assertNever;
133
- function assertEachNode(nodes, test, message, stackCrawlMark) {
134
- if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertEachNode")) {
135
- assert(test === undefined || every(nodes, test), message || "Unexpected node.", () => `Node array did not pass test '${getFunctionName(test)}'.`, stackCrawlMark || assertEachNode);
136
- }
137
- }
138
- Debug.assertEachNode = assertEachNode;
139
- function assertNode(node, test, message, stackCrawlMark) {
140
- if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNode")) {
141
- assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", () => `Node ${formatSyntaxKind(node.kind)} did not pass test '${getFunctionName(test)}'.`, stackCrawlMark || assertNode);
142
- }
143
- }
144
- Debug.assertNode = assertNode;
145
- function assertNotNode(node, test, message, stackCrawlMark) {
146
- if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNotNode")) {
147
- assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", () => `Node ${formatSyntaxKind(node.kind)} should not have passed test '${getFunctionName(test)}'.`, stackCrawlMark || assertNotNode);
148
- }
149
- }
150
- Debug.assertNotNode = assertNotNode;
151
- function assertOptionalNode(node, test, message, stackCrawlMark) {
152
- if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalNode")) {
153
- assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", () => `Node ${formatSyntaxKind(node.kind)} did not pass test '${getFunctionName(test)}'.`, stackCrawlMark || assertOptionalNode);
154
- }
155
- }
156
- Debug.assertOptionalNode = assertOptionalNode;
157
- function assertOptionalToken(node, kind, message, stackCrawlMark) {
158
- if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalToken")) {
159
- assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", () => `Node ${formatSyntaxKind(node.kind)} was not a '${formatSyntaxKind(kind)}' token.`, stackCrawlMark || assertOptionalToken);
160
- }
161
- }
162
- Debug.assertOptionalToken = assertOptionalToken;
163
- function assertMissingNode(node, message, stackCrawlMark) {
164
- if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertMissingNode")) {
165
- assert(node === undefined, message || "Unexpected node.", () => `Node ${formatSyntaxKind(node.kind)} was unexpected'.`, stackCrawlMark || assertMissingNode);
166
- }
167
- }
168
- Debug.assertMissingNode = assertMissingNode;
169
- function type(_value) { }
170
- Debug.type = type;
171
- function getFunctionName(func) {
172
- if (typeof func !== "function") {
173
- return "";
174
- }
175
- else if (func.hasOwnProperty("name")) {
176
- return func.name;
177
- }
178
- else {
179
- const text = Function.prototype.toString.call(func);
180
- const match = /^function\s+([\w\$]+)\s*\(/.exec(text);
181
- return match ? match[1] : "";
182
- }
183
- }
184
- Debug.getFunctionName = getFunctionName;
185
- function formatSymbol(symbol) {
186
- return `{ name: ${unescapeLeadingUnderscores(symbol.escapedName)}; flags: ${formatSymbolFlags(symbol.flags)}; declarations: ${map(symbol.declarations, node => formatSyntaxKind(node.kind))} }`;
187
- }
188
- Debug.formatSymbol = formatSymbol;
189
- /**
190
- * Formats an enum value as a string for debugging and debug assertions.
191
- */
192
- function formatEnum(value = 0, enumObject, isFlags) {
193
- const members = getEnumMembers(enumObject);
194
- if (value === 0) {
195
- return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
196
- }
197
- if (isFlags) {
198
- let result = "";
199
- let remainingFlags = value;
200
- for (const [enumValue, enumName] of members) {
201
- if (enumValue > value) {
202
- break;
203
- }
204
- if (enumValue !== 0 && enumValue & value) {
205
- result = `${result}${result ? "|" : ""}${enumName}`;
206
- remainingFlags &= ~enumValue;
207
- }
208
- }
209
- if (remainingFlags === 0) {
210
- return result;
211
- }
212
- }
213
- else {
214
- for (const [enumValue, enumName] of members) {
215
- if (enumValue === value) {
216
- return enumName;
217
- }
218
- }
219
- }
220
- return value.toString();
221
- }
222
- Debug.formatEnum = formatEnum;
223
- function getEnumMembers(enumObject) {
224
- const result = [];
225
- for (const name in enumObject) {
226
- const value = enumObject[name];
227
- if (typeof value === "number") {
228
- result.push([value, name]);
229
- }
230
- }
231
- return stableSort(result, (x, y) => compareValues(x[0], y[0]));
232
- }
233
- function formatSyntaxKind(kind) {
234
- return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
235
- }
236
- Debug.formatSyntaxKind = formatSyntaxKind;
237
- function formatNodeFlags(flags) {
238
- return formatEnum(flags, ts.NodeFlags, /*isFlags*/ true);
239
- }
240
- Debug.formatNodeFlags = formatNodeFlags;
241
- function formatModifierFlags(flags) {
242
- return formatEnum(flags, ts.ModifierFlags, /*isFlags*/ true);
243
- }
244
- Debug.formatModifierFlags = formatModifierFlags;
245
- function formatTransformFlags(flags) {
246
- return formatEnum(flags, ts.TransformFlags, /*isFlags*/ true);
247
- }
248
- Debug.formatTransformFlags = formatTransformFlags;
249
- function formatEmitFlags(flags) {
250
- return formatEnum(flags, ts.EmitFlags, /*isFlags*/ true);
251
- }
252
- Debug.formatEmitFlags = formatEmitFlags;
253
- function formatSymbolFlags(flags) {
254
- return formatEnum(flags, ts.SymbolFlags, /*isFlags*/ true);
255
- }
256
- Debug.formatSymbolFlags = formatSymbolFlags;
257
- let isDebugInfoEnabled = false;
258
- let extendedDebugModule;
259
- function extendedDebug() {
260
- enableDebugInfo();
261
- if (!extendedDebugModule) {
262
- throw new Error("Debugging helpers could not be loaded.");
263
- }
264
- return extendedDebugModule;
265
- }
266
- function printControlFlowGraph(flowNode) {
267
- return console.log(formatControlFlowGraph(flowNode));
268
- }
269
- Debug.printControlFlowGraph = printControlFlowGraph;
270
- function formatControlFlowGraph(flowNode) {
271
- return extendedDebug().formatControlFlowGraph(flowNode);
272
- }
273
- Debug.formatControlFlowGraph = formatControlFlowGraph;
274
- function attachFlowNodeDebugInfo(flowNode) {
275
- if (isDebugInfoEnabled) {
276
- if (!("__debugFlowFlags" in flowNode)) { // eslint-disable-line no-in-operator
277
- Object.defineProperties(flowNode, {
278
- __debugFlowFlags: { get() { return formatEnum(this.flags, ts.FlowFlags, /*isFlags*/ true); } },
279
- __debugToString: { value() { return formatControlFlowGraph(this); } }
280
- });
281
- }
282
- }
283
- }
284
- Debug.attachFlowNodeDebugInfo = attachFlowNodeDebugInfo;
285
- /**
286
- * Injects debug information into frequently used types.
287
- */
288
- function enableDebugInfo() {
289
- if (isDebugInfoEnabled)
290
- return;
291
- // Add additional properties in debug mode to assist with debugging.
292
- Object.defineProperties(objectAllocator.getSymbolConstructor().prototype, {
293
- __debugFlags: { get() { return formatSymbolFlags(this.flags); } }
294
- });
295
- // A informação dos tipos é do checker, que cria os tipos (o `enableTypeDebugInfo` dele).
296
- const nodeConstructors = [
297
- objectAllocator.getNodeConstructor(),
298
- objectAllocator.getIdentifierConstructor(),
299
- objectAllocator.getTokenConstructor(),
300
- objectAllocator.getSourceFileConstructor()
301
- ];
302
- for (const ctor of nodeConstructors) {
303
- if (!ctor.prototype.hasOwnProperty("__debugKind")) {
304
- Object.defineProperties(ctor.prototype, {
305
- __debugKind: { get() { return formatSyntaxKind(this.kind); } },
306
- __debugNodeFlags: { get() { return formatNodeFlags(this.flags); } },
307
- __debugModifierFlags: { get() { return formatModifierFlags(getModifierFlagsNoCache(this)); } },
308
- __debugTransformFlags: { get() { return formatTransformFlags(this.transformFlags); } },
309
- __debugIsParseTreeNode: { get() { return isParseTreeNode(this); } },
310
- __debugEmitFlags: { get() { return formatEmitFlags(getEmitFlags(this)); } },
311
- __debugGetText: {
312
- value(includeTrivia) {
313
- if (nodeIsSynthesized(this))
314
- return "";
315
- const parseNode = getParseTreeNode(this);
316
- const sourceFile = parseNode && getSourceFileOfNode(parseNode);
317
- return sourceFile ? getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
318
- }
319
- }
320
- });
321
- }
322
- }
323
- isDebugInfoEnabled = true;
324
- }
325
- Debug.enableDebugInfo = enableDebugInfo;
326
- })(Debug || (Debug = {}));
@@ -1,4 +0,0 @@
1
- // Modificado de microsoft/TypeScript v3.9.10, src/compiler/diagnosticInformationMap.generated.ts: o objeto `Diagnostics` é o
2
- // namespace das mensagens, um export por mensagem no `diagnosticMessages.generated.ts` (CK-76). O barril exporta este
3
- // arquivo, e o `Diagnostics` continua sendo o único nome que ele põe no `ts`.
4
- export * as Diagnostics from "./diagnosticMessages.generated.js";