@babel/traverse 7.20.0 → 7.20.5
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.
Potentially problematic release.
This version of @babel/traverse might be problematic. Click here for more details.
- package/lib/cache.js +0 -3
- package/lib/cache.js.map +1 -1
- package/lib/context.js +7 -21
- package/lib/context.js.map +1 -1
- package/lib/hub.js +0 -6
- package/lib/hub.js.map +1 -1
- package/lib/index.js +3 -21
- package/lib/index.js.map +1 -1
- package/lib/path/ancestry.js +3 -23
- package/lib/path/ancestry.js.map +1 -1
- package/lib/path/comments.js +0 -4
- package/lib/path/comments.js.map +1 -1
- package/lib/path/context.js +14 -54
- package/lib/path/context.js.map +1 -1
- package/lib/path/conversion.js +23 -78
- package/lib/path/conversion.js.map +1 -1
- package/lib/path/evaluation.js +9 -85
- package/lib/path/evaluation.js.map +1 -1
- package/lib/path/family.js +6 -73
- package/lib/path/family.js.map +1 -1
- package/lib/path/index.js +2 -61
- package/lib/path/index.js.map +1 -1
- package/lib/path/inference/index.js +2 -27
- package/lib/path/inference/index.js.map +1 -1
- package/lib/path/inference/inferer-reference.js +10 -31
- package/lib/path/inference/inferer-reference.js.map +1 -1
- package/lib/path/inference/inferers.js +4 -44
- package/lib/path/inference/inferers.js.map +1 -1
- package/lib/path/inference/util.js +0 -4
- package/lib/path/inference/util.js.map +1 -1
- package/lib/path/introspection.js +17 -59
- package/lib/path/introspection.js.map +1 -1
- package/lib/path/lib/hoister.js +7 -23
- package/lib/path/lib/hoister.js.map +1 -1
- package/lib/path/lib/removal-hooks.js +7 -3
- package/lib/path/lib/removal-hooks.js.map +1 -1
- package/lib/path/lib/virtual-types-validator.js +0 -23
- package/lib/path/lib/virtual-types-validator.js.map +1 -1
- package/lib/path/lib/virtual-types.js +1 -0
- package/lib/path/lib/virtual-types.js.map +1 -1
- package/lib/path/modification.js +12 -47
- package/lib/path/modification.js.map +1 -1
- package/lib/path/removal.js +0 -16
- package/lib/path/removal.js.map +1 -1
- package/lib/path/replacement.js +8 -50
- package/lib/path/replacement.js.map +1 -1
- package/lib/scope/binding.js +2 -14
- package/lib/scope/binding.js.map +1 -1
- package/lib/scope/index.js +19 -184
- package/lib/scope/index.js.map +1 -1
- package/lib/scope/lib/renamer.js +2 -25
- package/lib/scope/lib/renamer.js.map +1 -1
- package/lib/traverse-node.js +0 -7
- package/lib/traverse-node.js.map +1 -1
- package/lib/visitors.js +13 -44
- package/lib/visitors.js.map +1 -1
- package/package.json +4 -4
package/lib/path/family.js
CHANGED
@@ -17,11 +17,8 @@ exports.getOuterBindingIdentifierPaths = getOuterBindingIdentifierPaths;
|
|
17
17
|
exports.getOuterBindingIdentifiers = getOuterBindingIdentifiers;
|
18
18
|
exports.getPrevSibling = getPrevSibling;
|
19
19
|
exports.getSibling = getSibling;
|
20
|
-
|
21
20
|
var _index = require("./index");
|
22
|
-
|
23
21
|
var _t = require("@babel/types");
|
24
|
-
|
25
22
|
const {
|
26
23
|
getBindingIdentifiers: _getBindingIdentifiers,
|
27
24
|
getOuterBindingIdentifiers: _getOuterBindingIdentifiers,
|
@@ -31,71 +28,55 @@ const {
|
|
31
28
|
} = _t;
|
32
29
|
const NORMAL_COMPLETION = 0;
|
33
30
|
const BREAK_COMPLETION = 1;
|
34
|
-
|
35
31
|
function NormalCompletion(path) {
|
36
32
|
return {
|
37
33
|
type: NORMAL_COMPLETION,
|
38
34
|
path
|
39
35
|
};
|
40
36
|
}
|
41
|
-
|
42
37
|
function BreakCompletion(path) {
|
43
38
|
return {
|
44
39
|
type: BREAK_COMPLETION,
|
45
40
|
path
|
46
41
|
};
|
47
42
|
}
|
48
|
-
|
49
43
|
function getOpposite() {
|
50
44
|
if (this.key === "left") {
|
51
45
|
return this.getSibling("right");
|
52
46
|
} else if (this.key === "right") {
|
53
47
|
return this.getSibling("left");
|
54
48
|
}
|
55
|
-
|
56
49
|
return null;
|
57
50
|
}
|
58
|
-
|
59
51
|
function addCompletionRecords(path, records, context) {
|
60
52
|
if (path) {
|
61
53
|
records.push(..._getCompletionRecords(path, context));
|
62
54
|
}
|
63
|
-
|
64
55
|
return records;
|
65
56
|
}
|
66
|
-
|
67
57
|
function completionRecordForSwitch(cases, records, context) {
|
68
58
|
let lastNormalCompletions = [];
|
69
|
-
|
70
59
|
for (let i = 0; i < cases.length; i++) {
|
71
60
|
const casePath = cases[i];
|
72
|
-
|
73
61
|
const caseCompletions = _getCompletionRecords(casePath, context);
|
74
|
-
|
75
62
|
const normalCompletions = [];
|
76
63
|
const breakCompletions = [];
|
77
|
-
|
78
64
|
for (const c of caseCompletions) {
|
79
65
|
if (c.type === NORMAL_COMPLETION) {
|
80
66
|
normalCompletions.push(c);
|
81
67
|
}
|
82
|
-
|
83
68
|
if (c.type === BREAK_COMPLETION) {
|
84
69
|
breakCompletions.push(c);
|
85
70
|
}
|
86
71
|
}
|
87
|
-
|
88
72
|
if (normalCompletions.length) {
|
89
73
|
lastNormalCompletions = normalCompletions;
|
90
74
|
}
|
91
|
-
|
92
75
|
records.push(...breakCompletions);
|
93
76
|
}
|
94
|
-
|
95
77
|
records.push(...lastNormalCompletions);
|
96
78
|
return records;
|
97
79
|
}
|
98
|
-
|
99
80
|
function normalCompletionToBreak(completions) {
|
100
81
|
completions.forEach(c => {
|
101
82
|
c.type = BREAK_COMPLETION;
|
@@ -115,63 +96,51 @@ function replaceBreakStatementInBreakCompletion(completions, reachable) {
|
|
115
96
|
}
|
116
97
|
});
|
117
98
|
}
|
118
|
-
|
119
99
|
function getStatementListCompletion(paths, context) {
|
120
100
|
const completions = [];
|
121
|
-
|
122
101
|
if (context.canHaveBreak) {
|
123
102
|
let lastNormalCompletions = [];
|
124
|
-
|
125
103
|
for (let i = 0; i < paths.length; i++) {
|
126
104
|
const path = paths[i];
|
127
105
|
const newContext = Object.assign({}, context, {
|
128
106
|
inCaseClause: false
|
129
107
|
});
|
130
|
-
|
131
|
-
|
108
|
+
if (path.isBlockStatement() && (context.inCaseClause ||
|
109
|
+
context.shouldPopulateBreak)) {
|
132
110
|
newContext.shouldPopulateBreak = true;
|
133
111
|
} else {
|
134
112
|
newContext.shouldPopulateBreak = false;
|
135
113
|
}
|
136
|
-
|
137
114
|
const statementCompletions = _getCompletionRecords(path, newContext);
|
138
|
-
|
139
|
-
|
115
|
+
if (statementCompletions.length > 0 &&
|
116
|
+
statementCompletions.every(c => c.type === BREAK_COMPLETION)) {
|
140
117
|
if (lastNormalCompletions.length > 0 && statementCompletions.every(c => c.path.isBreakStatement({
|
141
118
|
label: null
|
142
119
|
}))) {
|
143
120
|
normalCompletionToBreak(lastNormalCompletions);
|
144
121
|
completions.push(...lastNormalCompletions);
|
145
|
-
|
146
122
|
if (lastNormalCompletions.some(c => c.path.isDeclaration())) {
|
147
123
|
completions.push(...statementCompletions);
|
148
124
|
replaceBreakStatementInBreakCompletion(statementCompletions, true);
|
149
125
|
}
|
150
|
-
|
151
126
|
replaceBreakStatementInBreakCompletion(statementCompletions, false);
|
152
127
|
} else {
|
153
128
|
completions.push(...statementCompletions);
|
154
|
-
|
155
129
|
if (!context.shouldPopulateBreak) {
|
156
130
|
replaceBreakStatementInBreakCompletion(statementCompletions, true);
|
157
131
|
}
|
158
132
|
}
|
159
|
-
|
160
133
|
break;
|
161
134
|
}
|
162
|
-
|
163
135
|
if (i === paths.length - 1) {
|
164
136
|
completions.push(...statementCompletions);
|
165
137
|
} else {
|
166
138
|
lastNormalCompletions = [];
|
167
|
-
|
168
139
|
for (let i = 0; i < statementCompletions.length; i++) {
|
169
140
|
const c = statementCompletions[i];
|
170
|
-
|
171
141
|
if (c.type === BREAK_COMPLETION) {
|
172
142
|
completions.push(c);
|
173
143
|
}
|
174
|
-
|
175
144
|
if (c.type === NORMAL_COMPLETION) {
|
176
145
|
lastNormalCompletions.push(c);
|
177
146
|
}
|
@@ -181,20 +150,16 @@ function getStatementListCompletion(paths, context) {
|
|
181
150
|
} else if (paths.length) {
|
182
151
|
for (let i = paths.length - 1; i >= 0; i--) {
|
183
152
|
const pathCompletions = _getCompletionRecords(paths[i], context);
|
184
|
-
|
185
153
|
if (pathCompletions.length > 1 || pathCompletions.length === 1 && !pathCompletions[0].path.isVariableDeclaration()) {
|
186
154
|
completions.push(...pathCompletions);
|
187
155
|
break;
|
188
156
|
}
|
189
157
|
}
|
190
158
|
}
|
191
|
-
|
192
159
|
return completions;
|
193
160
|
}
|
194
|
-
|
195
161
|
function _getCompletionRecords(path, context) {
|
196
162
|
let records = [];
|
197
|
-
|
198
163
|
if (path.isIfStatement()) {
|
199
164
|
records = addCompletionRecords(path.get("consequent"), records, context);
|
200
165
|
records = addCompletionRecords(path.get("alternate"), records, context);
|
@@ -222,7 +187,6 @@ function _getCompletionRecords(path, context) {
|
|
222
187
|
} else {
|
223
188
|
records.push(NormalCompletion(path));
|
224
189
|
}
|
225
|
-
|
226
190
|
return records;
|
227
191
|
}
|
228
192
|
|
@@ -232,10 +196,8 @@ function getCompletionRecords() {
|
|
232
196
|
shouldPopulateBreak: false,
|
233
197
|
inCaseClause: false
|
234
198
|
});
|
235
|
-
|
236
199
|
return records.map(r => r.path);
|
237
200
|
}
|
238
|
-
|
239
201
|
function getSibling(key) {
|
240
202
|
return _index.default.get({
|
241
203
|
parentPath: this.parentPath,
|
@@ -245,56 +207,45 @@ function getSibling(key) {
|
|
245
207
|
key: key
|
246
208
|
}).setContext(this.context);
|
247
209
|
}
|
248
|
-
|
249
210
|
function getPrevSibling() {
|
250
211
|
return this.getSibling(this.key - 1);
|
251
212
|
}
|
252
|
-
|
253
213
|
function getNextSibling() {
|
254
214
|
return this.getSibling(this.key + 1);
|
255
215
|
}
|
256
|
-
|
257
216
|
function getAllNextSiblings() {
|
258
217
|
let _key = this.key;
|
259
218
|
let sibling = this.getSibling(++_key);
|
260
219
|
const siblings = [];
|
261
|
-
|
262
220
|
while (sibling.node) {
|
263
221
|
siblings.push(sibling);
|
264
222
|
sibling = this.getSibling(++_key);
|
265
223
|
}
|
266
|
-
|
267
224
|
return siblings;
|
268
225
|
}
|
269
|
-
|
270
226
|
function getAllPrevSiblings() {
|
271
227
|
let _key = this.key;
|
272
228
|
let sibling = this.getSibling(--_key);
|
273
229
|
const siblings = [];
|
274
|
-
|
275
230
|
while (sibling.node) {
|
276
231
|
siblings.push(sibling);
|
277
232
|
sibling = this.getSibling(--_key);
|
278
233
|
}
|
279
|
-
|
280
234
|
return siblings;
|
281
235
|
}
|
282
236
|
|
283
237
|
function get(key, context = true) {
|
284
238
|
if (context === true) context = this.context;
|
285
239
|
const parts = key.split(".");
|
286
|
-
|
287
240
|
if (parts.length === 1) {
|
288
241
|
return this._getKey(key, context);
|
289
242
|
} else {
|
290
243
|
return this._getPattern(parts, context);
|
291
244
|
}
|
292
245
|
}
|
293
|
-
|
294
246
|
function _getKey(key, context) {
|
295
247
|
const node = this.node;
|
296
248
|
const container = node[key];
|
297
|
-
|
298
249
|
if (Array.isArray(container)) {
|
299
250
|
return container.map((_, i) => {
|
300
251
|
return _index.default.get({
|
@@ -314,10 +265,8 @@ function _getKey(key, context) {
|
|
314
265
|
}).setContext(context);
|
315
266
|
}
|
316
267
|
}
|
317
|
-
|
318
268
|
function _getPattern(parts, context) {
|
319
269
|
let path = this;
|
320
|
-
|
321
270
|
for (const part of parts) {
|
322
271
|
if (part === ".") {
|
323
272
|
path = path.parentPath;
|
@@ -329,67 +278,53 @@ function _getPattern(parts, context) {
|
|
329
278
|
}
|
330
279
|
}
|
331
280
|
}
|
332
|
-
|
333
281
|
return path;
|
334
282
|
}
|
335
|
-
|
336
283
|
function getBindingIdentifiers(duplicates) {
|
337
284
|
return _getBindingIdentifiers(this.node, duplicates);
|
338
285
|
}
|
339
|
-
|
340
286
|
function getOuterBindingIdentifiers(duplicates) {
|
341
287
|
return _getOuterBindingIdentifiers(this.node, duplicates);
|
342
288
|
}
|
343
|
-
|
344
289
|
function getBindingIdentifierPaths(duplicates = false, outerOnly = false) {
|
345
290
|
const path = this;
|
346
291
|
const search = [path];
|
347
292
|
const ids = Object.create(null);
|
348
|
-
|
349
293
|
while (search.length) {
|
350
294
|
const id = search.shift();
|
351
295
|
if (!id) continue;
|
352
296
|
if (!id.node) continue;
|
353
|
-
const keys =
|
354
|
-
|
297
|
+
const keys =
|
298
|
+
_getBindingIdentifiers.keys[id.node.type];
|
355
299
|
if (id.isIdentifier()) {
|
356
300
|
if (duplicates) {
|
357
301
|
const _ids = ids[id.node.name] = ids[id.node.name] || [];
|
358
|
-
|
359
302
|
_ids.push(id);
|
360
303
|
} else {
|
361
304
|
ids[id.node.name] = id;
|
362
305
|
}
|
363
|
-
|
364
306
|
continue;
|
365
307
|
}
|
366
|
-
|
367
308
|
if (id.isExportDeclaration()) {
|
368
309
|
const declaration = id.get("declaration");
|
369
|
-
|
370
310
|
if (isDeclaration(declaration)) {
|
371
311
|
search.push(declaration);
|
372
312
|
}
|
373
|
-
|
374
313
|
continue;
|
375
314
|
}
|
376
|
-
|
377
315
|
if (outerOnly) {
|
378
316
|
if (id.isFunctionDeclaration()) {
|
379
317
|
search.push(id.get("id"));
|
380
318
|
continue;
|
381
319
|
}
|
382
|
-
|
383
320
|
if (id.isFunctionExpression()) {
|
384
321
|
continue;
|
385
322
|
}
|
386
323
|
}
|
387
|
-
|
388
324
|
if (keys) {
|
389
325
|
for (let i = 0; i < keys.length; i++) {
|
390
326
|
const key = keys[i];
|
391
327
|
const child = id.get(key);
|
392
|
-
|
393
328
|
if (Array.isArray(child)) {
|
394
329
|
search.push(...child);
|
395
330
|
} else if (child.node) {
|
@@ -398,10 +333,8 @@ function getBindingIdentifierPaths(duplicates = false, outerOnly = false) {
|
|
398
333
|
}
|
399
334
|
}
|
400
335
|
}
|
401
|
-
|
402
336
|
return ids;
|
403
337
|
}
|
404
|
-
|
405
338
|
function getOuterBindingIdentifierPaths(duplicates = false) {
|
406
339
|
return this.getBindingIdentifierPaths(duplicates, true);
|
407
340
|
}
|
package/lib/path/family.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["getBindingIdentifiers","_getBindingIdentifiers","getOuterBindingIdentifiers","_getOuterBindingIdentifiers","isDeclaration","numericLiteral","unaryExpression","NORMAL_COMPLETION","BREAK_COMPLETION","NormalCompletion","path","type","BreakCompletion","getOpposite","key","getSibling","addCompletionRecords","records","context","push","_getCompletionRecords","completionRecordForSwitch","cases","lastNormalCompletions","i","length","casePath","caseCompletions","normalCompletions","breakCompletions","c","normalCompletionToBreak","completions","forEach","replaceBreakStatementInBreakCompletion","reachable","isBreakStatement","label","replaceWith","remove","getStatementListCompletion","paths","canHaveBreak","newContext","inCaseClause","isBlockStatement","shouldPopulateBreak","statementCompletions","every","some","pathCompletions","isVariableDeclaration","isIfStatement","get","isDoExpression","isFor","isWhile","isLabeledStatement","isProgram","isFunction","isTryStatement","isCatchClause","isSwitchStatement","isSwitchCase","getCompletionRecords","map","r","NodePath","parentPath","parent","container","listKey","setContext","getPrevSibling","getNextSibling","getAllNextSiblings","_key","sibling","siblings","node","getAllPrevSiblings","parts","split","_getKey","_getPattern","Array","isArray","_","part","duplicates","getBindingIdentifierPaths","outerOnly","search","ids","Object","create","id","shift","keys","isIdentifier","_ids","name","isExportDeclaration","declaration","isFunctionDeclaration","isFunctionExpression","child","getOuterBindingIdentifierPaths"],"sources":["../../src/path/family.ts"],"sourcesContent":["// This file contains methods responsible for dealing with/retrieving children or siblings.\n\nimport type TraversalContext from \"../context\";\nimport NodePath from \"./index\";\nimport {\n getBindingIdentifiers as _getBindingIdentifiers,\n getOuterBindingIdentifiers as _getOuterBindingIdentifiers,\n isDeclaration,\n numericLiteral,\n unaryExpression,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\n\nconst NORMAL_COMPLETION = 0 as const;\nconst BREAK_COMPLETION = 1 as const;\n\ntype Completion = {\n path: NodePath;\n type: 0 | 1;\n};\n\ntype CompletionContext = {\n // whether the current context allows `break` statement. When it allows, we have\n // to search all the statements for potential `break`\n canHaveBreak: boolean;\n // whether the statement is an immediate descendant of a switch case clause\n inCaseClause: boolean;\n // whether the `break` statement record should be populated to upper level\n // when a `break` statement is an immediate descendant of a block statement, e.g.\n // `{ break }`, it can influence the control flow in the upper levels.\n shouldPopulateBreak: boolean;\n};\n\nfunction NormalCompletion(path: NodePath) {\n return { type: NORMAL_COMPLETION, path };\n}\n\nfunction BreakCompletion(path: NodePath) {\n return { type: BREAK_COMPLETION, path };\n}\n\nexport function getOpposite(this: NodePath): NodePath | null {\n if (this.key === \"left\") {\n return this.getSibling(\"right\");\n } else if (this.key === \"right\") {\n return this.getSibling(\"left\");\n }\n return null;\n}\n\nfunction addCompletionRecords(\n path: NodePath | null | undefined,\n records: Completion[],\n context: CompletionContext,\n): Completion[] {\n if (path) {\n records.push(..._getCompletionRecords(path, context));\n }\n return records;\n}\n\nfunction completionRecordForSwitch(\n cases: NodePath<t.SwitchCase>[],\n records: Completion[],\n context: CompletionContext,\n): Completion[] {\n // https://tc39.es/ecma262/#sec-runtime-semantics-caseblockevaluation\n let lastNormalCompletions: Completion[] = [];\n for (let i = 0; i < cases.length; i++) {\n const casePath = cases[i];\n const caseCompletions = _getCompletionRecords(casePath, context);\n const normalCompletions = [];\n const breakCompletions = [];\n for (const c of caseCompletions) {\n if (c.type === NORMAL_COMPLETION) {\n normalCompletions.push(c);\n }\n if (c.type === BREAK_COMPLETION) {\n breakCompletions.push(c);\n }\n }\n if (normalCompletions.length) {\n lastNormalCompletions = normalCompletions;\n }\n records.push(...breakCompletions);\n }\n records.push(...lastNormalCompletions);\n return records;\n}\n\nfunction normalCompletionToBreak(completions: Completion[]) {\n completions.forEach(c => {\n c.type = BREAK_COMPLETION;\n });\n}\n\n/**\n * Determine how we should handle the break statement for break completions\n *\n * @param {Completion[]} completions\n * @param {boolean} reachable Whether the break statement is reachable after\n we mark the normal completions _before_ the given break completions as the final\n completions. For example,\n `{ 0 }; break;` is transformed to `{ return 0 }; break;`, the `break` here is unreachable\n and thus can be removed without consequences. We may in the future reserve them instead since\n we do not consistently remove unreachable statements _after_ break\n `{ var x = 0 }; break;` is transformed to `{ var x = 0 }; return void 0;`, the `break` is reachable\n because we can not wrap variable declaration under a return statement\n */\nfunction replaceBreakStatementInBreakCompletion(\n completions: Completion[],\n reachable: boolean,\n) {\n completions.forEach(c => {\n if (c.path.isBreakStatement({ label: null })) {\n if (reachable) {\n c.path.replaceWith(unaryExpression(\"void\", numericLiteral(0)));\n } else {\n c.path.remove();\n }\n }\n });\n}\n\nfunction getStatementListCompletion(\n paths: NodePath[],\n context: CompletionContext,\n): Completion[] {\n const completions = [];\n if (context.canHaveBreak) {\n let lastNormalCompletions = [];\n for (let i = 0; i < paths.length; i++) {\n const path = paths[i];\n const newContext = { ...context, inCaseClause: false };\n if (\n path.isBlockStatement() &&\n (context.inCaseClause || // case test: { break }\n context.shouldPopulateBreak) // case test: { { break } }\n ) {\n newContext.shouldPopulateBreak = true;\n } else {\n newContext.shouldPopulateBreak = false;\n }\n const statementCompletions = _getCompletionRecords(path, newContext);\n if (\n statementCompletions.length > 0 &&\n // we can stop search `paths` when we have seen a `path` that is\n // effectively a `break` statement. Examples are\n // - `break`\n // - `if (true) { 1; break } else { 2; break }`\n // - `{ break }```\n // In other words, the paths after this `path` are unreachable\n statementCompletions.every(c => c.type === BREAK_COMPLETION)\n ) {\n if (\n lastNormalCompletions.length > 0 &&\n statementCompletions.every(c =>\n c.path.isBreakStatement({ label: null }),\n )\n ) {\n // when a break completion has a path as BreakStatement, it must be `{ break }`\n // whose completion value we can not determine, otherwise it would have been\n // replaced by `replaceBreakStatementInBreakCompletion`\n // When we have seen normal completions from the last statement\n // it is safe to stop populating break and mark normal completions as break\n normalCompletionToBreak(lastNormalCompletions);\n completions.push(...lastNormalCompletions);\n // Declarations have empty completion record, however they can not be nested\n // directly in return statement, i.e. `return (var a = 1)` is invalid.\n if (lastNormalCompletions.some(c => c.path.isDeclaration())) {\n completions.push(...statementCompletions);\n replaceBreakStatementInBreakCompletion(\n statementCompletions,\n /* reachable */ true,\n );\n }\n replaceBreakStatementInBreakCompletion(\n statementCompletions,\n /* reachable */ false,\n );\n } else {\n completions.push(...statementCompletions);\n if (!context.shouldPopulateBreak) {\n replaceBreakStatementInBreakCompletion(\n statementCompletions,\n /* reachable */ true,\n );\n }\n }\n break;\n }\n if (i === paths.length - 1) {\n completions.push(...statementCompletions);\n } else {\n lastNormalCompletions = [];\n for (let i = 0; i < statementCompletions.length; i++) {\n const c = statementCompletions[i];\n if (c.type === BREAK_COMPLETION) {\n completions.push(c);\n }\n if (c.type === NORMAL_COMPLETION) {\n lastNormalCompletions.push(c);\n }\n }\n }\n }\n } else if (paths.length) {\n // When we are in a context where `break` must not exist, we can skip linear\n // search on statement lists and assume that the last\n // non-variable-declaration statement determines the completion.\n for (let i = paths.length - 1; i >= 0; i--) {\n const pathCompletions = _getCompletionRecords(paths[i], context);\n if (\n pathCompletions.length > 1 ||\n (pathCompletions.length === 1 &&\n !pathCompletions[0].path.isVariableDeclaration())\n ) {\n completions.push(...pathCompletions);\n break;\n }\n }\n }\n return completions;\n}\n\nfunction _getCompletionRecords(\n path: NodePath,\n context: CompletionContext,\n): Completion[] {\n let records: Completion[] = [];\n if (path.isIfStatement()) {\n records = addCompletionRecords(path.get(\"consequent\"), records, context);\n records = addCompletionRecords(path.get(\"alternate\"), records, context);\n } else if (\n path.isDoExpression() ||\n path.isFor() ||\n path.isWhile() ||\n path.isLabeledStatement()\n ) {\n // @ts-expect-error(flow->ts): todo\n return addCompletionRecords(path.get(\"body\"), records, context);\n } else if (path.isProgram() || path.isBlockStatement()) {\n // @ts-expect-error(flow->ts): todo\n return getStatementListCompletion(path.get(\"body\"), context);\n } else if (path.isFunction()) {\n return _getCompletionRecords(path.get(\"body\"), context);\n } else if (path.isTryStatement()) {\n records = addCompletionRecords(path.get(\"block\"), records, context);\n records = addCompletionRecords(path.get(\"handler\"), records, context);\n } else if (path.isCatchClause()) {\n return addCompletionRecords(path.get(\"body\"), records, context);\n } else if (path.isSwitchStatement()) {\n return completionRecordForSwitch(path.get(\"cases\"), records, context);\n } else if (path.isSwitchCase()) {\n return getStatementListCompletion(path.get(\"consequent\"), {\n canHaveBreak: true,\n shouldPopulateBreak: false,\n inCaseClause: true,\n });\n } else if (path.isBreakStatement()) {\n records.push(BreakCompletion(path));\n } else {\n records.push(NormalCompletion(path));\n }\n\n return records;\n}\n\n/**\n * Retrieve the completion records of a given path.\n * Note: to ensure proper support on `break` statement, this method\n * will manipulate the AST around the break statement. Do not call the method\n * twice for the same path.\n *\n * @export\n * @param {NodePath} this\n * @returns {NodePath[]} Completion records\n */\nexport function getCompletionRecords(this: NodePath): NodePath[] {\n const records = _getCompletionRecords(this, {\n canHaveBreak: false,\n shouldPopulateBreak: false,\n inCaseClause: false,\n });\n return records.map(r => r.path);\n}\n\nexport function getSibling(this: NodePath, key: string | number): NodePath {\n return NodePath.get({\n parentPath: this.parentPath,\n parent: this.parent,\n container: this.container,\n listKey: this.listKey,\n key: key,\n }).setContext(this.context);\n}\n\nexport function getPrevSibling(this: NodePath): NodePath {\n // @ts-expect-error todo(flow->ts) this.key could be a string\n return this.getSibling(this.key - 1);\n}\n\nexport function getNextSibling(this: NodePath): NodePath {\n // @ts-expect-error todo(flow->ts) this.key could be a string\n return this.getSibling(this.key + 1);\n}\n\nexport function getAllNextSiblings(this: NodePath): NodePath[] {\n // @ts-expect-error todo(flow->ts) this.key could be a string\n let _key: number = this.key;\n let sibling = this.getSibling(++_key);\n const siblings = [];\n while (sibling.node) {\n siblings.push(sibling);\n sibling = this.getSibling(++_key);\n }\n return siblings;\n}\n\nexport function getAllPrevSiblings(this: NodePath): NodePath[] {\n // @ts-expect-error todo(flow->ts) this.key could be a string\n let _key: number = this.key;\n let sibling = this.getSibling(--_key);\n const siblings = [];\n while (sibling.node) {\n siblings.push(sibling);\n sibling = this.getSibling(--_key);\n }\n return siblings;\n}\n\n// convert \"1\" to 1 (string index to number index)\ntype MaybeToIndex<T extends string> = T extends `${bigint}` ? number : T;\n\ntype Pattern<Obj extends string, Prop extends string> = `${Obj}.${Prop}`;\n\n// split \"body.body.1\" to [\"body\", \"body\", 1]\ntype Split<P extends string> = P extends Pattern<infer O, infer U>\n ? [MaybeToIndex<O>, ...Split<U>]\n : [MaybeToIndex<P>];\n\n// get all K with Node[K] is t.Node | t.Node[]\ntype NodeKeyOf<Node extends t.Node | t.Node[]> = keyof Pick<\n Node,\n {\n [Key in keyof Node]-?: Node[Key] extends t.Node | t.Node[] ? Key : never;\n }[keyof Node]\n>;\n\n// traverse the Node with tuple path [\"body\", \"body\", 1]\n// Path should be created with Split\ntype Trav<\n Node extends t.Node | t.Node[],\n Path extends unknown[],\n> = Path extends [infer K, ...infer R]\n ? K extends NodeKeyOf<Node>\n ? R extends []\n ? Node[K]\n : // @ts-expect-error ignore since TS is not smart enough\n Trav<Node[K], R>\n : never\n : never;\n\ntype ToNodePath<T> = T extends Array<t.Node | null | undefined>\n ? Array<NodePath<T[number]>>\n : T extends t.Node | null | undefined\n ? NodePath<T>\n : never;\n\nfunction get<T extends t.Node, K extends keyof T>(\n this: NodePath<T>,\n key: K,\n context?: boolean | TraversalContext,\n): T[K] extends Array<t.Node | null | undefined>\n ? Array<NodePath<T[K][number]>>\n : T[K] extends t.Node | null | undefined\n ? NodePath<T[K]>\n : never;\n\nfunction get<T extends t.Node, K extends string>(\n this: NodePath<T>,\n key: K,\n context?: boolean | TraversalContext,\n): ToNodePath<Trav<T, Split<K>>>;\n\nfunction get<T extends t.Node>(\n this: NodePath<T>,\n key: string,\n context?: true | TraversalContext,\n): NodePath | NodePath[];\n\nfunction get<T extends t.Node>(\n this: NodePath<T>,\n key: string,\n context: true | TraversalContext = true,\n): NodePath | NodePath[] {\n if (context === true) context = this.context;\n const parts = key.split(\".\");\n if (parts.length === 1) {\n // \"foo\"\n // @ts-expect-error key may not index T\n return this._getKey(key, context);\n } else {\n // \"foo.bar\"\n return this._getPattern(parts, context);\n }\n}\n\nexport { get };\n\nexport function _getKey<T extends t.Node>(\n this: NodePath<T>,\n key: keyof T & string,\n context?: TraversalContext,\n): NodePath | NodePath[] {\n const node = this.node;\n const container = node[key];\n\n if (Array.isArray(container)) {\n // requested a container so give them all the paths\n return container.map((_, i) => {\n return NodePath.get({\n listKey: key,\n parentPath: this,\n parent: node,\n container: container,\n key: i,\n }).setContext(context);\n });\n } else {\n return NodePath.get({\n parentPath: this,\n parent: node,\n container: node,\n key: key,\n }).setContext(context);\n }\n}\n\nexport function _getPattern(\n this: NodePath,\n parts: string[],\n context?: TraversalContext,\n): NodePath | NodePath[] {\n let path: NodePath | NodePath[] = this;\n for (const part of parts) {\n if (part === \".\") {\n // @ts-expect-error todo(flow-ts): Can path be an array here?\n path = path.parentPath;\n } else {\n if (Array.isArray(path)) {\n // @ts-expect-error part may not index path\n path = path[part];\n } else {\n path = path.get(part, context);\n }\n }\n }\n return path;\n}\n\nfunction getBindingIdentifiers(\n duplicates: true,\n): Record<string, t.Identifier[]>;\nfunction getBindingIdentifiers(\n duplicates?: false,\n): Record<string, t.Identifier>;\nfunction getBindingIdentifiers(\n duplicates: boolean,\n): Record<string, t.Identifier[] | t.Identifier>;\n\nfunction getBindingIdentifiers(\n this: NodePath,\n duplicates?: boolean,\n): Record<string, t.Identifier[] | t.Identifier> {\n return _getBindingIdentifiers(this.node, duplicates);\n}\n\nexport { getBindingIdentifiers };\n\nfunction getOuterBindingIdentifiers(\n duplicates: true,\n): Record<string, t.Identifier[]>;\nfunction getOuterBindingIdentifiers(\n duplicates?: false,\n): Record<string, t.Identifier>;\nfunction getOuterBindingIdentifiers(\n duplicates: boolean,\n): Record<string, t.Identifier[] | t.Identifier>;\n\nfunction getOuterBindingIdentifiers(\n this: NodePath,\n duplicates?: boolean,\n): Record<string, t.Identifier[] | t.Identifier> {\n return _getOuterBindingIdentifiers(this.node, duplicates);\n}\n\nexport { getOuterBindingIdentifiers };\n\nfunction getBindingIdentifierPaths(\n duplicates: true,\n outerOnly?: boolean,\n): Record<string, NodePath<t.Identifier>[]>;\nfunction getBindingIdentifierPaths(\n duplicates: false,\n outerOnly?: boolean,\n): Record<string, NodePath<t.Identifier>>;\nfunction getBindingIdentifierPaths(\n duplicates?: boolean,\n outerOnly?: boolean,\n): Record<string, NodePath<t.Identifier> | NodePath<t.Identifier>[]>;\n\n// original source - https://github.com/babel/babel/blob/main/packages/babel-types/src/retrievers/getBindingIdentifiers.js\n// path.getBindingIdentifiers returns nodes where the following re-implementation returns paths\nfunction getBindingIdentifierPaths(\n this: NodePath,\n duplicates: boolean = false,\n outerOnly: boolean = false,\n): Record<string, NodePath<t.Identifier> | NodePath<t.Identifier>[]> {\n const path = this;\n const search = [path];\n const ids = Object.create(null);\n\n while (search.length) {\n const id = search.shift();\n if (!id) continue;\n if (!id.node) continue;\n\n const keys =\n // @ts-expect-error _getBindingIdentifiers.keys do not cover all node types\n _getBindingIdentifiers.keys[id.node.type];\n\n if (id.isIdentifier()) {\n if (duplicates) {\n const _ids = (ids[id.node.name] = ids[id.node.name] || []);\n _ids.push(id);\n } else {\n ids[id.node.name] = id;\n }\n continue;\n }\n\n if (id.isExportDeclaration()) {\n const declaration = id.get(\"declaration\");\n if (isDeclaration(declaration)) {\n search.push(declaration);\n }\n continue;\n }\n\n if (outerOnly) {\n if (id.isFunctionDeclaration()) {\n search.push(id.get(\"id\"));\n continue;\n }\n if (id.isFunctionExpression()) {\n continue;\n }\n }\n\n if (keys) {\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const child = id.get(key);\n if (Array.isArray(child)) {\n search.push(...child);\n } else if (child.node) {\n search.push(child);\n }\n }\n }\n }\n\n return ids;\n}\n\nexport { getBindingIdentifierPaths };\n\nfunction getOuterBindingIdentifierPaths(\n duplicates: true,\n): Record<string, NodePath<t.Identifier>[]>;\nfunction getOuterBindingIdentifierPaths(\n duplicates?: false,\n): Record<string, NodePath<t.Identifier>>;\nfunction getOuterBindingIdentifierPaths(\n duplicates?: boolean,\n): Record<string, NodePath<t.Identifier> | NodePath<t.Identifier>[]>;\n\nfunction getOuterBindingIdentifierPaths(\n this: NodePath,\n duplicates: boolean = false,\n) {\n return this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QsB,IAAT,CAAH,GAAoBL,EAApB;MACD;;MACD;IACD;;IAED,IAAIA,EAAE,CAACM,mBAAH,EAAJ,EAA8B;MAC5B,MAAMC,WAAW,GAAGP,EAAE,CAAC3C,GAAH,CAAO,aAAP,CAApB;;MACA,IAAIjD,aAAa,CAACmG,WAAD,CAAjB,EAAgC;QAC9BX,MAAM,CAACzE,IAAP,CAAYoF,WAAZ;MACD;;MACD;IACD;;IAED,IAAIZ,SAAJ,EAAe;MACb,IAAIK,EAAE,CAACQ,qBAAH,EAAJ,EAAgC;QAC9BZ,MAAM,CAACzE,IAAP,CAAY6E,EAAE,CAAC3C,GAAH,CAAO,IAAP,CAAZ;QACA;MACD;;MACD,IAAI2C,EAAE,CAACS,oBAAH,EAAJ,EAA+B;QAC7B;MACD;IACF;;IAED,IAAIP,IAAJ,EAAU;MACR,KAAK,IAAI1E,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAG0E,IAAI,CAACzE,MAAzB,EAAiCD,CAAC,EAAlC,EAAsC;QACpC,MAAMV,GAAG,GAAGoF,IAAI,CAAC1E,CAAD,CAAhB;QACA,MAAMkF,KAAK,GAAGV,EAAE,CAAC3C,GAAH,CAAOvC,GAAP,CAAd;;QACA,IAAIuE,KAAK,CAACC,OAAN,CAAcoB,KAAd,CAAJ,EAA0B;UACxBd,MAAM,CAACzE,IAAP,CAAY,GAAGuF,KAAf;QACD,CAFD,MAEO,IAAIA,KAAK,CAAC3B,IAAV,EAAgB;UACrBa,MAAM,CAACzE,IAAP,CAAYuF,KAAZ;QACD;MACF;IACF;EACF;;EAED,OAAOb,GAAP;AACD;;AAcD,SAASc,8BAAT,CAEElB,UAAmB,GAAG,KAFxB,EAGE;EACA,OAAO,KAAKC,yBAAL,CAA+BD,UAA/B,EAA2C,IAA3C,CAAP;AACD"}
|
1
|
+
{"version":3,"names":["getBindingIdentifiers","_getBindingIdentifiers","getOuterBindingIdentifiers","_getOuterBindingIdentifiers","isDeclaration","numericLiteral","unaryExpression","NORMAL_COMPLETION","BREAK_COMPLETION","NormalCompletion","path","type","BreakCompletion","getOpposite","key","getSibling","addCompletionRecords","records","context","push","_getCompletionRecords","completionRecordForSwitch","cases","lastNormalCompletions","i","length","casePath","caseCompletions","normalCompletions","breakCompletions","c","normalCompletionToBreak","completions","forEach","replaceBreakStatementInBreakCompletion","reachable","isBreakStatement","label","replaceWith","remove","getStatementListCompletion","paths","canHaveBreak","newContext","inCaseClause","isBlockStatement","shouldPopulateBreak","statementCompletions","every","some","pathCompletions","isVariableDeclaration","isIfStatement","get","isDoExpression","isFor","isWhile","isLabeledStatement","isProgram","isFunction","isTryStatement","isCatchClause","isSwitchStatement","isSwitchCase","getCompletionRecords","map","r","NodePath","parentPath","parent","container","listKey","setContext","getPrevSibling","getNextSibling","getAllNextSiblings","_key","sibling","siblings","node","getAllPrevSiblings","parts","split","_getKey","_getPattern","Array","isArray","_","part","duplicates","getBindingIdentifierPaths","outerOnly","search","ids","Object","create","id","shift","keys","isIdentifier","_ids","name","isExportDeclaration","declaration","isFunctionDeclaration","isFunctionExpression","child","getOuterBindingIdentifierPaths"],"sources":["../../src/path/family.ts"],"sourcesContent":["// This file contains methods responsible for dealing with/retrieving children or siblings.\n\nimport type TraversalContext from \"../context\";\nimport NodePath from \"./index\";\nimport {\n getBindingIdentifiers as _getBindingIdentifiers,\n getOuterBindingIdentifiers as _getOuterBindingIdentifiers,\n isDeclaration,\n numericLiteral,\n unaryExpression,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\n\nconst NORMAL_COMPLETION = 0 as const;\nconst BREAK_COMPLETION = 1 as const;\n\ntype Completion = {\n path: NodePath;\n type: 0 | 1;\n};\n\ntype CompletionContext = {\n // whether the current context allows `break` statement. When it allows, we have\n // to search all the statements for potential `break`\n canHaveBreak: boolean;\n // whether the statement is an immediate descendant of a switch case clause\n inCaseClause: boolean;\n // whether the `break` statement record should be populated to upper level\n // when a `break` statement is an immediate descendant of a block statement, e.g.\n // `{ break }`, it can influence the control flow in the upper levels.\n shouldPopulateBreak: boolean;\n};\n\nfunction NormalCompletion(path: NodePath) {\n return { type: NORMAL_COMPLETION, path };\n}\n\nfunction BreakCompletion(path: NodePath) {\n return { type: BREAK_COMPLETION, path };\n}\n\nexport function getOpposite(this: NodePath): NodePath | null {\n if (this.key === \"left\") {\n return this.getSibling(\"right\");\n } else if (this.key === \"right\") {\n return this.getSibling(\"left\");\n }\n return null;\n}\n\nfunction addCompletionRecords(\n path: NodePath | null | undefined,\n records: Completion[],\n context: CompletionContext,\n): Completion[] {\n if (path) {\n records.push(..._getCompletionRecords(path, context));\n }\n return records;\n}\n\nfunction completionRecordForSwitch(\n cases: NodePath<t.SwitchCase>[],\n records: Completion[],\n context: CompletionContext,\n): Completion[] {\n // https://tc39.es/ecma262/#sec-runtime-semantics-caseblockevaluation\n let lastNormalCompletions: Completion[] = [];\n for (let i = 0; i < cases.length; i++) {\n const casePath = cases[i];\n const caseCompletions = _getCompletionRecords(casePath, context);\n const normalCompletions = [];\n const breakCompletions = [];\n for (const c of caseCompletions) {\n if (c.type === NORMAL_COMPLETION) {\n normalCompletions.push(c);\n }\n if (c.type === BREAK_COMPLETION) {\n breakCompletions.push(c);\n }\n }\n if (normalCompletions.length) {\n lastNormalCompletions = normalCompletions;\n }\n records.push(...breakCompletions);\n }\n records.push(...lastNormalCompletions);\n return records;\n}\n\nfunction normalCompletionToBreak(completions: Completion[]) {\n completions.forEach(c => {\n c.type = BREAK_COMPLETION;\n });\n}\n\n/**\n * Determine how we should handle the break statement for break completions\n *\n * @param {Completion[]} completions\n * @param {boolean} reachable Whether the break statement is reachable after\n we mark the normal completions _before_ the given break completions as the final\n completions. For example,\n `{ 0 }; break;` is transformed to `{ return 0 }; break;`, the `break` here is unreachable\n and thus can be removed without consequences. We may in the future reserve them instead since\n we do not consistently remove unreachable statements _after_ break\n `{ var x = 0 }; break;` is transformed to `{ var x = 0 }; return void 0;`, the `break` is reachable\n because we can not wrap variable declaration under a return statement\n */\nfunction replaceBreakStatementInBreakCompletion(\n completions: Completion[],\n reachable: boolean,\n) {\n completions.forEach(c => {\n if (c.path.isBreakStatement({ label: null })) {\n if (reachable) {\n c.path.replaceWith(unaryExpression(\"void\", numericLiteral(0)));\n } else {\n c.path.remove();\n }\n }\n });\n}\n\nfunction getStatementListCompletion(\n paths: NodePath[],\n context: CompletionContext,\n): Completion[] {\n const completions = [];\n if (context.canHaveBreak) {\n let lastNormalCompletions = [];\n for (let i = 0; i < paths.length; i++) {\n const path = paths[i];\n const newContext = { ...context, inCaseClause: false };\n if (\n path.isBlockStatement() &&\n (context.inCaseClause || // case test: { break }\n context.shouldPopulateBreak) // case test: { { break } }\n ) {\n newContext.shouldPopulateBreak = true;\n } else {\n newContext.shouldPopulateBreak = false;\n }\n const statementCompletions = _getCompletionRecords(path, newContext);\n if (\n statementCompletions.length > 0 &&\n // we can stop search `paths` when we have seen a `path` that is\n // effectively a `break` statement. Examples are\n // - `break`\n // - `if (true) { 1; break } else { 2; break }`\n // - `{ break }```\n // In other words, the paths after this `path` are unreachable\n statementCompletions.every(c => c.type === BREAK_COMPLETION)\n ) {\n if (\n lastNormalCompletions.length > 0 &&\n statementCompletions.every(c =>\n c.path.isBreakStatement({ label: null }),\n )\n ) {\n // when a break completion has a path as BreakStatement, it must be `{ break }`\n // whose completion value we can not determine, otherwise it would have been\n // replaced by `replaceBreakStatementInBreakCompletion`\n // When we have seen normal completions from the last statement\n // it is safe to stop populating break and mark normal completions as break\n normalCompletionToBreak(lastNormalCompletions);\n completions.push(...lastNormalCompletions);\n // Declarations have empty completion record, however they can not be nested\n // directly in return statement, i.e. `return (var a = 1)` is invalid.\n if (lastNormalCompletions.some(c => c.path.isDeclaration())) {\n completions.push(...statementCompletions);\n replaceBreakStatementInBreakCompletion(\n statementCompletions,\n /* reachable */ true,\n );\n }\n replaceBreakStatementInBreakCompletion(\n statementCompletions,\n /* reachable */ false,\n );\n } else {\n completions.push(...statementCompletions);\n if (!context.shouldPopulateBreak) {\n replaceBreakStatementInBreakCompletion(\n statementCompletions,\n /* reachable */ true,\n );\n }\n }\n break;\n }\n if (i === paths.length - 1) {\n completions.push(...statementCompletions);\n } else {\n lastNormalCompletions = [];\n for (let i = 0; i < statementCompletions.length; i++) {\n const c = statementCompletions[i];\n if (c.type === BREAK_COMPLETION) {\n completions.push(c);\n }\n if (c.type === NORMAL_COMPLETION) {\n lastNormalCompletions.push(c);\n }\n }\n }\n }\n } else if (paths.length) {\n // When we are in a context where `break` must not exist, we can skip linear\n // search on statement lists and assume that the last\n // non-variable-declaration statement determines the completion.\n for (let i = paths.length - 1; i >= 0; i--) {\n const pathCompletions = _getCompletionRecords(paths[i], context);\n if (\n pathCompletions.length > 1 ||\n (pathCompletions.length === 1 &&\n !pathCompletions[0].path.isVariableDeclaration())\n ) {\n completions.push(...pathCompletions);\n break;\n }\n }\n }\n return completions;\n}\n\nfunction _getCompletionRecords(\n path: NodePath,\n context: CompletionContext,\n): Completion[] {\n let records: Completion[] = [];\n if (path.isIfStatement()) {\n records = addCompletionRecords(path.get(\"consequent\"), records, context);\n records = addCompletionRecords(path.get(\"alternate\"), records, context);\n } else if (\n path.isDoExpression() ||\n path.isFor() ||\n path.isWhile() ||\n path.isLabeledStatement()\n ) {\n // @ts-expect-error(flow->ts): todo\n return addCompletionRecords(path.get(\"body\"), records, context);\n } else if (path.isProgram() || path.isBlockStatement()) {\n // @ts-expect-error(flow->ts): todo\n return getStatementListCompletion(path.get(\"body\"), context);\n } else if (path.isFunction()) {\n return _getCompletionRecords(path.get(\"body\"), context);\n } else if (path.isTryStatement()) {\n records = addCompletionRecords(path.get(\"block\"), records, context);\n records = addCompletionRecords(path.get(\"handler\"), records, context);\n } else if (path.isCatchClause()) {\n return addCompletionRecords(path.get(\"body\"), records, context);\n } else if (path.isSwitchStatement()) {\n return completionRecordForSwitch(path.get(\"cases\"), records, context);\n } else if (path.isSwitchCase()) {\n return getStatementListCompletion(path.get(\"consequent\"), {\n canHaveBreak: true,\n shouldPopulateBreak: false,\n inCaseClause: true,\n });\n } else if (path.isBreakStatement()) {\n records.push(BreakCompletion(path));\n } else {\n records.push(NormalCompletion(path));\n }\n\n return records;\n}\n\n/**\n * Retrieve the completion records of a given path.\n * Note: to ensure proper support on `break` statement, this method\n * will manipulate the AST around the break statement. Do not call the method\n * twice for the same path.\n *\n * @export\n * @param {NodePath} this\n * @returns {NodePath[]} Completion records\n */\nexport function getCompletionRecords(this: NodePath): NodePath[] {\n const records = _getCompletionRecords(this, {\n canHaveBreak: false,\n shouldPopulateBreak: false,\n inCaseClause: false,\n });\n return records.map(r => r.path);\n}\n\nexport function getSibling(this: NodePath, key: string | number): NodePath {\n return NodePath.get({\n parentPath: this.parentPath,\n parent: this.parent,\n container: this.container,\n listKey: this.listKey,\n key: key,\n }).setContext(this.context);\n}\n\nexport function getPrevSibling(this: NodePath): NodePath {\n // @ts-expect-error todo(flow->ts) this.key could be a string\n return this.getSibling(this.key - 1);\n}\n\nexport function getNextSibling(this: NodePath): NodePath {\n // @ts-expect-error todo(flow->ts) this.key could be a string\n return this.getSibling(this.key + 1);\n}\n\nexport function getAllNextSiblings(this: NodePath): NodePath[] {\n // @ts-expect-error todo(flow->ts) this.key could be a string\n let _key: number = this.key;\n let sibling = this.getSibling(++_key);\n const siblings = [];\n while (sibling.node) {\n siblings.push(sibling);\n sibling = this.getSibling(++_key);\n }\n return siblings;\n}\n\nexport function getAllPrevSiblings(this: NodePath): NodePath[] {\n // @ts-expect-error todo(flow->ts) this.key could be a string\n let _key: number = this.key;\n let sibling = this.getSibling(--_key);\n const siblings = [];\n while (sibling.node) {\n siblings.push(sibling);\n sibling = this.getSibling(--_key);\n }\n return siblings;\n}\n\n// convert \"1\" to 1 (string index to number index)\ntype MaybeToIndex<T extends string> = T extends `${bigint}` ? number : T;\n\ntype Pattern<Obj extends string, Prop extends string> = `${Obj}.${Prop}`;\n\n// split \"body.body.1\" to [\"body\", \"body\", 1]\ntype Split<P extends string> = P extends Pattern<infer O, infer U>\n ? [MaybeToIndex<O>, ...Split<U>]\n : [MaybeToIndex<P>];\n\n// get all K with Node[K] is t.Node | t.Node[]\ntype NodeKeyOf<Node extends t.Node | t.Node[]> = keyof Pick<\n Node,\n {\n [Key in keyof Node]-?: Node[Key] extends t.Node | t.Node[] ? Key : never;\n }[keyof Node]\n>;\n\n// traverse the Node with tuple path [\"body\", \"body\", 1]\n// Path should be created with Split\ntype Trav<\n Node extends t.Node | t.Node[],\n Path extends unknown[],\n> = Path extends [infer K, ...infer R]\n ? K extends NodeKeyOf<Node>\n ? R extends []\n ? Node[K]\n : // @ts-expect-error ignore since TS is not smart enough\n Trav<Node[K], R>\n : never\n : never;\n\ntype ToNodePath<T> = T extends Array<t.Node | null | undefined>\n ? Array<NodePath<T[number]>>\n : T extends t.Node | null | undefined\n ? NodePath<T>\n : never;\n\nfunction get<T extends t.Node, K extends keyof T>(\n this: NodePath<T>,\n key: K,\n context?: boolean | TraversalContext,\n): T[K] extends Array<t.Node | null | undefined>\n ? Array<NodePath<T[K][number]>>\n : T[K] extends t.Node | null | undefined\n ? NodePath<T[K]>\n : never;\n\nfunction get<T extends t.Node, K extends string>(\n this: NodePath<T>,\n key: K,\n context?: boolean | TraversalContext,\n): ToNodePath<Trav<T, Split<K>>>;\n\nfunction get<T extends t.Node>(\n this: NodePath<T>,\n key: string,\n context?: true | TraversalContext,\n): NodePath | NodePath[];\n\nfunction get<T extends t.Node>(\n this: NodePath<T>,\n key: string,\n context: true | TraversalContext = true,\n): NodePath | NodePath[] {\n if (context === true) context = this.context;\n const parts = key.split(\".\");\n if (parts.length === 1) {\n // \"foo\"\n // @ts-expect-error key may not index T\n return this._getKey(key, context);\n } else {\n // \"foo.bar\"\n return this._getPattern(parts, context);\n }\n}\n\nexport { get };\n\nexport function _getKey<T extends t.Node>(\n this: NodePath<T>,\n key: keyof T & string,\n context?: TraversalContext,\n): NodePath | NodePath[] {\n const node = this.node;\n const container = node[key];\n\n if (Array.isArray(container)) {\n // requested a container so give them all the paths\n return container.map((_, i) => {\n return NodePath.get({\n listKey: key,\n parentPath: this,\n parent: node,\n container: container,\n key: i,\n }).setContext(context);\n });\n } else {\n return NodePath.get({\n parentPath: this,\n parent: node,\n container: node,\n key: key,\n }).setContext(context);\n }\n}\n\nexport function _getPattern(\n this: NodePath,\n parts: string[],\n context?: TraversalContext,\n): NodePath | NodePath[] {\n let path: NodePath | NodePath[] = this;\n for (const part of parts) {\n if (part === \".\") {\n // @ts-expect-error todo(flow-ts): Can path be an array here?\n path = path.parentPath;\n } else {\n if (Array.isArray(path)) {\n // @ts-expect-error part may not index path\n path = path[part];\n } else {\n path = path.get(part, context);\n }\n }\n }\n return path;\n}\n\nfunction getBindingIdentifiers(\n duplicates: true,\n): Record<string, t.Identifier[]>;\nfunction getBindingIdentifiers(\n duplicates?: false,\n): Record<string, t.Identifier>;\nfunction getBindingIdentifiers(\n duplicates: boolean,\n): Record<string, t.Identifier[] | t.Identifier>;\n\nfunction getBindingIdentifiers(\n this: NodePath,\n duplicates?: boolean,\n): Record<string, t.Identifier[] | t.Identifier> {\n return _getBindingIdentifiers(this.node, duplicates);\n}\n\nexport { getBindingIdentifiers };\n\nfunction getOuterBindingIdentifiers(\n duplicates: true,\n): Record<string, t.Identifier[]>;\nfunction getOuterBindingIdentifiers(\n duplicates?: false,\n): Record<string, t.Identifier>;\nfunction getOuterBindingIdentifiers(\n duplicates: boolean,\n): Record<string, t.Identifier[] | t.Identifier>;\n\nfunction getOuterBindingIdentifiers(\n this: NodePath,\n duplicates?: boolean,\n): Record<string, t.Identifier[] | t.Identifier> {\n return _getOuterBindingIdentifiers(this.node, duplicates);\n}\n\nexport { getOuterBindingIdentifiers };\n\nfunction getBindingIdentifierPaths(\n duplicates: true,\n outerOnly?: boolean,\n): Record<string, NodePath<t.Identifier>[]>;\nfunction getBindingIdentifierPaths(\n duplicates: false,\n outerOnly?: boolean,\n): Record<string, NodePath<t.Identifier>>;\nfunction getBindingIdentifierPaths(\n duplicates?: boolean,\n outerOnly?: boolean,\n): Record<string, NodePath<t.Identifier> | NodePath<t.Identifier>[]>;\n\n// original source - https://github.com/babel/babel/blob/main/packages/babel-types/src/retrievers/getBindingIdentifiers.js\n// path.getBindingIdentifiers returns nodes where the following re-implementation returns paths\nfunction getBindingIdentifierPaths(\n this: NodePath,\n duplicates: boolean = false,\n outerOnly: boolean = false,\n): Record<string, NodePath<t.Identifier> | NodePath<t.Identifier>[]> {\n const path = this;\n const search = [path];\n const ids = Object.create(null);\n\n while (search.length) {\n const id = search.shift();\n if (!id) continue;\n if (!id.node) continue;\n\n const keys =\n // @ts-expect-error _getBindingIdentifiers.keys do not cover all node types\n _getBindingIdentifiers.keys[id.node.type];\n\n if (id.isIdentifier()) {\n if (duplicates) {\n const _ids = (ids[id.node.name] = ids[id.node.name] || []);\n _ids.push(id);\n } else {\n ids[id.node.name] = id;\n }\n continue;\n }\n\n if (id.isExportDeclaration()) {\n const declaration = id.get(\"declaration\");\n if (isDeclaration(declaration)) {\n search.push(declaration);\n }\n continue;\n }\n\n if (outerOnly) {\n if (id.isFunctionDeclaration()) {\n search.push(id.get(\"id\"));\n continue;\n }\n if (id.isFunctionExpression()) {\n continue;\n }\n }\n\n if (keys) {\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const child = id.get(key);\n if (Array.isArray(child)) {\n search.push(...child);\n } else if (child.node) {\n search.push(child);\n }\n }\n }\n }\n\n return ids;\n}\n\nexport { getBindingIdentifierPaths };\n\nfunction getOuterBindingIdentifierPaths(\n duplicates: true,\n): Record<string, NodePath<t.Identifier>[]>;\nfunction getOuterBindingIdentifierPaths(\n duplicates?: false,\n): Record<string, NodePath<t.Identifier>>;\nfunction getOuterBindingIdentifierPaths(\n duplicates?: boolean,\n): Record<string, NodePath<t.Identifier> | NodePath<t.Identifier>[]>;\n\nfunction getOuterBindingIdentifierPaths(\n this: NodePath,\n duplicates: boolean = false,\n) {\n return this.getBindingIdentifierPaths(duplicates, true);\n}\n\nexport { getOuterBindingIdentifierPaths };\n"],"m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