@tslite/parser 1.9.0 → 1.12.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.
Files changed (47) hide show
  1. package/LICENSE +55 -0
  2. package/NOTICE +14 -0
  3. package/dist/_namespaces/ts.d.ts +18 -0
  4. package/dist/_namespaces/ts.js +21 -0
  5. package/dist/_namespaces/ts.performance.d.ts +1 -0
  6. package/dist/_namespaces/ts.performance.js +2 -0
  7. package/dist/core.d.ts +450 -0
  8. package/dist/core.js +1394 -0
  9. package/dist/corePublic.d.ts +62 -0
  10. package/dist/corePublic.js +31 -0
  11. package/dist/debug.d.ts +74 -0
  12. package/dist/debug.js +326 -0
  13. package/dist/diagnosticInformationMap.generated.d.ts +1435 -0
  14. package/dist/diagnosticInformationMap.generated.js +1441 -0
  15. package/dist/factory.d.ts +78 -0
  16. package/dist/factory.js +622 -0
  17. package/dist/factoryPublic.d.ts +314 -0
  18. package/dist/factoryPublic.js +1796 -0
  19. package/dist/index.d.ts +1 -249
  20. package/dist/index.js +4 -6
  21. package/dist/parser.d.ts +59 -0
  22. package/dist/parser.js +5075 -0
  23. package/dist/path.d.ts +312 -0
  24. package/dist/path.js +475 -0
  25. package/dist/perfLogger.d.ts +4 -0
  26. package/dist/perfLogger.js +38 -0
  27. package/dist/performance.d.ts +20 -0
  28. package/dist/performance.js +49 -0
  29. package/dist/performanceTimestamp.d.ts +2 -0
  30. package/dist/performanceTimestamp.js +2 -0
  31. package/dist/scanner.d.ts +80 -0
  32. package/dist/scanner.js +1984 -0
  33. package/dist/shims/mapShim.d.ts +23 -0
  34. package/dist/shims/mapShim.js +156 -0
  35. package/dist/types.d.ts +2626 -0
  36. package/dist/types.js +1074 -0
  37. package/dist/utilities.d.ts +473 -0
  38. package/dist/utilities.js +2632 -0
  39. package/dist/utilitiesPublic.d.ts +274 -0
  40. package/dist/utilitiesPublic.js +1049 -0
  41. package/dist/visitor.d.ts +15 -0
  42. package/dist/visitor.js +64 -0
  43. package/dist/visitorPublic.d.ts +82 -0
  44. package/dist/visitorPublic.js +352 -0
  45. package/package.json +14 -42
  46. package/dist/index.cjs +0 -6
  47. package/dist/index.d.cts +0 -249
@@ -0,0 +1,62 @@
1
+ export declare const versionMajorMinor = "3.9";
2
+ /** The version of the TypeScript compiler release */
3
+ export declare const version: string;
4
+ /**
5
+ * Type of objects whose values are all of the same type.
6
+ * The `in` and `for-in` operators can *not* be safely used,
7
+ * since `Object.prototype` may be modified by outside code.
8
+ */
9
+ export interface MapLike<T> {
10
+ [index: string]: T;
11
+ }
12
+ export interface SortedReadonlyArray<T> extends ReadonlyArray<T> {
13
+ " __sortedArrayBrand": any;
14
+ }
15
+ export interface SortedArray<T> extends Array<T> {
16
+ " __sortedArrayBrand": any;
17
+ }
18
+ /** ES6 Map interface, only read methods included. */
19
+ export interface ReadonlyMap<T> {
20
+ get(key: string): T | undefined;
21
+ has(key: string): boolean;
22
+ forEach(action: (value: T, key: string) => void): void;
23
+ readonly size: number;
24
+ keys(): Iterator<string>;
25
+ values(): Iterator<T>;
26
+ entries(): Iterator<[string, T]>;
27
+ }
28
+ /** ES6 Map interface. */
29
+ export interface Map<T> extends ReadonlyMap<T> {
30
+ set(key: string, value: T): this;
31
+ delete(key: string): boolean;
32
+ clear(): void;
33
+ }
34
+ export interface MapConstructor {
35
+ new <T>(): Map<T>;
36
+ }
37
+ /**
38
+ * Returns the native Map implementation if it is available and compatible (i.e. supports iteration).
39
+ */
40
+ export declare function tryGetNativeMap(): MapConstructor | undefined;
41
+ export declare const Map: MapConstructor;
42
+ /** ES6 Iterator type. */
43
+ export interface Iterator<T> {
44
+ next(): {
45
+ value: T;
46
+ done?: false;
47
+ } | {
48
+ value: never;
49
+ done: true;
50
+ };
51
+ }
52
+ /** Array that is only intended to be pushed to, never read. */
53
+ export interface Push<T> {
54
+ push(...values: T[]): void;
55
+ }
56
+ export type EqualityComparer<T> = (a: T, b: T) => boolean;
57
+ export type Comparer<T> = (a: T, b: T) => Comparison;
58
+ export declare enum Comparison {
59
+ LessThan = -1,
60
+ EqualTo = 0,
61
+ GreaterThan = 1
62
+ }
@@ -0,0 +1,31 @@
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 = {}));
@@ -0,0 +1,74 @@
1
+ import * as ts from "./_namespaces/ts.js";
2
+ import { AssertionLevel, EmitFlags, ModifierFlags, NodeFlags, SymbolFlags, SyntaxKind, TransformFlags } from "./_namespaces/ts.js";
3
+ import type { AnyFunction, FlowNode, Node, NodeArray, Symbol } from "./_namespaces/ts.js";
4
+ export declare namespace Debug {
5
+ let isDebugging: boolean;
6
+ function getAssertionLevel(): ts.AssertionLevel;
7
+ function setAssertionLevel(level: AssertionLevel): void;
8
+ function shouldAssert(level: AssertionLevel): boolean;
9
+ function fail(message?: string, stackCrawlMark?: AnyFunction): never;
10
+ function failBadSyntaxKind(node: Node, message?: string, stackCrawlMark?: AnyFunction): never;
11
+ function assert(expression: unknown, message?: string, verboseDebugInfo?: string | (() => string), stackCrawlMark?: AnyFunction): asserts expression;
12
+ function assertEqual<T>(a: T, b: T, msg?: string, msg2?: string, stackCrawlMark?: AnyFunction): void;
13
+ function assertLessThan(a: number, b: number, msg?: string, stackCrawlMark?: AnyFunction): void;
14
+ function assertLessThanOrEqual(a: number, b: number, stackCrawlMark?: AnyFunction): void;
15
+ function assertGreaterThanOrEqual(a: number, b: number, stackCrawlMark?: AnyFunction): void;
16
+ function assertIsDefined<T>(value: T, message?: string, stackCrawlMark?: AnyFunction): asserts value is NonNullable<T>;
17
+ function checkDefined<T>(value: T | null | undefined, message?: string, stackCrawlMark?: AnyFunction): T;
18
+ /**
19
+ * @deprecated Use `checkDefined` to check whether a value is defined inline. Use `assertIsDefined` to check whether
20
+ * a value is defined at the statement level.
21
+ */
22
+ const assertDefined: typeof checkDefined;
23
+ function assertEachIsDefined<T extends Node>(value: NodeArray<T>, message?: string, stackCrawlMark?: AnyFunction): asserts value is NodeArray<T>;
24
+ function assertEachIsDefined<T>(value: readonly T[], message?: string, stackCrawlMark?: AnyFunction): asserts value is readonly NonNullable<T>[];
25
+ function checkEachDefined<T, A extends readonly T[]>(value: A, message?: string, stackCrawlMark?: AnyFunction): A;
26
+ /**
27
+ * @deprecated Use `checkEachDefined` to check whether the elements of an array are defined inline. Use `assertEachIsDefined` to check whether
28
+ * the elements of an array are defined at the statement level.
29
+ */
30
+ const assertEachDefined: typeof checkEachDefined;
31
+ function assertNever(member: never, message?: string, stackCrawlMark?: AnyFunction): never;
32
+ function assertEachNode<T extends Node, U extends T>(nodes: NodeArray<T>, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is NodeArray<U>;
33
+ function assertEachNode<T extends Node, U extends T>(nodes: readonly T[], test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is readonly U[];
34
+ function assertEachNode(nodes: readonly Node[], test: (node: Node) => boolean, message?: string, stackCrawlMark?: AnyFunction): void;
35
+ function assertNode<T extends Node, U extends T>(node: T | undefined, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts node is U;
36
+ function assertNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction): void;
37
+ function assertNotNode<T extends Node, U extends T>(node: T | undefined, test: (node: Node) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts node is Exclude<T, U>;
38
+ function assertNotNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction): void;
39
+ function assertOptionalNode<T extends Node, U extends T>(node: T, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts node is U;
40
+ function assertOptionalNode<T extends Node, U extends T>(node: T | undefined, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts node is U | undefined;
41
+ function assertOptionalNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction): void;
42
+ function assertOptionalToken<T extends Node, K extends SyntaxKind>(node: T, kind: K, message?: string, stackCrawlMark?: AnyFunction): asserts node is Extract<T, {
43
+ readonly kind: K;
44
+ }>;
45
+ function assertOptionalToken<T extends Node, K extends SyntaxKind>(node: T | undefined, kind: K, message?: string, stackCrawlMark?: AnyFunction): asserts node is Extract<T, {
46
+ readonly kind: K;
47
+ }> | undefined;
48
+ function assertOptionalToken(node: Node | undefined, kind: SyntaxKind | undefined, message?: string, stackCrawlMark?: AnyFunction): void;
49
+ function assertMissingNode(node: Node | undefined, message?: string, stackCrawlMark?: AnyFunction): asserts node is undefined;
50
+ /**
51
+ * Afirma que o valor tem o tipo dado só no tipo, sem asserção em runtime. Não é da tag: é do TypeScript 5.0, que o
52
+ * escreveu para a assinatura de implementação de um predicado que recebe `Node` (o §5 da arquitetura do checker).
53
+ */
54
+ function type<T>(value: unknown): asserts value is T;
55
+ function getFunctionName(func: AnyFunction): any;
56
+ function formatSymbol(symbol: Symbol): string;
57
+ /**
58
+ * Formats an enum value as a string for debugging and debug assertions.
59
+ */
60
+ function formatEnum(value: number | undefined, enumObject: any, isFlags?: boolean): string;
61
+ function formatSyntaxKind(kind: SyntaxKind | undefined): string;
62
+ function formatNodeFlags(flags: NodeFlags | undefined): string;
63
+ function formatModifierFlags(flags: ModifierFlags | undefined): string;
64
+ function formatTransformFlags(flags: TransformFlags | undefined): string;
65
+ function formatEmitFlags(flags: EmitFlags | undefined): string;
66
+ function formatSymbolFlags(flags: SymbolFlags | undefined): string;
67
+ function printControlFlowGraph(flowNode: FlowNode): void;
68
+ function formatControlFlowGraph(flowNode: FlowNode): string;
69
+ function attachFlowNodeDebugInfo(flowNode: FlowNode): void;
70
+ /**
71
+ * Injects debug information into frequently used types.
72
+ */
73
+ function enableDebugInfo(): void;
74
+ }
package/dist/debug.js ADDED
@@ -0,0 +1,326 @@
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 = {}));