@babel/traverse 8.0.0-beta.3 → 8.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +997 -762
- package/lib/index.js +216 -369
- package/lib/index.js.map +1 -1
- package/package.json +10 -10
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createDebug } from 'obug';
|
|
2
2
|
import { codeFrameColumns } from '@babel/code-frame';
|
|
3
3
|
import * as _t from '@babel/types';
|
|
4
4
|
import { parse } from '@babel/parser';
|
|
@@ -48,6 +48,134 @@ var virtualTypes = /*#__PURE__*/Object.freeze({
|
|
|
48
48
|
Var: Var
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
+
class TraversalContext {
|
|
52
|
+
constructor(opts, state) {
|
|
53
|
+
this.state = state;
|
|
54
|
+
this.opts = opts;
|
|
55
|
+
}
|
|
56
|
+
queue = null;
|
|
57
|
+
priorityQueue = null;
|
|
58
|
+
maybeQueue(path, notPriority) {
|
|
59
|
+
if (this.queue) {
|
|
60
|
+
if (notPriority) {
|
|
61
|
+
this.queue.push(path);
|
|
62
|
+
} else {
|
|
63
|
+
this.priorityQueue.push(path);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const {
|
|
70
|
+
VISITOR_KEYS: VISITOR_KEYS$4
|
|
71
|
+
} = _t;
|
|
72
|
+
function _visitPaths(ctx, paths) {
|
|
73
|
+
ctx.queue = paths;
|
|
74
|
+
ctx.priorityQueue = [];
|
|
75
|
+
const visited = new Set();
|
|
76
|
+
let stop = false;
|
|
77
|
+
let visitIndex = 0;
|
|
78
|
+
for (; visitIndex < paths.length;) {
|
|
79
|
+
const path = paths[visitIndex];
|
|
80
|
+
visitIndex++;
|
|
81
|
+
resync.call(path);
|
|
82
|
+
if (path.contexts.length === 0 || path.contexts[path.contexts.length - 1] !== ctx) {
|
|
83
|
+
pushContext.call(path, ctx);
|
|
84
|
+
}
|
|
85
|
+
if (path.key === null) continue;
|
|
86
|
+
const {
|
|
87
|
+
node
|
|
88
|
+
} = path;
|
|
89
|
+
if (visited.has(node)) continue;
|
|
90
|
+
if (node) visited.add(node);
|
|
91
|
+
if (_visit(ctx, path)) {
|
|
92
|
+
stop = true;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (ctx.priorityQueue.length) {
|
|
96
|
+
stop = _visitPaths(ctx, ctx.priorityQueue);
|
|
97
|
+
ctx.priorityQueue = [];
|
|
98
|
+
ctx.queue = paths;
|
|
99
|
+
if (stop) break;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
for (let i = 0; i < visitIndex; i++) {
|
|
103
|
+
popContext.call(paths[i]);
|
|
104
|
+
}
|
|
105
|
+
ctx.queue = null;
|
|
106
|
+
return stop;
|
|
107
|
+
}
|
|
108
|
+
function _visit(ctx, path) {
|
|
109
|
+
const node = path.node;
|
|
110
|
+
if (!node) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
const opts = ctx.opts;
|
|
114
|
+
const denylist = opts.denylist;
|
|
115
|
+
if (denylist?.includes(node.type)) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
if (opts.shouldSkip?.(path)) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
if (path.shouldSkip) return path.shouldStop;
|
|
122
|
+
if (_call.call(path, opts.enter)) return path.shouldStop;
|
|
123
|
+
if (path.node) {
|
|
124
|
+
if (_call.call(path, opts[node.type]?.enter)) return path.shouldStop;
|
|
125
|
+
}
|
|
126
|
+
path.shouldStop = traverseNode(path.node, opts, path.scope, ctx.state, path, path.skipKeys);
|
|
127
|
+
if (path.node) {
|
|
128
|
+
if (_call.call(path, opts.exit)) return true;
|
|
129
|
+
}
|
|
130
|
+
if (path.node) {
|
|
131
|
+
_call.call(path, opts[node.type]?.exit);
|
|
132
|
+
}
|
|
133
|
+
return path.shouldStop;
|
|
134
|
+
}
|
|
135
|
+
function traverseNode(node, opts, scope, state, path, skipKeys, visitSelf) {
|
|
136
|
+
const keys = VISITOR_KEYS$4[node.type];
|
|
137
|
+
if (!keys?.length) return false;
|
|
138
|
+
const ctx = new TraversalContext(opts, state);
|
|
139
|
+
if (visitSelf) {
|
|
140
|
+
if (skipKeys?.[path.parentKey]) return false;
|
|
141
|
+
return _visitPaths(ctx, [path]);
|
|
142
|
+
}
|
|
143
|
+
const hub = path == null ? node.type === "Program" || node.type === "File" ? new Hub() : undefined : path.hub;
|
|
144
|
+
for (const key of keys) {
|
|
145
|
+
if (skipKeys?.[key]) continue;
|
|
146
|
+
const prop = node[key];
|
|
147
|
+
if (!prop) continue;
|
|
148
|
+
if (Array.isArray(prop)) {
|
|
149
|
+
if (!prop.length) continue;
|
|
150
|
+
const paths = [];
|
|
151
|
+
for (let i = 0; i < prop.length; i++) {
|
|
152
|
+
const childPath = NodePath_Final.get({
|
|
153
|
+
parentPath: path,
|
|
154
|
+
parent: node,
|
|
155
|
+
container: prop,
|
|
156
|
+
key: i,
|
|
157
|
+
listKey: key,
|
|
158
|
+
hub
|
|
159
|
+
});
|
|
160
|
+
paths.push(childPath);
|
|
161
|
+
}
|
|
162
|
+
if (_visitPaths(ctx, paths)) return true;
|
|
163
|
+
} else {
|
|
164
|
+
if (_visitPaths(ctx, [NodePath_Final.get({
|
|
165
|
+
parentPath: path,
|
|
166
|
+
parent: node,
|
|
167
|
+
container: node,
|
|
168
|
+
key,
|
|
169
|
+
listKey: null,
|
|
170
|
+
hub
|
|
171
|
+
})])) {
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
|
|
51
179
|
const {
|
|
52
180
|
isBinding,
|
|
53
181
|
isBlockScoped: nodeIsBlockScoped,
|
|
@@ -266,7 +394,9 @@ function explode$1(visitor) {
|
|
|
266
394
|
if (existing) {
|
|
267
395
|
mergePair(existing, fns);
|
|
268
396
|
} else {
|
|
269
|
-
visitor[alias] =
|
|
397
|
+
visitor[alias] = {
|
|
398
|
+
...fns
|
|
399
|
+
};
|
|
270
400
|
}
|
|
271
401
|
}
|
|
272
402
|
}
|
|
@@ -287,7 +417,7 @@ function verify$1(visitor) {
|
|
|
287
417
|
}
|
|
288
418
|
if (shouldIgnoreKey(nodeType)) continue;
|
|
289
419
|
if (!TYPES.includes(nodeType)) {
|
|
290
|
-
throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type in @babel/traverse ${"8.0.0-
|
|
420
|
+
throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type in @babel/traverse ${"8.0.0-rc.1"}`);
|
|
291
421
|
}
|
|
292
422
|
const visitors = visitor[nodeType];
|
|
293
423
|
if (typeof visitors === "object") {
|
|
@@ -386,7 +516,7 @@ function wrapCheck(nodeType, fn) {
|
|
|
386
516
|
return newFn;
|
|
387
517
|
}
|
|
388
518
|
function shouldIgnoreKey(key) {
|
|
389
|
-
if (key
|
|
519
|
+
if (key.startsWith("_")) return true;
|
|
390
520
|
if (key === "enter" || key === "exit" || key === "shouldSkip") return true;
|
|
391
521
|
if (key === "denylist" || key === "noScope" || key === "skipKeys") {
|
|
392
522
|
return true;
|
|
@@ -404,17 +534,13 @@ const _environmentVisitor = {
|
|
|
404
534
|
if (path.isArrowFunctionExpression()) return;
|
|
405
535
|
path.skip();
|
|
406
536
|
if (path.isMethod()) {
|
|
407
|
-
|
|
408
|
-
path.requeueComputedKeyAndDecorators();
|
|
409
|
-
}
|
|
537
|
+
path.requeueComputedKeyAndDecorators();
|
|
410
538
|
}
|
|
411
539
|
},
|
|
412
540
|
Property(path) {
|
|
413
541
|
if (path.isObjectProperty()) return;
|
|
414
542
|
path.skip();
|
|
415
|
-
|
|
416
|
-
path.requeueComputedKeyAndDecorators();
|
|
417
|
-
}
|
|
543
|
+
path.requeueComputedKeyAndDecorators();
|
|
418
544
|
}
|
|
419
545
|
};
|
|
420
546
|
function environmentVisitor(visitor) {
|
|
@@ -445,9 +571,10 @@ const renameVisitor = {
|
|
|
445
571
|
if (!path.scope.bindingIdentifierEquals(state.oldName, state.binding.identifier)) {
|
|
446
572
|
path.skip();
|
|
447
573
|
if (path.isMethod()) {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
574
|
+
path.requeueComputedKeyAndDecorators();
|
|
575
|
+
}
|
|
576
|
+
if (path.isSwitchStatement()) {
|
|
577
|
+
path.context.maybeQueue(path.get("discriminant"));
|
|
451
578
|
}
|
|
452
579
|
}
|
|
453
580
|
},
|
|
@@ -530,11 +657,9 @@ class Renamer {
|
|
|
530
657
|
}
|
|
531
658
|
}
|
|
532
659
|
traverseNode(blockToTraverse, explode$1(renameVisitor), scope, this, scope.path, skipKeys);
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
this.binding.identifier.name = newName;
|
|
537
|
-
}
|
|
660
|
+
scope.removeOwnBinding(oldName);
|
|
661
|
+
scope.bindings[newName] = binding;
|
|
662
|
+
this.binding.identifier.name = newName;
|
|
538
663
|
if (parentDeclar) {
|
|
539
664
|
this.maybeConvertFromClassFunctionDeclaration(path);
|
|
540
665
|
this.maybeConvertFromClassFunctionExpression(path);
|
|
@@ -543,7 +668,7 @@ class Renamer {
|
|
|
543
668
|
}
|
|
544
669
|
|
|
545
670
|
const {
|
|
546
|
-
VISITOR_KEYS: VISITOR_KEYS$
|
|
671
|
+
VISITOR_KEYS: VISITOR_KEYS$3
|
|
547
672
|
} = _t;
|
|
548
673
|
function traverseForScope(path, visitors, state) {
|
|
549
674
|
const exploded = explode$1(visitors);
|
|
@@ -563,24 +688,17 @@ function traverseForScope(path, visitors, state) {
|
|
|
563
688
|
listKey,
|
|
564
689
|
key
|
|
565
690
|
});
|
|
566
|
-
|
|
691
|
+
_forceSetScope.call(path);
|
|
567
692
|
const visitor = exploded[node.type];
|
|
568
|
-
if (visitor) {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
visit.call(state, path, state);
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
if (visitor.exit) {
|
|
575
|
-
for (const visit of visitor.exit) {
|
|
576
|
-
visit.call(state, path, state);
|
|
577
|
-
}
|
|
693
|
+
if (visitor?.enter) {
|
|
694
|
+
for (const visit of visitor.enter) {
|
|
695
|
+
visit.call(state, path, state);
|
|
578
696
|
}
|
|
579
697
|
}
|
|
580
698
|
if (path.shouldSkip) {
|
|
581
699
|
return;
|
|
582
700
|
}
|
|
583
|
-
const keys = VISITOR_KEYS$
|
|
701
|
+
const keys = VISITOR_KEYS$3[node.type];
|
|
584
702
|
if (!keys?.length) {
|
|
585
703
|
return;
|
|
586
704
|
}
|
|
@@ -596,6 +714,11 @@ function traverseForScope(path, visitors, state) {
|
|
|
596
714
|
_traverse(path, node, prop, node, key, null);
|
|
597
715
|
}
|
|
598
716
|
}
|
|
717
|
+
if (visitor?.exit) {
|
|
718
|
+
for (const visit of visitor.exit) {
|
|
719
|
+
visit.call(state, path, state);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
599
722
|
}
|
|
600
723
|
}
|
|
601
724
|
|
|
@@ -716,7 +839,6 @@ var cache = /*#__PURE__*/Object.freeze({
|
|
|
716
839
|
|
|
717
840
|
const {
|
|
718
841
|
assignmentExpression: assignmentExpression$3,
|
|
719
|
-
callExpression: callExpression$3,
|
|
720
842
|
cloneNode: cloneNode$3,
|
|
721
843
|
getBindingIdentifiers: getBindingIdentifiers$2,
|
|
722
844
|
identifier: identifier$3,
|
|
@@ -749,13 +871,9 @@ const {
|
|
|
749
871
|
isVariableDeclaration: isVariableDeclaration$1,
|
|
750
872
|
expressionStatement: expressionStatement$3,
|
|
751
873
|
matchesPattern: matchesPattern$1,
|
|
752
|
-
memberExpression: memberExpression$1,
|
|
753
|
-
numericLiteral: numericLiteral$2,
|
|
754
874
|
toIdentifier,
|
|
755
875
|
variableDeclaration: variableDeclaration$1,
|
|
756
876
|
variableDeclarator: variableDeclarator$1,
|
|
757
|
-
isRecordExpression,
|
|
758
|
-
isTupleExpression,
|
|
759
877
|
isObjectProperty,
|
|
760
878
|
isTopicReference,
|
|
761
879
|
isMetaProperty,
|
|
@@ -1072,10 +1190,8 @@ class Scope {
|
|
|
1072
1190
|
i++;
|
|
1073
1191
|
} while (this.hasLabel(uid) || this.hasBinding(uid) || this.hasGlobal(uid) || this.hasReference(uid));
|
|
1074
1192
|
const program = this.getProgramParent();
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
program.uidsSet.add(uid);
|
|
1078
|
-
}
|
|
1193
|
+
program.referencesSet.add(uid);
|
|
1194
|
+
program.uidsSet.add(uid);
|
|
1079
1195
|
return uid;
|
|
1080
1196
|
}
|
|
1081
1197
|
generateUidBasedOnNode(node, defaultName) {
|
|
@@ -1129,9 +1245,7 @@ class Scope {
|
|
|
1129
1245
|
if (binding) {
|
|
1130
1246
|
newName ||= this.generateUidIdentifier(oldName).name;
|
|
1131
1247
|
const renamer = new Renamer(binding, oldName, newName);
|
|
1132
|
-
|
|
1133
|
-
renamer.rename();
|
|
1134
|
-
}
|
|
1248
|
+
renamer.rename();
|
|
1135
1249
|
}
|
|
1136
1250
|
}
|
|
1137
1251
|
dump() {
|
|
@@ -1214,9 +1328,7 @@ class Scope {
|
|
|
1214
1328
|
const parent = this.getProgramParent();
|
|
1215
1329
|
const ids = path.getOuterBindingIdentifiers(true);
|
|
1216
1330
|
for (const name of Object.keys(ids)) {
|
|
1217
|
-
|
|
1218
|
-
parent.referencesSet.add(name);
|
|
1219
|
-
}
|
|
1331
|
+
parent.referencesSet.add(name);
|
|
1220
1332
|
for (const id of ids[name]) {
|
|
1221
1333
|
const local = this.getOwnBinding(name);
|
|
1222
1334
|
if (local) {
|
|
@@ -1240,9 +1352,7 @@ class Scope {
|
|
|
1240
1352
|
this.globals[node.name] = node;
|
|
1241
1353
|
}
|
|
1242
1354
|
hasUid(name) {
|
|
1243
|
-
|
|
1244
|
-
return this.getProgramParent().uidsSet.has(name);
|
|
1245
|
-
}
|
|
1355
|
+
return this.getProgramParent().uidsSet.has(name);
|
|
1246
1356
|
}
|
|
1247
1357
|
hasGlobal(name) {
|
|
1248
1358
|
let scope = this;
|
|
@@ -1252,9 +1362,7 @@ class Scope {
|
|
|
1252
1362
|
return false;
|
|
1253
1363
|
}
|
|
1254
1364
|
hasReference(name) {
|
|
1255
|
-
|
|
1256
|
-
return this.getProgramParent().referencesSet.has(name);
|
|
1257
|
-
}
|
|
1365
|
+
return this.getProgramParent().referencesSet.has(name);
|
|
1258
1366
|
}
|
|
1259
1367
|
isPure(node, constantsOnly) {
|
|
1260
1368
|
if (isIdentifier$5(node)) {
|
|
@@ -1279,12 +1387,12 @@ class Scope {
|
|
|
1279
1387
|
return true;
|
|
1280
1388
|
} else if (isBinary(node)) {
|
|
1281
1389
|
return this.isPure(node.left, constantsOnly) && this.isPure(node.right, constantsOnly);
|
|
1282
|
-
} else if (isArrayExpression(node)
|
|
1390
|
+
} else if (isArrayExpression(node)) {
|
|
1283
1391
|
for (const elem of node.elements) {
|
|
1284
1392
|
if (elem !== null && !this.isPure(elem, constantsOnly)) return false;
|
|
1285
1393
|
}
|
|
1286
1394
|
return true;
|
|
1287
|
-
} else if (isObjectExpression(node)
|
|
1395
|
+
} else if (isObjectExpression(node)) {
|
|
1288
1396
|
for (const prop of node.properties) {
|
|
1289
1397
|
if (!this.isPure(prop, constantsOnly)) return false;
|
|
1290
1398
|
}
|
|
@@ -1354,9 +1462,6 @@ class Scope {
|
|
|
1354
1462
|
}
|
|
1355
1463
|
crawl() {
|
|
1356
1464
|
const path = this.path;
|
|
1357
|
-
if (path.opts?.noScope) {
|
|
1358
|
-
return;
|
|
1359
|
-
}
|
|
1360
1465
|
resetScope(this);
|
|
1361
1466
|
this.data = Object.create(null);
|
|
1362
1467
|
let scope = this;
|
|
@@ -1386,9 +1491,7 @@ class Scope {
|
|
|
1386
1491
|
}
|
|
1387
1492
|
}
|
|
1388
1493
|
}
|
|
1389
|
-
|
|
1390
|
-
traverseForScope(path, scopeVisitor, state);
|
|
1391
|
-
}
|
|
1494
|
+
traverseForScope(path, scopeVisitor, state);
|
|
1392
1495
|
this.crawling = false;
|
|
1393
1496
|
for (const path of state.assignments) {
|
|
1394
1497
|
const ids = path.getAssignmentIdentifiers();
|
|
@@ -1572,9 +1675,7 @@ class Scope {
|
|
|
1572
1675
|
}
|
|
1573
1676
|
removeBinding(name) {
|
|
1574
1677
|
this.getBinding(name)?.scope.removeOwnBinding(name);
|
|
1575
|
-
|
|
1576
|
-
this.getProgramParent().uidsSet.delete(name);
|
|
1577
|
-
}
|
|
1678
|
+
this.getProgramParent().uidsSet.delete(name);
|
|
1578
1679
|
}
|
|
1579
1680
|
hoistVariables(emit = id => this.push({
|
|
1580
1681
|
id
|
|
@@ -1627,7 +1728,7 @@ class Scope {
|
|
|
1627
1728
|
}
|
|
1628
1729
|
|
|
1629
1730
|
const {
|
|
1630
|
-
VISITOR_KEYS: VISITOR_KEYS$
|
|
1731
|
+
VISITOR_KEYS: VISITOR_KEYS$2
|
|
1631
1732
|
} = _t;
|
|
1632
1733
|
function findParent(callback) {
|
|
1633
1734
|
let path = this;
|
|
@@ -1663,7 +1764,7 @@ function getStatementParent() {
|
|
|
1663
1764
|
function getEarliestCommonAncestorFrom(paths) {
|
|
1664
1765
|
return this.getDeepestCommonAncestorFrom(paths, function (deepest, i, ancestries) {
|
|
1665
1766
|
let earliest;
|
|
1666
|
-
const keys = VISITOR_KEYS$
|
|
1767
|
+
const keys = VISITOR_KEYS$2[deepest.type];
|
|
1667
1768
|
for (const ancestry of ancestries) {
|
|
1668
1769
|
const path = ancestry[i + 1];
|
|
1669
1770
|
if (!earliest) {
|
|
@@ -1751,18 +1852,15 @@ function inType(...candidateTypes) {
|
|
|
1751
1852
|
const {
|
|
1752
1853
|
createFlowUnionType,
|
|
1753
1854
|
createTSUnionType,
|
|
1754
|
-
createUnionTypeAnnotation,
|
|
1755
1855
|
isFlowType,
|
|
1756
1856
|
isTSType
|
|
1757
1857
|
} = _t;
|
|
1758
1858
|
function createUnionType(types) {
|
|
1759
|
-
{
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
return createTSUnionType(types);
|
|
1765
|
-
}
|
|
1859
|
+
if (types.every(v => isFlowType(v))) {
|
|
1860
|
+
return createFlowUnionType(types);
|
|
1861
|
+
}
|
|
1862
|
+
if (types.every(v => isTSType(v))) {
|
|
1863
|
+
return createTSUnionType(types);
|
|
1766
1864
|
}
|
|
1767
1865
|
}
|
|
1768
1866
|
|
|
@@ -2688,8 +2786,8 @@ function replaceExpressionWithStatements(nodes) {
|
|
|
2688
2786
|
}
|
|
2689
2787
|
callee.arrowFunctionToExpression();
|
|
2690
2788
|
const newCallee = callee;
|
|
2691
|
-
const needToAwaitFunction = isParentAsync && traverse.hasType(
|
|
2692
|
-
const needToYieldFunction = isParentGenerator && traverse.hasType(
|
|
2789
|
+
const needToAwaitFunction = isParentAsync && traverse.hasType(newCallee.node.body, "AwaitExpression", FUNCTION_TYPES);
|
|
2790
|
+
const needToYieldFunction = isParentGenerator && traverse.hasType(newCallee.node.body, "YieldExpression", FUNCTION_TYPES);
|
|
2693
2791
|
if (needToAwaitFunction) {
|
|
2694
2792
|
newCallee.set("async", true);
|
|
2695
2793
|
if (!needToYieldFunction) {
|
|
@@ -2909,14 +3007,19 @@ function _evaluate(path, state) {
|
|
|
2909
3007
|
deopt(binding.path, state);
|
|
2910
3008
|
return;
|
|
2911
3009
|
}
|
|
2912
|
-
|
|
2913
|
-
if (resolved === path) {
|
|
3010
|
+
if (!binding) {
|
|
2914
3011
|
deopt(path, state);
|
|
2915
3012
|
return;
|
|
2916
3013
|
}
|
|
2917
|
-
const
|
|
3014
|
+
const bindingPath = binding.path;
|
|
3015
|
+
if (!bindingPath.isVariableDeclarator()) {
|
|
3016
|
+
deopt(bindingPath, state);
|
|
3017
|
+
return;
|
|
3018
|
+
}
|
|
3019
|
+
const initPath = bindingPath.get("init");
|
|
3020
|
+
const value = evaluateCached(initPath, state);
|
|
2918
3021
|
if (typeof value === "object" && value !== null && binding.references > 1) {
|
|
2919
|
-
deopt(
|
|
3022
|
+
deopt(initPath, state);
|
|
2920
3023
|
return;
|
|
2921
3024
|
}
|
|
2922
3025
|
return value;
|
|
@@ -3073,7 +3176,7 @@ function _evaluate(path, state) {
|
|
|
3073
3176
|
if (callee.isMemberExpression()) {
|
|
3074
3177
|
const object = callee.get("object");
|
|
3075
3178
|
const property = callee.get("property");
|
|
3076
|
-
if (object.isIdentifier() && property.isIdentifier() && isValidObjectCallee(object.node.name) && !isInvalidMethod(property.node.name)) {
|
|
3179
|
+
if (object.isIdentifier() && property.isIdentifier() && isValidObjectCallee(object.node.name) && !isInvalidMethod(property.node.name) && !path.scope.getBinding(object.node.name)) {
|
|
3077
3180
|
context = global[object.node.name];
|
|
3078
3181
|
const key = property.node.name;
|
|
3079
3182
|
if (Object.hasOwn(context, key)) {
|
|
@@ -3247,8 +3350,7 @@ function arrowFunctionToExpression({
|
|
|
3247
3350
|
});
|
|
3248
3351
|
}
|
|
3249
3352
|
fn.get("body").unshiftContainer("body", expressionStatement(callExpression(this.hub.addHelper("newArrowCheck"), [thisExpression(), checkBinding ? identifier(checkBinding.name) : identifier(thisBinding)])));
|
|
3250
|
-
fn.replaceWith(callExpression(memberExpression(fn.node, identifier("bind")), [checkBinding ? identifier(checkBinding.name) : thisExpression()]));
|
|
3251
|
-
return fn.get("callee.object");
|
|
3353
|
+
return fn.replaceWith(callExpression(memberExpression(fn.node, identifier("bind")), [checkBinding ? identifier(checkBinding.name) : thisExpression()]))[0].get("callee.object");
|
|
3252
3354
|
}
|
|
3253
3355
|
return fn;
|
|
3254
3356
|
}
|
|
@@ -3280,8 +3382,7 @@ function hoistFunctionEnvironment(fnPath, noNewArrows = true, allowInsertArrow =
|
|
|
3280
3382
|
if (arrowParent) {
|
|
3281
3383
|
thisEnvFn = arrowParent;
|
|
3282
3384
|
} else if (allowInsertArrow) {
|
|
3283
|
-
fnPath.replaceWith(callExpression(arrowFunctionExpression([], toExpression(fnPath.node)), []));
|
|
3284
|
-
thisEnvFn = fnPath.get("callee");
|
|
3385
|
+
thisEnvFn = fnPath.replaceWith(callExpression(arrowFunctionExpression([], toExpression(fnPath.node)), []))[0].get("callee");
|
|
3285
3386
|
fnPath = thisEnvFn.get("body");
|
|
3286
3387
|
} else {
|
|
3287
3388
|
throw fnPath.buildCodeFrameError("Unable to transform arrow inside class property");
|
|
@@ -3369,8 +3470,7 @@ function hoistFunctionEnvironment(fnPath, noNewArrows = true, allowInsertArrow =
|
|
|
3369
3470
|
} else if (isAssignment) {
|
|
3370
3471
|
superParentPath.replaceWith(call);
|
|
3371
3472
|
} else if (isTaggedTemplate) {
|
|
3372
|
-
superProp.replaceWith(callExpression(memberExpression(call, identifier("bind"), false), [thisExpression()]));
|
|
3373
|
-
thisPaths.push(superProp.get("arguments.0"));
|
|
3473
|
+
thisPaths.push(superProp.replaceWith(callExpression(memberExpression(call, identifier("bind"), false), [thisExpression()]))[0].get("arguments.0"));
|
|
3374
3474
|
} else {
|
|
3375
3475
|
superProp.replaceWith(call);
|
|
3376
3476
|
}
|
|
@@ -3430,9 +3530,9 @@ function standardizeSuperProperty(superProp) {
|
|
|
3430
3530
|
if (!superProp.parentPath.node.prefix) {
|
|
3431
3531
|
parts.push(identifier(tmp.name));
|
|
3432
3532
|
}
|
|
3433
|
-
updateExpr.replaceWith(sequenceExpression(parts));
|
|
3434
|
-
const left =
|
|
3435
|
-
const right =
|
|
3533
|
+
const sequenceExpr = updateExpr.replaceWith(sequenceExpression(parts))[0];
|
|
3534
|
+
const left = sequenceExpr.get("expressions.0.right");
|
|
3535
|
+
const right = sequenceExpr.get("expressions.1.left");
|
|
3436
3536
|
return [left, right];
|
|
3437
3537
|
}
|
|
3438
3538
|
return [superProp];
|
|
@@ -3676,17 +3776,13 @@ function ensureFunctionName(supportUnicodeId) {
|
|
|
3676
3776
|
}
|
|
3677
3777
|
if (!state.needsRename) {
|
|
3678
3778
|
this.node.id = id;
|
|
3679
|
-
|
|
3680
|
-
scope.getProgramParent().referencesSet.add(id.name);
|
|
3681
|
-
}
|
|
3779
|
+
scope.getProgramParent().referencesSet.add(id.name);
|
|
3682
3780
|
return this;
|
|
3683
3781
|
}
|
|
3684
3782
|
if (scope.hasBinding(id.name) && !scope.hasGlobal(id.name)) {
|
|
3685
3783
|
scope.rename(id.name);
|
|
3686
3784
|
this.node.id = id;
|
|
3687
|
-
|
|
3688
|
-
scope.getProgramParent().referencesSet.add(id.name);
|
|
3689
|
-
}
|
|
3785
|
+
scope.getProgramParent().referencesSet.add(id.name);
|
|
3690
3786
|
return this;
|
|
3691
3787
|
}
|
|
3692
3788
|
if (!isFunction(this.node)) return null;
|
|
@@ -3717,7 +3813,7 @@ function getFunctionArity(node) {
|
|
|
3717
3813
|
|
|
3718
3814
|
const {
|
|
3719
3815
|
STATEMENT_OR_BLOCK_KEYS,
|
|
3720
|
-
VISITOR_KEYS: VISITOR_KEYS$
|
|
3816
|
+
VISITOR_KEYS: VISITOR_KEYS$1,
|
|
3721
3817
|
isBlockStatement,
|
|
3722
3818
|
isExpression,
|
|
3723
3819
|
isIdentifier,
|
|
@@ -3785,7 +3881,7 @@ function referencesImport(moduleSource, importName) {
|
|
|
3785
3881
|
return false;
|
|
3786
3882
|
}
|
|
3787
3883
|
const binding = this.scope.getBinding(this.node.name);
|
|
3788
|
-
if (
|
|
3884
|
+
if (binding?.kind !== "module") return false;
|
|
3789
3885
|
const path = binding.path;
|
|
3790
3886
|
const parent = path.parentPath;
|
|
3791
3887
|
if (!parent.isImportDeclaration()) return false;
|
|
@@ -3903,7 +3999,7 @@ function _guessExecutionStatusRelativeToCached(base, target, cache) {
|
|
|
3903
3999
|
if (divergence.target.listKey && divergence.this.listKey && divergence.target.container === divergence.this.container) {
|
|
3904
4000
|
return divergence.target.key > divergence.this.key ? "before" : "after";
|
|
3905
4001
|
}
|
|
3906
|
-
const keys = VISITOR_KEYS$
|
|
4002
|
+
const keys = VISITOR_KEYS$1[commonPath.type];
|
|
3907
4003
|
const keyPosition = {
|
|
3908
4004
|
this: keys.indexOf(divergence.this.parentKey),
|
|
3909
4005
|
target: keys.indexOf(divergence.target.parentKey)
|
|
@@ -4153,9 +4249,10 @@ function getStatementListCompletion(paths, context) {
|
|
|
4153
4249
|
let lastNormalCompletions = [];
|
|
4154
4250
|
for (let i = 0; i < paths.length; i++) {
|
|
4155
4251
|
const path = paths[i];
|
|
4156
|
-
const newContext =
|
|
4252
|
+
const newContext = {
|
|
4253
|
+
...context,
|
|
4157
4254
|
inCaseClause: false
|
|
4158
|
-
}
|
|
4255
|
+
};
|
|
4159
4256
|
if (path.isBlockStatement() && (context.inCaseClause || context.shouldPopulateBreak)) {
|
|
4160
4257
|
newContext.shouldPopulateBreak = true;
|
|
4161
4258
|
} else {
|
|
@@ -4439,7 +4536,7 @@ function addComments(type, comments) {
|
|
|
4439
4536
|
const {
|
|
4440
4537
|
validate
|
|
4441
4538
|
} = _t;
|
|
4442
|
-
const debug =
|
|
4539
|
+
const debug = createDebug("babel");
|
|
4443
4540
|
const REMOVED = 1 << 0;
|
|
4444
4541
|
const SHOULD_STOP = 1 << 1;
|
|
4445
4542
|
const SHOULD_SKIP = 1 << 2;
|
|
@@ -4607,7 +4704,6 @@ const methods = {
|
|
|
4607
4704
|
isConstantExpression: isConstantExpression,
|
|
4608
4705
|
isInStrictMode: isInStrictMode,
|
|
4609
4706
|
isDenylisted: isDenylisted,
|
|
4610
|
-
visit: visit,
|
|
4611
4707
|
skip: skip,
|
|
4612
4708
|
skipKey: skipKey,
|
|
4613
4709
|
stop: stop,
|
|
@@ -4651,242 +4747,10 @@ for (const type of _t.TYPES) {
|
|
|
4651
4747
|
}
|
|
4652
4748
|
Object.assign(NodePath_Final.prototype, NodePath_virtual_types_validator);
|
|
4653
4749
|
for (const type of Object.keys(virtualTypes)) {
|
|
4654
|
-
if (type
|
|
4750
|
+
if (type.startsWith("_")) continue;
|
|
4655
4751
|
if (!_t.TYPES.includes(type)) _t.TYPES.push(type);
|
|
4656
4752
|
}
|
|
4657
4753
|
|
|
4658
|
-
const {
|
|
4659
|
-
VISITOR_KEYS: VISITOR_KEYS$2
|
|
4660
|
-
} = _t;
|
|
4661
|
-
class TraversalContext {
|
|
4662
|
-
constructor(scope, opts, state, parentPath) {
|
|
4663
|
-
this.parentPath = parentPath;
|
|
4664
|
-
this.scope = scope;
|
|
4665
|
-
this.state = state;
|
|
4666
|
-
this.opts = opts;
|
|
4667
|
-
}
|
|
4668
|
-
queue = null;
|
|
4669
|
-
priorityQueue = null;
|
|
4670
|
-
shouldVisit(node) {
|
|
4671
|
-
const opts = this.opts;
|
|
4672
|
-
if (opts.enter || opts.exit) return true;
|
|
4673
|
-
if (opts[node.type]) return true;
|
|
4674
|
-
const keys = VISITOR_KEYS$2[node.type];
|
|
4675
|
-
if (!keys?.length) return false;
|
|
4676
|
-
for (const key of keys) {
|
|
4677
|
-
if (node[key]) {
|
|
4678
|
-
return true;
|
|
4679
|
-
}
|
|
4680
|
-
}
|
|
4681
|
-
return false;
|
|
4682
|
-
}
|
|
4683
|
-
create(node, container, key, listKey) {
|
|
4684
|
-
return NodePath_Final.get({
|
|
4685
|
-
parentPath: this.parentPath,
|
|
4686
|
-
parent: node,
|
|
4687
|
-
container,
|
|
4688
|
-
key: key,
|
|
4689
|
-
listKey
|
|
4690
|
-
});
|
|
4691
|
-
}
|
|
4692
|
-
maybeQueue(path, notPriority) {
|
|
4693
|
-
if (this.queue) {
|
|
4694
|
-
if (notPriority) {
|
|
4695
|
-
this.queue.push(path);
|
|
4696
|
-
} else {
|
|
4697
|
-
this.priorityQueue.push(path);
|
|
4698
|
-
}
|
|
4699
|
-
}
|
|
4700
|
-
}
|
|
4701
|
-
visitMultiple(container, parent, listKey) {
|
|
4702
|
-
if (container.length === 0) return false;
|
|
4703
|
-
const queue = [];
|
|
4704
|
-
for (let key = 0; key < container.length; key++) {
|
|
4705
|
-
const node = container[key];
|
|
4706
|
-
if (node && this.shouldVisit(node)) {
|
|
4707
|
-
queue.push(this.create(parent, container, key, listKey));
|
|
4708
|
-
}
|
|
4709
|
-
}
|
|
4710
|
-
return this.visitQueue(queue);
|
|
4711
|
-
}
|
|
4712
|
-
visitSingle(node, key) {
|
|
4713
|
-
if (this.shouldVisit(node[key])) {
|
|
4714
|
-
return this.visitQueue([this.create(node, node, key)]);
|
|
4715
|
-
} else {
|
|
4716
|
-
return false;
|
|
4717
|
-
}
|
|
4718
|
-
}
|
|
4719
|
-
visitQueue(queue) {
|
|
4720
|
-
this.queue = queue;
|
|
4721
|
-
this.priorityQueue = [];
|
|
4722
|
-
const visited = new WeakSet();
|
|
4723
|
-
let stop = false;
|
|
4724
|
-
let visitIndex = 0;
|
|
4725
|
-
for (; visitIndex < queue.length;) {
|
|
4726
|
-
const path = queue[visitIndex];
|
|
4727
|
-
visitIndex++;
|
|
4728
|
-
resync.call(path);
|
|
4729
|
-
if (path.key === null) continue;
|
|
4730
|
-
if (path.contexts.length === 0 || path.contexts[path.contexts.length - 1] !== this) {
|
|
4731
|
-
pushContext.call(path, this);
|
|
4732
|
-
}
|
|
4733
|
-
const {
|
|
4734
|
-
node
|
|
4735
|
-
} = path;
|
|
4736
|
-
if (visited.has(node)) continue;
|
|
4737
|
-
if (node) visited.add(node);
|
|
4738
|
-
if (path.visit()) {
|
|
4739
|
-
stop = true;
|
|
4740
|
-
break;
|
|
4741
|
-
}
|
|
4742
|
-
if (this.priorityQueue.length) {
|
|
4743
|
-
stop = this.visitQueue(this.priorityQueue);
|
|
4744
|
-
this.priorityQueue = [];
|
|
4745
|
-
this.queue = queue;
|
|
4746
|
-
if (stop) break;
|
|
4747
|
-
}
|
|
4748
|
-
}
|
|
4749
|
-
for (let i = 0; i < visitIndex; i++) {
|
|
4750
|
-
if (queue[i].key === null) continue;
|
|
4751
|
-
popContext.call(queue[i]);
|
|
4752
|
-
}
|
|
4753
|
-
this.queue = null;
|
|
4754
|
-
return stop;
|
|
4755
|
-
}
|
|
4756
|
-
visit(node, key) {
|
|
4757
|
-
const nodes = node[key];
|
|
4758
|
-
if (!nodes) return false;
|
|
4759
|
-
if (Array.isArray(nodes)) {
|
|
4760
|
-
return this.visitMultiple(nodes, node, key);
|
|
4761
|
-
} else {
|
|
4762
|
-
return this.visitSingle(node, key);
|
|
4763
|
-
}
|
|
4764
|
-
}
|
|
4765
|
-
}
|
|
4766
|
-
|
|
4767
|
-
const {
|
|
4768
|
-
VISITOR_KEYS: VISITOR_KEYS$1
|
|
4769
|
-
} = _t;
|
|
4770
|
-
function _visitPaths(ctx, paths) {
|
|
4771
|
-
ctx.queue = paths;
|
|
4772
|
-
ctx.priorityQueue = [];
|
|
4773
|
-
const visited = new Set();
|
|
4774
|
-
let stop = false;
|
|
4775
|
-
let visitIndex = 0;
|
|
4776
|
-
for (; visitIndex < paths.length;) {
|
|
4777
|
-
const path = paths[visitIndex];
|
|
4778
|
-
visitIndex++;
|
|
4779
|
-
resync.call(path);
|
|
4780
|
-
if (path.contexts.length === 0 || path.contexts[path.contexts.length - 1] !== ctx) {
|
|
4781
|
-
pushContext.call(path, ctx);
|
|
4782
|
-
}
|
|
4783
|
-
if (path.key === null) continue;
|
|
4784
|
-
const {
|
|
4785
|
-
node
|
|
4786
|
-
} = path;
|
|
4787
|
-
if (visited.has(node)) continue;
|
|
4788
|
-
if (node) visited.add(node);
|
|
4789
|
-
if (_visit(ctx, path)) {
|
|
4790
|
-
stop = true;
|
|
4791
|
-
break;
|
|
4792
|
-
}
|
|
4793
|
-
if (ctx.priorityQueue.length) {
|
|
4794
|
-
stop = _visitPaths(ctx, ctx.priorityQueue);
|
|
4795
|
-
ctx.priorityQueue = [];
|
|
4796
|
-
ctx.queue = paths;
|
|
4797
|
-
if (stop) break;
|
|
4798
|
-
}
|
|
4799
|
-
}
|
|
4800
|
-
for (let i = 0; i < visitIndex; i++) {
|
|
4801
|
-
popContext.call(paths[i]);
|
|
4802
|
-
}
|
|
4803
|
-
ctx.queue = null;
|
|
4804
|
-
return stop;
|
|
4805
|
-
}
|
|
4806
|
-
function _visit(ctx, path) {
|
|
4807
|
-
const node = path.node;
|
|
4808
|
-
if (!node) {
|
|
4809
|
-
return false;
|
|
4810
|
-
}
|
|
4811
|
-
const opts = ctx.opts;
|
|
4812
|
-
const denylist = opts.denylist ?? opts.blacklist;
|
|
4813
|
-
if (denylist?.includes(node.type)) {
|
|
4814
|
-
return false;
|
|
4815
|
-
}
|
|
4816
|
-
if (opts.shouldSkip?.(path)) {
|
|
4817
|
-
return false;
|
|
4818
|
-
}
|
|
4819
|
-
if (path.shouldSkip) return path.shouldStop;
|
|
4820
|
-
if (_call.call(path, opts.enter)) return path.shouldStop;
|
|
4821
|
-
if (path.node) {
|
|
4822
|
-
if (_call.call(path, opts[node.type]?.enter)) return path.shouldStop;
|
|
4823
|
-
}
|
|
4824
|
-
path.shouldStop = _traverse(path.node, opts, path.scope, ctx.state, path, path.skipKeys);
|
|
4825
|
-
if (path.node) {
|
|
4826
|
-
if (_call.call(path, opts.exit)) return true;
|
|
4827
|
-
}
|
|
4828
|
-
if (path.node) {
|
|
4829
|
-
_call.call(path, opts[node.type]?.exit);
|
|
4830
|
-
}
|
|
4831
|
-
return path.shouldStop;
|
|
4832
|
-
}
|
|
4833
|
-
function _traverse(node, opts, scope, state, path, skipKeys, visitSelf) {
|
|
4834
|
-
const keys = VISITOR_KEYS$1[node.type];
|
|
4835
|
-
if (!keys?.length) return false;
|
|
4836
|
-
const ctx = new TraversalContext(scope, opts, state, path);
|
|
4837
|
-
if (visitSelf) {
|
|
4838
|
-
if (skipKeys?.[path.parentKey]) return false;
|
|
4839
|
-
return _visitPaths(ctx, [path]);
|
|
4840
|
-
}
|
|
4841
|
-
for (const key of keys) {
|
|
4842
|
-
if (skipKeys?.[key]) continue;
|
|
4843
|
-
const prop = node[key];
|
|
4844
|
-
if (!prop) continue;
|
|
4845
|
-
if (Array.isArray(prop)) {
|
|
4846
|
-
if (!prop.length) continue;
|
|
4847
|
-
const paths = [];
|
|
4848
|
-
for (let i = 0; i < prop.length; i++) {
|
|
4849
|
-
const childPath = NodePath_Final.get({
|
|
4850
|
-
parentPath: path,
|
|
4851
|
-
parent: node,
|
|
4852
|
-
container: prop,
|
|
4853
|
-
key: i,
|
|
4854
|
-
listKey: key
|
|
4855
|
-
});
|
|
4856
|
-
paths.push(childPath);
|
|
4857
|
-
}
|
|
4858
|
-
if (_visitPaths(ctx, paths)) return true;
|
|
4859
|
-
} else {
|
|
4860
|
-
if (_visitPaths(ctx, [NodePath_Final.get({
|
|
4861
|
-
parentPath: path,
|
|
4862
|
-
parent: node,
|
|
4863
|
-
container: node,
|
|
4864
|
-
key,
|
|
4865
|
-
listKey: null
|
|
4866
|
-
})])) {
|
|
4867
|
-
return true;
|
|
4868
|
-
}
|
|
4869
|
-
}
|
|
4870
|
-
}
|
|
4871
|
-
return false;
|
|
4872
|
-
}
|
|
4873
|
-
function traverseNode(node, opts, scope, state, path, skipKeys, visitSelf) {
|
|
4874
|
-
{
|
|
4875
|
-
return _traverse(node, opts, scope, state, path, skipKeys, visitSelf);
|
|
4876
|
-
}
|
|
4877
|
-
}
|
|
4878
|
-
|
|
4879
|
-
function call(key) {
|
|
4880
|
-
const opts = this.opts;
|
|
4881
|
-
this.debug(key);
|
|
4882
|
-
if (this.node) {
|
|
4883
|
-
if (_call.call(this, opts[key])) return true;
|
|
4884
|
-
}
|
|
4885
|
-
if (this.node) {
|
|
4886
|
-
return _call.call(this, opts[this.node.type]?.[key]);
|
|
4887
|
-
}
|
|
4888
|
-
return false;
|
|
4889
|
-
}
|
|
4890
4754
|
function _call(fns) {
|
|
4891
4755
|
if (!fns) return false;
|
|
4892
4756
|
for (const fn of fns) {
|
|
@@ -4906,37 +4770,7 @@ function _call(fns) {
|
|
|
4906
4770
|
return false;
|
|
4907
4771
|
}
|
|
4908
4772
|
function isDenylisted() {
|
|
4909
|
-
|
|
4910
|
-
return denylist?.includes(this.node.type);
|
|
4911
|
-
}
|
|
4912
|
-
function restoreContext(path, context) {
|
|
4913
|
-
if (path.context !== context) {
|
|
4914
|
-
path.context = context;
|
|
4915
|
-
path.state = context.state;
|
|
4916
|
-
path.opts = context.opts;
|
|
4917
|
-
}
|
|
4918
|
-
}
|
|
4919
|
-
function visit() {
|
|
4920
|
-
if (!this.node) {
|
|
4921
|
-
return false;
|
|
4922
|
-
}
|
|
4923
|
-
if (this.isDenylisted()) {
|
|
4924
|
-
return false;
|
|
4925
|
-
}
|
|
4926
|
-
if (this.opts.shouldSkip?.(this)) {
|
|
4927
|
-
return false;
|
|
4928
|
-
}
|
|
4929
|
-
const currentContext = this.context;
|
|
4930
|
-
if (this.shouldSkip || call.call(this, "enter")) {
|
|
4931
|
-
this.debug("Skip...");
|
|
4932
|
-
return this.shouldStop;
|
|
4933
|
-
}
|
|
4934
|
-
restoreContext(this, currentContext);
|
|
4935
|
-
this.debug("Recursing into...");
|
|
4936
|
-
this.shouldStop = traverseNode(this.node, this.opts, this.scope, this.state, this, this.skipKeys);
|
|
4937
|
-
restoreContext(this, currentContext);
|
|
4938
|
-
call.call(this, "exit");
|
|
4939
|
-
return this.shouldStop;
|
|
4773
|
+
return !!this.opts.denylist?.includes(this.node.type);
|
|
4940
4774
|
}
|
|
4941
4775
|
function skip() {
|
|
4942
4776
|
this.shouldSkip = true;
|
|
@@ -4950,13 +4784,28 @@ function skipKey(key) {
|
|
|
4950
4784
|
function stop() {
|
|
4951
4785
|
this._traverseFlags |= SHOULD_SKIP | SHOULD_STOP;
|
|
4952
4786
|
}
|
|
4787
|
+
function _forceSetScope() {
|
|
4788
|
+
let path = this.parentPath;
|
|
4789
|
+
if ((this.key === "key" || this.listKey === "decorators") && path.isMethod() || this.key === "discriminant" && path.isSwitchStatement()) {
|
|
4790
|
+
path = path.parentPath;
|
|
4791
|
+
}
|
|
4792
|
+
let target;
|
|
4793
|
+
while (path && !target) {
|
|
4794
|
+
target = path.scope;
|
|
4795
|
+
path = path.parentPath;
|
|
4796
|
+
}
|
|
4797
|
+
this.scope = this.getScope(target);
|
|
4798
|
+
this.scope?.init();
|
|
4799
|
+
}
|
|
4953
4800
|
function setScope() {
|
|
4801
|
+
if (this.opts?.noScope) return;
|
|
4954
4802
|
let path = this.parentPath;
|
|
4955
4803
|
if ((this.key === "key" || this.listKey === "decorators") && path.isMethod() || this.key === "discriminant" && path.isSwitchStatement()) {
|
|
4956
4804
|
path = path.parentPath;
|
|
4957
4805
|
}
|
|
4958
4806
|
let target;
|
|
4959
4807
|
while (path && !target) {
|
|
4808
|
+
if (path.opts?.noScope) return;
|
|
4960
4809
|
target = path.scope;
|
|
4961
4810
|
path = path.parentPath;
|
|
4962
4811
|
}
|
|
@@ -5040,9 +4889,7 @@ function setKey(key) {
|
|
|
5040
4889
|
}
|
|
5041
4890
|
function requeue(pathToQueue = this) {
|
|
5042
4891
|
if (pathToQueue.removed) return;
|
|
5043
|
-
|
|
5044
|
-
pathToQueue.shouldSkip = false;
|
|
5045
|
-
}
|
|
4892
|
+
pathToQueue.shouldSkip = false;
|
|
5046
4893
|
const contexts = this.contexts;
|
|
5047
4894
|
for (const context of contexts) {
|
|
5048
4895
|
context.maybeQueue(pathToQueue);
|